core: fix state reset with broken contract

Sync up with #2802, bad contract -> no contract ID at all.
This commit is contained in:
Anna Shaleva 2022-11-18 12:59:39 +03:00
parent ecda07736e
commit f52451e582

View file

@ -795,13 +795,15 @@ func (bc *Blockchain) resetStateInternal(height uint32, stage stateChangeStage)
copy(hash[:], k[mgmtCSPrefixLen:])
err = stackitem.DeserializeConvertible(v, cs)
if err != nil {
seekErr = fmt.Errorf("failed to deserialize contract %s state: %w", hash.StringLE(), seekErr)
return false
}
bc.log.Warn("failed to deserialize contract; ID for this contract won't be stored in the DB",
zap.String("hash", hash.StringLE()),
zap.Error(err))
} else {
cache.PutContractID(cs.ID, hash)
cnt++
contractIDsCnt++
}
}
return true
})