Skip to content

test_create_stack_depth_state_gas_consumed()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_stack_depth_state_gas_consumed@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py::test_create_stack_depth_state_gas_consumed --fork Amsterdam

Verify the state gas reservoir survives a deep recursion of nested CALLs that silently fail on gas or depth exhaustion.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_create.py
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
@pytest.mark.valid_from("EIP8037")
def test_create_stack_depth_state_gas_consumed(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Verify the state gas reservoir survives a deep recursion of
    nested CALLs that silently fail on gas or depth exhaustion.
    """
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    storage = Storage()
    recursive = pre.deploy_contract(
        code=(
            Op.POP(Op.CALL(Op.GAS, Op.ADDRESS, 0, 0, 0, 0, 0))
            + Op.SSTORE(storage.store_next(1, "reservoir_ok"), 1)
        ),
    )

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

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

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.