Skip to content

test_tstore_same_key()

Documentation for tests/benchmark/stateful/bloatnet/test_transient_storage.py::test_tstore_same_key@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/stateful/bloatnet/test_transient_storage.py::test_tstore_same_key --gas-benchmark-values 1

Benchmark TSTORE writing the same key repeatedly.

Measure transient storage hot-path performance by repeatedly writing to slot 0. Uses JumpLoopGenerator for maximum code fill.

Source code in tests/benchmark/stateful/bloatnet/test_transient_storage.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@pytest.mark.parametrize("with_tload", [True, False])
def test_tstore_same_key(
    benchmark_test: BenchmarkTestFiller,
    with_tload: bool,
) -> None:
    """
    Benchmark TSTORE writing the same key repeatedly.

    Measure transient storage hot-path performance by repeatedly
    writing to slot 0. Uses JumpLoopGenerator for maximum code fill.
    """
    attack_block = Op.TSTORE(0, 1)

    if with_tload:
        attack_block += Op.POP(Op.TLOAD(0))

    benchmark_test(
        target_opcode=Op.TSTORE,
        code_generator=JumpLoopGenerator(
            setup=Bytecode(),
            attack_block=attack_block,
        ),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 3 forks.