eth, triedb: ignore duplicated beacon header

This commit is contained in:
Gary Rong 2025-12-19 14:16:49 +08:00
parent 1a5f94b5d9
commit 51253bba16
3 changed files with 12 additions and 0 deletions

View file

@ -86,6 +86,7 @@ func (b *beaconBackfiller) resume() {
// If a previous filling cycle is still running, just ignore this start // If a previous filling cycle is still running, just ignore this start
// request. // TODO(karalabe): We should make this channel driven // request. // TODO(karalabe): We should make this channel driven
b.lock.Unlock() b.lock.Unlock()
log.Debug("Backfiller is running")
return return
} }
b.filling = true b.filling = true

View file

@ -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 // 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) 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 { if lastchain.Head+1 < number {
return fmt.Errorf("%w, head: %d, newHead: %d", errChainGapped, lastchain.Head, 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 { 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) return fmt.Errorf("%w, ancestor: %d, hash: %s, want: %s", errChainForked, number-1, parent.Hash(), head.ParentHash)
} }

View file

@ -148,6 +148,7 @@ func (g *generator) stop() {
g.abort <- ch g.abort <- ch
<-ch <-ch
g.running = false g.running = false
log.Debug("Snapshot generation has been terminated")
} }
// completed returns the flag indicating if the whole generation is done. // completed returns the flag indicating if the whole generation is done.