From 091097258a6c8197b57781a92773570bfe470daf Mon Sep 17 00:00:00 2001 From: "larry.lx" Date: Wed, 22 Mar 2023 18:14:51 +0800 Subject: [PATCH] fix: snapshot generation issue after chain reinit from a freezer --- consensus/parlia/parlia.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index b1abc1221f..3fc94e8342 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -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