From 51253bba16e156a2568287d54cc97e56014fb19a Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Fri, 19 Dec 2025 14:16:49 +0800 Subject: [PATCH] eth, triedb: ignore duplicated beacon header --- eth/downloader/beaconsync.go | 1 + eth/downloader/skeleton.go | 10 ++++++++++ triedb/pathdb/generate.go | 1 + 3 files changed, 12 insertions(+) diff --git a/eth/downloader/beaconsync.go b/eth/downloader/beaconsync.go index 1a3f109e0d..aa8f9b1615 100644 --- a/eth/downloader/beaconsync.go +++ b/eth/downloader/beaconsync.go @@ -86,6 +86,7 @@ func (b *beaconBackfiller) resume() { // If a previous filling cycle is still running, just ignore this start // request. // TODO(karalabe): We should make this channel driven b.lock.Unlock() + log.Debug("Backfiller is running") return } b.filling = true diff --git a/eth/downloader/skeleton.go b/eth/downloader/skeleton.go index e504a73e0a..720cddeb2e 100644 --- a/eth/downloader/skeleton.go +++ b/eth/downloader/skeleton.go @@ -675,9 +675,19 @@ func (s *skeleton) processNewHead(head *types.Header, final *types.Header) error // Not a noop / double head announce, abort with a reorg return fmt.Errorf("%w, tail: %d, head: %d, newHead: %d", errChainReorged, lastchain.Tail, lastchain.Head, number) } + // Terminate the sync if the chain head is gapped if lastchain.Head+1 < number { return fmt.Errorf("%w, head: %d, newHead: %d", errChainGapped, lastchain.Head, number) } + // Ignore the duplicated beacon header announcement + if lastchain.Head == number { + local := rawdb.ReadSkeletonHeader(s.db, number) + if local != nil && local.Hash() == head.Hash() { + log.Debug("Ignored the identical beacon header", "number", number, "hash", local.Hash()) + return nil + } + } + // Terminate the sync if the chain head is forked if parent := rawdb.ReadSkeletonHeader(s.db, number-1); parent.Hash() != head.ParentHash { return fmt.Errorf("%w, ancestor: %d, hash: %s, want: %s", errChainForked, number-1, parent.Hash(), head.ParentHash) } diff --git a/triedb/pathdb/generate.go b/triedb/pathdb/generate.go index 2efbbbb4e1..d3d26fff26 100644 --- a/triedb/pathdb/generate.go +++ b/triedb/pathdb/generate.go @@ -148,6 +148,7 @@ func (g *generator) stop() { g.abort <- ch <-ch g.running = false + log.Debug("Snapshot generation has been terminated") } // completed returns the flag indicating if the whole generation is done.