Skip to content

Commit 50b6b30

Browse files
fix linting and typing issue
1 parent 41f0caa commit 50b6b30

File tree

6 files changed

+27
-37
lines changed

6 files changed

+27
-37
lines changed

tests/benchmark/test_worst_blocks.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
BenchmarkTestFiller,
1919
Block,
2020
BlockchainTestFiller,
21-
Environment,
2221
Hash,
2322
Transaction,
2423
)
@@ -117,13 +116,11 @@ def ether_transfer_case(
117116
def test_block_full_of_ether_transfers(
118117
benchmark_test: BenchmarkTestFiller,
119118
pre: Alloc,
120-
env: Environment,
121119
case_id: str,
122120
ether_transfer_case: Tuple[Generator[Address, None, None], Generator[Address, None, None]],
123121
iteration_count: int,
124122
transfer_amount: int,
125123
intrinsic_cost: int,
126-
gas_benchmark_value: int,
127124
) -> None:
128125
"""
129126
Single test for ether transfer scenarios.
@@ -183,8 +180,7 @@ def calldata_generator(
183180
gas_amount: int,
184181
zero_byte: int,
185182
total_cost_floor_per_token: int,
186-
total_cost_standard_per_token: int,
187-
):
183+
) -> bytes:
188184
"""Calculate the calldata based on the gas amount and zero byte."""
189185
# Gas cost calculation based on EIP-7683: (https://eips.ethereum.org/EIPS/eip-7683)
190186
#
@@ -228,7 +224,7 @@ def test_block_full_data(
228224
tx_gas_limit_cap: int,
229225
total_cost_standard_per_token: int,
230226
fork: Fork,
231-
):
227+
) -> None:
232228
"""Test a block with empty payload."""
233229
iteration_count = math.ceil(gas_benchmark_value / tx_gas_limit_cap)
234230

@@ -241,7 +237,6 @@ def test_block_full_data(
241237
gas_available,
242238
zero_byte,
243239
total_cost_floor_per_token,
244-
total_cost_standard_per_token,
245240
)
246241

247242
total_gas_used += fork.transaction_intrinsic_cost_calculator()(calldata=data)
@@ -272,7 +267,7 @@ def test_block_full_access_list_and_data(
272267
fork: Fork,
273268
gas_benchmark_value: int,
274269
tx_gas_limit_cap: int,
275-
):
270+
) -> None:
276271
"""
277272
Test a block with access lists (60% gas) and calldata (40% gas) using
278273
random mixed bytes.

tests/benchmark/test_worst_bytecode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ def test_worst_create(
343343
max_code_size_ratio: float,
344344
non_zero_data: bool,
345345
value: int,
346-
gas_benchmark_value: int,
347346
) -> None:
348347
"""
349348
Test the CREATE and CREATE2 performance with different configurations.

tests/benchmark/test_worst_compute.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Any, cast
1010

1111
import pytest
12+
from _pytest.mark import ParameterSet
1213
from py_ecc.bn128 import G1, G2, multiply
1314

1415
from ethereum_test_base_types.base_types import Bytes, HexNumber
@@ -20,7 +21,6 @@
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(
215211
def 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(
22682268
def 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.

tests/benchmark/test_worst_memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_worst_codecopy(
155155
fork: Fork,
156156
max_code_size_ratio: float,
157157
fixed_src_dst: bool,
158-
):
158+
) -> None:
159159
"""Test running a block filled with CODECOPY executions."""
160160
max_code_size = fork.max_code_size()
161161

@@ -212,7 +212,7 @@ def test_worst_returndatacopy(
212212
pre: Alloc,
213213
size: int,
214214
fixed_dst: bool,
215-
):
215+
) -> None:
216216
"""Test running a block filled with RETURNDATACOPY executions."""
217217
# Create the contract that will RETURN the data that will be used for
218218
# RETURNDATACOPY.
@@ -278,7 +278,7 @@ def test_worst_mcopy(
278278
pre: Alloc,
279279
size: int,
280280
fixed_src_dst: bool,
281-
):
281+
) -> None:
282282
"""Test running a block filled with MCOPY executions."""
283283
src_dst = 0 if fixed_src_dst else Op.MOD(Op.GAS, 7)
284284
attack_block = Op.MCOPY(src_dst, src_dst, size)

tests/benchmark/test_worst_opcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_worst_log_opcodes(
4444
size: int,
4545
fixed_offset: bool,
4646
non_zero_data: bool,
47-
):
47+
) -> None:
4848
"""Test running a block with as many LOG opcodes as possible."""
4949
setup = Bytecode()
5050

tests/benchmark/test_worst_stateful_opcodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_worst_address_state_warm(
139139
pre: Alloc,
140140
opcode: Op,
141141
absent_target: bool,
142-
):
142+
) -> None:
143143
"""
144144
Test running a block with as many stateful opcodes doing warm access
145145
for an account.
@@ -376,7 +376,7 @@ def test_worst_storage_access_warm(
376376
storage_action: StorageAction,
377377
gas_benchmark_value: int,
378378
env: Environment,
379-
):
379+
) -> None:
380380
"""
381381
Test running a block with as many warm storage slot accesses as
382382
possible.
@@ -441,7 +441,7 @@ def test_worst_blockhash(
441441
fork: Fork,
442442
gas_benchmark_value: int,
443443
tx_gas_limit_cap: int,
444-
):
444+
) -> None:
445445
"""
446446
Test running a block with as many blockhash accessing oldest allowed block
447447
as possible.
@@ -483,7 +483,7 @@ def test_worst_blockhash(
483483
def test_worst_selfbalance(
484484
benchmark_test: BenchmarkTestFiller,
485485
pre: Alloc,
486-
):
486+
) -> None:
487487
"""Test running a block with as many SELFBALANCE opcodes as possible."""
488488
benchmark_test(
489489
pre=pre,

0 commit comments

Comments
 (0)