Skip to content

feat(core/txpool,eth): track only accepted-or-retryable local txs #31202 #31618#2181

Open
gzliudan wants to merge 6 commits intoXinFinOrg:dev-upgradefrom
gzliudan:skip-failed-tx
Open

feat(core/txpool,eth): track only accepted-or-retryable local txs #31202 #31618#2181
gzliudan wants to merge 6 commits intoXinFinOrg:dev-upgradefrom
gzliudan:skip-failed-tx

Conversation

@gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Mar 13, 2026

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:

  • 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

Ref:

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

gzliudan and others added 4 commits March 13, 2026 15:06
…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>
Copilot AI review requested due to automatic review settings March 13, 2026 08:28
@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

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: 4c372b14-2b7c-4555-a737-e81aff84e028

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
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/locals local transaction tracker (journal + resubmission loop) and wire it into eth.New when TxPool.NoLocals is false.
  • Simplify txpool/subpool Add APIs by removing the local flag, and remove “local tx” eviction/pricing exemptions from legacypool.
  • Update EthAPIBackend.SendTx to 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 sortedMapSortedMap 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
})
Comment on lines +194 to +198
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")
@gzliudan gzliudan changed the title feat(eth): do not add failed tx to localTxTracker #31202 #31618 feat(core/txpool,eth): track only accepted-or-retryable local txs #31202 #31618 Mar 13, 2026
…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
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.

4 participants