Skip to content

test_sstore_state_gas_drawn_from_reservoir()

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

Test SSTORE state gas drawn from reservoir before gas_left.

Provide enough gas above TX_MAX_GAS_LIMIT to fully cover the SSTORE state gas from the reservoir, leaving gas_left untouched by the state gas charge.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_sstore.py
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
@pytest.mark.valid_from("EIP8037")
def test_sstore_state_gas_drawn_from_reservoir(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    Test SSTORE state gas drawn from reservoir before gas_left.

    Provide enough gas above TX_MAX_GAS_LIMIT to fully cover the
    SSTORE state gas from the reservoir, leaving gas_left untouched
    by the state gas charge.
    """
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)

    storage = Storage()
    contract = pre.deploy_contract(
        code=Op.SSTORE(storage.store_next(1), 1),
    )

    tx = Transaction(
        to=contract,
        state_gas_reservoir=sstore_state_gas,
        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.