Skip to content

Conversation

mulmarta
Copy link
Contributor

@mulmarta mulmarta commented Oct 3, 2025

The RFC requires that unmerged leaves MUST be sorted. Moreover, some of our mechanisms rely on this to work correctly. This PR enforces this when validating the tree on join and inserts the leaf in the correct position when updating the list of unmerged leaves.

I believe that the motivation behind the RFC's requirement is the fact that in a normal execution the list will always be sorted if upon updating the list the new index is simply pushed to the end. The reason is that the list of unmerged leaves of N can only be emptied (when a member in N's subtree is removed, updates or commits) or, when a member is added, extended by the first free leaf index in N's subtree for the new member.

However, I think that one can (maliciously) craft a valid tree where this argument does not hold. For example, a tree with 8 leaves where leaf 3 is an unmerged leaf of its grandparent and leaf 2 is empty.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT license.

@mulmarta mulmarta requested a review from a team as a code owner October 3, 2025 18:02
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.70%. Comparing base (738e250) to head (9b81591).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mls-rs/src/tree_kem/mod.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #321   +/-   ##
=======================================
  Coverage   88.69%   88.70%           
=======================================
  Files         182      182           
  Lines       28985    29001   +16     
=======================================
+ Hits        25709    25724   +15     
- Misses       3276     3277    +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.

stefunctional
stefunctional previously approved these changes Oct 3, 2025
@tomleavy
Copy link
Contributor

tomleavy commented Oct 3, 2025

@mulmarta no problem just raising the rust MSRV up to 1.82 so that sort function unsupported warning goes away

@tomleavy tomleavy merged commit 8b8b521 into main Oct 13, 2025
32 checks passed
@tomleavy tomleavy deleted the sorted-unmerged branch October 13, 2025 15:00
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.

4 participants