Skip to content

test_pricing_at_various_gas_limits()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_pricing_at_various_gas_limits@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py::test_pricing_at_various_gas_limits --fork Amsterdam

Test SSTORE succeeds at various block gas limits.

EIP-8037 prices state gas at a constant cost_per_state_byte, independent of block gas limit. At each block size, an SSTORE zero-to-nonzero should succeed when given sufficient total gas.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_pricing.py
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
@EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
@pytest.mark.parametrize("block_gas_limit", BLOCK_GAS_LIMITS)
@pytest.mark.valid_from("EIP8037")
def test_pricing_at_various_gas_limits(
    state_test: StateTestFiller,
    pre: Alloc,
    block_gas_limit: int,
    fork: Fork,
) -> None:
    """
    Test SSTORE succeeds at various block gas limits.

    EIP-8037 prices state gas at a constant `cost_per_state_byte`,
    independent of block gas limit. At each block size, an SSTORE
    zero-to-nonzero should succeed when given sufficient total gas.
    """
    gas_limit_cap = fork.transaction_gas_limit_cap()
    assert gas_limit_cap is not None
    env = Environment(gas_limit=block_gas_limit)
    sstore_state_gas = Op.SSTORE(new_value=1).state_cost(fork)
    tx_gas = min(gas_limit_cap + sstore_state_gas, block_gas_limit)

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

    tx = Transaction(
        to=contract,
        gas_limit=tx_gas,
        sender=pre.fund_eoa(),
    )

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

Parametrized Test Cases

This test generates 10 parametrized test cases across 1 fork.