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 we're at the genesis, snapshot the initial state. Alternatively if we have
if number == 0 { // 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) checkpoint := chain.GetHeaderByNumber(number)
if checkpoint != nil { if checkpoint != nil {
// get checkpoint data // get checkpoint data