99from typing import Any , cast
1010
1111import pytest
12+ from _pytest .mark import ParameterSet
1213from py_ecc .bn128 import G1 , G2 , multiply
1314
1415from ethereum_test_base_types .base_types import Bytes , HexNumber
2021 BenchmarkTestFiller ,
2122 Block ,
2223 Bytecode ,
23- Environment ,
2424 Transaction ,
2525 add_kzg_version ,
2626)
@@ -82,8 +82,6 @@ def test_worst_zero_param(
8282 benchmark_test : BenchmarkTestFiller ,
8383 pre : Alloc ,
8484 opcode : Op ,
85- fork : Fork ,
86- gas_benchmark_value : int ,
8785) -> None :
8886 """Test running a block with as many zero-parameter opcodes as possible."""
8987 benchmark_test (
@@ -122,7 +120,6 @@ def test_worst_callvalue(
122120 fork : Fork ,
123121 non_zero_value : bool ,
124122 from_origin : bool ,
125- gas_benchmark_value : int ,
126123) -> None :
127124 """
128125 Test running a block with as many CALLVALUE opcodes as possible.
@@ -180,7 +177,6 @@ def test_worst_returndatasize_nonzero(
180177 pre : Alloc ,
181178 returned_size : int ,
182179 return_data_style : ReturnDataStyle ,
183- gas_benchmark_value : int ,
184180) -> None :
185181 """
186182 Test running a block which execute as many RETURNDATASIZE opcodes which
@@ -215,7 +211,7 @@ def test_worst_returndatasize_nonzero(
215211def test_worst_returndatasize_zero (
216212 benchmark_test : BenchmarkTestFiller ,
217213 pre : Alloc ,
218- ):
214+ ) -> None :
219215 """
220216 Test running a block with as many RETURNDATASIZE opcodes as possible with
221217 a zero buffer.
@@ -395,7 +391,7 @@ def test_worst_precompile_only_data_input(
395391 )
396392
397393
398- def create_modexp_test_cases ():
394+ def create_modexp_test_cases () -> list [ ParameterSet ] :
399395 """Create test cases for the MODEXP precompile."""
400396 test_cases = [
401397 # (base, exponent, modulus, test_id)
@@ -1195,7 +1191,6 @@ def test_worst_precompile_fixed_cost(
11951191 fork : Fork ,
11961192 precompile_address : Address ,
11971193 parameters : list [str ] | list [BytesConcatenation ] | list [bytes ],
1198- gas_benchmark_value : int ,
11991194) -> None :
12001195 """Test running a block filled with a precompile with fixed cost."""
12011196 if precompile_address not in fork .precompiles ():
@@ -1546,7 +1541,7 @@ def test_worst_tstore(
15461541 pre : Alloc ,
15471542 key_mut : bool ,
15481543 dense_val_mut : bool ,
1549- ):
1544+ ) -> None :
15501545 """Test running a block with as many TSTORE calls as possible."""
15511546 init_key = 42
15521547 setup = Op .PUSH1 (init_key )
@@ -1825,7 +1820,7 @@ def test_worst_memory_access(
18251820 offset : int ,
18261821 offset_initialized : bool ,
18271822 big_memory_expansion : bool ,
1828- ):
1823+ ) -> None :
18291824 """
18301825 Test running a block with as many memory access instructions as
18311826 possible.
@@ -2070,12 +2065,18 @@ def test_worst_calldataload(
20702065 benchmark_test : BenchmarkTestFiller ,
20712066 pre : Alloc ,
20722067 calldata : bytes ,
2073- ):
2068+ gas_benchmark_value : int ,
2069+ fork : Fork ,
2070+ ) -> None :
20742071 """Test running a block with as many CALLDATALOAD as possible."""
2072+ tx = JumpLoopGenerator (setup = Op .PUSH0 , attack_block = Op .CALLDATALOAD ).generate_transaction (
2073+ pre , gas_benchmark_value , fork
2074+ )
2075+ tx .data = Bytes (calldata )
20752076 benchmark_test (
20762077 pre = pre ,
20772078 post = {},
2078- code_generator = JumpLoopGenerator ( setup = Op . PUSH0 , attack_block = Op . CALLDATALOAD ) ,
2079+ tx = tx ,
20792080 )
20802081
20812082
@@ -2141,7 +2142,7 @@ def test_worst_dup(
21412142 pre : Alloc ,
21422143 fork : Fork ,
21432144 opcode : Op ,
2144- ):
2145+ ) -> None :
21452146 """Test running a block with as many DUP as possible."""
21462147 max_stack_height = fork .max_stack_height ()
21472148
@@ -2200,7 +2201,7 @@ def test_worst_push(
22002201 benchmark_test : BenchmarkTestFiller ,
22012202 pre : Alloc ,
22022203 opcode : Op ,
2203- ):
2204+ ) -> None :
22042205 """Test running a block with as many PUSH as possible."""
22052206 benchmark_test (
22062207 pre = pre ,
@@ -2232,7 +2233,6 @@ def test_worst_return_revert(
22322233 opcode : Op ,
22332234 return_size : int ,
22342235 return_non_zero_data : bool ,
2235- gas_benchmark_value : int ,
22362236) -> None :
22372237 """Test running a block with as many RETURN or REVERT as possible."""
22382238 max_code_size = fork .max_code_size ()
@@ -2268,9 +2268,6 @@ def test_worst_return_revert(
22682268def test_worst_clz_same_input (
22692269 benchmark_test : BenchmarkTestFiller ,
22702270 pre : Alloc ,
2271- fork : Fork ,
2272- gas_benchmark_value : int ,
2273- env : Environment ,
22742271) -> None :
22752272 """Test running a block with as many CLZ with same input as possible."""
22762273 magic_value = 248 # CLZ(248) = 248
@@ -2287,8 +2284,7 @@ def test_worst_clz_diff_input(
22872284 benchmark_test : BenchmarkTestFiller ,
22882285 pre : Alloc ,
22892286 fork : Fork ,
2290- env : Environment ,
2291- ):
2287+ ) -> None :
22922288 """
22932289 Test running a block with as many CLZ with different input as
22942290 possible.
0 commit comments