From 8e3f2417f4c7ed11aa60b57d88a658310c88ccf5 Mon Sep 17 00:00:00 2001 From: AnnaShaleva Date: Mon, 28 Feb 2022 13:25:08 +0300 Subject: [PATCH] core: add check for native activations history It should be consistent with storage states. --- pkg/core/blockchain.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 36b299511..e86b1fe0b 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -448,13 +448,16 @@ func (bc *Blockchain) init() error { // contract state from DAO via high-level bc API. for _, c := range bc.contracts.Contracts { md := c.Metadata() + storedCS := bc.GetContractState(md.Hash) history := md.UpdateHistory if len(history) == 0 || history[0] > bHeight { + if storedCS != nil { + return fmt.Errorf("native contract %s is already stored, but marked as inactive for height %d in config", md.Name, bHeight) + } continue } - storedCS := bc.GetContractState(md.Hash) if storedCS == nil { - return fmt.Errorf("native contract %s is not stored", md.Name) + return fmt.Errorf("native contract %s is not stored, but should be active at height %d according to config", md.Name, bHeight) } storedCSBytes, err := stackitem.SerializeConvertible(storedCS) if err != nil {