Skip to content

test_sstore_multiple_slots()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py::test_sstore_multiple_slots@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_multiple_slots --fork Amsterdam

Test multiple zero-to-nonzero SSTOREs each charge state gas.

Each slot written from zero to nonzero independently charges STATE_BYTES_PER_STORAGE_SET * cost_per_state_byte of state gas.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
@pytest.mark.parametrize(
    "num_slots",
    [
        pytest.param(1, id="single_slot"),
        pytest.param(5, id="five_slots"),
        pytest.param(10, id="ten_slots"),
    ],
)
@pytest.mark.valid_from("EIP8037")
def test_sstore_multiple_slots(
    state_test: StateTestFiller,
    pre: Alloc,
    num_slots: int,
) -> None:
    """
    Test multiple zero-to-nonzero SSTOREs each charge state gas.

    Each slot written from zero to nonzero independently charges
    STATE_BYTES_PER_STORAGE_SET * cost_per_state_byte of state gas.
    """
    storage = Storage()
    code = Bytecode()
    for _ in range(num_slots):
        code += Op.SSTORE(storage.store_next(1), 1)
    contract = pre.deploy_contract(code=code)

    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 3 parametrized test cases across 1 fork.