Skip to content

test_call_to_pre_authorized_oog()

Documentation for tests/prague/eip7702_set_code_tx/test_gas.py::test_call_to_pre_authorized_oog@3719e927.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_gas.py::test_call_to_pre_authorized_oog --fork Prague

Test additional cost of delegation contract access in call instructions.

Source code in tests/prague/eip7702_set_code_tx/test_gas.py
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
@pytest.mark.with_all_call_opcodes()
def test_call_to_pre_authorized_oog(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    call_opcode: Op,
):
    """Test additional cost of delegation contract access in call instructions."""
    # Delegation contract. It should never be reached by a call.
    delegation_code = Op.SSTORE(0, 1)
    delegation = pre.deploy_contract(delegation_code)

    # Delegate to the delegation contract.
    auth_signer = pre.fund_eoa(0, delegation=delegation)

    # Callee tries to call the auth_signer which delegates
    # to the delegation contract. The call instruction should out-of-gas
    # because of the addition cost of the delegation account access.
    callee_code = Bytecode(
        Op.SSTORE(0, call_opcode(gas=0, address=auth_signer)),
    )
    callee_storage = Storage()
    callee_storage[0] = 0xFF  # Value other than 0 or 1. Should not be changed.
    callee_address = pre.deploy_contract(callee_code, storage=callee_storage)

    gas_costs = fork.gas_costs()
    intrinsic_gas_cost_calculator = fork.transaction_intrinsic_cost_calculator()
    tx_gas_limit = (
        intrinsic_gas_cost_calculator()
        + len(call_opcode.kwargs) * gas_costs.G_VERY_LOW  # type: ignore
        + (gas_costs.G_COLD_ACCOUNT_ACCESS * 2)
        - 1
    )
    tx = Transaction(
        gas_limit=tx_gas_limit,  # Specific gas to trigger CALL out-of-gas.
        to=callee_address,
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            callee_address: Account(storage=callee_storage),
            auth_signer: Account(code=Spec.delegation_designation(delegation)),
            delegation: Account(storage=Storage()),
        },
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) call_opcode evm_code_type
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-state_test EXTCALL EOF_V1
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-blockchain_test_from_state_test EXTCALL EOF_V1
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-state_test EXTSTATICCALL EOF_V1
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-blockchain_test_from_state_test EXTSTATICCALL EOF_V1
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-state_test EXTDELEGATECALL EOF_V1
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-blockchain_test_from_state_test EXTDELEGATECALL EOF_V1
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY