Skip to content

feat(Merkle): Tree and Node IDs for Verify#960

Open
kurtisc wants to merge 1 commit intomainfrom
kurtis/durable-storage/verify-resolver
Open

feat(Merkle): Tree and Node IDs for Verify#960
kurtisc wants to merge 1 commit intomainfrom
kurtis/durable-storage/verify-resolver

Conversation

@kurtisc
Copy link
Copy Markdown
Contributor

@kurtisc kurtisc commented Mar 27, 2026

Closes RV-949

What

Adds support for parsing MAVL tree proofs for Verify mode

Why

This is needed as part of supporting Verify mode in the Merkle layer.

How

  • Adds VerifyNodeId/VerifyTreeId
  • Implements Resolver for each
  • Implements proof parsing for the nodes and trees

Manually Testing

make all

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.

@kurtisc kurtisc force-pushed the kurtis/durable-storage/verify-resolver branch 2 times, most recently from 1945f6f to da9bc7d Compare March 27, 2026 14:15
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.71%. Comparing base (6b8df3c) to head (1134f2a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #960   +/-   ##
=======================================
  Coverage   89.70%   89.71%           
=======================================
  Files         110      110           
  Lines       22136    22136           
  Branches    22136    22136           
=======================================
+ Hits        19857    19859    +2     
+ Misses       1884     1882    -2     
  Partials      395      395           

☔ 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.

@kurtisc kurtisc force-pushed the kurtis/durable-storage/verify-resolver branch 3 times, most recently from 8799a96 to 9646f78 Compare March 30, 2026 12:14
Adds implementations of `Resolver` and `FromProof` for IDs used for
implementing `Verify` mode for the Merkle layer.
@kurtisc kurtisc force-pushed the kurtis/durable-storage/verify-resolver branch from 9646f78 to 1134f2a Compare March 30, 2026 12:22
@kurtisc kurtisc marked this pull request as ready for review March 30, 2026 12:22
@github-actions
Copy link
Copy Markdown

Benchmark results for revision b182284:

Metric Duration TPS
Mean 1.514799249s 26.406
Worst 1.527380199s 26.189
Best 1.506206439s 26.557
Standard Deviation ±4.64438ms ±0.081
Full results
Run Transfers Duration TPS
1 40 1.520909999s 26.300
2 40 1.527380199s 26.189
3 40 1.511833493s 26.458
4 40 1.510037723s 26.489
5 40 1.514118517s 26.418
6 40 1.515533099s 26.393
7 40 1.517493153s 26.359
8 40 1.51223969s 26.451
9 40 1.517552244s 26.358
10 40 1.514197186s 26.417
11 40 1.514144255s 26.418
12 40 1.511205461s 26.469
13 40 1.512609547s 26.444
14 40 1.52015069s 26.313
15 40 1.506206439s 26.557
16 40 1.519702984s 26.321
17 40 1.509591092s 26.497
18 40 1.515697117s 26.390
19 40 1.512895867s 26.439
20 40 1.512486228s 26.447

Compare the results above with those for the default branch.


/// Identifier for a tree resolved in [`Verify`] mode.
pub enum VerifyTreeId {
Present(Tree<Arc<VerifyNodeId>>),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's keep the reference counting in the node/node ID, like LazyNodeId and ArcNodeId.

}
}

impl Resolver<VerifyTreeId, Tree<Arc<VerifyNodeId>>> for VerifyResolver {
Copy link
Copy Markdown
Collaborator

@vapourismo vapourismo Mar 30, 2026

Choose a reason for hiding this comment

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

Something doesn't add up here. Resolving VerifyTreeId -> Tree<Arc<VerifyNodeId>> implies that Arc<VerifyNodeId> is a node ID, but it's not. The Arc prevents it.

}
}

/// Identifier for a node resolved in [`Verify`] mode.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

perhaps worth a comment about why Absent doesn't exist

Comment on lines +561 to +573
let (ctx, present) = ctx.next_branch_with(|proof| proof.into_leaf::<bool>())?;
match present {
Partial::Present(true) => {
let (ctx, node_id) = ctx.next_branch_with(|proof| {
let suspended = VerifyNodeId::from_proof(proof)?;
Ok(suspended.map(Arc::new))
})?;
ctx.done(VerifyTreeId::Present(Tree::from(Some(node_id))))
}
Partial::Present(false) => ctx.done(VerifyTreeId::Present(Tree::default())),
// SAFETY: called only in `Verify` mode
Partial::Blinded(_) | Partial::Absent => unsafe { not_found() },
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This portion should be done by the parser (not necessarily FromProof) for Tree. I think the VerifyTreeId type doesn't need to implement on behalf of Tree.

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