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@01f496f4.

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
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
@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