Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Extended type directly instead of using rlp.Extended #1050

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/ethereum/cancun/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from ethereum.utils.hexadecimal import hex_to_bytes

from .. import rlp
from ..rlp import Extended
from .blocks import Receipt, Withdrawal
from .fork_types import Account, Address, Root, encode_account
from .transactions import LegacyTransaction
Expand Down Expand Up @@ -83,7 +84,7 @@ class LeafNode:
"""Leaf node in the Merkle Trie"""

rest_of_key: Bytes
value: rlp.Extended
value: Extended


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

key_segment: Bytes
subnode: rlp.Extended
subnode: Extended


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

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


InternalNode = Union[LeafNode, ExtensionNode, BranchNode]


def encode_internal_node(node: Optional[InternalNode]) -> rlp.Extended:
def encode_internal_node(node: Optional[InternalNode]) -> 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 @@ -123,10 +124,10 @@ def encode_internal_node(node: Optional[InternalNode]) -> rlp.Extended:

Returns
-------
encoded : `rlp.Extended`
encoded : `Extended`
The node encoded as RLP.
"""
unencoded: rlp.Extended
unencoded: Extended
if node is None:
unencoded = b""
elif isinstance(node, LeafNode):
Expand Down
Loading