fix: use nextOwnerIndex instead of ownerCount in findOwnerIndex#282
Merged
stephancill merged 1 commit intomasterfrom Apr 27, 2026
Merged
Conversation
Collaborator
✅ Heimdall Review Status
|
19332ac to
c36f9f0
Compare
findOwnerIndex used ownerCount to bound its iteration, but ownerCount excludes removed owners (ownerCount = nextOwnerIndex - removedOwnersCount). This caused the function to miss owners at higher indices when previous owners had been removed, leading to unnecessary reauthorization attempts that revert with AlreadyOwner onchain.
c36f9f0 to
c6b6d5d
Compare
Contributor
|
PR Title: valid ( Summary: Clean, well-targeted bug fix. No issues found. The change from
|
fan-zhang-sv
approved these changes
Apr 27, 2026
spencerstock
approved these changes
Apr 27, 2026
Contributor
spencerstock
left a comment
There was a problem hiding this comment.
LGTM - looks pretty straightforward. Thanks for fixing.
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.
Summary
findOwnerIndexusedownerCount()to bound its iteration over owner slots. However,ownerCount = nextOwnerIndex - removedOwnersCount, which means it skips owners at higher indices when previous owners have been removed.For example, a sub-account with
nextOwnerIndex=15andremovedOwnersCount=13reportsownerCount=2, sofindOwnerIndexonly checks indices 0-1 — missing the owner at index 14. This causes a false negative, triggering an unnecessary reauthorization flow that attemptsaddOwnerPublicKeyand reverts onchain withAlreadyOwner.The fix changes the iteration bound from
ownerCount()tonextOwnerIndex(), ensuring all owner slots (including those at high indices after removals) are checked. Empty slots from removed owners return0xand are naturally skipped by the comparison.How did you test your changes?
ownerCounttonextOwnerIndex)finds owner at high index when previous owners have been removed0x463f3D229E2fe046807d189CCD0cE9758851f10b) on Base where this exact bug was occurring