|
|
|
@ -1377,23 +1377,25 @@ func (d *Downloader) processHeaders(origin uint64, td, ttd *big.Int, beaconMode |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if n, err := d.lightchain.InsertHeaderChain(chunkHeaders, frequency); err != nil { |
|
|
|
|
rollbackErr = err |
|
|
|
|
if len(chunkHeaders) > 0 { |
|
|
|
|
if n, err := d.lightchain.InsertHeaderChain(chunkHeaders, frequency); err != nil { |
|
|
|
|
rollbackErr = err |
|
|
|
|
|
|
|
|
|
// If some headers were inserted, track them as uncertain
|
|
|
|
|
if (mode == SnapSync || frequency > 1) && n > 0 && rollback == 0 { |
|
|
|
|
rollback = chunkHeaders[0].Number.Uint64() |
|
|
|
|
// If some headers were inserted, track them as uncertain
|
|
|
|
|
if (mode == SnapSync || frequency > 1) && n > 0 && rollback == 0 { |
|
|
|
|
rollback = chunkHeaders[0].Number.Uint64() |
|
|
|
|
} |
|
|
|
|
log.Warn("Invalid header encountered", "number", chunkHeaders[n].Number, "hash", chunkHashes[n], "parent", chunkHeaders[n].ParentHash, "err", err) |
|
|
|
|
return fmt.Errorf("%w: %v", errInvalidChain, err) |
|
|
|
|
} |
|
|
|
|
log.Warn("Invalid header encountered", "number", chunkHeaders[n].Number, "hash", chunkHashes[n], "parent", chunkHeaders[n].ParentHash, "err", err) |
|
|
|
|
return fmt.Errorf("%w: %v", errInvalidChain, err) |
|
|
|
|
} |
|
|
|
|
// All verifications passed, track all headers within the alloted limits
|
|
|
|
|
if mode == SnapSync { |
|
|
|
|
head := chunkHeaders[len(chunkHeaders)-1].Number.Uint64() |
|
|
|
|
if head-rollback > uint64(fsHeaderSafetyNet) { |
|
|
|
|
rollback = head - uint64(fsHeaderSafetyNet) |
|
|
|
|
} else { |
|
|
|
|
rollback = 1 |
|
|
|
|
// All verifications passed, track all headers within the allowed limits
|
|
|
|
|
if mode == SnapSync { |
|
|
|
|
head := chunkHeaders[len(chunkHeaders)-1].Number.Uint64() |
|
|
|
|
if head-rollback > uint64(fsHeaderSafetyNet) { |
|
|
|
|
rollback = head - uint64(fsHeaderSafetyNet) |
|
|
|
|
} else { |
|
|
|
|
rollback = 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if len(rejected) != 0 { |
|
|
|
|