Measure the access cost of every call opcode with no value transfer.
EIP-8038 charges COLD_ACCOUNT_ACCESS cold and WARM_ACCESS
warm for all four call opcodes.
Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py
| @EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.with_all_call_opcodes()
@pytest.mark.parametrize("warm", [False, True], ids=["cold", "warm"])
def test_call_access_gas(
state_test: StateTestFiller,
env: Environment,
pre: Alloc,
fork: Fork,
call_opcode: Op,
warm: bool,
) -> None:
"""
Measure the access cost of every call opcode with no value transfer.
EIP-8038 charges ``COLD_ACCOUNT_ACCESS`` cold and ``WARM_ACCESS``
warm for all four call opcodes.
"""
target = pre.deploy_contract(Op.STOP)
measured_code = call_opcode(gas=0, address=target)
cost_metadata = call_opcode(address_warm=warm)
measure_address = _measure_call(
pre, fork, measured_code, call_opcode(address_warm=False)
)
# The opcode's own cost is the expected access gas.
expected_gas = cost_metadata.gas_cost(fork)
access_list = (
[AccessList(address=target, storage_keys=[])] if warm else None
)
tx = Transaction(
to=measure_address,
sender=pre.fund_eoa(),
access_list=access_list,
)
post = {measure_address: Account(storage={0: expected_gas})}
state_test(env=env, pre=pre, post=post, tx=tx)
|