A leaf node is defined as the tuple [encodedPath, value], and encodedPath uses the Hex-Prefix encoding. Is it possible we have a leaf node with encodedPath having only the prefix and no partial path included?
Taking the following data...
<5e 52> : 'val1'
<ac 40> : 'val2'
<ac 4f> : 'val3'
...would the trie look like this or I am wrong?
rootHash: [ <>, <>, <>, <>, <>, hashA, <>, <>, <>, <>, hashB, <>, <>, <>, <>, <>, <> ]
hashA: [ <3e 52>, 'val1' ]
hashB: [ <00 c4>, hashC ]
hashC: [ hashD, <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, <>, hashE, <> ]
hashD: [ <20>, 'val2' ]
hashE: [ <20>, 'val3' ]
Note that rootHash
and hashC
are branch nodes; hashB
is an extension node; and hashA
, hashD
and hashE
are leaf nodes.
My doubt is related to hashD
and hashE
encodedPaths. If I understood it's correct to put 20
as in HP encoding a leaf node with even path length (in these cases 0) should get the prefix 2
and an additional 0
padding nibble.