Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fix(trie): decode inline child nodes #2369
fix(trie): decode inline child nodes #2369
Changes from all commits
fee33f3
3dc3fd5
cb21042
ff5ba1e
130487c
54d9b8a
db64597
3612b6c
02a3e67
cbe4b73
657b624
c94e83c
5154e16
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question, I guess this inline format cannot be used for branches right? Only for leaves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah so a few things here I think. Technically there could be, my impression of the logic is that any child node < 32 bytes can be in-lined leaf or branch.
The child parsing seems to be wrong in general? It looks like its currently parsing every child as a leaf node. Although I'm not sure it semantically makes a difference when its just a hash pointer.
Also, there are a few header types that are missing from the impl:
The mask size for hashed leaves and branches are different but after digging through the scale decoder implementation it looks like it handles that internally?
I think it's probably worth looking into some of the other issues but outside the scope of this PR? Maybe just have some open issues for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the
decodeBranch
comment mentions:In another PR, it would be interesting to refactor this to load from database as it decodes, especially since you can have in-lined encoded nodes, otherwise it's rather confusing. Created #2375.
That might be the case, I opened #2374, thanks so much for your investigation!
Are you sure? Can you point to some code you've seen? @timwu20 maybe do you have a clue on this?
Totally 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like that way based on this section of the header parsing code I shared above.
https://github.com/paritytech/substrate/blob/345e3b1fcbbb0c479a031c45859d7154e7c4b5f7/primitives/trie/src/node_header.rs#L97-L102
Leaf hash mask:
11100000
Branch hash mask:
11110000
Inisde of
decode_size()
, the max value of the header size is then32
and16
for leaf and branch headers respectively.