Skip to content

Commit e34ee25

Browse files
committed
fix(specs): Fix issues with new ruff + mypy rules after rebase
1 parent 1aa2044 commit e34ee25

File tree

7 files changed

+53
-53
lines changed

7 files changed

+53
-53
lines changed

src/ethereum/forks/amsterdam/block_access_lists/builder.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
"""
2-
Block Access List Builder for EIP-7928
3-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4-
5-
This module implements the Block Access List builder that tracks all account
2+
Implements the Block Access List builder that tracks all account
63
and storage accesses during block execution and constructs the final
74
[`BlockAccessList`].
85

src/ethereum/forks/amsterdam/block_access_lists/rlp_types.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
"""
2-
RLP Types for EIP-7928 Block-Level Access Lists
3-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4-
5-
This module defines the RLP data structures for Block-Level Access Lists
2+
Defines the RLP data structures for Block-Level Access Lists
63
as specified in EIP-7928. These structures enable efficient encoding and
74
decoding of all accounts and storage locations accessed during block execution.
85
96
The encoding follows the pattern:
10-
address -> field -> block_access_index -> change
7+
address -> field -> block_access_index -> change.
118
"""
129

1310
from dataclasses import dataclass
@@ -38,8 +35,8 @@
3835
@dataclass
3936
class StorageChange:
4037
"""
41-
Storage change: [block_access_index, new_value]
42-
RLP encoded as a list
38+
Storage change: [block_access_index, new_value].
39+
RLP encoded as a list.
4340
"""
4441

4542
block_access_index: BlockAccessIndex
@@ -50,8 +47,8 @@ class StorageChange:
5047
@dataclass
5148
class BalanceChange:
5249
"""
53-
Balance change: [block_access_index, post_balance]
54-
RLP encoded as a list
50+
Balance change: [block_access_index, post_balance].
51+
RLP encoded as a list.
5552
"""
5653

5754
block_access_index: BlockAccessIndex
@@ -62,8 +59,8 @@ class BalanceChange:
6259
@dataclass
6360
class NonceChange:
6461
"""
65-
Nonce change: [block_access_index, new_nonce]
66-
RLP encoded as a list
62+
Nonce change: [block_access_index, new_nonce].
63+
RLP encoded as a list.
6764
"""
6865

6966
block_access_index: BlockAccessIndex
@@ -74,8 +71,8 @@ class NonceChange:
7471
@dataclass
7572
class CodeChange:
7673
"""
77-
Code change: [block_access_index, new_code]
78-
RLP encoded as a list
74+
Code change: [block_access_index, new_code].
75+
RLP encoded as a list.
7976
"""
8077

8178
block_access_index: BlockAccessIndex
@@ -86,8 +83,8 @@ class CodeChange:
8683
@dataclass
8784
class SlotChanges:
8885
"""
89-
All changes to a single storage slot: [slot, [changes]]
90-
RLP encoded as a list
86+
All changes to a single storage slot: [slot, [changes]].
87+
RLP encoded as a list.
9188
"""
9289

9390
slot: StorageKey
@@ -100,7 +97,7 @@ class AccountChanges:
10097
"""
10198
All changes for a single account, grouped by field type.
10299
RLP encoded as: [address, storage_changes, storage_reads,
103-
balance_changes, nonce_changes, code_changes]
100+
balance_changes, nonce_changes, code_changes].
104101
"""
105102

106103
address: Address
@@ -127,7 +124,7 @@ class BlockAccessList:
127124
"""
128125
Block-Level Access List for EIP-7928.
129126
Contains all addresses accessed during block execution.
130-
RLP encoded as a list of AccountChanges
127+
RLP encoded as a list of AccountChanges.
131128
"""
132129

133130
account_changes: Tuple[AccountChanges, ...]

src/ethereum/forks/amsterdam/block_access_lists/rlp_utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
"""
2-
Block Access List RLP Utilities for EIP-7928
3-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4-
52
Utilities for working with Block Access Lists using RLP encoding,
63
as specified in EIP-7928.
74

src/ethereum/forks/amsterdam/block_access_lists/tracker.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
"""
2-
Block Access List State Change Tracker for EIP-7928
3-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4-
5-
This module provides state change tracking functionality for building Block
2+
Provides state change tracking functionality for building Block
63
Access Lists during transaction execution.
74
85
The tracker integrates with the EVM execution to capture all state accesses
96
and modifications, distinguishing between actual changes and no-op operations.
107
It maintains a cache of pre-state values to enable accurate change detection
118
throughout block execution.
129
13-
See [EIP-7928] for the full specification.
14-
10+
See [EIP-7928] for the full specification
1511
[EIP-7928]: https://eips.ethereum.org/EIPS/eip-7928
1612
"""
1713

src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ def signing_hash_155(self) -> Any:
131131

132132
@property
133133
def build_block_access_list(self) -> Any:
134-
"""Build function of the fork"""
134+
"""Build function of the fork."""
135135
return self._module("block_access_lists").build_block_access_list
136136

137137
@property
138138
def compute_block_access_list_hash(self) -> Any:
139-
"""compute_block_access_list_hash function of the fork"""
139+
"""compute_block_access_list_hash function of the fork."""
140140
return self._module(
141141
"block_access_lists"
142142
).compute_block_access_list_hash
143143

144144
@property
145145
def set_block_access_index(self) -> Any:
146-
"""set_block_access_index function of the fork"""
146+
"""set_block_access_index function of the fork."""
147147
return self._module("block_access_lists").set_block_access_index
148148

149149
@property

tests/json_infra/block_access_lists/test_bal_implementation.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Edge cases and error handling
99
"""
1010

11+
from typing import Dict
1112
from unittest.mock import MagicMock, patch
1213

1314
import pytest
@@ -24,6 +25,7 @@
2425
add_storage_write,
2526
add_touched_account,
2627
build_block_access_list,
28+
track_address_access,
2729
)
2830
from ethereum.forks.amsterdam.block_access_lists.rlp_types import (
2931
MAX_CODE_CHANGES,
@@ -38,6 +40,9 @@
3840
track_nonce_change,
3941
track_storage_write,
4042
)
43+
from ethereum.forks.amsterdam.fork_types import Address
44+
from ethereum.forks.amsterdam.state import State
45+
from ethereum.forks.amsterdam.trie import Trie
4146

4247

4348
class TestBALCore:
@@ -199,7 +204,7 @@ def test_tracker_set_block_access_index(self) -> None:
199204
builder = BlockAccessListBuilder()
200205
tracker = StateChangeTracker(builder)
201206

202-
set_block_access_index(tracker, 5)
207+
set_block_access_index(tracker, Uint(5))
203208
assert tracker.current_block_access_index == 5
204209
# Pre-storage cache should be cleared for new block access index
205210
assert tracker.pre_storage_cache == {}
@@ -239,7 +244,7 @@ def test_tracker_storage_write_actual_change(
239244
"""Test tracking storage write with actual change."""
240245
builder = BlockAccessListBuilder()
241246
tracker = StateChangeTracker(builder)
242-
tracker.current_block_access_index = 1
247+
tracker.current_block_access_index = Uint(1)
243248

244249
mock_state = MagicMock()
245250
address = Bytes20(b"\x01" * 20)
@@ -269,7 +274,7 @@ def test_tracker_storage_write_no_change(
269274
"""Test tracking storage write with no actual change."""
270275
builder = BlockAccessListBuilder()
271276
tracker = StateChangeTracker(builder)
272-
tracker.current_block_access_index = 1
277+
tracker.current_block_access_index = Uint(1)
273278

274279
mock_state = MagicMock()
275280
address = Bytes20(b"\x01" * 20)
@@ -289,7 +294,7 @@ def test_tracker_balance_change(self) -> None:
289294
"""Test tracking balance changes."""
290295
builder = BlockAccessListBuilder()
291296
tracker = StateChangeTracker(builder)
292-
tracker.current_block_access_index = 2
297+
tracker.current_block_access_index = Uint(2)
293298

294299
address = Bytes20(b"\x01" * 20)
295300
new_balance = U256(1000)
@@ -308,7 +313,7 @@ def test_tracker_nonce_change(self) -> None:
308313
"""Test tracking nonce changes."""
309314
builder = BlockAccessListBuilder()
310315
tracker = StateChangeTracker(builder)
311-
tracker.current_block_access_index = 3
316+
tracker.current_block_access_index = Uint(3)
312317

313318
address = Bytes20(b"\x01" * 20)
314319
new_nonce = U64(10)
@@ -326,7 +331,7 @@ def test_tracker_code_change(self) -> None:
326331
"""Test tracking code changes."""
327332
builder = BlockAccessListBuilder()
328333
tracker = StateChangeTracker(builder)
329-
tracker.current_block_access_index = 1
334+
tracker.current_block_access_index = Uint(1)
330335

331336
address = Bytes20(b"\x01" * 20)
332337
new_code = Bytes(b"\x60\x80\x60\x40")
@@ -624,11 +629,10 @@ class TestValueCalls:
624629
"""Test value call scenarios including 0 ETH calls."""
625630

626631
def test_zero_eth_value_call_tracks_address_without_balance(self) -> None:
627-
"""Test that 0 ETH calls track recipient address without balance changes."""
628-
from ethereum.forks.amsterdam.block_access_lists.tracker import (
629-
track_address_access,
630-
)
631-
632+
"""
633+
Test that 0 ETH calls track recipient address without
634+
balance changes.
635+
"""
632636
builder = BlockAccessListBuilder()
633637
tracker = StateChangeTracker(builder)
634638
set_block_access_index(tracker, Uint(1))
@@ -651,7 +655,10 @@ def test_zero_eth_value_call_tracks_address_without_balance(self) -> None:
651655
assert recipient_found
652656

653657
def test_nonzero_eth_value_call_tracks_with_balance(self) -> None:
654-
"""Test that non-zero ETH calls track addresses with balance changes."""
658+
"""
659+
Test that non-zero ETH calls track addresses with balance
660+
changes.
661+
"""
655662
builder = BlockAccessListBuilder()
656663
tracker = StateChangeTracker(builder)
657664
set_block_access_index(tracker, Uint(1))
@@ -683,10 +690,6 @@ def test_nonzero_eth_value_call_tracks_with_balance(self) -> None:
683690

684691
def test_multiple_zero_eth_calls_deduplication(self) -> None:
685692
"""Test that multiple 0 ETH calls to same address are deduplicated."""
686-
from ethereum.forks.amsterdam.block_access_lists.tracker import (
687-
track_address_access,
688-
)
689-
690693
builder = BlockAccessListBuilder()
691694
tracker = StateChangeTracker(builder)
692695
set_block_access_index(tracker, Uint(1))
@@ -740,8 +743,8 @@ def test_storage_write_becomes_read_on_revert(
740743
begin_call_frame(tracker)
741744

742745
# Mock state for storage operations
743-
class MockState:
744-
_storage_tries = {}
746+
class MockState(State):
747+
_storage_tries: Dict[Address, Trie[Bytes32, U256]] = {}
745748

746749
state = MockState()
747750

@@ -778,7 +781,10 @@ class MockState:
778781
assert account_found
779782

780783
def test_balance_changes_removed_on_revert(self) -> None:
781-
"""Test that balance changes are removed on revert but address remains."""
784+
"""
785+
Test that balance changes are removed on revert but address
786+
remains.
787+
"""
782788
from ethereum.forks.amsterdam.block_access_lists.tracker import (
783789
begin_call_frame,
784790
rollback_call_frame,
@@ -813,7 +819,10 @@ def test_balance_changes_removed_on_revert(self) -> None:
813819
assert account_found
814820

815821
def test_nested_call_frames_with_partial_revert(self) -> None:
816-
"""Test nested call frames where inner frame reverts but outer succeeds."""
822+
"""
823+
Test nested call frames where inner frame reverts but outer
824+
succeeds.
825+
"""
817826
from ethereum.forks.amsterdam.block_access_lists.tracker import (
818827
begin_call_frame,
819828
commit_call_frame,

tests/json_infra/block_access_lists/test_rlp.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Tests for RLP encoding and decoding of Cancun-specific objects."""
2+
13
import pytest
24
from ethereum_rlp import rlp
35
from ethereum_types.bytes import Bytes, Bytes0, Bytes8, Bytes32
@@ -174,6 +176,7 @@
174176
],
175177
)
176178
def test_cancun_rlp(rlp_object: rlp.Extended) -> None:
179+
"""Test RLP encoding and decoding for various Cancun objects."""
177180
encoded = rlp.encode(rlp_object)
178181
assert rlp.decode_to(type(rlp_object), encoded) == rlp_object
179182

@@ -182,5 +185,6 @@ def test_cancun_rlp(rlp_object: rlp.Extended) -> None:
182185
"tx", [legacy_transaction, access_list_transaction, transaction_1559]
183186
)
184187
def test_transaction_encoding(tx: Transaction) -> None:
188+
"""Test transaction RLP encoding and decoding."""
185189
encoded = encode_transaction(tx)
186190
assert decode_transaction(encoded) == tx

0 commit comments

Comments
 (0)