Skip to content

Tracking PR fo v0.24.0 release#895

Draft
bobbinth wants to merge 6 commits intomainfrom
next
Draft

Tracking PR fo v0.24.0 release#895
bobbinth wants to merge 6 commits intomainfrom
next

Conversation

@bobbinth
Copy link
Contributor

This is a tracking PR for v0.24.0 release.

bobbinth and others added 6 commits March 11, 2026 16:35
* mmr: reject oversized forests to prevent num_nodes panics

Forest deserialization previously accepted unbounded usize values. For values > usize::MAX/2 + 1, Forest::num_nodes asserted and would panic when downstream APIs (peaks/open/delta) were called.

An attacker could craft a serialized MMR with forest = usize::MAX/2 + 2 to crash consumers after deserialization.

This change enforces a maximum forest size at construction and deserialization, removes infallible constructors in favor of fallible ones, makes leaf appends return errors, and adds tests to cover oversize and iterator growth paths so oversized inputs are rejected before any panic can occur.

* mmr: cap forest size safely

* mmr: simplify append flow and document forest invariant

* mmr: trust apply invariants for new_peaks

* mmr: hard-cap max leaves to 2^k-1 and simplify xor/or

* mmr: remove redundant bounds checks and harden invariants

* mmr: centralize mask->node count helper usage
This changes `LargeSmtForest::entries` to return an iterator over items
that are `Result<TreeEntry>` instead of bare `TreeEntry`, ensuring that
the potential failure of iteration in the backend is communicated
clearly to the caller performing the iteration.

We also add benchmarks to the iteration in order to confirm that the
changes incur no performance impact.
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