feat(core/txpool,eth): track already-known local transactions on resubmit - #2537
feat(core/txpool,eth): track already-known local transactions on resubmit#2537gzliudan wants to merge 1 commit into
Conversation
|
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 |
There was a problem hiding this comment.
Pull request overview
Ensures already-known local transactions retain resubmission and journal protection while preserving the original caller error.
Changes:
- Tracks
ErrAlreadyKnowntransactions 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.
1431067 to
fc8dada
Compare
…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.
fc8dada to
5146619
Compare
Summary
A local transaction that reaches the pool through a concurrent submission
(peer gossip, wallet retry, or a parallel RPC endpoint) returns
txpool.ErrAlreadyKnownfromTxPool.Add, but is not placed in the desiredlocal-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
ErrAlreadyKnownas the desired state on the initial admissionpath.
AddLocalandEthAPIBackend.SendTxstill surface the error to thecaller (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 retainsalready-known transactions in the tracked set, because
recheckskipstransactions still present in the pool (
pool.Has). The only gap was on theinitial admission path, which this PR closes.
Changes
core/txpool/txpool.go:AddLocaltracks the transaction when it isaccepted, temporarily rejected, or already known to the pool.
eth/api_backend.go:SendTxtracks the transaction unless it ispermanently rejected; an already-known transaction is still tracked while
the error is surfaced to the caller.
TestAddLocalTracksAlreadyKnownTransaction,TestSendTxTracksAlreadyKnown.Test plan
go test ./core/txpool/ -run TestAddLocalgo test ./eth/ -run TestSendTxRisk
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.