test_stacked_storage_commit()
Documentation for tests/benchmark/compute/instruction/test_storage.py::test_stacked_storage_commit@ffe48572.
Generate fixtures for these test cases for Bogota with:
fill -v tests/benchmark/compute/instruction/test_storage.py::test_stacked_storage_commit --gas-benchmark-values 1
Benchmark storage writes on branching self-DELEGATECALL frames.
Source code in tests/benchmark/compute/instruction/test_storage.py
| @pytest.mark.parametrize("writes_per_frame", [16, 64, 256])
def test_stacked_storage_commit(
benchmark_test: BenchmarkTestFiller,
pre: Alloc,
fork: Fork,
writes_per_frame: int,
gas_benchmark_value: int,
tx_gas_limit: int,
) -> None:
"""Benchmark storage writes on branching self-DELEGATECALL frames."""
# The first frame pays a cold write per slot, so a large write set does
# not fit in a small benchmark budget.
first_frame_gas = writes_per_frame * fork.gas_costs().COLD_STORAGE_WRITE
if first_frame_gas > min(tx_gas_limit, gas_benchmark_value):
pytest.skip("write set does not fit in the transaction gas limit")
# The second call spends the 1/64 of the gas EIP-150 withholds from the
# first; with a single call the transaction leaves most of it unspent.
delegate = Op.DELEGATECALL(address=Op.ADDRESS)
writes = Bytecode()
# Seeded slots keep every write a reset; a set costs state gas.
storage = Storage({})
for slot in range(writes_per_frame):
writes += Op.SSTORE(slot, Op.GAS)
storage[slot] = 1
contract = pre.deploy_contract(
writes + delegate + delegate, storage=storage
)
benchmark_test(
pre=pre,
# The frame tree stops just short of the gas limit.
skip_gas_used_validation=True,
verifications=[ReceiptStatusExpected()],
tx=Transaction(to=contract, sender=pre.fund_eoa()),
)
|
Parametrized Test Cases
This test generates 3 parametrized test cases across 4 forks.