Skip to content

fix(imt): use index-based parent check for lastSubtrees in _update#63

Open
0x471 wants to merge 1 commit intozk-kit:mainfrom
0x471:fix/imt-update-lastsubtrees
Open

fix(imt): use index-based parent check for lastSubtrees in _update#63
0x471 wants to merge 1 commit intozk-kit:mainfrom
0x471:fix/imt-update-lastsubtrees

Conversation

@0x471
Copy link

@0x471 0x471 commented Jan 24, 2026

Description

This PR fixes _update in both InternalBinaryIMT and InternalQuinaryIMT by replacing the value-based equality checks on lastSubtrees with deterministic index-based parent comparison.

Now we only update lastSubtrees[i] when the update and last-insert paths share the same parent node at level i+1. Also moved the bounds check before the main loop to prevent a uint256 underflow panic on empty trees

Related Issue(s)

Closes #41

Checklist

  • I have read and understand the contributor guidelines and code of conduct.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run yarn style without getting any errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@0x471 0x471 requested a review from vplasencia as a code owner January 24, 2026 17:23
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.

optimization with nodes to keep track the most recent nodes does not work with duplicated nodes

1 participant