9
9
from typing import Any , cast
10
10
11
11
import pytest
12
+ from _pytest .mark import ParameterSet
12
13
from py_ecc .bn128 import G1 , G2 , multiply
13
14
14
15
from ethereum_test_base_types .base_types import Bytes , HexNumber
20
21
BenchmarkTestFiller ,
21
22
Block ,
22
23
Bytecode ,
23
- Environment ,
24
24
Transaction ,
25
25
add_kzg_version ,
26
26
)
@@ -82,8 +82,6 @@ def test_worst_zero_param(
82
82
benchmark_test : BenchmarkTestFiller ,
83
83
pre : Alloc ,
84
84
opcode : Op ,
85
- fork : Fork ,
86
- gas_benchmark_value : int ,
87
85
) -> None :
88
86
"""Test running a block with as many zero-parameter opcodes as possible."""
89
87
benchmark_test (
@@ -122,7 +120,6 @@ def test_worst_callvalue(
122
120
fork : Fork ,
123
121
non_zero_value : bool ,
124
122
from_origin : bool ,
125
- gas_benchmark_value : int ,
126
123
) -> None :
127
124
"""
128
125
Test running a block with as many CALLVALUE opcodes as possible.
@@ -180,7 +177,6 @@ def test_worst_returndatasize_nonzero(
180
177
pre : Alloc ,
181
178
returned_size : int ,
182
179
return_data_style : ReturnDataStyle ,
183
- gas_benchmark_value : int ,
184
180
) -> None :
185
181
"""
186
182
Test running a block which execute as many RETURNDATASIZE opcodes which
@@ -215,7 +211,7 @@ def test_worst_returndatasize_nonzero(
215
211
def test_worst_returndatasize_zero (
216
212
benchmark_test : BenchmarkTestFiller ,
217
213
pre : Alloc ,
218
- ):
214
+ ) -> None :
219
215
"""
220
216
Test running a block with as many RETURNDATASIZE opcodes as possible with
221
217
a zero buffer.
@@ -395,7 +391,7 @@ def test_worst_precompile_only_data_input(
395
391
)
396
392
397
393
398
- def create_modexp_test_cases ():
394
+ def create_modexp_test_cases () -> list [ ParameterSet ] :
399
395
"""Create test cases for the MODEXP precompile."""
400
396
test_cases = [
401
397
# (base, exponent, modulus, test_id)
@@ -1195,7 +1191,6 @@ def test_worst_precompile_fixed_cost(
1195
1191
fork : Fork ,
1196
1192
precompile_address : Address ,
1197
1193
parameters : list [str ] | list [BytesConcatenation ] | list [bytes ],
1198
- gas_benchmark_value : int ,
1199
1194
) -> None :
1200
1195
"""Test running a block filled with a precompile with fixed cost."""
1201
1196
if precompile_address not in fork .precompiles ():
@@ -1546,7 +1541,7 @@ def test_worst_tstore(
1546
1541
pre : Alloc ,
1547
1542
key_mut : bool ,
1548
1543
dense_val_mut : bool ,
1549
- ):
1544
+ ) -> None :
1550
1545
"""Test running a block with as many TSTORE calls as possible."""
1551
1546
init_key = 42
1552
1547
setup = Op .PUSH1 (init_key )
@@ -1825,7 +1820,7 @@ def test_worst_memory_access(
1825
1820
offset : int ,
1826
1821
offset_initialized : bool ,
1827
1822
big_memory_expansion : bool ,
1828
- ):
1823
+ ) -> None :
1829
1824
"""
1830
1825
Test running a block with as many memory access instructions as
1831
1826
possible.
@@ -2070,12 +2065,18 @@ def test_worst_calldataload(
2070
2065
benchmark_test : BenchmarkTestFiller ,
2071
2066
pre : Alloc ,
2072
2067
calldata : bytes ,
2073
- ):
2068
+ gas_benchmark_value : int ,
2069
+ fork : Fork ,
2070
+ ) -> None :
2074
2071
"""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 )
2075
2076
benchmark_test (
2076
2077
pre = pre ,
2077
2078
post = {},
2078
- code_generator = JumpLoopGenerator ( setup = Op . PUSH0 , attack_block = Op . CALLDATALOAD ) ,
2079
+ tx = tx ,
2079
2080
)
2080
2081
2081
2082
@@ -2141,7 +2142,7 @@ def test_worst_dup(
2141
2142
pre : Alloc ,
2142
2143
fork : Fork ,
2143
2144
opcode : Op ,
2144
- ):
2145
+ ) -> None :
2145
2146
"""Test running a block with as many DUP as possible."""
2146
2147
max_stack_height = fork .max_stack_height ()
2147
2148
@@ -2200,7 +2201,7 @@ def test_worst_push(
2200
2201
benchmark_test : BenchmarkTestFiller ,
2201
2202
pre : Alloc ,
2202
2203
opcode : Op ,
2203
- ):
2204
+ ) -> None :
2204
2205
"""Test running a block with as many PUSH as possible."""
2205
2206
benchmark_test (
2206
2207
pre = pre ,
@@ -2232,7 +2233,6 @@ def test_worst_return_revert(
2232
2233
opcode : Op ,
2233
2234
return_size : int ,
2234
2235
return_non_zero_data : bool ,
2235
- gas_benchmark_value : int ,
2236
2236
) -> None :
2237
2237
"""Test running a block with as many RETURN or REVERT as possible."""
2238
2238
max_code_size = fork .max_code_size ()
@@ -2268,9 +2268,6 @@ def test_worst_return_revert(
2268
2268
def test_worst_clz_same_input (
2269
2269
benchmark_test : BenchmarkTestFiller ,
2270
2270
pre : Alloc ,
2271
- fork : Fork ,
2272
- gas_benchmark_value : int ,
2273
- env : Environment ,
2274
2271
) -> None :
2275
2272
"""Test running a block with as many CLZ with same input as possible."""
2276
2273
magic_value = 248 # CLZ(248) = 248
@@ -2287,8 +2284,7 @@ def test_worst_clz_diff_input(
2287
2284
benchmark_test : BenchmarkTestFiller ,
2288
2285
pre : Alloc ,
2289
2286
fork : Fork ,
2290
- env : Environment ,
2291
- ):
2287
+ ) -> None :
2292
2288
"""
2293
2289
Test running a block with as many CLZ with different input as
2294
2290
possible.
0 commit comments