fix(nonce_manager): skip out-of-order-confirmed nonces on acquire#118
Merged
abhicris merged 1 commit intoJun 7, 2026
Merged
Conversation
A nonce confirmed ahead of confirmed_nonce (out-of-order) is already mined on-chain but is dropped from pending_nonces on confirmation, so the gap-reuse walk in _reserve_next_nonce — which only consulted pending_nonces — re-handed it out. The chain then rejects the new tx with "nonce too low", stalling the whole pending queue (Ethereum requires gapless nonces). Fix: the walk now skips nonces present in out_of_order_confirmations as well as pending_nonces. +1 regression test (test_acquire_skips_out_of_order_confirmed_nonce). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
🤖 Audit verdict: Legitimate bugfix to nonce management with clear defensive intent and comprehensive regression test; no malicious payloads, supply-chain risk, credential leakage, or dangerous logic errors. Audited by the kcolbchain PR pipeline. See pipeline docs. |
Contributor
|
Merged — thanks, @kite-builds. That's 6 merged PRs to kcolbchain now. You're a Fellow — when paid research, partner-org work, or grant milestones come up, you're in the first invite pool. Next-up issues across the org: https://kcolbchain.com/invitations/ |
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.
Problem
NonceManagersupports out-of-order confirmations:confirm_nonce(n)for anngreater thanconfirmed_noncedropsnfrompending_noncesand stashes it inout_of_order_confirmationsto be rolled intoconfirmed_nonceonce the gap fills.But
_reserve_next_nonce(the gap-reuse walk introduced for therelease_nonce/gap case in #93) only consultedpending_nonces. An out-of-order-confirmed nonce is not pending (it was dropped) and not belowconfirmed_nonce, so the walk happily re-hands it out — even though it is already mined on-chain. The chain then rejects the new transaction with "nonce too low", and because Ethereum requires gapless nonces, every higher-nonce pending tx stalls behind it.Reproduction (current
main)Expected:
3.Fix
_reserve_next_noncenow skips nonces present inout_of_order_confirmationsin addition topending_nonces. Behaviour in the gapless common case (and the #93 release/gap-reuse case) is unchanged.Tests
test_acquire_skips_out_of_order_confirmed_nonce— fails onmain(2 != 3), passes with the fix.ruff check switchboard/nonce_manager.pyclean.Follow-up to the same gap-reuse logic as #93.