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@892e6d1e.

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
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
@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.