test_bls12_pairing()
Documentation for tests/benchmark/compute/precompile/test_bls12_381.py::test_bls12_pairing@c17999c0.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/benchmark/compute/precompile/test_bls12_381.py::test_bls12_pairing --gas-benchmark-values 1
Benchmark BLS12_PAIRING precompile with varying number of pairs.
Source code in tests/benchmark/compute/precompile/test_bls12_381.py
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220 | @pytest.mark.repricing
@pytest.mark.parametrize("num_pairs", [1, 3, 6, 12, 24])
def test_bls12_pairing(
benchmark_test: BenchmarkTestFiller,
fork: Fork,
num_pairs: int,
) -> None:
"""Benchmark BLS12_PAIRING precompile with varying number of pairs."""
precompile_address = bls12381_spec.Spec.PAIRING
if precompile_address not in fork.precompiles():
pytest.skip("BLS12_PAIRING precompile not enabled")
# Generate num_pairs pairs of (G1, G2) points
calldata = Bytes(
(bls12381_spec.Spec.G1 + bls12381_spec.Spec.G2) * num_pairs
)
attack_block = Op.POP(
Op.STATICCALL(
gas=Op.GAS, address=precompile_address, args_size=Op.CALLDATASIZE
),
)
benchmark_test(
target_opcode=Precompile.BLS12_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.