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@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

Test additional cost of delegation contract access in call instructions.

Source code in tests/prague/eip7702_set_code_tx/test_gas.py
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
@pytest.mark.with_all_call_opcodes()
def test_call_to_pre_authorized_oog(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
    call_opcode: Op,
) -> None:
    """
    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
        + (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(
        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_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