Skip to content

test_call_precompile_is_warm()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py::test_call_precompile_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_precompile_is_warm --fork Amsterdam

Verify a call to a precompile is warm from the start.

Precompiles are part of the accessed-addresses set from the start of every transaction, so a call to one pays only WARM_ACCESS. The identity precompile (address 4) is used as the target.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_call_gas.py
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.with_all_call_opcodes()
def test_call_precompile_is_warm(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    fork: Fork,
    call_opcode: Op,
) -> None:
    """
    Verify a call to a precompile is warm from the start.

    Precompiles are part of the accessed-addresses set from the start of
    every transaction, so a call to one pays only ``WARM_ACCESS``.
    The identity precompile (address 4) is used as the target.
    """
    identity_precompile = Address(4)

    measured_code = call_opcode(gas=0, address=identity_precompile)
    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.