From f52451e5820e7cc2f2d2c9f8f3e12fdaca21fb11 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 18 Nov 2022 12:59:39 +0300 Subject: [PATCH] core: fix state reset with broken contract Sync up with #2802, bad contract -> no contract ID at all. --- pkg/core/blockchain.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 6161abb7d..03f8c3ddc 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -795,12 +795,14 @@ 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++ } - cache.PutContractID(cs.ID, hash) - cnt++ - contractIDsCnt++ } return true