Skip to content

Commit 2c4b60e

Browse files
committed
refactor: move rlp_utils to block_access_lists; bal -> block_access_lists
1 parent e8b05b4 commit 2c4b60e

File tree

13 files changed

+34
-28
lines changed

13 files changed

+34
-28
lines changed

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,12 @@ ignore = [
517517
"src/ethereum/forks/amsterdam/blocks.py" = [
518518
"E501" # Line too long - needed for long ref links
519519
]
520+
"src/ethereum/forks/amsterdam/block_access_lists/builder.py" = [
521+
"E501" # Line too long - needed for long ref links
522+
]
523+
"src/ethereum/forks/amsterdam/block_access_lists/rlp_utils.py" = [
524+
"E501" # Line too long - needed for long ref links
525+
]
520526

521527
[tool.ruff.lint.mccabe]
522528
# Set the maximum allowed cyclomatic complexity. C901 default is 10.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ethereum_types.numeric import U64, U256
2424

2525
from ..fork_types import Address
26-
from ..rlp_types import (
26+
from .rlp_types import (
2727
AccountChanges,
2828
BalanceChange,
2929
BlockAccessIndex,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
from ethereum.crypto.hash import Hash32, keccak256
2626

27-
from ..rlp_types import MAX_CODE_SIZE, MAX_TXS, BlockAccessList
2827
from .builder import BlockAccessListBuilder
28+
from .rlp_types import MAX_CODE_SIZE, MAX_TXS, BlockAccessList
2929

3030

3131
def compute_block_access_list_hash(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from ethereum_types.numeric import U64, U256, Uint
2323

2424
from ..fork_types import Address
25-
from ..rlp_types import BlockAccessIndex
2625
from .builder import (
2726
BlockAccessListBuilder,
2827
add_balance_change,
@@ -32,6 +31,7 @@
3231
add_storage_write,
3332
add_touched_account,
3433
)
34+
from .rlp_types import BlockAccessIndex
3535

3636
if TYPE_CHECKING:
3737
from ..state import State # noqa: F401

src/ethereum/forks/amsterdam/blocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
from ethereum.crypto.hash import Hash32
2020

21+
from .block_access_lists.rlp_types import BlockAccessList
2122
from .fork_types import Address, Bloom, Root
22-
from .rlp_types import BlockAccessList
2323
from .transactions import (
2424
AccessListTransaction,
2525
BlobTransaction,
@@ -242,7 +242,7 @@ class Header:
242242
[SHA2-256]: https://en.wikipedia.org/wiki/SHA-2
243243
"""
244244

245-
bal_hash: Hash32
245+
block_access_list_hash: Hash32
246246
"""
247247
[SHA2-256] hash of the Block Access List containing all accounts and
248248
storage locations accessed during block execution. Introduced in

src/ethereum/forks/amsterdam/fork.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def state_transition(chain: BlockChain, block: Block) -> None:
271271
raise InvalidBlock
272272
if requests_hash != block.header.requests_hash:
273273
raise InvalidBlock
274-
if computed_block_access_list_hash != block.header.bal_hash:
274+
if computed_block_access_list_hash != block.header.block_access_list_hash:
275275
raise InvalidBlock("Invalid block access list hash")
276276

277277
chain.blocks.append(block)
@@ -765,7 +765,7 @@ def apply_body(
765765
block_output = vm.BlockOutput()
766766

767767
# Set system transaction index for pre-execution system contracts
768-
# EIP-7928: System contracts use bal_index 0
768+
# EIP-7928: System contracts use block_access_index 0
769769
set_transaction_index(block_env.state.change_tracker, Uint(0))
770770

771771
process_unchecked_system_transaction(
@@ -783,7 +783,7 @@ def apply_body(
783783
for i, tx in enumerate(map(decode_transaction, transactions)):
784784
process_transaction(block_env, block_output, tx, Uint(i))
785785

786-
# EIP-7928: Post-execution uses bal_index len(transactions) + 1
786+
# EIP-7928: Post-execution uses block_access_index len(transactions) + 1
787787
post_execution_index = ulen(transactions) + Uint(1)
788788
set_transaction_index(block_env.state.change_tracker, post_execution_index)
789789

@@ -873,7 +873,7 @@ def process_transaction(
873873
index:
874874
Index of the transaction in the block.
875875
"""
876-
# EIP-7928: Transactions use bal_index 1 to len(transactions)
876+
# EIP-7928: Transactions use block_access_index 1 to len(transactions)
877877
set_transaction_index(block_env.state.change_tracker, index + Uint(1))
878878

879879
trie_set(

src/ethereum/forks/amsterdam/vm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
from ethereum.crypto.hash import Hash32
2323
from ethereum.exceptions import EthereumException
2424

25+
from ..block_access_lists.rlp_types import BlockAccessList
2526
from ..blocks import Log, Receipt, Withdrawal
2627
from ..fork_types import Address, Authorization, VersionedHash
27-
from ..rlp_types import BlockAccessList
2828
from ..state import State, TransientStorage
2929
from ..transactions import LegacyTransaction
3030
from ..trie import Trie

src/ethereum/genesis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def add_genesis_block(
259259
if has_field(hardfork.Header, "requests_hash"):
260260
fields["requests_hash"] = Hash32(b"\0" * 32)
261261

262-
if has_field(hardfork.Header, "bal_hash"):
263-
fields["bal_hash"] = Hash32(b"\0" * 32)
262+
if has_field(hardfork.Header, "block_access_list_hash"):
263+
fields["block_access_list_hash"] = Hash32(b"\0" * 32)
264264

265265
genesis_header = hardfork.Header(**fields)
266266

src/ethereum_spec_tools/evm_tools/t8n/t8n_types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def update(self, t8n: "T8N", block_env: Any, block_output: Any) -> None:
333333
)
334334
)
335335

336-
def _bal_to_json(self, bal: Any) -> Any:
336+
def _block_access_list_to_json(self, bal: Any) -> Any:
337337
"""
338338
Convert BlockAccessList to JSON format matching the Pydantic models.
339339
"""
@@ -475,7 +475,9 @@ def to_json(self) -> Any:
475475

476476
if self.block_access_list is not None:
477477
# Convert BAL to JSON format
478-
data["blockAccessList"] = self._bal_to_json(self.block_access_list)
478+
data["blockAccessList"] = self._block_access_list_to_json(
479+
self.block_access_list
480+
)
479481

480482
if self.block_access_list_hash is not None:
481483
data["blockAccessListHash"] = encode_to_hex(

0 commit comments

Comments
 (0)