Skip to content

Conversation

@clabby
Copy link
Collaborator

@clabby clabby commented Jan 7, 2026

Overview

Adds multi-proof support to storage::bmt.

This PR also breaks the API of the MMR Proof's Read impl - the Read::Cfg is now the max number of items, rather than the max number of digests in the proof. The upper bound is inferred.

closes #2221
closes #2506

zoda::encode

mmr -> bmt, large change in perf.

zoda::encode/msg_len=1048576 chunks=50 conc=1
                        time:   [34.751 ms 35.043 ms 35.257 ms]
                        change: [−14.404% −13.989% −13.572%] (p = 0.00 < 0.05)
                        Performance has improved.

zoda::encode/msg_len=1048576 chunks=50 conc=4
                        time:   [21.227 ms 21.269 ms 21.304 ms]
                        change: [−30.137% −29.321% −28.654%] (p = 0.00 < 0.05)
                        Performance has improved.

zoda::encode/msg_len=1048576 chunks=50 conc=8
                        time:   [19.397 ms 19.447 ms 19.499 ms]
                        change: [−31.636% −31.395% −31.165%] (p = 0.00 < 0.05)
                        Performance has improved.

reed_solomon::encode

Still using bmt, now forced to use the multi-proof path. No significant change in perf.

reed_solomon::encode/msg_len=1048576 chunks=50 conc=1
                        time:   [6.2472 ms 6.2612 ms 6.2816 ms]
                        change: [+0.0229% +0.5795% +1.0971%] (p = 0.07 > 0.05)
                        No change in performance detected.

reed_solomon::encode/msg_len=1048576 chunks=50 conc=4
                        time:   [2.0799 ms 2.0854 ms 2.0896 ms]
                        change: [+0.6271% +1.0928% +1.5377%] (p = 0.00 < 0.05)
                        Change within noise threshold.

reed_solomon::encode/msg_len=1048576 chunks=50 conc=8
                        time:   [1.4275 ms 1.4370 ms 1.4451 ms]
                        change: [+0.1988% +0.9165% +1.6285%] (p = 0.03 < 0.05)
                        Change within noise threshold.

@clabby clabby self-assigned this Jan 7, 2026
@clabby clabby added the breaking-format This PR modifies codec and/or storage formats. label Jan 7, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 7, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
commonware-mcp 9d9c468 Jan 08 2026, 07:29 PM

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 7, 2026

Deploying monorepo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9d9c468
Status: ✅  Deploy successful!
Preview URL: https://ff003c9e.monorepo-eu0.pages.dev
Branch Preview URL: https://cl-bmt-multiproofs.monorepo-eu0.pages.dev

View logs

@clabby clabby added this to Tracker Jan 7, 2026
@clabby clabby force-pushed the cl/bmt-multiproofs branch 2 times, most recently from d515f7b to f443733 Compare January 7, 2026 21:41
@clabby clabby marked this pull request as ready for review January 7, 2026 21:51
@clabby clabby changed the title [storage/bmt] Add MultiProof [storage/bmt] Add multi-proof support Jan 7, 2026
@clabby clabby requested a review from patrick-ogrady January 8, 2026 01:32
@clabby clabby force-pushed the cl/bmt-multiproofs branch 2 times, most recently from f938b23 to 26490c6 Compare January 8, 2026 02:57
@clabby clabby added the breaking-api This PR modifies the public interface of a function. label Jan 8, 2026
@clabby clabby force-pushed the cl/bmt-multiproofs branch 3 times, most recently from 9ff2afd to c4a1377 Compare January 8, 2026 03:51
impl<H: Hasher> Read for Proof<H> {
/// The maximum number of items being proven.
///
/// The upper bound on sibling hashes is derived as `max_items * MAX_LEVELS`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're using NonZeroRange now? forgot

@clabby clabby force-pushed the cl/bmt-multiproofs branch from c4a1377 to 46eccd1 Compare January 8, 2026 15:42
@clabby clabby force-pushed the cl/bmt-multiproofs branch from 46eccd1 to 7abbb18 Compare January 8, 2026 16:18
/// The proof of the shard in the [bmt] at the given index.
proof: bmt::Proof<H>,
/// The multi-proof of the shard in the [bmt] at the given index.
proof: bmt::Proof<H::Digest>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Chunk could also be parameterized on D: Digest and verify updated to take in a &mut Hasher like the proof verify methods. If we decide to do that, I think it's fine to defer to a future PR to keep this diff smaller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's do that in a follow-up - #2753


/// Returns the number of levels in a tree with `leaf_count` leaves.
/// A tree with 1 leaf has 1 level, a tree with 2 leaves has 2 levels, etc.
const fn levels_in_tree(leaf_count: u32) -> usize {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems we always call this with leaf_count > 0 -- should we make the 0 case unreachable! instead of returning 1? Not a big deal either way but I was a bit surprised that levels_in_tree(0) == 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rationale for levels_in_tree(0) == 1 is that a tree with 0 leaves does still have a root. I think we should probably keep all leaf_counts valid inputs for that reason

danlaine
danlaine previously approved these changes Jan 8, 2026
@clabby clabby enabled auto-merge January 8, 2026 19:53
@clabby clabby added this pull request to the merge queue Jan 8, 2026
Merged via the queue into main with commit dde1a26 Jan 8, 2026
130 checks passed
@clabby clabby deleted the cl/bmt-multiproofs branch January 8, 2026 21:51
@github-project-automation github-project-automation bot moved this to Done in Tracker Jan 8, 2026
@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 97.05240% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.22%. Comparing base (5ca1fb0) to head (9d9c468).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/bmt/mod.rs 97.58% 20 Missing ⚠️
storage/src/mmr/proof.rs 87.27% 7 Missing ⚠️
@@            Coverage Diff             @@
##             main    #2733      +/-   ##
==========================================
+ Coverage   93.20%   93.22%   +0.02%     
==========================================
  Files         372      372              
  Lines      113359   114143     +784     
==========================================
+ Hits       105655   106413     +758     
- Misses       7704     7730      +26     
Files with missing lines Coverage Δ
coding/src/reed_solomon.rs 97.39% <100.00%> (ø)
coding/src/zoda.rs 94.68% <100.00%> (+0.05%) ⬆️
storage/src/mmr/proof.rs 94.82% <87.27%> (-0.38%) ⬇️
storage/src/bmt/mod.rs 97.68% <97.58%> (-0.01%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ca1fb0...9d9c468. Read the comment docs.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-api This PR modifies the public interface of a function. breaking-format This PR modifies codec and/or storage formats.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[coding/zoda] Fix Encoding Logic [storage/bmt] Support Multi-Proofs

4 participants