Skip to content

test_sstore_zero_to_nonzero()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py::test_sstore_zero_to_nonzero@a9abd46e.

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

Test SSTORE zero-to-nonzero charges state gas.

Writing a nonzero value to a previously-zero slot charges STATE_BYTES_PER_STORAGE_SET * cost_per_state_byte of state gas in addition to regular gas.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.valid_from("EIP8037")
def test_sstore_zero_to_nonzero(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test SSTORE zero-to-nonzero charges state gas.

    Writing a nonzero value to a previously-zero slot charges
    STATE_BYTES_PER_STORAGE_SET * cost_per_state_byte of state gas
    in addition to regular gas.
    """
    storage = Storage()
    contract = pre.deploy_contract(
        code=Op.SSTORE(storage.store_next(1), 1),
    )

    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.