go-ethereum/core
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
..
asm all: pre-allocate memory for slices and maps, close XFN-148 (#1714) 2025-11-14 20:13:36 +05:30
bloombits all: use WaigGroup.Go() to simplify code (#1699) 2025-11-29 17:17:08 +05:30
rawdb contracts, core/rawdb: refactor read and write randomizeKey (#1806) 2025-12-09 11:01:37 +05:30
state all: implement eip-7702 set code tx #30078 (#1759) 2025-12-19 14:09:45 +04:00
tracing eth/tracers: various fixes #30540 (#1491) 2025-09-17 09:04:38 +08:00
txpool core/txpool: fix global MinGasPrice override and single test failure, fix #1881 (#1880) 2025-12-22 12:01:21 +05:30
types core/types: updates for EIP-7702 API functions #30933 (#1827) 2025-12-20 11:13:04 +05:30
vm all: implement eip-7702 set code tx #30078 (#1759) 2025-12-19 14:09:45 +04:00
.gitignore Renamed chain => core 2014-12-04 10:28:02 +01:00
bench_test.go all: implement eip-7702 set code tx #30078 (#1759) 2025-12-19 14:09:45 +04:00
block_validator.go all: remove mongodb support in XDCx (#1679) 2025-11-15 16:50:02 +05:30
block_validator_test.go core: remove outdated tests #27662 (#1496) 2025-09-17 08:16:07 +08:00
blockchain.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
blockchain_insert.go all: simplify timestamps to uint64 #19372 (#1318) 2025-08-08 10:33:37 +08:00
blockchain_reader.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
blockchain_test.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
blocks.go new EVM Upgrade 2021-09-21 16:53:46 +05:30
chain_indexer.go core: refactor read and write valid sections (#1808) 2025-12-08 15:07:33 +05:30
chain_indexer_test.go light: CHT and bloom trie indexers working in light mode (#16534) 2025-03-06 15:30:48 +08:00
chain_makers.go all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30
chain_makers_test.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
dao_test.go all: change chain head markers from block to header #26777 (#1846) 2025-12-16 07:36:51 +04:00
error.go all: implement eip-7702 set code tx #30078 (#1759) 2025-12-19 14:09:45 +04:00
events.go eth/filters: remove use of event.TypeMux for pending logs (#20312) 2024-08-03 10:03:22 +08:00
evm.go core/state: move state log mechanism to a separate layer #30569 #30732 (#1775) 2025-12-16 07:33:19 +04:00
gaspool.go miner: avoid unnecessary work (#15883) 2018-01-15 12:57:06 +02:00
gen_genesis.go all: format golang files (#1548) 2025-09-21 19:41:54 +08:00
genesis.go core :use batch to write chain config (#1760) 2025-11-14 19:59:10 +05:30
genesis_alloc_devnet.go all: format golang files (#1548) 2025-09-21 19:41:54 +08:00
genesis_alloc_mainnet.go core: tidy up genesis alloc 2025-02-19 14:15:09 +08:00
genesis_alloc_testnet.go core: tidy up genesis alloc 2025-02-19 14:15:09 +08:00
genesis_test.go core, light, params: clean genesis hash 2025-03-05 14:30:39 +08:00
headerchain.go all: simplify timestamps to uint64 #19372 (#1318) 2025-08-08 10:33:37 +08:00
mkalloc.go core: use slices package for sorting #27489 #27909 (#1701) 2025-12-07 15:43:24 +05:30
sender_cacher.go all: refactor txpool into it's own package in prep for 4844 (#26038) 2024-11-01 11:36:53 +08:00
state_prefetcher.go core/types: remove message #25977 (#1322) 2025-09-09 11:23:47 +08:00
state_processor.go core/state: move state log mechanism to a separate layer #30569 #30732 (#1775) 2025-12-16 07:33:19 +04:00
state_processor_test.go core/types: updates for EIP-7702 API functions #30933 (#1827) 2025-12-20 11:13:04 +05:30
state_transition.go core/types: updates for EIP-7702 API functions #30933 (#1827) 2025-12-20 11:13:04 +05:30
token_validator.go all: rework trc21 (#1777) 2025-11-18 11:24:56 +05:30
types.go core: use atomic type #27011 2025-04-28 16:57:56 +08:00