Closed weipin closed 6 months ago
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'
>>> b'5'.hex() '35'
Expected behavior
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 :)
Thanks for reporting @weipin,
@jmcook1186 could you have a look?
This issue is stale because it has been open 45 days with no activity.
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:
Uses py-trie to example the internal data of hashD:
Note:
b'5'
in the output above represents 0x35Expected behavior
I am new to this concept. Hope this issue makes sense and I wasn't missing anything.
May I @jmcook1186 :)