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

Refactor Trie #2355

Open
wants to merge 44 commits into
base: weiihann/improve-state-trie
Choose a base branch
from
Open

Conversation

weiihann
Copy link
Contributor

@weiihann weiihann commented Dec 31, 2024

This PR introduces a complete new Trie implementation. Some of the major changes:

  • Separation of node types - Makes code more intuitive, reduce redundant storage, separation of concerns, easier to extend functionalities
  • Performance Optimization - Stores trie in-memory, cache node hashes, Trie.Update + Trie.Commit is 4x faster
  • Range Proof - Solves the edge case of gapped range proof from the previous implementation

This PR is a standalone package and has not been integrated with the other parts of Juno. The integration and replacement of legacy trie implementation will be given in another PR.

Also, do note that the implementation of BitArray is exactly the same as before, please ignore it during the review process.

@weiihann weiihann changed the base branch from main to weiihann/improve-state-trie January 23, 2025 03:51
@weiihann weiihann marked this pull request as ready for review January 23, 2025 04:42
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 71.86825% with 521 lines in your changes missing coverage. Please review.

Project coverage is 73.63%. Comparing base (2fc5f61) to head (18b6b2a).

Files with missing lines Patch % Lines
core/trie2/trieutils/bitarray.go 73.71% 136 Missing and 7 partials ⚠️
core/trie2/proof.go 67.58% 103 Missing and 38 partials ⚠️
core/trie2/trie.go 78.88% 59 Missing and 17 partials ⚠️
core/trie2/node_enc.go 58.55% 31 Missing and 15 partials ⚠️
core/trie2/node.go 44.23% 29 Missing ⚠️
core/trie2/triedb/database.go 59.70% 21 Missing and 6 partials ⚠️
core/trie2/id.go 32.14% 19 Missing ⚠️
core/trie2/trienode/nodeset.go 72.22% 10 Missing and 5 partials ⚠️
core/trie2/hasher.go 86.66% 8 Missing and 2 partials ⚠️
utils/orderedset.go 0.00% 6 Missing ⚠️
... and 3 more
Additional details and impacted files
@@                       Coverage Diff                       @@
##           weiihann/improve-state-trie    #2355      +/-   ##
===============================================================
- Coverage                        73.77%   73.63%   -0.14%     
===============================================================
  Files                              138      150      +12     
  Lines                            16901    18753    +1852     
===============================================================
+ Hits                             12468    13809    +1341     
- Misses                            3568     3987     +419     
- Partials                           865      957      +92     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@weiihann weiihann force-pushed the weiihann/node-type branch 2 times, most recently from 1219c57 to 0d6173d Compare February 10, 2025 00:03
@weiihann weiihann added the State All things related to state label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
State All things related to state
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant