Skip to content

Port nonce-aware tx mempool (#971) to the soft-finality branch - #977

Merged
vishalchangrani merged 4 commits into
mpeter/poc-index-finalized-block-resultsfrom
vishal/port-971-nonce-mempool-soft-finality
Jul 15, 2026
Merged

Port nonce-aware tx mempool (#971) to the soft-finality branch#977
vishalchangrani merged 4 commits into
mpeter/poc-index-finalized-block-resultsfrom
vishal/port-971-nonce-mempool-soft-finality

Conversation

@vishalchangrani

Copy link
Copy Markdown
Contributor

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) and mpeter/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-pool had merged recent main (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) — TxMemPool with 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: split NonceView out of NonceProvider, renamed GetNonceGetNextNonce, cached the built block view by indexed height, and added cache hit/miss metrics. NewLocalNonceProvider now takes a metrics.Collector.
  • bootstrap/bootstrap.go — wired TxMemPool behind the new --tx-mempool-mode flag.
  • config/config.go + cmd/run/cmd.goTx* mempool config fields, flags, and validation.
  • metrics/collector.go + metrics/nop.gotxpool_* and nonce-view-cache metrics.
  • models/errors/errors.goErrInFlightNonce, ErrNonceTooLow, ErrNonceTooHigh.
  • services/requester/tx_mempool_test.go + tests/tx_mempool_test.go (new) — unit and e2e tests.

Notable conflict resolutions / adaptations

  • nonce_provider.go already 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 (NewOverridableBlocksProvider 3-arg signature, blockGasLimit) match the soft-finality branch's APIs. The existing BatchTxPool caller uses GetBlockView().GetNonce(addr), which remains compatible with the new NonceView interface — only its NewLocalNonceProvider call needed the added collector arg.
  • 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's experimental-* flags and its [DEPRECATED] eoa-activity-cache-ttl help text).
  • e2e tests — the soft-finality branch had folded an older iteration of the mempool e2e tests into tests/tx_batching_test.go (with a duplicate fundEOA). 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 own setupTxMemPoolGatewayNode helper.

Validation

  • go build ./... — pass
  • go vet ./services/requester/ ./metrics/ ./bootstrap/ ./cmd/... — pass
  • go test ./services/requester/ ./metrics/ -count=1 — pass
  • go vet ./... / go build ./... in the tests/ module — pass
  • gofmt -l on every touched file — clean

e2e tests were not run in this port (generous gas limits are harmless on either fork per the porting brief).

🤖 Generated with Claude Code

vishalchangrani and others added 2 commits July 1, 2026 18:48
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>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8566c45f-6df7-4289-90ad-d8e5ed3f0e85

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vishal/port-971-nonce-mempool-soft-finality

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vishalchangrani vishalchangrani self-assigned this Jul 1, 2026
@vishalchangrani

Copy link
Copy Markdown
Contributor Author

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 web3_clientVersion): flow-evm-gateway@v1.5.1-eoa-nonce-cache-2-with-sf

Results:

  • Fast path (single expected-nonce tx): 1/1 mined, status 1.
  • In-order burst (50 txs submitted concurrently): sent in ~235ms with 0 send errors → 50/50 mined, status1=50, status0=0, not-mined=0 (~19s). No silent drops.

Both scenarios were verified via on-chain receipts against evm-001.devnet0. Since the mempool code here is an identical port of #971 (whose fuller scenario suite — gap/hold, TTL, duplicate, sustained 200-tx, multi-EOA — already passed on the main-line build), this confirms the soft-finality build submits, batches, and mines correctly.

🤖 Generated with Claude Code

…-results' into vishal/port-971-nonce-mempool-soft-finality

@m-Peter m-Peter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vishalchangrani

vishalchangrani commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

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.

Screenshot 2026-07-13 at 6 40 17 PM

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.
@vishalchangrani
vishalchangrani merged commit eff23ea into mpeter/poc-index-finalized-block-results Jul 15, 2026
2 checks passed
@vishalchangrani
vishalchangrani deleted the vishal/port-971-nonce-mempool-soft-finality branch July 15, 2026 00:46
@github-project-automation github-project-automation Bot moved this from 👀 In Review to ✅ Done in 🌊 Flow 4D Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants