[SharovBot] fix(txpool): evict zombie queued txns exceeding MaxNonceGap (cherry-pick #19449 → release/3.3)#19591
Merged
yperbasis merged 2 commits intorelease/3.3from Mar 5, 2026
Conversation
…ap (#19449) **[SharovBot]** ## Split from #19393 per @yperbasis review This PR contains **Bug #2 only** (zombie queued transaction eviction), extracted from #19393 which was asked to be split into separate PRs. ## Problem Queued transactions with an impossibly large nonce gap (e.g. on-chain nonce=281, queued nonce=16,814 — gap of 16,533) sit in the pool forever. They can never become pending without filling thousands of nonce positions first, causing unbounded queued pool bloat (4,000+ txns observed on Gnosis Chain, Erigon 3.3.8). The existing blob-txn nonce-gap eviction only covered `BlobTxnType`. Regular transactions had no gap limit. ## Fix - Add `MaxNonceGap uint64` to `txpoolcfg.Config` (default: 64) - Add `NonceTooDistant` (DiscardReason 37) for observability - In `onSenderStateChange`, evict txns whose nonce exceeds `noGapsNonce` by more than `MaxNonceGap` - `noGapsNonce` accounts for consecutive txns already pooled, so consecutive txns are never zombie-evicted - Fix `toDelReasons` parallel slice to track correct discard reason per evicted tx (was always logging `NonceTooLow`) ## Tests - `TestZombieQueuedEviction` — 3 sub-tests: 1. Zombie tx (gap=65 > MaxNonceGap=64) is evicted with `NonceTooDistant` 2. Tx at exactly MaxNonceGap boundary (gap=64) is kept 3. Consecutive txns beyond MaxNonceGap are never zombie-evicted ## Testing ``` go build ./txnprovider/txpool/... ✅ go test ./txnprovider/txpool/... -run TestZombieQueuedEviction -count=1 ✅ ``` ## Related - Bug #1 (stale pending / AuRa nonce) will be addressed separately per @yperbasis feedback - Backport to release/3.3 will follow once this is merged - Original combined PR: #19393
…h{} for release/3.3 compat
EmptyCodeHash is not exported in the release/3.3 accounts package; use the
zero-value common.Hash{} instead. Functionally identical for nonce-eviction tests.
yperbasis
approved these changes
Mar 5, 2026
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.
[SharovBot]
Cherry-pick of #19449 onto
release/3.3.What
Evicts zombie queued transactions from senders whose nonce has advanced past
MaxNonceGap(default: 64). These txns pile up in the queued sub-pool indefinitely without this fix, causingtxpool_queuedto grow unbounded (observed: 4.4K → 80-120 after fix on Gnosis/Sepolia validators).Original PR
See #19449 for full description, rationale, and test coverage.
Changes
txpoolcfg/txpoolcfg.go: AddedNonceTooDistantdiscard reason (37),MaxNonceGapconfig field (default 64)txnprovider/txpool/pool.go: MaxNonceGap eviction logic inonSenderStateChangetxnprovider/txpool/pool_test.go:TestZombieQueuedEvictiontest (3 sub-cases)Testing
All tests pass. Validated in production on Gnosis/Sepolia validator nodes.