Skip to content

test_reservoir_available_after_transition()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_fork_transition.py::test_reservoir_available_after_transition@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_fork_transition.py::test_reservoir_available_after_transition --fork Amsterdam

Test reservoir is available for state ops after the fork.

Before the fork, tx.gas is capped at TX_MAX_GAS_LIMIT and there is no reservoir. After the fork, gas above the cap feeds the reservoir, which child calls can draw from for state operations.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_fork_transition.py
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
@EIPChecklist.GasCostChanges.Test.ForkTransition.After()
def test_reservoir_available_after_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test reservoir is available for state ops after the fork.

    Before the fork, tx.gas is capped at TX_MAX_GAS_LIMIT and there is
    no reservoir. After the fork, gas above the cap feeds the reservoir,
    which child calls can draw from for state operations.
    """
    after_fork = fork.fork_at(timestamp=15_000)
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(after_fork)

    child_storage = Storage()
    child = pre.deploy_contract(
        code=Op.SSTORE(child_storage.store_next(1), 1),
    )

    parent_storage = Storage()
    parent = pre.deploy_contract(
        code=(
            Op.SSTORE(
                parent_storage.store_next(1),
                Op.CALL(gas=100_000, address=child),
            )
        ),
    )

    blocks = [
        Block(
            timestamp=15_000,
            txs=[
                Transaction(
                    to=parent,
                    state_gas_reservoir=sstore_state_gas,
                    sender=pre.fund_eoa(),
                ),
            ],
        ),
    ]

    post = {
        parent: Account(storage=parent_storage),
        child: Account(storage=child_storage),
    }

    blockchain_test(pre=pre, blocks=blocks, post=post)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.