Skip to content

test_alt_bn128_benchmark()

Documentation for tests/benchmark/compute/precompile/test_alt_bn128.py::test_alt_bn128_benchmark@7b8124a7.

Generate fixtures for these test cases for Osaka with:

fill -v tests/benchmark/compute/precompile/test_alt_bn128.py::test_alt_bn128_benchmark --gas-benchmark-values 1

Benchmark BN128 pairings precompile with varying number of pairs.

Source code in tests/benchmark/compute/precompile/test_alt_bn128.py
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
@pytest.mark.repricing
@pytest.mark.parametrize("num_pairs", [1, 3, 6, 12, 24])
def test_alt_bn128_benchmark(
    benchmark_test: BenchmarkTestFiller,
    num_pairs: int,
) -> None:
    """Benchmark BN128 pairings precompile with varying number of pairs."""
    calldata = _generate_bn128_pairs(num_pairs, seed=42)

    attack_block = Op.POP(
        Op.STATICCALL(gas=Op.GAS, address=0x08, args_size=Op.CALLDATASIZE),
    )

    benchmark_test(
        target_opcode=Op.STATICCALL,
        code_generator=JumpLoopGenerator(
            setup=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE),
            attack_block=attack_block,
            tx_kwargs={"data": calldata},
        ),
    )

Parametrized Test Cases

This test generates 5 parametrized test cases across 2 forks.