go-ethereum/eth
rjl493456442 4531bfebec
eth/downloader: fix stale beacon header deletion (#33481)
In this PR, two things have been fixed:

--- 

(a) truncate the stale beacon headers with latest snap block

Originally, b.filled is used as the indicator for deleting stale beacon headers. 
This field is set only after synchronization has been scheduled, under the 
assumption that the skeleton chain is already linked to the local chain.

However, the local chain can be mutated via `debug_setHead`, which may
cause `b.filled` outdated. For instance, `b.filled` refers to the last head snap block 
in the last sync cycle while after `debug_setHead`, the head snap block has been 
rewounded to 1.

As a result, Geth can enter an unintended loop: it repeatedly downloads
the missing beacon headers for the skeleton chain and attempts to schedule the 
actual synchronization, but in the final step, all recently fetched headers are removed 
by `cleanStales` due to the stale `b.filled` value.

This issue is addressed by always using the latest snap block as the indicator, 
without relying on any cached value. However, note that before the skeleton
chain is linked to the local chain, the latest snap block will always be below
skeleton.tail, and this condition should not be treated as an error.

--- 

(b) merge the subchains once the skeleton chain links to local chain

Once the skeleton chain links with local one, it will try to schedule the 
synchronization by fetching the missing blocks and import them then. 
It's possible the last subchain already overwrites the previous subchain and 
results in having two subchains leftover. As a result, an error log will printed
https://github.com/ethereum/go-ethereum/blob/master/eth/downloader/skeleton.go#L1074
2025-12-29 16:13:30 +08:00
..
catalyst core, eth: add lock protection in snap sync (#33428) 2025-12-19 09:36:48 +01:00
downloader eth/downloader: fix stale beacon header deletion (#33481) 2025-12-29 16:13:30 +08:00
ethconfig core: log detailed statistics for slow block (#32812) 2025-12-02 14:43:51 +01:00
fetcher eth/fetcher: add metadata validation in tx announcement (#33378) 2025-12-11 12:11:52 +08:00
filters eth/filters: change error code for invalid parameter errors (#33320) 2025-12-04 11:02:42 +01:00
gasestimator eth/gasestimator: check ErrGasLimitTooHigh conditions (#32348) 2025-08-05 19:51:16 +08:00
gasprice core: consolidate BlockChain constructor options (#31925) 2025-06-19 12:21:15 +02:00
protocols eth/protocols/eth: reject message containing duplicated txs and drop peer (#32728) 2025-10-15 10:24:48 +02:00
syncer eth/downloader: keep current syncmode in downloader only (#33157) 2025-12-08 22:49:57 +01:00
tracers cmd/workload, eth/tracers/native: introduce state proof tests (#32247) 2025-12-15 08:35:02 +01:00
api_admin.go eth: ignore genesis block on importChain (#27956) 2023-08-21 13:32:34 -04:00
api_backend.go internal/ethapi: add eth_SendRawTransactionSync (#32830) 2025-10-16 17:34:47 +02:00
api_backend_test.go core/txpool: add eip2681 check for incoming transactions (#32726) 2025-09-25 13:15:12 +02:00
api_debug.go core: log detailed statistics for slow block (#32812) 2025-12-02 14:43:51 +01:00
api_debug_test.go core: consolidate BlockChain constructor options (#31925) 2025-06-19 12:21:15 +02:00
api_miner.go miner: refactor the miner, make the pending block on demand (#28623) 2024-03-06 14:45:03 +02:00
backend.go eth/downloader: keep current syncmode in downloader only (#33157) 2025-12-08 22:49:57 +01:00
dropper.go eth: fix panic in randomDuration when min equals max (#33193) 2025-11-19 01:54:53 +08:00
handler.go eth/fetcher: add metadata validation in tx announcement (#33378) 2025-12-11 12:11:52 +08:00
handler_eth.go eth: check blob transaction validity on the peer goroutine when received (#31219) 2025-03-01 14:10:38 +01:00
handler_eth_test.go eth/downloader: keep current syncmode in downloader only (#33157) 2025-12-08 22:49:57 +01:00
handler_snap.go eth: check snap satelliteness, delegate drop to eth (#22235) 2021-02-02 10:44:36 +02:00
handler_test.go eth/fetcher: add metadata validation in tx announcement (#33378) 2025-12-11 12:11:52 +08:00
peer.go eth/protocols/eth: implement eth/69 (#29158) 2025-05-16 17:10:47 +02:00
peerset.go eth: stabilize tx relay peer selection (#31714) 2025-08-28 16:05:54 +02:00
state_accessor.go core, eth, triedb: serve historical states over RPC (#31161) 2025-06-25 16:50:54 +08:00
sync.go core/txpool/blobpool: filter blob txs with sidecar version (#32577) 2025-09-15 20:48:59 +08:00
sync_test.go eth/downloader: keep current syncmode in downloader only (#33157) 2025-12-08 22:49:57 +01:00