test_blake2f_benchmark()
Documentation for tests/benchmark/compute/precompile/test_blake2f.py::test_blake2f_benchmark@ffe48572.
Generate fixtures for these test cases for Bogota with:
fill -v tests/benchmark/compute/precompile/test_blake2f.py::test_blake2f_benchmark --gas-benchmark-values 1
Benchmark BLAKE2F precompile with varying number of rounds.
Source code in tests/benchmark/compute/precompile/test_blake2f.py
| @pytest.mark.repricing
@pytest.mark.parametrize("num_rounds", [1, 6, 12, 24])
def test_blake2f_benchmark(
benchmark_test: BenchmarkTestFiller,
fork: Fork,
num_rounds: int,
) -> None:
"""Benchmark BLAKE2F precompile with varying number of rounds."""
precompile_address = Blake2bSpec.BLAKE2_PRECOMPILE_ADDRESS
if precompile_address not in fork.precompiles():
pytest.skip("Precompile not enabled")
calldata = Blake2bInput(rounds=num_rounds, f=True)
attack_block = Op.POP(
Op.STATICCALL(
gas=Op.GAS, address=precompile_address, args_size=Op.CALLDATASIZE
),
)
benchmark_test(
target_opcode=Precompile.BLAKE2F,
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 4 forks.