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.
This commit is contained in:
parent
dbbe57d11a
commit
6d32751292
1 changed files with 2 additions and 2 deletions
|
@ -1844,9 +1844,9 @@ func (bc *Blockchain) updateStateHeight(newHeight uint32) error {
|
||||||
h, err := bc.dao.GetCurrentStateRootHeight()
|
h, err := bc.dao.GetCurrentStateRootHeight()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "can't get current state root height")
|
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)
|
updateStateHeightMetric(newHeight)
|
||||||
return bc.dao.PutCurrentStateRootHeight(h + 1)
|
return bc.dao.PutCurrentStateRootHeight(newHeight)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue