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@636b5f17.

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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
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
@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)
    child_code = Op.SSTORE(0, 1, original_value=0, new_value=1)
    sstore_state_gas = child_code.state_cost(after_fork)

    child_storage = Storage()
    child_storage.store_next(1, "child_slot_set")
    child = pre.deploy_contract(code=child_code)

    parent_storage = Storage()
    parent = pre.deploy_contract(
        code=Op.SSTORE(
            parent_storage.store_next(1, "subcall_succeeds"),
            Op.CALL(gas=child_code.execution_cost(after_fork), 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.