From c034aae37881b2c36eb9822f9863df40584a7a51 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 4 Dec 2019 19:51:57 +0300 Subject: [PATCH] core: fix wrong data being read in interops (part of #501) When 74590551 introduced this code we had no proper caching layer, so there were these strange fallbacks in the code. fc0031e5 should'd removed them, but failed to do so, so do it now and fix processing of transactions that touch storage for the same key (address) in the same block. --- pkg/core/interop_system.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/core/interop_system.go b/pkg/core/interop_system.go index 1d8a4a981..942ed3789 100644 --- a/pkg/core/interop_system.go +++ b/pkg/core/interop_system.go @@ -410,9 +410,6 @@ func (ic *interopContext) storageDelete(v *vm.VM) error { } key := v.Estack().Pop().Bytes() si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key) - if si == nil { - si = ic.bc.GetStorageItem(stc.ScriptHash, key) - } if si != nil && si.IsConst { return errors.New("storage item is constant") } @@ -432,9 +429,6 @@ func (ic *interopContext) storageGet(v *vm.VM) error { } key := v.Estack().Pop().Bytes() si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key) - if si == nil { - si = ic.bc.GetStorageItem(stc.ScriptHash, key) - } if si != nil && si.Value != nil { v.Estack().PushVal(si.Value) } else { @@ -479,10 +473,7 @@ func (ic *interopContext) putWithContextAndFlags(stc *StorageContext, key []byte } si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key) if si == nil { - si = ic.bc.GetStorageItem(stc.ScriptHash, key) - if si == nil { - si = &StorageItem{} - } + si = &StorageItem{} } if si.IsConst { return errors.New("storage item exists and is read-only")