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

Add content for 4.5: Database and Merklized Storage #31

Merged
merged 5 commits into from
Jul 13, 2022

Conversation

sacha-l
Copy link

@sacha-l sacha-l commented May 20, 2022

First pass at adding content for 4.5: Database and Merklized Storage lesson.

Still need to flesh some things out with a little help of SMEs.

Things to note when reviewing:

  • Please include ideas for diagrams you'd like to see / add notes with TODOs.
  • Not sure how the "Cost to Read and Write" slide fits (this was material from the original lesson plan)
  • Most of this content is taken from Shawn's storage deep dive.

@sacha-l sacha-l requested a review from shawntabrizi May 20, 2022 16:43
## Complexity

* Reading
* Writing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is merkle proof on this slide?

@sacha-l sacha-l requested a review from cheme July 6, 2022 16:47
@cheme
Copy link

cheme commented Jul 7, 2022

@sacha-l I did review a bit in https://github.com/paritytech/polkadot-blockchain-academy/compare/sl/module-4-db-storage...ec-4-5?expand=1 .
Some is just possible additional content. Tell me if you want me to create proper github comment.

![Diagram of trie](http://placehold.jp/150x150.png)

</div>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea of slide for node description (general message is 'radix tree' is a well knowned struct and merklizing it is rather direct and elegant):

## Anatomy of a node

Tree contains nodes, in radix tree node is partialkey ++ n children ++ maybe_value

Merkle version is
partialkey ++ n children hash ++ maybe_value

Add constraint that terminal node always contains a value
Specialized this node for merklizing to these variants
Header branch ++ partialkey ++ n children hash ++ maybevaleu
Header leaf ++ partially ++ value hash
Value
And you got current trie
With the subtleties that if content under hash is smaller than it s hash, then it is written in the parent node instead of hash

@cheme
Copy link

cheme commented Jul 7, 2022

Been thinking, I got this branch that is a very incomplete, quite bad implementation of mmr as child trie, I was thinking of removing content from it and make it a 'complete code' exercise.
Could be ok for this module (not directly related but it can touch the overlay logic, and the encoded node storage model).

@sacha-l
Copy link
Author

sacha-l commented Jul 8, 2022

Thanks for the review @cheme. Your exercise seems like a great idea. Please share it and we can add it as a workshop option for this lecture.

As for the ec-4-5 branch, yes please make a PR against this branch with comments on what stuff you're adding. 🙏🏻

@cheme
Copy link

cheme commented Jul 8, 2022

The branch with child mmr is this one paritytech/substrate@master...cheme:substrate:child_other_contract2 that's pretty bad code (just drafting things).
The idea would be to work locally on the substrate branch (there is two test case so running both cargo test -p ... would take some time but only once so seems somehow manageable).
Still needs comments to help and more importantly removing the content to complete (not a huge work).
I did not implement the cumulus part which could be interesting as a followup.
Will try to do a PR (I also have to do one for 4.4 this afternoon (will be a bit off next week)).

@shawntabrizi shawntabrizi merged commit 200ccf8 into main Jul 13, 2022
@shawntabrizi shawntabrizi deleted the sl/module-4-db-storage branch July 13, 2022 12:54
kianenigma pushed a commit that referenced this pull request Jul 19, 2023
* Add draft content to 4.5

* Add and update content

* Additional content for 4.5 (#180)

* Comments

* clean a bit

* update

Co-authored-by: cheme <[email protected]>
Co-authored-by: Shawn Tabrizi <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants