Skip to content

Commit fa36237

Browse files
committed
refactor(bal): Simplify the BlockAccessList class
- The class itself doesn't need to be `RLPSerializable`, just have simple instructions to serialize its elements (`rlp()`).
1 parent bc2e123 commit fa36237

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/ethereum_test_types/block_access_list.py

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

8-
from typing import Any, ClassVar, Dict, List
8+
from typing import Any, ClassVar, List
99

10+
import ethereum_rlp as eth_rlp
1011
from pydantic import Field
1112

1213
from ethereum_test_base_types import (
@@ -98,7 +99,7 @@ class BalAccountChange(CamelModel, RLPSerializable):
9899
]
99100

100101

101-
class BlockAccessList(CamelModel, RLPSerializable):
102+
class BlockAccessList(CamelModel):
102103
"""
103104
Expected Block Access List for verification.
104105
@@ -132,21 +133,19 @@ class BlockAccessList(CamelModel, RLPSerializable):
132133
default_factory=list, description="List of account changes in the block"
133134
)
134135

135-
rlp_fields: ClassVar[List[str]] = ["account_changes"]
136-
137-
def to_list(self, signing: bool = False) -> List[Any]:
136+
def to_list(self) -> List[Any]:
138137
"""
139-
Override to_list to return the account changes list directly.
138+
Return the account changes list directly for RLP encoding.
140139
141140
The BlockAccessList IS the list of account changes, not a container
142141
that contains a list, per EIP-7928.
143142
"""
144143
# Return the list of accounts directly, not wrapped in another list
145144
return to_serializable_element(self.account_changes)
146145

147-
def to_dict(self) -> Dict[str, Any]:
148-
"""Convert to dictionary for serialization."""
149-
return self.model_dump(exclude_none=True)
146+
def rlp(self) -> Bytes:
147+
"""Return the RLP encoded block access list for hash verification."""
148+
return Bytes(eth_rlp.encode(self.to_list()))
150149

151150
def verify_against(self, actual_bal: "BlockAccessList") -> None:
152151
"""

0 commit comments

Comments
 (0)