Skip to content

Conversation

@danielpapp-trilitech
Copy link
Contributor

What

Unifying the tree implementations as specializations of the Tree<A> generic and adding data to the node variant.

Why

We need to store data in the node variants as well, because we would like to include the AVL tree in the proofs and this is a tree that contains the balance factor in the internal nodes so we need a way to store data in the internal nodes.

How

I changed the Tree<A> into a Tree<LeafData, NodeData> type. Made the MerkleProof and the CompressedMerkleProof a specialization of this. Once these changes are in place we should be able to turn the AVL tree and the whole registry in the durable storage into a proof and include it in the PVM.

Manually Testing

make all

Regressions

N/A

Tasks for the Author

  • Link all Linear issues related to this MR using magic words (e.g. part of, relates to, closes).
  • Eliminate dead code and other spurious artefacts introduced in your changes.
  • Document new public functions, methods and types.
  • Make sure the documentation for updated functions, methods, and types is correct.
  • Add tests for bugs that have been fixed.
  • Explain changes to regression test captures when applicable.
  • Write commit messages in agreement with our guidelines.
  • Self-review your changes to ensure they are high-quality.
  • Complete all of the above before assigning this MR to reviewers.

@github-actions
Copy link

Benchmark results for revision c2070a7:

Metric Duration TPS
Mean 1.692332004s 23.636
Worst 1.703769385s 23.477
Best 1.684374084s 23.748
Standard Deviation ±5.208625ms ±0.073
Full results
Run Transfers Duration TPS
1 40 1.703676221s 23.479
2 40 1.695537733s 23.591
3 40 1.695085907s 23.598
4 40 1.687457708s 23.704
5 40 1.691804753s 23.643
6 40 1.69797168s 23.558
7 40 1.691338249s 23.650
8 40 1.684374084s 23.748
9 40 1.703769385s 23.477
10 40 1.685747727s 23.728
11 40 1.692662661s 23.631
12 40 1.693648056s 23.618
13 40 1.690209237s 23.666
14 40 1.695714287s 23.589
15 40 1.688304039s 23.692
16 40 1.691843536s 23.643
17 40 1.6913659s 23.650
18 40 1.692961632s 23.627
19 40 1.686743354s 23.714
20 40 1.686423933s 23.719

Compare the results above with those for the default branch.

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 90.73806% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.71%. Comparing base (8a66770) to head (15b7bac).

Files with missing lines Patch % Lines
data/src/compressed_merkle_tree.rs 91.73% 6 Missing and 25 partials ⚠️
src/riscv/lib/src/state_backend/proof_layout.rs 40.00% 22 Missing and 2 partials ⚠️
data/src/merkle_proof/proof_tree.rs 91.95% 3 Missing and 4 partials ⚠️
data/src/tree.rs 0.00% 1 Missing ⚠️
...riscv/lib/src/state_backend/proof_backend/proof.rs 98.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #516      +/-   ##
==========================================
- Coverage   90.93%   90.71%   -0.22%     
==========================================
  Files         110      111       +1     
  Lines       20070    20395     +325     
  Branches    20070    20395     +325     
==========================================
+ Hits        18250    18502     +252     
- Misses       1540     1614      +74     
+ Partials      280      279       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danielpapp-trilitech danielpapp-trilitech force-pushed the dpapp/change_the_merkle_stree_structure branch 3 times, most recently from 7410580 to a88d59c Compare November 26, 2025 13:25
@danielpapp-trilitech danielpapp-trilitech force-pushed the dpapp/change_the_merkle_stree_structure branch 3 times, most recently from 5cf4e22 to 15b7bac Compare November 27, 2025 19:46
Making the mentioned enum variant a struct for
better readability.

WIP reafactor(data): Removing impl_modify_map_collect

I'm removing the mentioned function because I
need to make some modifications to the MerkleTree
struct and I need to change how it's
serialized and this function is just
not lending itself to refactoring.

refactor(data): Adding the tailcall crate

Added the tailcall trait and moved all former
impl_modify_map_collect implementations to
recursive From trait implementations.
Added a generic NodeData variable to the Tree
data structure and changed the MerkleTree
implementation accordingly.
Making the CompressedMerkleTree a specialization
of the Tree generic type.
Making the MerkleTree be a type synonym for
a Tree<LeafData, NodeData>
@danielpapp-trilitech danielpapp-trilitech force-pushed the dpapp/change_the_merkle_stree_structure branch from 15b7bac to ca3c925 Compare November 28, 2025 11:51
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.

2 participants