test_bls12_g1_msm()
Documentation for tests/benchmark/compute/precompile/test_bls12_381.py::test_bls12_g1_msm@c17999c0.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/benchmark/compute/precompile/test_bls12_381.py::test_bls12_g1_msm --gas-benchmark-values 1
Benchmark BLS12_G1_MSM precompile with varying number of points.
Source code in tests/benchmark/compute/precompile/test_bls12_381.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 | @pytest.mark.repricing
@pytest.mark.parametrize("k", [1, 16, 64, 128])
def test_bls12_g1_msm(
benchmark_test: BenchmarkTestFiller,
fork: Fork,
gas_benchmark_value: int,
k: int,
) -> None:
"""Benchmark BLS12_G1_MSM precompile with varying number of points."""
precompile_address = bls12381_spec.Spec.G1MSM
if precompile_address not in fork.precompiles():
pytest.skip("BLS12_G1_MSM precompile not enabled")
calldata = _g1msm_worstcase_calldata(k)
intrinsic_gas_cost = fork.transaction_intrinsic_cost_calculator()(
calldata=calldata
)
if intrinsic_gas_cost > gas_benchmark_value:
pytest.skip("k configuration exceeds the gas limit")
attack_block = Op.POP(
Op.STATICCALL(
gas=Op.GAS, address=precompile_address, args_size=Op.CALLDATASIZE
),
)
benchmark_test(
target_opcode=Precompile.BLS12_G1MSM,
code_generator=JumpLoopGenerator(
setup=Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE),
attack_block=attack_block,
tx_kwargs={"data": calldata},
),
)
|
Parametrized Test Cases
This test generates 4 parametrized test cases across 3 forks.