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

HashE (node E) from the "Patricia Merkle Trie" example is embeddable #6860

Closed
weipin opened this issue Jun 29, 2022 · 2 comments · Fixed by #11850
Closed

HashE (node E) from the "Patricia Merkle Trie" example is embeddable #6860

weipin opened this issue Jun 29, 2022 · 2 comments · Fixed by #11850
Assignees
Labels
bug 🐛 Something isn't working Status: Stale This issue is stale because it has been open 30 days with no activity.

Comments

@weipin
Copy link

weipin commented Jun 29, 2022

HashE (node E) from the "Patricia Merkle Trie" example is embeddable

The current trie example lists "hashE" as a standalone extension node.
The node has a length of 31 in bytes in RLP encoding, making it actually "embeddable."
In other words, "hashE" shouldn't exist as a standalone node but be embedded in "hashD".

To Reproduce
Steps to reproduce the behavior:

Uses pyrlp to calculate the node length in bytes:

>>> import rlp
>>> len(rlp.encode([ 0x17, [ [], [], [], [], [], [], [ 0x35, "coin" ], [], [], [], [], [], [], [], [], [], "puppy" ] ]))
31

Uses py-trie to example the internal data of hashD:

>>> from trie import HexaryTrie

>>> t = HexaryTrie(db={})
>>> t.set(b'do', b'verb')
>>> t.set(b'dog', b'puppy')
>>> t.set(b'doge', b'coin')
>>> t.set(b'horse', b'stallion')

>>> t.traverse(t.root_node.sub_segments[0] + (0x4, 0x6, 0xf))
HexaryTrieNode(sub_segments=((0x6,),), value=b'verb', suffix=(), raw=[b'', b'', b'', b'', b'', b'', [b'\x17', [b'', b'', b'', b'', b'', b'', [b'5', b'coin'], b'', b'', b'', b'', b'', b'', b'', b'', b'', b'puppy']], b'', b'', b'', b'', b'', b'', b'', b'', b'', b'verb'], node_type=<NodeType.BRANCH: 3>)

Note: b'5' in the output above represents 0x35

>>> b'5'.hex()
'35'

Expected behavior

  • The length of "HashE" (node E) in bytes is greater or equal to 32 (so it will be standalone).
  • The internal data of hashD is something like this:
    HexaryTrieNode(sub_segments=((0x6,),), value=b'verb', suffix=(), raw=[b'', b'', b'', b'', b'', b'', b'XXXX hashE XXXX', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'verb'], node_type=<NodeType.BRANCH: 3>)
    

I am new to this concept. Hope this issue makes sense and I wasn't missing anything.

May I @jmcook1186 :)

@weipin weipin added the bug 🐛 Something isn't working label Jun 29, 2022
@minimalsm
Copy link
Contributor

Thanks for reporting @weipin,

@jmcook1186 could you have a look?

@github-actions
Copy link
Contributor

This issue is stale because it has been open 45 days with no activity.

@github-actions github-actions bot added the Status: Stale This issue is stale because it has been open 30 days with no activity. label Aug 15, 2022
lgaroche added a commit to lgaroche/ethereum-org-website that referenced this issue Jan 2, 2024
lgaroche added a commit to lgaroche/ethereum-org-website that referenced this issue Jan 2, 2024
lgaroche added a commit to lgaroche/ethereum-org-website that referenced this issue Jan 15, 2024
lgaroche added a commit to lgaroche/ethereum-org-website that referenced this issue Jan 15, 2024
wackerow added a commit that referenced this issue Apr 23, 2024
Correct example trie structure [Fixes #6860]
This was referenced Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working Status: Stale This issue is stale because it has been open 30 days with no activity.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants