Port nonce-aware tx mempool (#971) to the soft-finality branch - #977
Conversation
Port the nonce-aware transaction mempool feature (PR #971) onto the soft-finality branch. Only the mempool feature is ported; no main/ Glamsterdam changes are included. - Add TxMemPool (services/requester/tx_mempool.go) with fast-path submission, nonce-gap holding, TTL, submission spacing and batch caps. - Upgrade the existing nonce_provider.go to the final #971 API: split NonceView out of NonceProvider, rename GetNonce -> GetNextNonce, cache the built block view by indexed height, and record cache hit/miss via the metrics collector. NewLocalNonceProvider now takes a collector. - Wire TxMemPool in bootstrap behind the new tx-mempool-mode flag and pass the collector to the existing BatchTxPool's LocalNonceProvider. - Add Tx* mempool config fields, cmd flags and validation. - Add txpool_* / nonce-view-cache metrics and ErrInFlightNonce / ErrNonceTooLow / ErrNonceTooHigh errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The soft-finality branch carried an earlier iteration of the mempool e2e tests folded into tests/tx_batching_test.go. Add the canonical #971 suite in tests/tx_mempool_test.go (adds TTLExpiry and InFlightNonce rejection cases, uses its own setupTxMemPoolGatewayNode helper) and remove the now-duplicated Test_TxMemPool_* functions and the redundant fundEOA helper from tx_batching_test.go, along with the imports only those tests used. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
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 Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Testnet validation ✅The soft-finality build was deployed to Flow testnet and validated end-to-end against a live gateway, mirroring the testing done for the base PR (#971). Build under test (confirmed via Results:
Both scenarios were verified via on-chain receipts against 🤖 Generated with Claude Code |
…-results' into vishal/port-971-nonce-mempool-soft-finality
|
Deployed these changes to the foundation run mainnet EVM GW one hour back and so far its looking good. DFNS traffic is being served OK - no dropped transactions and the EOA nonce cache is working as expected.
Tag: https://github.com/onflow/flow-evm-gateway/releases/tag/v1.5.1-eoa-nonce-cache-3-with-sf |
Add tx-mempool-mode, tx-collection-window, tx-submission-spacing, tx-pool-ttl, tx-max-batch-size, and tx-max-nonce-gap to the Configuration Flags table so operators can find them without reading the source.
eff23ea
into
mpeter/poc-index-finalized-block-results

Summary
This is a port of #971 (the nonce-aware transaction mempool) onto the soft-finality branch
mpeter/poc-index-finalized-block-results. The team maintains two parallel lines —main(no soft-finality) andmpeter/poc-index-finalized-block-results(with soft-finality); #971 landed on the main line and now needs to exist here too.Only the mempool feature was ported.
vishal/nonce-aware-mini-poolhad merged recentmain(including the Glamsterdam EVM upgrade); none of that main/Glamsterdam churn is included here — this is a feature-diff port, not a whole-branch merge.What was ported
services/requester/tx_mempool.go(new) —TxMemPoolwith fast-path submission of expected-nonce txs, out-of-order nonce-gap holding, TTL, per-EOA submission spacing, and batch-size caps.services/requester/nonce_provider.go— upgraded the branch's existing (earlier-iteration) provider to the final Add nonce-aware transaction pool #971 API: splitNonceViewout ofNonceProvider, renamedGetNonce→GetNextNonce, cached the built block view by indexed height, and added cache hit/miss metrics.NewLocalNonceProvidernow takes ametrics.Collector.bootstrap/bootstrap.go— wiredTxMemPoolbehind the new--tx-mempool-modeflag.config/config.go+cmd/run/cmd.go—Tx*mempool config fields, flags, and validation.metrics/collector.go+metrics/nop.go—txpool_*and nonce-view-cache metrics.models/errors/errors.go—ErrInFlightNonce,ErrNonceTooLow,ErrNonceTooHigh.services/requester/tx_mempool_test.go+tests/tx_mempool_test.go(new) — unit and e2e tests.Notable conflict resolutions / adaptations
nonce_provider.goalready existed on the soft-finality branch as an earlier iteration of this same feature. Took the final Add nonce-aware transaction pool #971 version. Verified its dependencies (NewOverridableBlocksProvider3-arg signature,blockGasLimit) match the soft-finality branch's APIs. The existingBatchTxPoolcaller usesGetBlockView().GetNonce(addr), which remains compatible with the newNonceViewinterface — only itsNewLocalNonceProvidercall needed the addedcollectorarg.cmd/run/cmd.go— both the soft-finality flags/validation and the mempool flags/validation add code at the same anchor points; combined both (kept soft-finality'sexperimental-*flags and its[DEPRECATED]eoa-activity-cache-ttlhelp text).tests/tx_batching_test.go(with a duplicatefundEOA). Removed those older duplicates and the imports they alone used, and added the canonical Add nonce-aware transaction pool #971 suite (tests/tx_mempool_test.go), which adds TTL-expiry and in-flight-nonce-rejection cases and uses its ownsetupTxMemPoolGatewayNodehelper.Validation
go build ./...— passgo vet ./services/requester/ ./metrics/ ./bootstrap/ ./cmd/...— passgo test ./services/requester/ ./metrics/ -count=1— passgo vet ./.../go build ./...in thetests/module — passgofmt -lon every touched file — cleane2e tests were not run in this port (generous gas limits are harmless on either fork per the porting brief).
🤖 Generated with Claude Code