Skip to content

Commit 697da8f

Browse files
committed
Address comments from PR ethereum#2067
1 parent f8eaee7 commit 697da8f

File tree

6 files changed

+24
-50
lines changed

6 files changed

+24
-50
lines changed

src/ethereum_clis/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class Result(CamelModel):
6363
blob_gas_used: HexNumber | None = None
6464
requests_hash: Hash | None = None
6565
requests: List[Bytes] | None = None
66-
block_access_list: BlockAccessList | None = Field(None, alias="blockAccessList")
67-
block_access_list_hash: Hash | None = Field(None, alias="blockAccessListHash")
66+
block_access_list: BlockAccessList | None
67+
block_access_list_hash: Hash | None
6868
block_exception: Annotated[
6969
BlockExceptionWithMessage | UndefinedException | None, ExceptionMapperValidator
7070
] = None

src/ethereum_test_fixtures/blockchain.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ def genesis(cls, fork: Fork, env: Environment, state_root: Hash) -> "FixtureHead
234234
extras = {
235235
"state_root": state_root,
236236
"requests_hash": Requests() if fork.header_requests_required(0, 0) else None,
237-
# TODO: How should we handle the genesis block access list? Is `Hash(0)` fine?
238-
"block_access_list_hash": Hash(0) if fork.header_bal_hash_required(0, 0) else None,
237+
"block_access_list_hash": Hash([]) if fork.header_bal_hash_required(0, 0) else None,
239238
"fork": fork,
240239
}
241240
return FixtureHeader(**environment_values, **extras)
@@ -267,6 +266,10 @@ class FixtureExecutionPayload(CamelModel):
267266
transactions: List[Bytes]
268267
withdrawals: List[Withdrawal] | None = None
269268

269+
block_access_list: Bytes | None = Field(
270+
None, description="RLP-serialized EIP-7928 Block Access List"
271+
)
272+
270273
@classmethod
271274
def from_fixture_header(
272275
cls,

src/ethereum_test_forks/forks/forks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ class Amsterdam(Osaka):
18191819
@classmethod
18201820
def header_bal_hash_required(cls, block_number: int = 0, timestamp: int = 0) -> bool:
18211821
"""From Amsterdam, header must contain block access list hash (EIP-7928)."""
1822-
return block_number > 0 # Not required in genesis block
1822+
return True
18231823

18241824
@classmethod
18251825
def is_deployed(cls) -> bool:

src/ethereum_test_specs/blockchain.py

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,6 @@ class BlockchainTest(BaseTest):
430430
Exclude the post state from the fixture output.
431431
In this case, the state verification is only performed based on the state root.
432432
"""
433-
expected_block_access_list: BlockAccessListExpectation | None = None
434-
"""
435-
Expected block access list for verification.
436-
If set, verifies that the block access list returned by the client matches expectations.
437-
Use BlockAccessListExpectation to define partial validation expectations.
438-
"""
439433

440434
supported_fixture_formats: ClassVar[Sequence[FixtureFormat | LabeledFixtureFormat]] = [
441435
BlockchainFixture,
@@ -612,15 +606,18 @@ def generate_block_data(
612606
requests_list = block.requests
613607

614608
if fork.header_bal_hash_required(header.number, header.timestamp):
615-
if transition_tool_output.result.block_access_list is not None:
616-
rlp = transition_tool_output.result.block_access_list.rlp()
617-
computed_bal_hash = Hash(rlp.keccak256())
618-
if computed_bal_hash != header.block_access_list_hash:
619-
raise Exception(
620-
"Block access list hash in header does not match the "
621-
f"computed hash from BAL: {header.block_access_list_hash} "
622-
f"!= {computed_bal_hash}"
623-
)
609+
assert transition_tool_output.result.block_access_list is not None, (
610+
"Block access list is required for this block but was not provided "
611+
"by the transition tool"
612+
)
613+
614+
rlp = transition_tool_output.result.block_access_list.rlp()
615+
computed_bal_hash = Hash(rlp.keccak256())
616+
assert computed_bal_hash == header.block_access_list_hash, (
617+
"Block access list hash in header does not match the "
618+
f"computed hash from BAL: {header.block_access_list_hash} "
619+
f"!= {computed_bal_hash}"
620+
)
624621

625622
if block.rlp_modifier is not None:
626623
# Modify any parameter specified in the `rlp_modifier` after
@@ -708,28 +705,6 @@ def verify_post_state(self, t8n, t8n_state: Alloc, expected_state: Alloc | None
708705
print_traces(t8n.get_traces())
709706
raise e
710707

711-
def verify_block_access_list(
712-
self, actual_bal: BlockAccessList | None, expected_bal: BlockAccessListExpectation | None
713-
):
714-
"""
715-
Verify that the actual block access list matches expectations.
716-
717-
Args:
718-
actual_bal: The BlockAccessList returned by the client
719-
expected_bal: The expected BlockAccessList object
720-
721-
"""
722-
if expected_bal is None:
723-
return
724-
725-
if actual_bal is None:
726-
raise Exception("Expected block access list but got none.")
727-
728-
try:
729-
expected_bal.verify_against(actual_bal)
730-
except Exception as e:
731-
raise Exception("Block access list verification failed.") from e
732-
733708
def make_fixture(
734709
self,
735710
t8n: TransitionTool,

src/ethereum_test_types/block_access_list/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
these are simple data classes that can be composed together.
66
"""
77

8-
from typing import Any, Callable, ClassVar, List, Optional
8+
from typing import Any, Callable, ClassVar, List
99

1010
import ethereum_rlp as eth_rlp
1111
from pydantic import Field
@@ -169,7 +169,7 @@ class BlockAccessListExpectation(CamelModel):
169169
default_factory=list, description="Expected account changes to verify"
170170
)
171171

172-
modifier: Optional[Callable[["BlockAccessList"], "BlockAccessList"]] = Field(
172+
modifier: Callable[["BlockAccessList"], "BlockAccessList"] | None = Field(
173173
None,
174174
exclude=True,
175175
description="Optional modifier to modify the BAL for invalid tests",
@@ -281,10 +281,6 @@ def _compare_account_changes(
281281
)
282282
continue
283283

284-
# If actual is ``None`` but we expected something, raise
285-
if actual_value is None:
286-
raise AssertionError(f"Expected {field_name} but found none")
287-
288284
if field_name == "storage_reads":
289285
# Convert to comparable format (both are lists of 32-byte values)
290286
expected_set = {bytes(v) if hasattr(v, "__bytes__") else v for v in expected_value}

tests/amsterdam/eip7928_block_level_access_lists/spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class ReferenceSpec:
2121
class Spec:
2222
"""Constants and parameters from EIP-7928."""
2323

24-
# SSZ encoding is used for block access list data structures
25-
BAL_ENCODING_FORMAT: str = "SSZ"
24+
# RLP encoding is used for block access list data structures
25+
BAL_ENCODING_FORMAT: str = "RLP"
2626

2727
# Maximum limits for block access list data structures
2828
TARGET_MAX_GAS_LIMIT = 600_000_000

0 commit comments

Comments
 (0)