Skip to content

test_reservoir_returned_on_oog()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py::test_reservoir_returned_on_oog@c74f1a67.

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

Test state gas reservoir is returned to parent on child OOG.

The child runs out of regular gas. The parent recovers the reservoir and can use it for its own state operations.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_call.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
@pytest.mark.valid_from("EIP8037")
def test_reservoir_returned_on_oog(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test state gas reservoir is returned to parent on child OOG.

    The child runs out of regular gas. The parent recovers the
    reservoir and can use it for its own state operations.
    """
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    # Child that consumes all gas
    child = pre.deploy_contract(code=Op.INVALID)

    parent_storage = Storage()
    parent = pre.deploy_contract(
        code=(
            # Call child with minimal gas — it will OOG (returns 0)
            Op.POP(Op.CALL(gas=100, address=child))
            # Parent can still use reservoir for 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.