Skip to content

test_reservoir_restored_after_child_full_drain_and_revert()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_reservoir_restored_after_child_full_drain_and_revert@5c024cbb.

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_reservoir_restored_after_child_full_drain_and_revert --fork Amsterdam

Test reservoir restored when child exactly exhausts it then reverts.

The child performs exactly one SSTORE consuming the entire reservoir (no spill into gas_left), then REVERTs. The full reservoir is returned to the parent.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
@pytest.mark.valid_from("EIP8037")
def test_reservoir_restored_after_child_full_drain_and_revert(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test reservoir restored when child exactly exhausts it then reverts.

    The child performs exactly one SSTORE consuming the entire reservoir
    (no spill into gas_left), then REVERTs. The full reservoir is
    returned to the parent.
    """
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    child = pre.deploy_contract(
        code=(Op.SSTORE(0, 1) + Op.REVERT(0, 0)),
    )

    parent_storage = Storage()
    parent = pre.deploy_contract(
        code=(
            Op.POP(Op.CALL(gas=500_000, address=child))
            + 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.