Skip to content

test_bal_max_sloads()

Documentation for tests/benchmark/stateful/eip7928_block_level_access_lists/test_block_access_lists_max_sloads.py::test_bal_max_sloads@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/stateful/eip7928_block_level_access_lists/test_block_access_lists_max_sloads.py::test_bal_max_sloads --gas-benchmark-values 1

Test BAL with maximum sequential SLOADs via cursor.

Source code in tests/benchmark/stateful/eip7928_block_level_access_lists/test_block_access_lists_max_sloads.py
 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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
@pytest.mark.parametrize(
    "reverse",
    [False, True],
    ids=["forward", "reverse"],
)
def test_bal_max_sloads(
    pre: Alloc,
    benchmark_test: BenchmarkTestFiller,
    fork: Fork,
    gas_benchmark_value: int,
    tx_gas_limit: int,
    reverse: bool,
) -> None:
    """Test BAL with maximum sequential SLOADs via cursor."""
    body = sload_loop_body_reverse() if reverse else sload_loop_body()
    body_gas = body.gas_cost(fork)
    plan = plan_benchmark(
        fork,
        loop_body_gas=body_gas,
        setup_gas=cursor_read().gas_cost(fork),
        gas_benchmark_value=gas_benchmark_value,
    )
    total = plan.total_iterations
    # Cursor starts at slot 0; forward reads slots 1..total,
    # reverse reads slots total..1.
    cursor_start = total if reverse else 1
    authority = pre.fund_eoa(amount=0)
    run_bal_benchmark(
        pre=pre,
        fork=fork,
        benchmark_test=benchmark_test,
        contract_code=create_sload_loop_contract(
            plan.gas_threshold, reverse=reverse
        ),
        plan=plan,
        tx_gas_limit=tx_gas_limit,
        authority=authority,
        storage_init_ranges=[
            StorageInitRange(1, total, 0),
            StorageInitRange(0, 1, cursor_start),
        ],
        data_slot_reads=list(range(1, total + 1)),
    )

Parametrized Test Cases

This test generates 2 parametrized test cases across 1 fork.