Skip to content

Commit

Permalink
Port #968 to prague
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWilsn committed Aug 13, 2024
1 parent 90ce8d4 commit e46144d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/ethereum/prague/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
Sequence,
TypeVar,
Union,
cast,
)

from ethereum.cancun import trie as previous_trie
Expand Down Expand Up @@ -81,7 +80,7 @@ class LeafNode:
"""Leaf node in the Merkle Trie"""

rest_of_key: Bytes
value: rlp.RLP
value: rlp.Extended


@slotted_freezable
Expand All @@ -90,22 +89,22 @@ class ExtensionNode:
"""Extension node in the Merkle Trie"""

key_segment: Bytes
subnode: rlp.RLP
subnode: rlp.Extended


@slotted_freezable
@dataclass
class BranchNode:
"""Branch node in the Merkle Trie"""

subnodes: List[rlp.RLP]
value: rlp.RLP
subnodes: List[rlp.Extended]
value: rlp.Extended


InternalNode = Union[LeafNode, ExtensionNode, BranchNode]


def encode_internal_node(node: Optional[InternalNode]) -> rlp.RLP:
def encode_internal_node(node: Optional[InternalNode]) -> rlp.Extended:
"""
Encodes a Merkle Trie node into its RLP form. The RLP will then be
serialized into a `Bytes` and hashed unless it is less that 32 bytes
Expand All @@ -121,10 +120,10 @@ def encode_internal_node(node: Optional[InternalNode]) -> rlp.RLP:
Returns
-------
encoded : `rlp.RLP`
encoded : `rlp.Extended`
The node encoded as RLP.
"""
unencoded: rlp.RLP
unencoded: rlp.Extended
if node is None:
unencoded = b""
elif isinstance(node, LeafNode):
Expand Down Expand Up @@ -159,7 +158,7 @@ def encode_node(node: Node, storage_root: Optional[Bytes] = None) -> Bytes:
assert storage_root is not None
return encode_account(node, storage_root)
elif isinstance(node, (LegacyTransaction, Receipt, Withdrawal, U256)):
return rlp.encode(cast(rlp.RLP, node))
return rlp.encode(node)
elif isinstance(node, Bytes):
return node
else:
Expand Down

0 comments on commit e46144d

Please sign in to comment.