Commit graph

14188 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
Wanwiset Peerapatanapokin
fe01006381
migrate deployment notification to new slack (#2193) 2026-03-18 08:50: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
3a505d50b0
fix(eth): initialize engine with finalized chain config, fix #2138 (#2180)
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.
2026-03-17 13:21:17 +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
bfe9a3e714
refactor(eth): remove duplicated chain config source #19344 (#2177)
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.
2026-03-17 12:02:42 +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
5625cf6f6e
test(ethclient/simulated): add rollback transaction coverage #31020 (#2174) 2026-03-17 12:01:58 +05:30
Daniel Liu
cd5ce5ae48
fix(core): use sync.Once for SenderCacher initialization #31029 (#2173) 2026-03-17 12:01:41 +05:30
Daniel Liu
129b1c877b
fix(core/txpool/legacypool): fix flaky test TestAllowedTxSize #30975 (#2172) 2026-03-17 12:01:20 +05:30
Daniel Liu
08d7dbc182
refactor(core/txpool): remove unused parameter local #30871 (#2171) 2026-03-17 11:18:46 +05:30
Daniel Liu
bd355d7b3f
fix(core/txpool/legacypool): prevent uint256 overflow panic in executable tx filtering, fix #2134 (#2168)
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
2026-03-17 11:18:22 +05:30
Daniel Liu
5b5c39d849
feat(core/txpool): improve error responses #30715 (#2170) 2026-03-17 11:18:01 +05:30
Daniel Liu
eef6327046
perf(core/txpool/legacypool): use maps.Keys and maps.Copy #30091 (#2165)
- slice and map are reference types, we can use themselves as pointers.
- Use maps.Keys and maps.Copy simplify code.
2026-03-17 11:17:44 +05:30
Daniel Liu
7d3e73951f
perf(core/txpool): use the cached address in ValidateTransactionWithState #30208 (#2166)
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>
2026-03-17 11:17:27 +05:30
Daniel Liu
1ac34cbac3
refactor(core/txpool): no need to log loud rotate if no local txs #29083 (#2164)
* 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>
2026-03-17 11:17:08 +05:30
Daniel Liu
5b0e2e4bf0
fix(core/txpool): clarify tx validation error messages #29081 (#2163)
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.
2026-03-17 11:16:44 +05:30
Daniel Liu
df8c94ce5b
docs(core,eth): fix typos #29024 #29036 (#2161) 2026-03-17 11:15:29 +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
benjamin202410
2137fb3e8d
rollback devnet and reset switch block (#2178)
Co-authored-by: liam.lai <liam.lai@babylonchain.io>
2026-03-16 18:28:29 -07:00
benjamin202410
be36b32b3e
fix(consensus): fix config object not reference to same one and concurrency issues and refactor access pattern (#2146)
* bug fix for using same config object

* update

* change log level to trace on ispochswtich

---------

Co-authored-by: liam.lai <liam.lai@babylonchain.io>
2026-03-12 12:12:49 -07:00
Daniel Liu
c762053cd6
refactor(txpool): remove wrapper type #27841 (#2124)
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.
2026-03-11 09:00:40 +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
8850835f6b
perf(core/txpool,miner): speed up pending transaction ordering with uint256 #29008 (#2159)
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).
2026-03-11 08:50:56 +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
5bc363275c
feat(core/txpool): respect nolocals-setting #28435 (#2128) 2026-03-11 07:44:44 +05:30
Daniel Liu
ae6da0583f
fix(miner): recompute timestamp after sleep (#2052) 2026-03-11 07:27:06 +05:30
Daniel Liu
338d1b4632
feat(eth,miner): wire miner gas tip updates from RPC #28933 (#2136)
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
2026-03-11 07:26:47 +05:30
Daniel Liu
de142957b3
refactor(core/txpool): don't inject lazy resolved transactions into the container #28917 (#2133) 2026-03-11 07:26:37 +05:30
Daniel Liu
9eb90bca0e
feat(eth): log full node id after register peer (#2149) 2026-03-10 18:53:07 +05:30
Daniel Liu
be40f8ac21
chore(cicd,common): unify XDC runtime binary across networks (#2147)
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
2026-03-10 18:52:38 +05:30
Daniel Liu
d8fd0923a9
refactor(miner): polish miner configuration #19480 (#2135)
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.
2026-03-10 18:51:36 +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
f5e2d16f50
refactor‌(core/txpool/legacypool): tiny #28654 (#2131) 2026-03-10 18:48:29 +05:30
Daniel Liu
d1860fa38e
test(build,Makefile): switch quick-test from --quick to -short (#2130)
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.
2026-03-10 18:47:49 +05:30
Daniel Liu
bad1116a28
test(consensus,core): skip long-running tests in short mode (#2129) 2026-03-10 18:46:59 +05:30
Daniel Liu
e9043cceb2
refactor(txpool/legacypool): remove ErrAlreadyKnown in legacypool #28400 (#2127) 2026-03-10 18:45:30 +05:30
Daniel Liu
c8f241ce15
docs(core/txpool/legacypool): fix typos #28258 (#2126) 2026-03-10 18:45:06 +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
5bb1f035a2
feat(core/vm): implement EIP-7883 - ModExp Gas Cost Increase #31606 #32015 (#2123)
https://eips.ethereum.org/EIPS/eip-7883

---------

Co-authored-by: jwasinger <j-wasinger@hotmail.com>
Co-authored-by: MariusVanDerWijden <m.vanderwijden@live.de>
Co-authored-by: Felix Lange <fjl@twurst.com>
2026-03-10 18:43:55 +05:30
Daniel Liu
0581dec6b7
fix(common/countdown): stabilize reset timing assertions (#2120)
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
2026-03-10 18:42:58 +05:30
Daniel Liu
8331c1431f
refactor(params): rename AllXDPoSProtocolChanges to AllDevChainProtocolChanges (#2054) 2026-03-10 18:42:26 +05:30
anunay-xin
4e902c2939
ci: add Slack notification for PR readiness (#2148)
* feat(workflow): add Slack notification for PR readiness

* fix(workflow): enhance Slack notification conditions for PRs
2026-03-10 10:10:19 +05:30
Daniel Liu
e02bc0723a
refactor(core): semantic journalling #28880 (#2081)
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>
2026-03-07 17:42:10 +05:30
anunay-xin
973efe6482
feat(start.sh): add configurable miner gas limit with default value (#2140) 2026-03-07 17:26:11 +08:00
Daniel Liu
ed95075f03
fix(params): accept legacy foudationwalletaddr in chain config, fix #2063 (#2141)
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/...
2026-03-07 06:37:24 +08:00
Daniel Liu
4f599282b3
fix(core): remove slot dirtyness if it's set back to origin value #29731 #31874 (#2080) 2026-03-06 13:25:30 +05:30
Daniel Liu
92ffb4dba7
test(ethclient): port gethclient tests from upstream (#2053) 2026-03-06 13:20:03 +05:30
Daniel Liu
0b47621d05
fix(miner): avoid XDPoS-only paths on non-XDPoS engines (#2049) 2026-03-06 11:24:39 +05:30
Daniel Liu
d542efe08d
feat(core/vm): implement EIP-7823 - Set upper bounds for MODEXP #31818 #32363 (#2119) 2026-03-06 11:24:22 +05:30