Skip to content

test_parallel_execution_serial_chain()

Documentation for tests/benchmark/compute/eip7928_block_level_access_lists/test_block_access_list.py::test_parallel_execution_serial_chain@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/benchmark/compute/eip7928_block_level_access_lists/test_block_access_list.py::test_parallel_execution_serial_chain --gas-benchmark-values 1

Benchmark a fully serial chain as a baseline for parallel execution.

All transactions conflict on slot 0 — with a BAL, clients know upfront the block is serial and avoid speculation overhead.

Deploy a contract that initializes storage slot 0 to 1. Each execution transaction performs a keccak256 hash chain from a literal 1 seed (iteration count determined by available gas), then combines the result with slot 0 via SSTORE(0, ADD(SLOAD(0), result)).

The shared-state access (SLOAD/SSTORE on slot 0) is deliberately placed at the end so speculative parallel execution wastes maximum resources before discovering the conflict.

Source code in tests/benchmark/compute/eip7928_block_level_access_lists/test_block_access_list.py
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
def test_parallel_execution_serial_chain(
    benchmark_test: BenchmarkTestFiller,
    pre: Alloc,
    fork: Fork,
    gas_benchmark_value: int,
    tx_gas_limit: int,
) -> None:
    """
    Benchmark a fully serial chain as a baseline for parallel execution.

    All transactions conflict on slot 0 — with a BAL, clients know
    upfront the block is serial and avoid speculation overhead.

    Deploy a contract that initializes storage slot 0 to 1. Each
    execution transaction performs a keccak256 hash chain from a
    literal ``1`` seed (iteration count determined by available gas),
    then combines the result with slot 0 via
    ``SSTORE(0, ADD(SLOAD(0), result))``.

    The shared-state access (SLOAD/SSTORE on slot 0) is
    deliberately placed at the end so speculative parallel
    execution wastes maximum resources before discovering the
    conflict.
    """
    intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator()
    intrinsic_gas = intrinsic_gas_calculator()

    runtime_code, setup_gas, _, reserve_gas = _build_keccak_chain(fork)
    min_per_tx_gas = intrinsic_gas + setup_gas + reserve_gas

    tx_gas_schedule = _derive_tx_schedule(
        gas_benchmark_value, min_per_tx_gas, tx_gas_limit, TxDensity.GREEDY
    )

    creation_code = Initcode(
        deploy_code=runtime_code,
        initcode_prefix=Op.SSTORE(0, 1),
    )

    blocks = []

    with TestPhaseManager.setup():
        deployer = pre.fund_eoa()
        deploy_tx = Transaction(
            to=None,
            gas_limit=tx_gas_limit,
            data=creation_code,
            sender=deployer,
        )
        blocks.append(Block(txs=[deploy_tx]))

    contract_address = compute_create_address(address=deployer, nonce=0)

    with TestPhaseManager.execution():
        exec_txs = []
        for gas_limit in tx_gas_schedule:
            exec_txs.append(
                Transaction(
                    to=contract_address,
                    gas_limit=gas_limit,
                    sender=pre.fund_eoa(),
                )
            )
        blocks.append(Block(txs=exec_txs))

    benchmark_test(blocks=blocks, skip_gas_used_validation=True)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.