Commit graph

47 commits

Author SHA1 Message Date
Daniel Liu
ec0f96d538
feat(core/txpool,eth): align local tx tracking with geth #31202 #31618 (#2181)
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
2026-03-18 09:54:40 +05:30
Daniel Liu
1e5d6e5d1b
docs(core/txpool): notice Clear is not for production #31567 (#2184) 2026-03-17 13:53:42 +05:30
Daniel Liu
13548d5d9e
refactor(core/txpool): remove locals-tracking from pools #30559 (#2176) 2026-03-17 12:24:20 +05:30
Daniel Liu
6f02401575
fix(core/txpool): avoid blocking reset completion on close #31030 (#2175)
* 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
2026-03-17 12:02:17 +05:30
Daniel Liu
a9be217e6e
fix(core/txpool): coordinate reset lifecycle and shutdown signaling #28837 (#2132)
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.
2026-03-17 11:13:47 +05:30
Daniel Liu
7d67a4ead4
refactor(txpool,eth,miner): use pending filter struct #29026 (#2160)
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.
2026-03-11 08:58:07 +05:30
Daniel Liu
b5eec529d0
perf(core/txpool): pre-filter dynamic fees during pending tx retrieval #29005 (#2137)
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.
2026-03-11 08:42:09 +05:30
Daniel Liu
9d6e8fc83f
refactor(core/txpool/legacypool): use uint256.Int instead of big.Int #28606 (#2134) 2026-03-10 18:50:40 +05:30
Daniel Liu
d4a6f43ef2
refactor(core/txpool): migrate tx subscription to SubscribeTransactions #28243 (#2125)
* 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.
2026-03-10 18:44:38 +05:30
Daniel Liu
a1b0d5476d
core/txpool: add 7702 protection to blobpool #31526 (#1930) 2026-01-26 11:20:02 +05:30
Daniel Liu
cb48e25ccf
core/txpool: declare address already reserved error #29095 (#1920) 2026-01-19 12:18:08 +05:30
Daniel Liu
3e1f75eafb
core, eth, miner: 4844 blob transaction pool #26940 (#1911) 2026-01-19 11:24:01 +05:30
Daniel Liu
b736bd6967
core/txpool: fix typos (#1915) 2026-01-16 15:42:04 +05:30
Daniel Liu
a7050de4f3
core/txpool: remove use of errors.Join function #27523 (#1914) 2026-01-13 16:51:57 +05:30
Daniel Liu
b3d354a897
all: move main transaction pool into a subpool #27463 (#1890) 2026-01-05 15:43:50 +05:30
Daniel Liu
1886219894
core/txpool: use right type for field Txs in NewTxsEvent (#1897)
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.
2026-01-05 12:12:28 +05:30
Daniel Liu
292c0506c0
core/txpool, eth: refactor function IsSigner (#1889) 2025-12-25 09:27:37 +05:30
Daniel Liu
aa8c43caf3
core/txpool: make tx validation reusable across packages/pools #27429 (#1873) 2025-12-23 16:28:30 +05:30
Daniel Liu
3fd03e0814
core, core/types: rename AuthList to SetCodeAuthorizations #30935 (#1884) 2025-12-23 15:40:53 +05:30
Daniel Liu
835579e304
core/txpool: add validation and comprehensive tests for SetGasPrice (#1876)
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
2025-12-23 15:40:24 +05:30
wit liu
13b0e39412
core/txpool: remove unused function GetSender (#1886) 2025-12-23 11:56:34 +05:30
Daniel Liu
d78d79add0
core/txpool: allow zero tip transactions with minimum gas price enforcement (#1879)
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.
2025-12-22 12:51:48 +05:30
Daniel Liu
142b1155d8
all: implement eip-7702 set code tx #30078 (#1759) 2025-12-19 14:09:45 +04:00
Daniel Liu
d976cc65d2
core/txpool: fix isGapped implementation #27404 (#1864) 2025-12-18 13:15:50 +04:00
Daniel Liu
503d51945b
core/txpool: disallow future churn by remote txs #26907 (#1860) 2025-12-16 11:05:39 +04:00
Daniel Liu
c9a730d859
core/txpool: use atomic int added in go1.19 #26913 (#1856) 2025-12-16 10:43:09 +04:00
Daniel Liu
999ded17da
all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
Daniel Liu
cbb0605e0f
core/txpool: used priceList.Put instead of heap.Push #26863 (#1855) 2025-12-16 07:34:47 +04:00
Daniel Liu
ed6f9e82fc
core/txpool: allow future local tx #26930 (#1857) 2025-12-16 07:34:20 +04:00
Daniel Liu
d9867ea87d
core/txpool: move some validation to outside of mutex #27006 (#1858) 2025-12-15 12:34:23 +04:00
Daniel Liu
322ec7f997
core/txpool : fix map size avoid resizing #27221 (#1861) 2025-12-15 12:33:56 +04:00
Daniel Liu
12554081cd
core/txpool: implement additional DoS defenses #26648 (#1853) 2025-12-15 12:32:47 +04:00
Daniel Liu
d8aac24223
core/txpool: check if initcode size is exceeded #26504 (#1842) 2025-12-11 16:18:18 +05:30
Daniel Liu
4881c9445a
core, eth: for types with accurate size calcs, return uint64 #26046 (#1791) 2025-12-07 15:52:03 +05:30
Daniel Liu
ec08863ba0
all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30
Daniel Liu
0050bef807
all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30
Daniel Liu
f8553d5871
core, miner: fix inconsistent tx blacklist enforcement, close XFN-98 (#1674) 2025-11-18 11:24:08 +05:30
wit liu
e5c480f234
core/txpool: add eip2681 check for incoming transactions #32726 (#1594) 2025-10-08 12:51:48 +08:00
Daniel Liu
e974d96977
core/txpool: accept non-local transaction with zero tip (#950) 2025-04-21 16:11:43 +08:00
Daniel Liu
f2f2044470 core/txpool: fix zero tip tx always pending 2025-03-25 11:56:46 +08:00
Daniel Liu
b60396a233 core, internal/ethapi: improve function IsSpecialTransaction 2025-02-20 12:48:17 +08:00
Daniel Liu
cfc8cca674 common: refactor constants 2025-02-17 09:13:40 +08:00
Péter Szilágyi
39e9d8f94d common/prque: generic priority queue (#26290) 2024-12-28 09:06:31 +08:00
Daniel Liu
c254b08443 core/txpool: fix very high pending special transactions 2024-11-07 17:47:59 +08:00
Daniel Liu
9b20ac785e consensus/misc: move eip1559 into a package (#27828) 2024-11-01 11:36:53 +08:00
Daniel Liu
f64aea4ba0 core/vm: implement EIP-3860: Limit and meter initcode (#23847) 2024-11-01 11:36:53 +08:00
Daniel Liu
8b2e8d9b3a all: refactor txpool into it's own package in prep for 4844 (#26038) 2024-11-01 11:36:53 +08:00
Renamed from core/tx_pool.go (Browse further)