Repository navigation
Conversation
…mbers Fix an indexed Merkle tree depth that stays at `0` after members are added. For example, adding three leaves currently produces size `3` and depth `0`; the correct LeanIMT depth is `2`. re semaphore-protocol#1108
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix an indexed Merkle tree depth that stays at
0after members are added. For example, adding three leaves currently produces size3and depth0; the correct LeanIMT depth is2.Add a shared integer-based helper and recompute depth from the updated size in both
addMember()andaddMembers(). The calculation returns0for an empty or single-leaf tree andceil(log2(size))for larger trees.Extend the existing assertions and add isolated regression tests covering individual additions through nine leaves, batch additions across multiple depth levels, and preservation of size and depth after member updates and removals. This is a bug fix with no schema or contract changes.
Related Issue(s)
Fixes #1108
Other information
Validation:
0instead of1for two leaves and depth0instead of2for three leaves.yarn test:subgraphpasses all 10 tests using the repository's pinned Matchstick binary 0.5.0.yarn workspace @semaphore-protocol/utils build,yarn build:subgraph, andyarn build:librariespass.yarn formatpasses.yarn lintpasses after building the workspace libraries. Solhint reports 27 warnings in unchanged Solidity files; ESLint reports no errors.Existing indexed data needs reindexing/replaying events to correct all affected groups and historical results. A subsequent member-add event recomputes the current depth for that group, but groups without further additions retain the previously stored value.
The unit-test verification covers the subgraph suite; unrelated test suites were not run.
Checklist
yarn formatandyarn lintwithout getting any errorsImportant
We do not accept pull requests for minor grammatical fixes (e.g., correcting typos, rewording sentences) or for fixing broken links, unless they significantly improve clarity or functionality. These contributions, while appreciated, are not a priority for merging. If you notice any of these issues, please create a GitHub Issue to report them so they can be properly tracked and addressed.