Skip to content

feat(core/txpool,eth): track already-known local transactions on resubmit - #2537

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:track-already-known-local
Open

feat(core/txpool,eth): track already-known local transactions on resubmit#2537
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:track-already-known-local

Conversation

@gzliudan

Copy link
Copy Markdown
Collaborator

Summary

A local transaction that reaches the pool through a concurrent submission
(peer gossip, wallet retry, or a parallel RPC endpoint) returns
txpool.ErrAlreadyKnown from TxPool.Add, but is not placed in the desired
local-tracking state: the local tracker only starts on a successful admission.
If that transaction is later evicted, it loses its local resubmit and journal
protection and silently disappears.

This PR treats ErrAlreadyKnown as the desired state on the initial admission
path. AddLocal and EthAPIBackend.SendTx still surface the error to the
caller (matching upstream go-ethereum semantics) but now also register the
transaction with the local tracker so it keeps the resubmit and journal
guarantees.

Background

The resubmit loop (TxTracker.loop -> TxTracker.recheck) already retains
already-known transactions in the tracked set, because recheck skips
transactions still present in the pool (pool.Has). The only gap was on the
initial admission path, which this PR closes.

Changes

  • core/txpool/txpool.go: AddLocal tracks the transaction when it is
    accepted, temporarily rejected, or already known to the pool.
  • eth/api_backend.go: SendTx tracks the transaction unless it is
    permanently rejected; an already-known transaction is still tracked while
    the error is surfaced to the caller.
  • Tests: TestAddLocalTracksAlreadyKnownTransaction,
    TestSendTxTracksAlreadyKnown.

Test plan

  • go test ./core/txpool/ -run TestAddLocal
  • go test ./eth/ -run TestSendTx

Risk

Low. The change only adds tracking for an already-known transaction and
preserves the original error returned to the caller; the resubmit path was
already consistent.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

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 Plus

Run ID: 6d42b20a-4e4c-443e-b3e0-f494c945c12f

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

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Ensures already-known local transactions retain resubmission and journal protection while preserving the original caller error.

Changes:

  • Tracks ErrAlreadyKnown transactions in both local submission paths.
  • Adds focused unit and integration tests for the behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
core/txpool/txpool.go Tracks already-known transactions in AddLocal.
core/txpool/txpool_local_test.go Tests AddLocal tracking and error behavior.
eth/api_backend.go Tracks already-known RPC submissions while returning the error.
eth/api_backend_test.go Tests the RPC submission path.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gzliudan
gzliudan force-pushed the track-already-known-local branch from 1431067 to fc8dada Compare August 23, 2026 15:32
…bmit

A local transaction that reaches the pool through a concurrent submission
(peer gossip, wallet retry, or a parallel RPC endpoint) returns
txpool.ErrAlreadyKnown from TxPool.Add, but is not in the desired local
tracking state: the local tracker only starts on a successful admission.
If that transaction is later evicted, it has no local resubmit or journal
protection and silently disappears.

Treat ErrAlreadyKnown as the desired state on the initial admission path:
AddLocal and EthAPIBackend.SendTx still surface the error to the caller
(matching upstream go-ethereum semantics), but now also register the
transaction with the local tracker so it keeps the resubmit and journal
guarantees. The resubmit loop (TxTracker.loop -> TxTracker.recheck) already
retains already-known transactions in the tracked set, because recheck skips
transactions still present in the pool (pool.Has), so the two paths are now
consistent.
@gzliudan
gzliudan force-pushed the track-already-known-local branch from fc8dada to 5146619 Compare August 24, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants