Skip to content

test_sstore_state_gas_at_transition()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_fork_transition.py::test_sstore_state_gas_at_transition@c74f1a67.

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

Test SSTORE state gas activates at the EIP-8037 fork boundary.

Before the fork, an SSTORE zero-to-nonzero succeeds with only regular gas (no state gas dimension). After the fork, the same operation requires state gas. Both blocks use TX_MAX_GAS_LIMIT which provides enough gas in either regime.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_fork_transition.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@EIPChecklist.GasCostChanges.Test.ForkTransition.Before()
@EIPChecklist.GasCostChanges.Test.ForkTransition.After()
def test_sstore_state_gas_at_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test SSTORE state gas activates at the EIP-8037 fork boundary.

    Before the fork, an SSTORE zero-to-nonzero succeeds with only
    regular gas (no state gas dimension). After the fork, the same
    operation requires state gas. Both blocks use TX_MAX_GAS_LIMIT
    which provides enough gas in either regime.
    """
    contract_before = pre.deploy_contract(
        code=Op.SSTORE(0, 1),
    )
    contract_after = pre.deploy_contract(
        code=Op.SSTORE(0, 1),
    )

    blocks = [
        # Before fork: SSTORE succeeds with regular gas only
        Block(
            timestamp=14_999,
            txs=[
                Transaction(
                    to=contract_before,
                    state_gas_reservoir=0,
                    sender=pre.fund_eoa(),
                ),
            ],
        ),
        # After fork: SSTORE succeeds — state gas drawn from gas_left
        Block(
            timestamp=15_000,
            txs=[
                Transaction(
                    to=contract_after,
                    state_gas_reservoir=0,
                    sender=pre.fund_eoa(),
                ),
            ],
        ),
    ]

    post = {
        contract_before: Account(storage={0: 1}),
        contract_after: Account(storage={0: 1}),
    }

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

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.