Merge pull request #542 from nspcc-dev/fix-storage-interop-reads

core: fix wrong data being read in interops (part of #501)
This commit is contained in:
Roman Khimov 2019-12-05 09:08:38 +03:00 committed by GitHub
commit 8beb135829
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -411,9 +411,6 @@ func (ic *interopContext) storageDelete(v *vm.VM) error {
} }
key := v.Estack().Pop().Bytes() key := v.Estack().Pop().Bytes()
si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key) si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key)
if si == nil {
si = ic.bc.GetStorageItem(stc.ScriptHash, key)
}
if si != nil && si.IsConst { if si != nil && si.IsConst {
return errors.New("storage item is constant") return errors.New("storage item is constant")
} }
@ -433,9 +430,6 @@ func (ic *interopContext) storageGet(v *vm.VM) error {
} }
key := v.Estack().Pop().Bytes() key := v.Estack().Pop().Bytes()
si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key) si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key)
if si == nil {
si = ic.bc.GetStorageItem(stc.ScriptHash, key)
}
if si != nil && si.Value != nil { if si != nil && si.Value != nil {
v.Estack().PushVal(si.Value) v.Estack().PushVal(si.Value)
} else { } else {
@ -479,12 +473,9 @@ func (ic *interopContext) putWithContextAndFlags(stc *StorageContext, key []byte
return err return err
} }
si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key) si := getStorageItemFromStore(ic.mem, stc.ScriptHash, key)
if si == nil {
si = ic.bc.GetStorageItem(stc.ScriptHash, key)
if si == nil { if si == nil {
si = &StorageItem{} si = &StorageItem{}
} }
}
if si.IsConst { if si.IsConst {
return errors.New("storage item exists and is read-only") return errors.New("storage item exists and is read-only")
} }