go-ethereum/eth/downloader
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
..
api.go eth/downloader: fix incomplete code comment (#32354) 2025-08-07 16:31:02 +02:00
beacondevsync.go eth/downloader: keep current syncmode in downloader only (#33157) 2025-12-08 22:49:57 +01:00
beaconsync.go eth/downloader: fix stale beacon header deletion (#33481) 2025-12-29 16:13:30 +08:00
downloader.go eth/downloader: fix stale beacon header deletion (#33481) 2025-12-29 16:13:30 +08:00
downloader_test.go eth/downloader: keep current syncmode in downloader only (#33157) 2025-12-08 22:49:57 +01:00
events.go cmd,eth: 16400 Add an option to stop geth once in sync. WIP for light mode (#17321) 2019-01-30 08:40:36 +01:00
fetchers.go cmd, eth, internal: introduce debug_sync (#32177) 2025-07-28 14:57:45 +08:00
fetchers_concurrent.go eth/downloader: purge pre-merge sync code (#29281) 2024-04-30 15:46:53 +02:00
fetchers_concurrent_bodies.go all: implement flat deposit requests encoding (#30425) 2024-10-09 12:24:58 +02:00
fetchers_concurrent_receipts.go eth/protocols/eth: implement eth/69 (#29158) 2025-05-16 17:10:47 +02:00
metrics.go core, eth/downloader: implement pruning mode sync (#31414) 2025-04-03 15:16:35 +02:00
peer.go all: nuke total difficulty (#30744) 2025-01-28 18:55:41 +01:00
queue.go eth/downloader: remove dead proc counter (#33309) 2025-11-28 10:42:22 +08:00
queue_test.go eth/downloader: fix incorrect waitgroup in test XTestDelivery (#33047) 2025-10-30 15:39:02 +08:00
resultstore.go core, eth/downloader: implement pruning mode sync (#31414) 2025-04-03 15:16:35 +02:00
skeleton.go eth/downloader: fix stale beacon header deletion (#33481) 2025-12-29 16:13:30 +08:00
skeleton_test.go eth/downloader: fix stale beacon header deletion (#33481) 2025-12-29 16:13:30 +08:00
statesync.go eth: request id dispatcher and direct req/reply APIs (#23576) 2021-11-26 13:26:03 +02:00
syncmode.go core, eth: add lock protection in snap sync (#33428) 2025-12-19 09:36:48 +01:00
testchain_test.go core: consolidate BlockChain constructor options (#31925) 2025-06-19 12:21:15 +02:00