fix: snapshot generation issue after chain reinit from a freezer (#1381)

This commit is contained in:
Larry 2023-03-29 16:51:48 +08:00 committed by GitHub
parent ece84d4dcd
commit 75529530a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -454,8 +454,10 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
}
}
// If we're at the genesis, snapshot the initial state.
if number == 0 {
// If we're at the genesis, snapshot the initial state. Alternatively if we have
// piled up more headers than allowed to be reorged (chain reinit from a freezer),
// consider the checkpoint trusted and snapshot it.
if number == 0 || (number%p.config.Epoch == 0 && (len(headers) > params.FullImmutabilityThreshold)) {
checkpoint := chain.GetHeaderByNumber(number)
if checkpoint != nil {
// get checkpoint data