Skip to content

Commit e86958f

Browse files
chore: shorten docstrings and single-line comments to 79 (ruff w505: doc-line-too-long) (ethereum#2180)
* split comments across multiple lines when necessary * chore(tooling): check w505 in tox lint env * fixes * chore: remove abstract and other admonitions from test module docstrings * fixes * chore: fix more malformatted tables * chore: fix broken unordered-lists/args * chore: fix broken unordered-lists/args * chore: improve docstrings, also for D205 * chore: improve docstrings, also for D205 * chore: fix long or poorly formatted comments * chore: manually revert and fix docstrings/comments * fix: bad string formatting fix in unit test * last batch of manual fixes * fix * fix --------- Co-authored-by: danceratopz <danceratopz@gmail.com>
1 parent e92ba45 commit e86958f

File tree

229 files changed

+5110
-3380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+5110
-3380
lines changed

amsterdam/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
"""Test cases for EVM functionality introduced in Amsterdam, [EIP-7773: Hardfork Meta - Glamsterdam](https://eip.directory/eips/eip-7773).""" # noqa: E501
1+
"""
2+
Test cases for EVM functionality introduced in Amsterdam, [EIP-7773: Hardfork
3+
Meta - Glamsterdam](https://eip.directory/eips/eip-7773).
4+
"""

amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Test cases for invalid Block Access Lists.
33
4-
These tests verify that clients properly reject blocks with corrupted BALs
4+
These tests verify that clients properly reject blocks with corrupted BALs.
55
"""
66

77
import pytest
@@ -52,7 +52,10 @@ def test_bal_invalid_missing_nonce(
5252
blockchain_test: BlockchainTestFiller,
5353
pre: Alloc,
5454
):
55-
"""Test that clients reject blocks where BAL is missing required nonce changes."""
55+
"""
56+
Test that clients reject blocks where BAL is missing required nonce
57+
changes.
58+
"""
5659
sender = pre.fund_eoa(amount=10**18)
5760
receiver = pre.fund_eoa(amount=0)
5861

@@ -91,7 +94,9 @@ def test_bal_invalid_nonce_value(
9194
blockchain_test: BlockchainTestFiller,
9295
pre: Alloc,
9396
):
94-
"""Test that clients reject blocks where BAL contains incorrect nonce value."""
97+
"""
98+
Test that clients reject blocks where BAL contains incorrect nonce value.
99+
"""
95100
sender = pre.fund_eoa(amount=10**18)
96101
receiver = pre.fund_eoa(amount=0)
97102

@@ -130,7 +135,10 @@ def test_bal_invalid_storage_value(
130135
blockchain_test: BlockchainTestFiller,
131136
pre: Alloc,
132137
):
133-
"""Test that clients reject blocks where BAL contains incorrect storage values."""
138+
"""
139+
Test that clients reject blocks where BAL contains incorrect storage
140+
values.
141+
"""
134142
sender = pre.fund_eoa(amount=10**18)
135143

136144
# Simple storage contract with canary values
@@ -190,7 +198,10 @@ def test_bal_invalid_tx_order(
190198
blockchain_test: BlockchainTestFiller,
191199
pre: Alloc,
192200
):
193-
"""Test that clients reject blocks where BAL has incorrect transaction ordering."""
201+
"""
202+
Test that clients reject blocks where BAL has incorrect transaction
203+
ordering.
204+
"""
194205
sender1 = pre.fund_eoa(amount=10**18)
195206
sender2 = pre.fund_eoa(amount=10**18)
196207
receiver = pre.fund_eoa(amount=0)
@@ -247,7 +258,10 @@ def test_bal_invalid_account(
247258
blockchain_test: BlockchainTestFiller,
248259
pre: Alloc,
249260
):
250-
"""Test that clients reject blocks where BAL contains accounts that don't exist."""
261+
"""
262+
Test that clients reject blocks where BAL contains accounts that don't
263+
exist.
264+
"""
251265
sender = pre.fund_eoa(amount=10**18)
252266
receiver = pre.fund_eoa(amount=0)
253267
phantom = pre.fund_eoa(amount=0)
@@ -295,7 +309,10 @@ def test_bal_invalid_duplicate_account(
295309
blockchain_test: BlockchainTestFiller,
296310
pre: Alloc,
297311
):
298-
"""Test that clients reject blocks where BAL contains duplicate account entries."""
312+
"""
313+
Test that clients reject blocks where BAL contains duplicate account
314+
entries.
315+
"""
299316
sender = pre.fund_eoa(amount=10**18)
300317
receiver = pre.fund_eoa(amount=0)
301318

@@ -337,7 +354,9 @@ def test_bal_invalid_account_order(
337354
blockchain_test: BlockchainTestFiller,
338355
pre: Alloc,
339356
):
340-
"""Test that clients reject blocks where BAL has incorrect account ordering."""
357+
"""
358+
Test that clients reject blocks where BAL has incorrect account ordering.
359+
"""
341360
sender = pre.fund_eoa(amount=10**18)
342361
receiver = pre.fund_eoa(amount=0)
343362

@@ -454,7 +473,9 @@ def test_bal_invalid_missing_account(
454473
blockchain_test: BlockchainTestFiller,
455474
pre: Alloc,
456475
):
457-
"""Test that clients reject blocks where BAL is missing an entire account."""
476+
"""
477+
Test that clients reject blocks where BAL is missing an entire account.
478+
"""
458479
sender = pre.fund_eoa(amount=10**18)
459480
receiver = pre.fund_eoa(amount=0)
460481

@@ -496,7 +517,9 @@ def test_bal_invalid_balance_value(
496517
blockchain_test: BlockchainTestFiller,
497518
pre: Alloc,
498519
):
499-
"""Test that clients reject blocks where BAL contains incorrect balance value."""
520+
"""
521+
Test that clients reject blocks where BAL contains incorrect balance value.
522+
"""
500523
sender = pre.fund_eoa(amount=10**18)
501524
receiver = pre.fund_eoa(amount=0)
502525

benchmark/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
2-
abstract: Benchmark tests for EVMs.
3-
Benchmark tests aim to maximize the usage of a specific opcode,
4-
precompile, or operation within a transaction or block. These can
5-
be executed against EVM implementations to ensure they handle
6-
pathological cases efficiently and correctly, allowing Ethereum to
7-
safely [Scale the L1](https://protocol.ethereum.foundation/).
2+
Benchmark tests for EVMs.
3+
4+
Benchmark tests aim to maximize the usage of a specific opcode, precompile,
5+
or operation within a transaction or block. These can be executed against
6+
EVM implementations to ensure they handle pathological cases efficiently
7+
and correctly, allowing Ethereum to safely
8+
[Scale the L1](https://protocol.ethereum.foundation/).
89
"""

benchmark/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111

1212
def pytest_generate_tests(metafunc):
13-
"""Modify test generation to enforce default benchmark fork for benchmark tests."""
13+
"""
14+
Modify test generation to enforce default benchmark fork for benchmark
15+
tests.
16+
"""
1417
benchmark_dir = Path(__file__).parent
1518
test_file_path = Path(metafunc.definition.fspath)
1619

benchmark/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def code_loop_precompile_call(calldata: Bytecode, attack_block: Bytecode, fork:
99
"""Create a code loop that calls a precompile with the given calldata."""
1010
max_code_size = fork.max_code_size()
1111

12-
# The attack contract is: CALLDATA_PREP + #JUMPDEST + [attack_block]* + JUMP(#)
12+
# The attack contract is: CALLDATA_PREP + #JUMPDEST + [attack_block]* +
13+
# JUMP(#)
1314
jumpdest = Op.JUMPDEST
1415
jump_back = Op.JUMP(len(calldata))
1516
max_iters_loop = (max_code_size - len(calldata) - len(jumpdest) - len(jump_back)) // len(

benchmark/test_worst_blocks.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
"""
2-
abstract: Tests that benchmark EVMs in worst-case block scenarios.
3-
Tests that benchmark EVMs in worst-case block scenarios.
4-
5-
Tests running worst-case block scenarios for EVMs.
2+
Tests that benchmark EVMs in worst-case block scenarios.
63
"""
74

85
import random
@@ -26,7 +23,10 @@
2623

2724
@pytest.fixture
2825
def iteration_count(intrinsic_cost: int, gas_benchmark_value: int):
29-
"""Calculate the number of iterations based on the gas limit and intrinsic cost."""
26+
"""
27+
Calculate the number of iterations based on the gas limit and intrinsic
28+
cost.
29+
"""
3030
return gas_benchmark_value // intrinsic_cost
3131

3232

@@ -186,12 +186,14 @@ def test_block_full_data(
186186
gas_benchmark_value: int,
187187
):
188188
"""Test a block with empty payload."""
189-
# Gas cost calculation based on EIP-7683: (https://eips.ethereum.org/EIPS/eip-7683)
189+
# Gas cost calculation based on EIP-7683:
190+
# (https://eips.ethereum.org/EIPS/eip-7683)
190191
#
191192
# tx.gasUsed = 21000 + max(
192193
# STANDARD_TOKEN_COST * tokens_in_calldata
193194
# + execution_gas_used
194-
# + isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata)),
195+
# + isContractCreation * (32000 +
196+
# INITCODE_WORD_COST * words(calldata)),
195197
# TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata)
196198
#
197199
# Simplified in this test case:
@@ -208,7 +210,8 @@ def test_block_full_data(
208210
# Token accounting:
209211
# tokens_in_calldata = zero_bytes + 4 * non_zero_bytes
210212
#
211-
# So we calculate how many bytes we can fit into calldata based on available gas.
213+
# So we calculate how many bytes we can fit into calldata based on
214+
# available gas.
212215

213216
gas_available = gas_benchmark_value - intrinsic_cost
214217

@@ -240,7 +243,10 @@ def test_block_full_access_list_and_data(
240243
fork: Fork,
241244
gas_benchmark_value: int,
242245
):
243-
"""Test a block with access lists (60% gas) and calldata (40% gas) using random mixed bytes."""
246+
"""
247+
Test a block with access lists (60% gas) and calldata (40% gas) using
248+
random mixed bytes.
249+
"""
244250
attack_gas_limit = gas_benchmark_value
245251
gas_available = attack_gas_limit - intrinsic_cost
246252

@@ -271,7 +277,8 @@ def test_block_full_access_list_and_data(
271277
)
272278
]
273279

274-
# Calculate calldata with 29% of gas for zero bytes and 71% for non-zero bytes
280+
# Calculate calldata with 29% of gas for zero bytes and 71% for non-zero
281+
# bytes
275282
# Token accounting: tokens_in_calldata = zero_bytes + 4 * non_zero_bytes
276283
# We want to split the gas budget:
277284
# - 29% of gas_for_calldata for zero bytes
@@ -287,7 +294,8 @@ def test_block_full_access_list_and_data(
287294
# Zero bytes: 1 token per byte
288295
# Non-zero bytes: 4 tokens per byte
289296
num_zero_bytes = tokens_for_zero_bytes # 1 token = 1 zero byte
290-
num_non_zero_bytes = tokens_for_non_zero_bytes // 4 # 4 tokens = 1 non-zero byte
297+
# 4 tokens = 1 non-zero byte
298+
num_non_zero_bytes = tokens_for_non_zero_bytes // 4
291299

292300
# Create calldata with mixed bytes
293301
calldata = bytearray()

0 commit comments

Comments
 (0)