Skip to content

test_alt_bn128_benchmark()

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

Generate fixtures for these test cases for Amsterdam 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
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
@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=EIP197Spec.ECPAIRING,
            args_size=Op.CALLDATASIZE,
        ),
    )

    benchmark_test(
        target_opcode=Precompile.BN128_PAIRING,
        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 3 forks.