Skip to content

test_storage_sload_same_key_benchmark()

Documentation for tests/benchmark/stateful/bloatnet/test_single_opcode.py::test_storage_sload_same_key_benchmark@5c024cbb.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/stateful/bloatnet/test_single_opcode.py::test_storage_sload_same_key_benchmark --gas-benchmark-values 1

Benchmark SLOAD instruction when loading the same key over and over.

Variants: - storage_keys_pre_set: The key is pre-set to a non-zero value.

Source code in tests/benchmark/stateful/bloatnet/test_single_opcode.py
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
@pytest.mark.repricing
@pytest.mark.parametrize("storage_keys_pre_set", [False, True])
def test_storage_sload_same_key_benchmark(
    benchmark_test: BenchmarkTestFiller,
    storage_keys_pre_set: bool,
) -> None:
    """
    Benchmark SLOAD instruction when loading the same key over and over.

    Variants:
    - storage_keys_pre_set: The key is pre-set to a non-zero value.
    """
    contract_storage = Storage()
    if storage_keys_pre_set:
        contract_storage[1] = 1

    benchmark_test(
        target_opcode=Op.SLOAD,
        code_generator=JumpLoopGenerator(
            setup=Op.PUSH1(1) if storage_keys_pre_set else Op.PUSH0,
            attack_block=Op.SLOAD,
            contract_storage=contract_storage,
        ),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 3 forks.