test(requester): add BatchTxPool wedge → recovery e2e test - #988
Merged
vishalchangrani merged 1 commit intoAug 19, 2026
Merged
Conversation
Reproduces the wedge state from #983 (Cadence wrapper reverts before advancing state, leaving the pool's in-flight marker ahead of the on-chain frontier) and asserts BatchTxPool clears it within TxBatchInterval*stalenessFactor. Auto-mine is disabled so the pool's staleEntry timing is exposed - otherwise validateTransactionWithState preempts once state catches up, masking the pool's recovery. This is the counterpart to Test_BatchTxPool_InFlightNonceRejection, which only verifies the wedge state is entered, not that it recovers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
vishalchangrani
requested review from
janezpodhostnik,
m-Peter,
peterargue and
zhangchiqing
as code owners
August 19, 2026 17:08
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
6 tasks
vishalchangrani
added a commit
that referenced
this pull request
Aug 20, 2026
#986) * Rework BatchTxPool functionality to a legitimate Ethereum tx mempool * Address review comments * Log transaction submissions from BatchTxPool * Close the window between batch detachment and the lastSubmittedAt update * Deprecate --eoa-activity-cache-ttl CLI flag as it is no longer applicable * Reject transactions with in-flight nonces * Solidify BatchTxPool rework: fix log tag, race, sizing, and add unit tests - flush success log tagged as flushReasonPrefix (metric already correct) - flush success/failure paths merge lastSubmittedNonce/At with max() so a concurrent Add() fast-path is never regressed by a stale ack or rollback - eoaEnqueueTxs preserves an existing same-nonce entry: last-write-wins keeps a client's fresher payload over a re-queued failed batch - rename maxEOAPoolSize -> maxNonceLookahead (that's what it enforces and add a real per-EOA size cap at admission time via maxEOAQueueSize + ErrTxPoolFull - staleEntry no longer marks a freshly-created queue (zero lastSubmittedAt) as stale - selectSequentialNonces walks the nonce-keyed map directly (O(k)) instead of sorting the full queue every tick - add batch_tx_pool_test.go: txQueue primitives + rollback preserve-fresh * Revert logic change on staleEntry() * Move state index nonce read after the duplication, in-flight checks * Update comments on the new logic of BatchTxPool * Remove unused from field from batchSubmission type * Re-use eoaQueueEntry() in eoaEnqueueTxs() * Move the cap check to just before the enqueue, so fast-path-eligible txs bypass it * Prune transactions that exceed the queue TTL * Cap retries per tx and drop with a WARN + TransactionsDropped after N attempts * Add unit tests for ErrTxPoolFull and the flush failure/success merge branches * Reset txQueue retries on submission success * Update stalenessFactor so that it's about 10 seconds with the current tx-batch-interval * Fix comment on eoaEnqueueTxs boolean value Co-authored-by: Leo Zhang <zhangchiqing@gmail.com> * Move rollback of nonce range reservation to eoaEnqueueTxs() * Add comments on the fields of batchSubmission type * Distinguish the 2 cases for fast-path submission for logging * Guard elapsed spacing in processPooledTransactions() and add an E2E test * test(requester): add BatchTxPool wedge -> recovery e2e test (#988) Reproduces the wedge state from #983 (Cadence wrapper reverts before advancing state, leaving the pool's in-flight marker ahead of the on-chain frontier) and asserts BatchTxPool clears it within TxBatchInterval*stalenessFactor. Auto-mine is disabled so the pool's staleEntry timing is exposed - otherwise validateTransactionWithState preempts once state catches up, masking the pool's recovery. This is the counterpart to Test_BatchTxPool_InFlightNonceRejection, which only verifies the wedge state is entered, not that it recovers. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: vishal <1117327+vishalchangrani@users.noreply.github.com> Co-authored-by: Leo Zhang <zhangchiqing@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Stacked on top of #986.
Why
#986 changes
BatchTxPoolto solidify it as a legitimate mempool, and itsstaleEntryeviction is what closes the wedge described in #983 (comment): a Cadence wrapper reverts, on-chain state stays at N, but the pool'slastSubmittedNoncemarker is at N — every retry hitsErrInFlightNonceuntil the queue is evicted.The PR ships
Test_BatchTxPool_InFlightNonceRejection, which proves the wedge state is entered. What was missing was a test proving the wedge exits withinTxBatchInterval * stalenessFactor(~10s at mainnet timings).What the test does
lastSubmittedNonce = 0.ErrInFlightNonce. Wedge confirmed.TxBatchInterval * stalenessFactor + 2scushion (12s total).Why the auto-mine has to be off
Without freezing state,
validateTransactionWithState(services/requester/requester.go:224) intercepts every retry withErrNonceTooLowas soon as tx1 mines and state indexes to 1 — that happens in ~1–3s regardless of pool implementation, so the pool's own eviction timing is never exposed. This is also the reason the wedge cannot be reproduced or measured on testnet: state validation always preempts before the pool'sstaleEntrywindow elapses.Test plan
go test ./ -run Test_BatchTxPool_WedgeRecovery -vpasses in ~16s (10s staleness + 2s cushion + fixture cost)Test_BatchTxPool_InFlightNonceRejectionstill passes — this test doesn't share state with it🤖 Generated with Claude Code