Skip to content

test_call_self_is_warm()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py::test_call_self_is_warm@2867859a.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py::test_call_self_is_warm --fork Amsterdam

Verify a self-call is warm: the executing account is pre-warmed.

The current target is in the accessed-addresses set on message entry, so a call to ADDRESS pays only WARM_ACCESS.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.with_all_call_opcodes()
def test_call_self_is_warm(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    fork: Fork,
    call_opcode: Op,
) -> None:
    """
    Verify a self-call is warm: the executing account is pre-warmed.

    The current target is in the accessed-addresses set on message
    entry, so a call to ``ADDRESS`` pays only ``WARM_ACCESS``.
    """
    # `Op.ADDRESS` is the call's address argument, embedded inside the
    # runnable call; the self address is in the accessed set on entry, so
    # the call is warm. The overhead subtracts the call's own cold cost,
    # leaving the ADDRESS push and the other arg pushes as overhead.
    measured_code = call_opcode(gas=0, address=Op.ADDRESS)
    measure_address = _measure_call(
        pre, fork, measured_code, call_opcode(address_warm=False)
    )

    expected_gas = call_opcode(address_warm=True).gas_cost(fork)

    tx = Transaction(to=measure_address, sender=pre.fund_eoa())

    post = {measure_address: Account(storage={0: expected_gas})}
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 4 parametrized test cases across 1 fork.