Implements ethereum/go-ethereum PR #31202 and #31618.
When local tracking is enabled:
- EthAPIBackend.SendTx tracks transactions after pool submission and keeps tracking temporary rejects so they can be retried by the local tracker.
- TxPool.AddLocal tracks accepted submissions and temporary rejects for local re-journal/re-submit flows, while preserving the original txpool error return to the caller.
This avoids persisting permanently invalid transactions while preserving retry signals for transient failures without masking submission outcomes in caller workflows.
Also included:
- classify temporary rejection reasons in core/txpool/locals
- expose SubPool.ValidateTxBasics and align LegacyPool implementation
- split low-tip rejection into ErrTxGasPriceTooLow
- simplify local tracker integration in txpool
- update txpool and eth tests for accepted vs retryable local tracking behavior
Refs: ethereum/go-ethereum#31202
Refs: ethereum/go-ethereum#31618
* fix(core/txpool): coordinate reset lifecycle and shutdown signaling #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.
* fix(core/txpool): avoid blocking reset completion on close#31030
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.
Introduce txpool.PendingFilter and migrate Pending(...) signatures from positional params to a typed struct.
- Add core/txpool.PendingFilter with MinTip/BaseFee fields for cheap call-site filtering
- Update txpool subpool interface and all call sites in eth/miner to pass the filter struct
- Keep behavior unchanged for empty filter (equivalent to previous nil,nil usage)
- Refresh legacypool tests to use the new API shape
This is a refactor-only change intended to improve API clarity and future extensibility without changing consensus or RPC semantics.
Introduce dynamic-fee pre-filtering in txpool pending retrieval to reduce
allocations and downstream processing work during mining and tx propagation.
What changed:
- Change the `Pending` API from `Pending(enforceTips bool)` to
`Pending(minTip *uint256.Int, baseFee *uint256.Int)` in txpool interfaces.
- Implement pre-filtering in `legacypool.Pending` by comparing effective tip
against the provided `minTip/baseFee` for non-local, non-special txs.
- Update call sites to the new API:
- miner work assembly (`miner/worker.go`)
- tx sync (`eth/sync.go`)
- pool transaction retrieval (`eth/api_backend.go`)
- protocol/test interfaces (`eth/protocol.go`, `eth/helper_test.go`).
Tests:
- Add targeted coverage for pending filtering semantics in
`core/txpool/legacypool/legacypool_test.go`, including:
- minTip threshold boundary behavior
- baseFee-aware effective tip filtering
- local/special transaction exemption behavior
- dynamic-fee boundary behavior when baseFee is nil.
Impact:
- Preserves existing behavior while making pending selection cheaper for
downstream consumers.
- Improves confidence in edge-case behavior through dedicated tests.
* refactor(txpool): remove wrapper type #27841
Partial backport of ethereum/go-ethereum PR #27841, limited to txpool wrapper removal.
- Migrate txpool interfaces/call sites from `*txpool.Transaction` to `*types.Transaction`
- Update eth/miner/contracts paths and related tests accordingly
- No intended behavior change
Blob sidecar validation/handling changes from upstream are not included here.
* refactor(core/txpool): migrate tx subscription to SubscribeTransactions #28243
Replace the old SubscribeNewTxsEvent-style plumbing with the new
SubscribeTransactions(ch, reorgs) interface across txpool, eth protocol
manager, API backend, miner worker, and test helpers.
Key changes:
- Extend txpool/subpool tx subscription interface with a reorgs flag
- Route eth tx announcement path to reorgs=false (new tx announcements only)
- Route API/miner subscriptions to reorgs=true
- Move subscription-scope cleanup to TxPool.Close()
- Add Gas field to LazyTransaction in legacy pending view
Note:
LegacyPool currently cannot strictly separate newly seen and resurrected txs,
so the reorgs flag is accepted for API compatibility and future blob-subpool
integration.
This commit updates the Txs field in NewTxsEvent to use []*types.Transaction instead of types.Transactions. This ensures type consistency for event broadcasting and handling, improving reliability of transaction propagation across the network. The change also removes unnecessary goroutine usage for txFeed.Send, making event delivery synchronous and safer for downstream consumers.
This commit adds robust input validation to the SetGasPrice method and
implements comprehensive table-driven tests to ensure correct behavior.
Changes in core/txpool/txpool.go:
- Add nil gas price validation with graceful error handling
- Add validation to reject negative gas prices
- Add validation to reject gas prices exceeding 1000 GWei maximum
- Return detailed error messages for each validation failure
- Log warnings when invalid gas prices are rejected
Changes in eth/api_miner.go:
- Update MinerAPI.SetGasPrice to check error return from txPool.SetGasPrice
- Return false when validation fails (when SetGasPrice returns error)
- Return true when validation succeeds (when SetGasPrice returns nil)
New tests in core/txpool/txpool_test.go:
- Implement TestSetGasPrice using table-driven test pattern
- Test 4 invalid cases: nil, negative, exceed max+1, exceed 10000 GWei
- Test 7 valid cases: 0, 1 wei, 1 GWei, 100 GWei, 500 GWei, max-1, max
- Each test case includes expected error value for precise validation
- All 11 test cases verify both error returns and gas price state
- Tests use isolated pool instances to ensure independence
This commit simplifies the transaction pool's gas price validation logic while
maintaining network security through the existing minimum gas price requirement.
Changes:
- Set default PriceLimit to 0 (was 1), allowing transactions with zero tip
- Remove PriceLimit >= 1 validation in config sanitization
- Simplify Pending() method by using EffectiveGasTipIntCmp consistently
- Unify validateTxBasics() logic to use GasTipCapIntCmp for all transactions
Key Points:
1. Economic Protection: All transactions still require gasPrice >= 12.5 Gwei
(enforced by GetMinGasPrice check in validateTx), providing sufficient
protection against DoS attacks even with zero tip.
2. Miner Incentives: Since XDPoSChain includes baseFee in miner rewards
(unlike standard EIP-1559), miners still earn the full gasPrice even when
tip is 0. This maintains miner revenue while allowing greater flexibility.
3. Special Transactions: BlockSigner and Randomize contract transactions
remain exempt from gas price checks, as they are critical for consensus.
4. Code Quality: Reduces complexity by 11 lines and unifies validation logic,
making the codebase more maintainable.
Security Analysis:
- No nil pointer risks: EffectiveGasTipIntCmp has built-in nil handling
- No DoS vulnerability: 12.5 Gwei minimum ensures economic cost per transaction
- EIP-1559 compatible: Existing minGasPrice check covers all validation needs
- Backward compatible: Only relaxes restrictions, doesn't break existing behavior
This change benefits system transactions and special use cases while maintaining
all existing security guarantees through the network's minimum gas price floor.