Skip to content

test_bal_compute_then_sload()

Documentation for tests/benchmark/stateful/eip7928_block_level_access_lists/test_block_access_lists_compute_then_sload.py::test_bal_compute_then_sload@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/stateful/eip7928_block_level_access_lists/test_block_access_lists_compute_then_sload.py::test_bal_compute_then_sload --gas-benchmark-values 1

Test BAL with mixed computation and SLOAD per iteration.

Source code in tests/benchmark/stateful/eip7928_block_level_access_lists/test_block_access_lists_compute_then_sload.py
 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
102
103
@pytest.mark.parametrize(
    "compute_percent",
    [5, 10, 25, 50],
    ids=lambda p: f"compute_{p}pct",
)
def test_bal_compute_then_sload(
    pre: Alloc,
    benchmark_test: BenchmarkTestFiller,
    fork: Fork,
    gas_benchmark_value: int,
    tx_gas_limit: int,
    compute_percent: int,
) -> None:
    """Test BAL with mixed computation and SLOAD per iteration."""
    n = _compute_steps_for_percent(fork, compute_percent)
    body = _mixed_body(n)
    plan = plan_benchmark(
        fork,
        loop_body_gas=body.gas_cost(fork),
        setup_gas=cursor_read().gas_cost(fork),
        gas_benchmark_value=gas_benchmark_value,
    )
    total = plan.total_iterations
    authority = pre.fund_eoa(amount=0)
    run_bal_benchmark(
        pre=pre,
        fork=fork,
        benchmark_test=benchmark_test,
        contract_code=gas_check_loop_contract(
            setup=cursor_read(),
            body=body,
            gas_threshold=plan.gas_threshold,
        ),
        plan=plan,
        tx_gas_limit=tx_gas_limit,
        authority=authority,
        storage_init_ranges=[StorageInitRange(0, total + 1, 1)],
        data_slot_reads=list(range(1, total + 1)),
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 1 fork.