From 47eadcdf2a2e073dc422eb33ba3c63e22ee3bf19 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 22 Jul 2020 11:05:10 +0300 Subject: [PATCH] core: adjust System.Storage.Put interop Part of #1055. Maximum storage key len has been changed. Also added maximum storage value len restriction. --- pkg/core/interop_system.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/core/interop_system.go b/pkg/core/interop_system.go index 745b20a9b..2b17b2d6f 100644 --- a/pkg/core/interop_system.go +++ b/pkg/core/interop_system.go @@ -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") }