Commit graph

1726 commits

Author SHA1 Message Date
Daniel Liu
001bd7ef3b
fix(eth/hooks,contracts): use parent-state randomize data for checkpoint validator verification (#2186)
Read randomize values at the checkpoint parent height during v1 HookValidator and HookVerifyMNs instead of the latest chain state. This fixes a sync-time race where historical checkpoint headers could be rejected with ErrInvalidCheckpointValidators and then accepted later after local state advanced.

The accompanying regression test now derives expected validators independently from HookValidator and the M2 generation path uses a local RNG source, removing CI-only nondeterminism during repeated verification.
2026-03-21 15:26:54 +08:00
Daniel Liu
8be617c17a
fix(core/txpool): fix nonce assignment in local tracker #31496 (#2183) 2026-03-18 11:41:47 +05:30
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
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
df8c94ce5b
docs(core,eth): fix typos #29024 #29036 (#2161) 2026-03-17 11:15:29 +05:30
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
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
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
9eb90bca0e
feat(eth): log full node id after register peer (#2149) 2026-03-10 18:53:07 +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
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
2611f1dd9a
fix(all): fix typo foudation (#2063) 2026-02-28 18:00:55 +04:00
Daniel Liu
ad0eea0f07
refactor(crypto): vendor in golang.org/x/crypto/sha3 #33323 (#2046)
The upstream libray has removed the assembly-based implementation of
keccak. We need to maintain our own library to avoid a peformance
regression.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: lightclient <lightclient@protonmail.com>
2026-02-28 17:23:57 +04:00
Daniel Liu
5f3613e203
fix(eth): add index to callTracer log #33629 (#2044)
closes https://github.com/ethereum/go-ethereum/issues/33566

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2026-02-28 17:01:13 +04:00
Daniel Liu
9f720806e1
refactor(core): remove unnecessary parameters #30776 (#2068) 2026-02-20 13:51:30 +05:30
Daniel Liu
296d612167
fix(eth): align traceBlockParallel with Prague parent-hash pre-exec (#2067)
traceBlockParallel replays transactions from the parent state to build per-tx prestate for tracers. In the previous flow, Prague's parent-hash system contract processing was not applied before replay, so the prepared state could diverge from canonical block execution semantics.

This commit keeps the parallel tracing path consistent with block processing rules by applying ProcessParentBlockHash before tx replay when Prague is active.

The regression test TestTraceBlockParallelPragueParentHashSystemCall is strengthened to assert the actual EIP-2935 history slot value (ring-buffer key for block-1) equals block.ParentHash(), instead of relying on an indirect EXTCODESIZE side effect. This makes the test deterministic and directly tied to the bug.

Validation: go test ./eth/tracers -run TestTraceBlockParallelPragueParentHashSystemCall
2026-02-17 15:00:55 +05:30
Daniel Liu
bba58ec20b
fix(eth): fix state hooks in API #30830 (#2066) 2026-02-17 14:44:47 +05:30
Daniel Liu
cfca45a7eb
refactor(all): rework EVM constructor #30745 (#2065) 2026-02-17 14:35:18 +05:30
Daniel Liu
373037032f
fix(eth): do system contract processing prior to parallel-tracing #30520 (#2064) 2026-02-17 14:22:39 +05:30
Daniel Liu
cc2109342c
feat(core): implement EIP-2935 #29465 #30924 (#2033) 2026-02-12 09:01:26 +05:30
Daniel Liu
85f2bebfd1
refactor(all): move genesis initialization to blockchain #25523 (#2018) 2026-02-10 16:56:34 +05:30
Daniel Liu
d7a42cb038
refactor(core): clean up EVM environmental structure #31061 (#1985) 2026-02-10 16:40:54 +05:30
Daniel Liu
e39a523260
refactor(all): cleanup the APIs for initializing genesis #25473 #26747 (#2017)
* refactor(all): cleanup the APIs for initializing genesis #25473

* fix(core): fix accessor mismatch for genesis state #26747
2026-02-07 00:18:39 +05:30
Daniel Liu
d74c23cca1
perf(core): use uint256 in state #28598 (#1977) 2026-02-05 13:59:23 +05:30
Daniel Liu
934c8d0679
perf(all): use big.Int.Sign() to compare with 0 (#1969) 2026-02-05 11:45:44 +05:30
Daniel Liu
9cf795c908
perf: improve state reader with error handling and committed flag #27428 (#1166)
- Add error returns to Database.Reader() and NodeIterator() methods
- Introduce committed flag to prevent usage of tries after commit
- Update callers to handle new error signatures
- Add MustNodeIterator() helper for backward compatibility

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2026-02-03 20:55:53 +05:30
Daniel Liu
7ce60a2a79
rpc: add a rpc.rangelimit flag #33163 (#1957) 2026-01-29 11:50:58 +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
4768d00e1e
eth/filters, cmd: add config of eth_getLogs address limit #33320 #32327 (#1961)
* eth/filters: change error code for invalid parameter errors #33320

* eth/filters, cmd: add config of eth_getLogs address limit #32327
2026-01-29 11:26:45 +05:30
Daniel Liu
bd42edee0b
eth/filters: fix error when blockHash is used with fromBlock/toBlock #31877 (#1962) 2026-01-27 08:46:24 +05:30
Daniel Liu
3e1f75eafb
core, eth, miner: 4844 blob transaction pool #26940 (#1911) 2026-01-19 11:24:01 +05:30
Daniel Liu
3e68f0e1d8
cmd/utils, eth: rename ApiBackend to APIBackend (#1955) 2026-01-16 17:27:48 +05:30
Daniel Liu
583338686f
all: expose block number information to statedb #27753 (#1936) 2026-01-16 15:55:04 +05:30
Daniel Liu
b3d354a897
all: move main transaction pool into a subpool #27463 (#1890) 2026-01-05 15:43:50 +05:30
wit liu
3fb8b87a87
eth/filters: terminate pending tx subscription on error #32794 (#1901) 2026-01-04 17:31:29 +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
Daniel Liu
8c380e76f5
core, eth/tracers: support debug_traceCall for special tx, fix #1870 (#1872)
- Fix "invalid transaction v, r, s values" error when calling debug_traceCall
  on BlockSigners contract (0x89)
- Fix "nonce too low" error by respecting Message.SkipNonceChecks flag
- ApplySignTransaction now accepts *Message and uses msg.From directly
- Add fallback to signature recovery for real transactions
- Skip nonce validation when SkipNonceChecks=true (for traceCall)
- Add comprehensive unit tests for both scenarios

Root cause: BlockSigners uses special fast-path that calls
ApplySignTransaction directly, which previously attempted signature
recovery on unsigned transactions from debug_traceCall.

Fixes #1870
2025-12-22 12:02:05 +05:30
Daniel Liu
510be504ef
eth/tracers: prestate lookup EIP7702 delegation account #32080 (#1828)
Implement https://github.com/ethereum/go-ethereum/issues/32078
Parse and lookup the delegation account if EIP7702 is enabled.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Delweng <delweng@gmail.com>
2025-12-20 11:12:33 +05:30
Daniel Liu
142b1155d8
all: implement eip-7702 set code tx #30078 (#1759) 2025-12-19 14:09:45 +04:00
wit liu
a83c43f240
all: use 0x-prefix string for type Address in log message (#1874) 2025-12-19 08:55:21 +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
ebbbdf2bff
core/state: move state log mechanism to a separate layer #30569 #30732 (#1775) 2025-12-16 07:33:19 +04:00