Skip to content

test_staticcall_passes_reservoir()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_staticcall_passes_reservoir@2119b382.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_staticcall_passes_reservoir --fork Amsterdam

Test STATICCALL passes reservoir but cannot use it for state ops.

STATICCALL forbids state-modifying operations. The reservoir is passed to the child but cannot be consumed. After the STATICCALL returns, the parent can still use the reservoir for its own SSTORE.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
@pytest.mark.valid_from("EIP8037")
def test_staticcall_passes_reservoir(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test STATICCALL passes reservoir but cannot use it for state ops.

    STATICCALL forbids state-modifying operations. The reservoir is
    passed to the child but cannot be consumed. After the STATICCALL
    returns, the parent can still use the reservoir for its own SSTORE.
    """
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    # Child does a read-only operation
    child = pre.deploy_contract(
        code=Op.MSTORE(0, Op.ADDRESS),
    )

    parent_storage = Storage()
    parent = pre.deploy_contract(
        code=(
            Op.POP(Op.STATICCALL(gas=100_000, address=child))
            # Reservoir should still be available for parent's SSTORE
            + Op.SSTORE(parent_storage.store_next(1), 1)
        ),
    )

    tx = Transaction(
        to=parent,
        state_gas_reservoir=sstore_state_gas,
        sender=pre.fund_eoa(),
    )

    post = {parent: Account(storage=parent_storage)}
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.