Skip to content

test_alt_bn128_benchmark()

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

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
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
@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.