test_ripemd160()
Documentation for tests/benchmark/compute/precompile/test_ripemd160.py::test_ripemd160@892e6d1e.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/benchmark/compute/precompile/test_ripemd160.py::test_ripemd160 --gas-benchmark-values 1
Benchmark RIPEMD-160 precompile.
Source code in tests/benchmark/compute/precompile/test_ripemd160.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 | def test_ripemd160(
benchmark_test: BenchmarkTestFiller,
fork: Fork,
tx_gas_limit: int,
) -> None:
"""Benchmark RIPEMD-160 precompile."""
intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator()
gas_available = tx_gas_limit - intrinsic_gas_calculator()
gas_costs = fork.gas_costs()
optimal_input_length = calculate_optimal_input_length(
available_gas=gas_available,
fork=fork,
static_cost=gas_costs.PRECOMPILE_RIPEMD160_BASE,
per_word_dynamic_cost=gas_costs.PRECOMPILE_RIPEMD160_PER_WORD,
bytes_per_unit_of_work=64,
)
attack_block = Op.POP(
Op.STATICCALL(
Op.GAS,
PrecompilesSpec.RIPEMD160,
Op.PUSH0,
optimal_input_length,
Op.PUSH0,
Op.PUSH0,
)
)
benchmark_test(
target_opcode=Precompile.RIPEMD160,
code_generator=JumpLoopGenerator(
setup=Op.CODECOPY(0, 0, optimal_input_length),
attack_block=attack_block,
),
)
|
Parametrized Test Cases
This test generates 1 parametrized test case across 3 forks.