mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
eth, triedb: ignore duplicated beacon header
This commit is contained in:
parent
1a5f94b5d9
commit
51253bba16
3 changed files with 12 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue