Skip to content

test_sstore_zero_to_zero()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py::test_sstore_zero_to_zero@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py::test_sstore_zero_to_zero --fork Amsterdam

Test SSTORE zero-to-zero charges no state gas.

Writing zero to an already-zero slot creates no new state. Only the warm access regular gas cost is charged.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
@pytest.mark.valid_from("EIP8037")
def test_sstore_zero_to_zero(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test SSTORE zero-to-zero charges no state gas.

    Writing zero to an already-zero slot creates no new state. Only
    the warm access regular gas cost is charged.
    """
    storage = Storage()
    contract = pre.deploy_contract(
        code=Op.SSTORE(storage.store_next(0), 0),
    )

    tx = Transaction(
        to=contract,
        state_gas_reservoir=0,
        sender=pre.fund_eoa(),
    )

    post = {contract: Account(storage=storage)}
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.