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
Reorder initialization in eth.New so the effective chain config is resolved and persisted via core.SetupGenesisBlock before creating the consensus engine.
Background:
- On first sync from genesis, LoadChainConfig could return a stored/incomplete config (notably with XDPoS.V2 unset in legacy testnet setups).
- Creating XDPoS before finalizing genesis config could trigger mainnet V2 fallback and log/behavior mismatches around SwitchBlock.
What changed:
- Replace early LoadChainConfig usage with SetupGenesisBlock in eth.New.
- Keep ConfigCompatError semantics consistent with core/blockchain initialization: fail only on non-compat errors.
- Initialize consensus engine after finalized chainConfig is available.
Result:
- Consensus engine now starts with finalized network config on first boot.
- Avoids incorrect V2 fallback parameters (e.g. wrong SwitchBlock) during initial testnet sync.
Tests:
- Added regression tests in eth/backend_test.go to cover legacy missing-V2 repair and SetupGenesisBlock idempotency.
Drop Ethereum.chainConfig and consistently read chain configuration from blockchain.Config() to avoid dual sources of truth.
Changes include API/backend call sites and DebugAPI constructor cleanup. No functional behavior change is intended.
* 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
A runtime panic was triggered in promoteExecutables/demoteUnexecutables when
account balance was converted with uint256.MustFromBig(...):
panic: overflow
... legacypool.go:1637
Root cause:
- pool.currentState.GetBalance(addr) can exceed uint256 range in this code path.
- uint256.MustFromBig(balance) panics on overflow, crashing the reorg loop.
What this commit changes:
- remove uint256.MustFromBig(balance) from executable/non-executable filtering paths
- change list.Filter costLimit from *uint256.Int to *big.Int, and compare costs using big.Int directly
- keep overflow-safe totalcost accounting for replacements (subtract old cost first, then add new)
- return txpool.ErrSpecialTxCostOverflow for special-tx cost/totalcost overflow instead of returning (false, nil)
- avoid partial pending-state mutation by attaching a new pending list only after overflow-safe totalcost calculation succeeds
Tests:
- add regression coverage for special-tx overflow rejection returning non-nil error
- verify no pending/lookup/nonce mutation on overflow rejection
- cover replacement paths to ensure no intermediate-overflow regressions in list.Add/promoteSpecialTx
The address recover is executed and cached in ValidateTransaction already. It's
expected that the cached one is returned in ValidateTransaction. However,
currently, we use the wrong function signer.Sender instead of types.Sender which
will do all the address recover again.
Co-authored-by: minh-bq <97180373+minh-bq@users.noreply.github.com>
* core/txpool: no need to run rotate if no local txs
* Revert "core/txpool: no need to run rotate if no local txs"
This reverts commit 17fab17388.
* use Debug if todo is empty
---------
Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
Adjust txpool validation error wording to report actual and minimum values consistently.
- intrinsic gas error now reports: gas <actual>, minimum needed <required>
- underpriced tip error now reports: gas tip cap <actual>, minimum needed <required>
No transaction validation logic is changed in this commit; only error message text is updated.
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.
* bug fix for using same config object
* update
* change log level to trace on ispochswtich
---------
Co-authored-by: liam.lai <liam.lai@babylonchain.io>
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.
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.
Switch LazyTransaction gas caps from *big.Int to *uint256.Int and convert once at pending retrieval time.
In miner ordering, keep fee comparisons on uint256 and precompute TRC21 gas price in uint256 form to avoid repeated big-int conversions in heap comparisons.
Also update affected tests and call sites in legacypool/worker/helper paths.
Compatibility: LazyTransaction exported field types changed (GasFeeCap/GasTipCap).
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.
Synchronize miner gas tip updates across subsystems when RPC updates gas price.
- update eth miner API to apply gas tip changes to both txpool and miner
- add miner/worker SetGasTip path and initialize worker tip from config
- adjust bind util test to use params.GWei over base fee
Ref: #28933
Package a single XDC binary for all networks and remove binary-switching logic from the CI/CD flow.
Changes:
- cicd/Dockerfile: build once and copy only /usr/bin/XDC
- cicd/entry.sh: validate NETWORK and remove runtime relink
- Makefile: make XDC-devnet-local depend on XDC; remove constants file swap
- common/constants: delete duplicated constants.go.{testnet,devnet,local}
Impact:
- network differences are now driven by runtime config, not separate binaries
Miner configuration is unified under [Eth.Miner] (GasCeil/GasPrice/Etherbase/ExtraData), replacing legacy top-level [Eth] miner keys.
Operational impact: existing config files using [Eth].GasPrice/[Eth].Etherbase/[Eth].ExtraData must be migrated before upgrade.
Behavior update: gasprice=0 remains valid; only negative gas prices are sanitized at startup.
Default change: XDCGenesisGasLimit is reduced to 42,000,000 and now feeds miner default GasCeil (including default --miner-gaslimit), so nodes relying on defaults should review capacity expectations.
Replace the quick-test target to run `go run build/ci.go test -short -failfast`.
Remove the `--quick` flag and package-filter path from `build/ci.go`, so test selection relies on Go's built-in short mode instead of custom package exclusion.
This keeps quick-test behavior aligned with tests guarded by `testing.Short()` and avoids maintaining bespoke skip logic in CI tooling.
* 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.
Fix flaky countdown reset tests by performing an explicit second Reset before validating the second timeout window, and using a boundary-safe time check.
Observed failure:
--- FAIL: TestCountdownShouldReset (14.00s)
countdown_test.go:53: Correctly reset the countdown once
countdown_test.go:72: Countdown did not reset correctly second time
This is a follow-up to #29520, and a preparatory PR to a more thorough
change in the journalling system.
This PR hides the journal-implementation details away, so that the
statedb invokes methods like `JournalCreate`, instead of explicitly
appending journal-events in a list. This means that it's up to the
journal whether to implement it as a sequence of events or
aggregate/merge events.
This PR also makes it so that management of valid snapshots is moved
inside the journal, exposed via the methods `Snapshot() int` and
`RevertToSnapshot(revid int, s *StateDB)`.
JournalSetCode journals the setting of code: it is implicit that the
previous values were "no code" and emptyCodeHash. Therefore, we can
simplify the setCode journal.
The self-destruct journalling is a bit strange: we allow the
selfdestruct operation to be journalled several times. This makes it so
that we also are forced to store whether the account was already
destructed.
What we can do instead, is to only journal the first destruction, and
after that only journal balance-changes, but not journal the
selfdestruct itself.
This simplifies the journalling, so that internals about state
management does not leak into the journal-API.
Preimages were, for some reason, integrated into the journal management,
despite not being a consensus-critical data structure. This PR undoes
that.
---------
Co-authored-by: Martin HS <martin@swende.se>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Add backward-compatible XDPoSConfig JSON decoding for the legacy key
"foudationWalletAddr" introduced before PR #2063 renamed it to
"foundationWalletAddr".
Without this compatibility layer, old on-disk chain configs are decoded with a
zero FoundationWalletAddr, causing XDPoSConfigEqual mismatch and startup rewind
("mismatching XDPoS not equal in database").
This patch:
- Implements custom UnmarshalJSON for XDPoSConfig that reads both keys.
- Prefers foundationWalletAddr when both keys are present.
- Keeps existing behavior for all other fields.
- Adds regression tests for legacy-key decoding and precedence.
Validation:
- go test ./params/...