feat(core/txpool,eth): track only accepted-or-retryable local txs #31202 #31618#2181
feat(core/txpool,eth): track only accepted-or-retryable local txs #31202 #31618#2181gzliudan wants to merge 6 commits intoXinFinOrg:dev-upgradefrom
Conversation
…thereum#28837 Improve txpool loop synchronization around background resets. This change: - adds an explicit termination channel to signal pool shutdown - tracks forced-reset intent and a waiter channel inside the reset loop - ensures reset waiters are notified on completion or on pool termination - allows an explicit sync request path to trigger an additional reset round when needed Scope is limited to internal txpool concurrency control in core/txpool/txpool.go, with no protocol or RPC behavior change.
…ereum#29083 * core/txpool: no need to run rotate if no local txs Signed-off-by: jsvisa <delweng@gmail.com> * Revert "core/txpool: no need to run rotate if no local txs" This reverts commit 17fab17. Signed-off-by: jsvisa <delweng@gmail.com> * use Debug if todo is empty Signed-off-by: jsvisa <delweng@gmail.com> --------- Signed-off-by: jsvisa <delweng@gmail.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)
📝 Coding Plan
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 |
5f917e8 to
35591d2
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors local transaction handling in the eth service and core/txpool by introducing a dedicated local transaction tracker and adjusting txpool APIs so that locally submitted transactions are only tracked/journaled when they are accepted or temporarily rejected (instead of on permanent failure).
Changes:
- Add
core/txpool/localslocal transaction tracker (journal + resubmission loop) and wire it intoeth.NewwhenTxPool.NoLocalsis false. - Simplify txpool/subpool
AddAPIs by removing thelocalflag, and remove “local tx” eviction/pricing exemptions fromlegacypool. - Update
EthAPIBackend.SendTxto only track locally submitted txs when accepted or temporarily rejected, and add/adjust tests accordingly.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
eth/protocol_test.go |
Updates tests to match new txpool Add signature. |
eth/protocol.go |
Updates protocol txPool interface to the new Add(txs, sync) shape. |
eth/helper_test.go |
Updates test txpool stub Add signature. |
eth/handler.go |
Updates inbound-tx handling to call new Add signature. |
eth/backend.go |
Wires up locals.TxTracker (journal/resubmit) into the node lifecycle and txpool when locals are enabled. |
eth/api_backend_test.go |
Adds coverage for SendTx behavior with/without local tracker configured. |
eth/api_backend.go |
Changes SendTx to (a) add to pool first, (b) track only on success/temporary reject, and (c) swallow temporary errors when locals are enabled. |
core/txpool/validation.go |
Switches min-tip validation to wrap ErrTxGasPriceTooLow instead of ErrUnderpriced. |
core/txpool/txpool_local_test.go |
Adds tests for local-tracker tracking order vs subpool add. |
core/txpool/txpool.go |
Adds local tracker plumbing (SetLocalTracker, AddLocal(s)), and adds a Sync() helper for deterministic simulator/test runs. |
core/txpool/subpool.go |
Updates SubPool interface: adds ValidateTxBasics, changes Add signature, removes Locals. |
core/txpool/locals/tx_tracker.go |
Introduces local tx tracking, journaling integration, and periodic resubmission. |
core/txpool/locals/journal.go |
Moves journal implementation into locals and adjusts rotation logging behavior. |
core/txpool/locals/errors.go |
Adds error classification helper for “temporary” rejects used by SendTx. |
core/txpool/legacypool/list.go |
Exports and renames sortedMap → SortedMap for reuse by locals tracker. |
core/txpool/legacypool/legacypool_test.go |
Updates tests/benchmarks to reflect removal of local exemptions and new error types. |
core/txpool/legacypool/legacypool2_test.go |
Minor formatting adjustments in tests. |
core/txpool/legacypool/legacypool.go |
Removes local-account exemptions/journaling from legacy pool and adapts to updated lookup/pricing logic. |
core/txpool/legacypool/journal_shared.go |
Adds shared helpers for non-EVM journal implementations in legacypool. |
core/txpool/errors.go |
Adds ErrTxGasPriceTooLow and clarifies ErrUnderpriced semantics. |
contracts/utils.go |
Switches internal tx submission to TxPool.AddLocal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| tracker.journal.load(func(transactions []*types.Transaction) []error { | ||
| tracker.TrackAll(transactions) | ||
| return nil | ||
| }) |
| checkJournal := tracker.journal != nil && time.Since(lastJournal) > tracker.rejournal | ||
| resubmits, rejournal := tracker.recheck(checkJournal) | ||
| if len(resubmits) > 0 { | ||
| tracker.pool.Add(resubmits, false) | ||
| } |
| if resetWaiter != nil { | ||
| // A previous sync waiter is still pending; notify it to avoid | ||
| // leaking a goroutine waiting on the old channel. | ||
| resetWaiter <- errors.New("sync request superseded by a new request") |
…ereum#31202 ethereum#31618 When local tracking is enabled, EthAPIBackend.SendTx now adds the tx to the tracker only after pool submission and only if the failure is temporary/retryable. Permanent errors are returned to the caller and are not tracked. This prevents invalid transactions from being persisted and repeatedly retried by the local tracker while still preserving resubmission behavior for transient conditions (e.g. inflight limit or pool pressure). Also included: - classify temporary rejection reasons in core/txpool/locals - expose SubPool.ValidateTxBasics and align LegacyPool implementation - separate low-tip rejection as ErrTxGasPriceTooLow - update/add tests for txpool and eth backend behavior Refs: ethereum#31202 ethereum#31618
35591d2 to
86b8c38
Compare
Proposed changes
When local tracking is enabled, EthAPIBackend.SendTx now adds the tx to the
tracker only after pool submission and only if the failure is temporary/retryable.
Permanent errors are returned to the caller and are not tracked.
This prevents invalid transactions from being persisted and repeatedly retried
by the local tracker while still preserving resubmission behavior for transient
conditions (e.g. inflight limit or pool pressure).
Also included:
Ref:
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that