fix(sequencer): gate waitForMinTxs on age-eligible pending tx count - #24315
Merged
spalladino merged 3 commits intoJun 29, 2026
Conversation
spalladino
enabled auto-merge (squash)
June 26, 2026 12:57
PhilWindle
approved these changes
Jun 29, 2026
spalladino
deleted the
spl/a-1251-waitformintxs-gates-on-non-age-filtered-pending-count
branch
June 29, 2026 07:30
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.
Context
waitForMinTxsdecided whether enough txs were available to build a block by pollingp2pClient.getPendingTxCount(), which counts all pending txs regardless of age. The block builder, however, only iterates txs older thanminTxPoolAgeMs(2000ms in production). When a fresh burst lands on a near-empty mempool the gate returnedcanStartBuilding: trueimmediately while the eligible iterator yielded zero txs, so the builder threwInsufficientValidTxsErrorand the sub-slot was wasted (worst case on the last sub-slot: an empty checkpoint and a skipped slot). The gate never actually waited for txs to age in.Approach
Add an age-aware predicate
hasEligiblePendingTxs(minCount)through the tx-pool → P2P → client layers and gate block building on it instead of the raw pending count, so the gate and the builder agree on age eligibility and the poll loop waits for aging (bounded by the existingstartBuildingDeadline).A predicate rather than an eligible count: the gate only needs to know whether at least
minTxseligible txs exist, andminTxsis typically 0 or 1.hasEligiblePendingTxsearly-exits as soon as the threshold is met and short-circuits in O(1) when the total pending count is already belowminCount(eligible txs are a subset of pending), instead of scanning the whole pool on every poll.getPendingTxCount()stays O(1) and is reused only for the informational tx count in logs/events; its semantics are unchanged. The two automine sequencer gates switch to the same predicate (a no-op under automine'sminTxPoolAgeMs=0, kept for consistency).API changes
New
hasEligiblePendingTxs(minCount): Promise<boolean>on the internalTxPoolV2andP2Pinterfaces (and theTxPoolIndices/TxPoolV2Impllayers). No public RPC change — stdlib'sP2PApiis untouched.Fixes A-1251