Commit graph

83 commits

Author SHA1 Message Date
Daniel Liu
50210d90e3
refactor(all): remove term whitelist and blacklist (#1994) 2026-02-10 17:09:21 +05:30
Daniel Liu
9dba15a673
feat(core): implement EIP-7623 increase calldata cost 30946 (#2031)
Link to spec: https://eips.ethereum.org/EIPS/eip-7623

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com>
Co-authored-by: lightclient <lightclient@protonmail.com>
2026-02-05 14:45:11 +05:30
Daniel Liu
e77ac510d0
all: replace Div/Mul with Rsh/Lsh if possible #29911 (#1966) 2026-01-29 11:31:58 +05:30
Daniel Liu
84aedaa7bf
core/txpool/legacypool: fix stale counter #33653 (#1990) 2026-01-29 11:25:55 +05:30
Daniel Liu
0206909058
core/txpool/legacypool: add metric for accounts in txpool #33646 (#1980) 2026-01-29 11:22:31 +05:30
Daniel Liu
43b005c479
txpool: make unreserve idempotent to avoid false non-reserved errors, fix #1975 (#1976) 2026-01-26 11:20:33 +05:30
Daniel Liu
a1b0d5476d
core/txpool: add 7702 protection to blobpool #31526 (#1930) 2026-01-26 11:20:02 +05:30
Daniel Liu
48b6063261
core/txpool/legacypool: reject gapped tx from delegated account #31430 (#1928) 2026-01-21 13:28:23 +05:30
Daniel Liu
96a9c89aa6
core/txpool: move setcode tx validation into legacyPool #31209 (#1927) 2026-01-21 11:13:10 +05:30
Daniel Liu
c27d49c03e
core/txpool/legacypool: add setCodeTx reorg test #31206 (#1924) 2026-01-21 10:48:47 +05:30
Daniel Liu
217b069ec0
core/txpool, types: add support for SetCode transactions #31073 (#1922) 2026-01-19 14:19:34 +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
e764d842da
core/txpool/legacypool: narrow down the scope of the variable #27471 (#1910) 2026-01-16 15:52:12 +05:30
Daniel Liu
939225bd87
core/txpool: improve transaction validate (#1921) 2026-01-16 15:45:07 +05:30
Daniel Liu
86cbf4a897
core/txpool/legacypool: handle genesis state missing #28171 (#1919) 2026-01-16 15:43:43 +05:30
Daniel Liu
dee0e37564
core/txpool/legacypool: remove outdated tests #27662 (#1916) 2026-01-16 15:43:13 +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
a7ddd8ac03
core/txpool/legacypool: remove redundant check for floatingRatio #27477 (#1913) 2026-01-13 16:51:21 +05:30
Daniel Liu
4addc980f4
core/txpool/legacypool: reheap the priced list if london fork not enabled #27481 (#1912) 2026-01-13 16:51:02 +05:30
Daniel Liu
d38d746773
core/txpool/legacypool: handle missing head in reset #27479 (#1909) 2026-01-13 16:49:33 +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
1dd09427ed
core/txpool: fix global MinGasPrice override and single test failure, fix #1881 (#1880)
Since commit 845d3d49e (July 2023), MinGasPrice validation (250000000 wei /
0.25 Gwei) has been enforced for all non-special transactions in validateTx().
Later, commit 141cb75c (Dec 2025) refactored this validation logic into the
standalone ValidateTransactionWithState() function for code reusability.

However, the transaction pool test suite was never updated to comply with the
MinGasPrice requirement and continued using extremely low gas prices (1-6 wei),
causing test failures when run independently.

The root cause of this issue was that testQueueTimeLimiting() set the global
variable 'common.MinGasPrice = big.NewInt(0)' without restoring it. This global
variable modification created severe testing problems:

1. Intermittent, non-deterministic failures: The same test would randomly pass
   or fail without any code changes, depending on whether testQueueTimeLimiting
   had executed and set MinGasPrice=0 before other tests checked it

2. Race conditions in concurrent execution: Since tests use t.Parallel(), multiple
   tests could simultaneously access the shared global MinGasPrice variable,
   creating unpredictable timing-dependent behavior

3. Test order dependency: When running 'make test', if testQueueTimeLimiting
   executed early and set MinGasPrice=0, other tests with low gas prices would
   pass. Running the same tests individually or in a different order would fail
   with 'under min gas price' errors

4. Global state pollution: The MinGasPrice modification affected ALL concurrently
   running tests in the suite, violating test isolation principles and making
   debugging extremely difficult

5. Masked real validation issues: The global override hid the fact that test
   transactions violated MinGasPrice requirements that would be enforced in
   production, reducing test effectiveness

6. No cleanup mechanism: The changed value was never restored, permanently
   affecting subsequent tests and creating cascading failures

This intermittent behavior made CI/CD pipelines unreliable - tests could pass
locally but fail in CI, or pass on retry without changes, wasting developer time
investigating 'phantom' failures.

This commit systematically updates all affected test cases to use gas prices
that satisfy the MinGasPrice requirement:

- Replace transaction() helper calls with pricedTransaction() using gas prices
  >= 250000000 wei (MinGasPrice)
- Update dynamicFeeTx() calls to use gasFeeCap and gasTipCap >= 250000000 wei
- Scale account balances proportionally to cover the higher transaction costs
- Maintain test logic and relative price relationships between transactions

Tests fixed (36 total):
- TestStateChangeDuringReset
- TestInvalidTransactions
- TestChainFork
- TestDoubleNonce
- TestMissingNonce
- TestNonceRecovery
- TestPostponing
- TestGapFilling
- TestQueueAccountLimiting
- TestQueueGlobalLimiting
- TestQueueGlobalLimitingNoLocals
- TestQueueTimeLimiting
- TestQueueTimeLimitingNoLocals
- TestPendingLimiting
- TestPendingGlobalLimiting
- TestAllowedTxSize
- TestCapClearsFromAll
- TestPendingMinimumAllowance
- TestRepricing
- TestRepricingDynamicFee
- TestRepricingKeepsLocals
- TestPoolUnderpricing
- TestPoolStableUnderpricing
- TestUnderpricingDynamicFee
- TestDualHeapEviction
- TestDeduplication
- TestReplacement
- TestReplacementDynamicFee
- TestJournaling
- TestJournalingNoLocals
- TestStatusCheck
- TestDropping
- TestQueue
- TestQueue2
- TestNegativeValue
- TestSlotCount

All tests now pass consistently when run with: go test ./core/txpool -count=1
2025-12-22 12:01:21 +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
0894fcdb6e
core/txpool: use types.EmptyRootHash instead of null #27230 (#1862) 2025-12-16 07:33:45 +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
6ccbf98292
core/txpool: remove deprecated uses of math.rand #26710 (#1843) 2025-12-11 16:19:20 +05:30
Daniel Liu
d3e994377b
core: assign zero after resize in implementations of heap.Interface #26296 (#1841) 2025-12-11 16:18:55 +05:30
Daniel Liu
d8aac24223
core/txpool: check if initcode size is exceeded #26504 (#1842) 2025-12-11 16:18:18 +05:30
wit liu
d6309612fc
all: fix unnecessary whitespace (#1800) 2025-12-08 15:07:11 +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
93d453c4c4
core/txpool: remove a redundant heap.Init #28910 (#1706) 2025-12-07 15:47:20 +05:30
wit liu
5ada9b8866
core: fix unused warnings (#1811) 2025-12-07 15:39:31 +05:30
Daniel Liu
ec08863ba0
all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30