core: adjust System.Storage.Put interop

Part of #1055.

Maximum storage key len has been changed. Also added maximum storage
value len restriction.
This commit is contained in:
Anna Shaleva 2020-07-22 11:05:10 +03:00
parent b5185d5d1a
commit 47eadcdf2a

View file

@ -23,7 +23,10 @@ import (
const (
// MaxStorageKeyLen is the maximum length of a key for storage items.
MaxStorageKeyLen = 1024
MaxStorageKeyLen = 64
// MaxStorageValueLen is the maximum length of a value for storage items.
// It is set to be the maximum value for uint16.
MaxStorageValueLen = 65535
// MaxTraceableBlocks is the maximum number of blocks before current chain
// height we're able to give information about.
MaxTraceableBlocks = transaction.MaxValidUntilBlockIncrement
@ -363,6 +366,9 @@ func putWithContextAndFlags(ic *interop.Context, v *vm.VM, stc *StorageContext,
if len(key) > MaxStorageKeyLen {
return errors.New("key is too big")
}
if len(value) > MaxStorageValueLen {
return errors.New("value is too big")
}
if stc.ReadOnly {
return errors.New("StorageContext is read only")
}