Merge pull request #1850 from nspcc-dev/fex-storage-price

core: fix storage.Put price
This commit is contained in:
Roman Khimov 2021-03-19 19:10:22 +03:00 committed by GitHub
commit 57d4990fe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -9,7 +9,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
@ -69,7 +68,6 @@ func storageDelete(ic *interop.Context) error {
if stc.ReadOnly {
return errors.New("StorageContext is read only")
}
ic.VM.AddGas(ic.Chain.GetPolicer().GetStoragePrice())
key := ic.VM.Estack().Pop().Bytes()
return ic.DAO.DeleteStorageItem(stc.ID, key)
}
@ -129,7 +127,6 @@ func putWithContext(ic *interop.Context, stc *StorageContext, key []byte, value
si := ic.DAO.GetStorageItem(stc.ID, key)
sizeInc := len(value)
if si == nil {
si = state.StorageItem{}
sizeInc = len(key) + len(value)
} else if len(value) != 0 {
if len(value) <= len(si) {

View file

@ -57,7 +57,7 @@ var systemInterops = []interop.Function{
{Name: interopnames.SystemRuntimeNotify, Func: runtime.Notify, Price: 1 << 15, RequiredFlags: callflag.AllowNotify,
ParamCount: 2},
{Name: interopnames.SystemRuntimePlatform, Func: runtime.Platform, Price: 1 << 3},
{Name: interopnames.SystemStorageDelete, Func: storageDelete, Price: 0,
{Name: interopnames.SystemStorageDelete, Func: storageDelete, Price: 1 << 15,
RequiredFlags: callflag.WriteStates, ParamCount: 2},
{Name: interopnames.SystemStorageFind, Func: storageFind, Price: 1 << 15, RequiredFlags: callflag.ReadStates,
ParamCount: 3},
@ -67,8 +67,8 @@ var systemInterops = []interop.Function{
RequiredFlags: callflag.ReadStates},
{Name: interopnames.SystemStorageGetReadOnlyContext, Func: storageGetReadOnlyContext, Price: 1 << 4,
RequiredFlags: callflag.ReadStates},
{Name: interopnames.SystemStoragePut, Func: storagePut, Price: 0, RequiredFlags: callflag.WriteStates,
ParamCount: 3}, // These don't have static price in C# code.
{Name: interopnames.SystemStoragePut, Func: storagePut, Price: 1 << 15, RequiredFlags: callflag.WriteStates,
ParamCount: 3},
{Name: interopnames.SystemStorageAsReadOnly, Func: storageContextAsReadOnly, Price: 1 << 4,
RequiredFlags: callflag.ReadStates, ParamCount: 1},
}