Merge pull request #1213 from nspcc-dev/fix-stateheight-sync-for-nonzero-enableindex

core: fix stateroot height update for testnet
This commit is contained in:
Roman Khimov 2020-07-18 21:37:11 +03:00 committed by GitHub
commit 7d5d6b620e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -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
} }

View file

@ -630,7 +630,7 @@ func (s *Server) handleRootsCmd(p Peer, rs *payload.StateRoots) error {
} }
h := s.chain.StateHeight() h := s.chain.StateHeight()
if h < s.chain.GetConfig().StateRootEnableIndex { if h < s.chain.GetConfig().StateRootEnableIndex {
h = s.chain.GetConfig().StateRootEnableIndex h = s.chain.GetConfig().StateRootEnableIndex - 1
} }
for i := range rs.Roots { for i := range rs.Roots {
if rs.Roots[i].Index <= h { if rs.Roots[i].Index <= h {