diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 4d1217b89..fa0d8870c 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -490,9 +490,8 @@ func (bc *Blockchain) jumpToStateInternal(p uint32, stage stateJumpStage) error // Firstly, remove all old genesis-related items. b := bc.dao.Store.Batch() bc.dao.Store.Seek([]byte{byte(storage.STStorage)}, func(k, _ []byte) { - // Must copy here, #1468. - key := slice.Copy(k) - b.Delete(key) + // #1468, but don't need to copy here, because it is done by Store. + b.Delete(k) }) b.Put(jumpStageKey, []byte{byte(oldStorageItemsRemoved)}) err := bc.dao.Store.PutBatch(b) @@ -509,14 +508,12 @@ func (bc *Blockchain) jumpToStateInternal(p uint32, stage stateJumpStage) error if count >= maxStorageBatchSize { return } - // Must copy here, #1468. - oldKey := slice.Copy(k) - b.Delete(oldKey) + // #1468, but don't need to copy here, because it is done by Store. + b.Delete(k) key := make([]byte, len(k)) key[0] = byte(storage.STStorage) copy(key[1:], k[1:]) - value := slice.Copy(v) - b.Put(key, value) + b.Put(key, slice.Copy(v)) count += 2 }) if count > 0 { diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index 885db02cc..bf4587ee0 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -16,7 +16,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/util/slice" ) // HasTransaction errors. @@ -324,12 +323,10 @@ func (dao *Simple) GetStorageItemsWithPrefix(id int32, prefix []byte) ([]state.S saveToArr := func(k, v []byte) { // Cut prefix and hash. - // Must copy here, #1468. - key := slice.Copy(k) - val := slice.Copy(v) + // #1468, but don't need to copy here, because it is done by Store. siArr = append(siArr, state.StorageItemWithKey{ - Key: key, - Item: state.StorageItem(val), + Key: k, + Item: state.StorageItem(v), }) } dao.Seek(id, prefix, saveToArr) diff --git a/pkg/core/stateroot/module.go b/pkg/core/stateroot/module.go index a96bac1f1..fdc053595 100644 --- a/pkg/core/stateroot/module.go +++ b/pkg/core/stateroot/module.go @@ -13,7 +13,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/util/slice" "go.uber.org/atomic" "go.uber.org/zap" ) @@ -147,9 +146,8 @@ func (s *Module) CleanStorage() error { // b := s.Store.Batch() s.Store.Seek([]byte{byte(storage.DataMPT)}, func(k, _ []byte) { - // Must copy here, #1468. - key := slice.Copy(k) - b.Delete(key) + // #1468, but don't need to copy here, because it is done by Store. + b.Delete(k) }) err = s.Store.PutBatch(b) if err != nil {