Skip to content

[wip]: perf(types): compute commitment roots without retaining NMT leaves - #982

Draft
citizen-stig wants to merge 1 commit into
mainfrom
nikolai/perf-root-only-nmt
Draft

[wip]: perf(types): compute commitment roots without retaining NMT leaves#982
citizen-stig wants to merge 1 commit into
mainfrom
nikolai/perf-root-only-nmt

Conversation

@citizen-stig

@citizen-stig citizen-stig commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

(cherry picked from commit 5ac130a)

Overview

Commitment::from_shares built a full Nmt per subtree, and nmt-rs copies every 512-byte leaf into the tree (15,229 leaves for 7 MiB) plus grows a leaf vector.

Replaced with an incremental merkle fold (nmt_subtree_root) that computes each subtree root directly with SHA-256, keeping only O(log n) intermediate hashes.

Correctness is pinned by a new test comparing against the previous nmt-rs implementation across share versions, namespaces, and 40+ sizes.

Impact: one commitment pass −22.9 MB cumulative, −61,882 allocations; full construct+submit −45.8 MB, −123,767 allocations (commitment is computed twice: Blob::new and Blob::validate). Largest single win in the stack.

Related to #862

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.

1 participant