From 75529530a26cf3a3cc53909518359b8bd55e4c27 Mon Sep 17 00:00:00 2001 From: Larry <92799281+brilliant-lx@users.noreply.github.com> Date: Wed, 29 Mar 2023 16:51:48 +0800 Subject: [PATCH] fix: snapshot generation issue after chain reinit from a freezer (#1381) --- 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