From 6d3275129238d2883aff4e9a3f82d447b0852662 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Sat, 18 Jul 2020 10:10:22 +0300 Subject: [PATCH] core: fix stateroot height update for testnet When synchronizing with stateroot-enabled network from genesis and if stateroot is not enabled in block zero we were failing to update state height because initially it's updated with a jump from 0 to StateRootEnableIndex, so we should allow that to happen to have correct state height. --- pkg/core/blockchain.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 118028676..8f029846f 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1844,9 +1844,9 @@ func (bc *Blockchain) updateStateHeight(newHeight uint32) error { h, err := bc.dao.GetCurrentStateRootHeight() if err != nil { return errors.WithMessage(err, "can't get current state root height") - } else if newHeight == h+1 { + } else if (h < bc.config.StateRootEnableIndex && newHeight == bc.config.StateRootEnableIndex) || newHeight == h+1 { updateStateHeightMetric(newHeight) - return bc.dao.PutCurrentStateRootHeight(h + 1) + return bc.dao.PutCurrentStateRootHeight(newHeight) } return nil }