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

Is there any docs or words to explain way pr#142 change the leaf node from storing normal value to a hashed node? #152

Open
atenjin opened this issue Feb 20, 2022 · 2 comments

Comments

@atenjin
Copy link

atenjin commented Feb 20, 2022

relate to #142 and substrate pr paritytech/substrate#9732
I don't know why you design this feature, to change the leaf node from storing a normal value to a hashed node related to threshold.
This change causes a migration for substrate node, but I do not understand this feature is necessary.

It seems that this feature uses one more hash to bring less cause for calculating state root? or something else?

I do not find any discuss for this. Can you explain more reason for this feature?

@bkchr
Copy link
Member

bkchr commented Aug 4, 2022

CC @cheme

@cheme
Copy link
Contributor

cheme commented Aug 4, 2022

It is only to reduce proof size.

Gist of it is, if value is behind same merkle hash as the partial key of its node, then every access to the partial key will add the value in the proof and for three use case it is better to be able to only add hash of the value.

  • when you delete a value, you have to access the partial key in the node, and consequently check the full node, and consequently include the value to delete in the proof.
  • when splitting a node partial key (on some insert) some sibling value can be include in the proof.
  • when merging a parent node with its child (on some sibling removal).

I have no trace of original discussion (on riot a long time ago), but paritytech/substrate#11607 goes into more details about the implementation details.

Edit: forgot to mention, but also when updating a value without reading it, this allow not having the old value in proof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants