From 9a41356a3b491fba60bfdf9aa50fdb09e8d6de99 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 12:33:29 +0300 Subject: [PATCH 01/13] core: add getUint256FromItem helper to native ledger --- pkg/core/native/ledger.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/core/native/ledger.go b/pkg/core/native/ledger.go index a5d56133b..d82342373 100644 --- a/pkg/core/native/ledger.go +++ b/pkg/core/native/ledger.go @@ -166,25 +166,29 @@ func getBlockHashFromItem(bc interop.Ledger, item stackitem.Item) util.Uint256 { } return bc.GetHeaderHash(int(index)) } - bytes, err := item.TryBytes() - if err != nil { - panic(err) - } - hash, err := util.Uint256DecodeBytesBE(bytes) + hash, err := getUint256FromItem(item) if err != nil { panic(err) } return hash } +func getUint256FromItem(item stackitem.Item) (util.Uint256, error) { + hashbytes, err := item.TryBytes() + if err != nil { + return util.Uint256{}, fmt.Errorf("failed to get hash bytes: %w", err) + } + hash, err := util.Uint256DecodeBytesBE(hashbytes) + if err != nil { + return util.Uint256{}, fmt.Errorf("failed to decode hash: %w", err) + } + return hash, nil +} + // getTransactionAndHeight returns transaction and its height if it's present // on the chain. It panics if anything goes wrong. func getTransactionAndHeight(d *dao.Simple, item stackitem.Item) (*transaction.Transaction, uint32, error) { - hashbytes, err := item.TryBytes() - if err != nil { - panic(err) - } - hash, err := util.Uint256DecodeBytesBE(hashbytes) + hash, err := getUint256FromItem(item) if err != nil { panic(err) } From 6343720adfff1269fd54443016dfc22a6f6ad688 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 12:47:29 +0300 Subject: [PATCH 02/13] dao: return ErrKeyNotFound from GetAppExecResults for dummy txs Otherwise decoding error may be returned which can be misleading. --- pkg/core/dao/dao.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index 5a2971c96..f7e6f065e 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -259,6 +259,9 @@ func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]st return nil, err } case storage.ExecTransaction: + if len(bs) >= 6 && bs[5] == transaction.DummyVersion { + return nil, storage.ErrKeyNotFound + } _ = r.ReadU32LE() tx := &transaction.Transaction{} tx.DecodeBinary(r) From 2972569a0a518d3576c82dfcfe193f856e5e52f3 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 13:52:29 +0300 Subject: [PATCH 03/13] vm: make byte representation of VMState compatible with C# --- pkg/vm/state.go | 4 ++-- pkg/vm/state_test.go | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/vm/state.go b/pkg/vm/state.go index c94de5a22..8247a9dc5 100644 --- a/pkg/vm/state.go +++ b/pkg/vm/state.go @@ -10,14 +10,14 @@ type State uint8 // Available States. const ( - // NoneState represents NONE VM state. - NoneState State = 0 // HaltState represents HALT VM state. HaltState State = 1 << iota // FaultState represents FAULT VM state. FaultState // BreakState represents BREAK VM state. BreakState + // NoneState represents NONE VM state. + NoneState State = 0 ) // HasFlag checks for State flag presence. diff --git a/pkg/vm/state_test.go b/pkg/vm/state_test.go index be31dc5ee..7c4d87015 100644 --- a/pkg/vm/state_test.go +++ b/pkg/vm/state_test.go @@ -86,3 +86,12 @@ func TestState_UnmarshalJSON(t *testing.T) { assert.NoError(t, err) assert.Equal(t, NoneState, s) } + +// TestState_EnumCompat tests that byte value of State matches the C#'s one got from +// https://github.com/neo-project/neo-vm/blob/0028d862e253bda3c12eb8bb007a2d95822d3922/src/neo-vm/VMState.cs#L16. +func TestState_EnumCompat(t *testing.T) { + assert.Equal(t, byte(0), byte(NoneState)) + assert.Equal(t, byte(1<<0), byte(HaltState)) + assert.Equal(t, byte(1<<1), byte(FaultState)) + assert.Equal(t, byte(1<<2), byte(BreakState)) +} From 18c5f638b979ff407a367f2b8f57448e390a84ef Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 19:07:32 +0300 Subject: [PATCH 04/13] dao: adjust usages of `Internal DB inconsistency` error --- pkg/core/dao/dao.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index f7e6f065e..e5e27d4ba 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -25,6 +25,9 @@ var ( // ErrHasConflicts is returned when transaction is in the list of conflicting // transactions which are already in dao. ErrHasConflicts = errors.New("transaction has conflicts") + // ErrInternalDBInconsistency is returned when the format of retrieved DAO + // record is unexpected. + ErrInternalDBInconsistency = errors.New("internal DB inconsistency") ) // Simple is memCached wrapper around DB, simple DAO implementation. @@ -252,7 +255,7 @@ func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]st return nil, err } r := io.NewBinReaderFromBuf(bs) - switch r.ReadB() { + switch pref := r.ReadB(); pref { case storage.ExecBlock: _, err = block.NewTrimmedFromReader(dao.Version.StateRootInHeader, r) if err != nil { @@ -265,6 +268,8 @@ func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]st _ = r.ReadU32LE() tx := &transaction.Transaction{} tx.DecodeBinary(r) + default: + return nil, fmt.Errorf("%w: unexpected executable prefix %d", ErrInternalDBInconsistency, pref) } if r.Err != nil { return nil, r.Err @@ -358,7 +363,8 @@ func (dao *Simple) getBlock(key []byte) (*block.Block, error) { r := io.NewBinReaderFromBuf(b) if r.ReadB() != storage.ExecBlock { - return nil, errors.New("internal DB inconsistency") + // It may be a transaction. + return nil, storage.ErrKeyNotFound } block, err := block.NewTrimmedFromReader(dao.Version.StateRootInHeader, r) if err != nil { @@ -522,7 +528,8 @@ func (dao *Simple) GetTransaction(hash util.Uint256) (*transaction.Transaction, return nil, 0, errors.New("bad transaction bytes") } if b[0] != storage.ExecTransaction { - return nil, 0, errors.New("internal DB inconsistency") + // It may be a block. + return nil, 0, storage.ErrKeyNotFound } if b[5] == transaction.DummyVersion { return nil, 0, storage.ErrKeyNotFound From 4254407a9b19ed56954727cd244b676c0fdb0369 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 19:28:36 +0300 Subject: [PATCH 05/13] dao: add GetTxExecResult method --- pkg/core/dao/dao.go | 93 +++++++++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 25 deletions(-) diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index e5e27d4ba..b178d2aaf 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -254,41 +254,84 @@ func (dao *Simple) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]st if err != nil { return nil, err } - r := io.NewBinReaderFromBuf(bs) - switch pref := r.ReadB(); pref { + if len(bs) == 0 { + return nil, fmt.Errorf("%w: empty execution log", ErrInternalDBInconsistency) + } + switch bs[0] { case storage.ExecBlock: + r := io.NewBinReaderFromBuf(bs) + _ = r.ReadB() _, err = block.NewTrimmedFromReader(dao.Version.StateRootInHeader, r) if err != nil { return nil, err } - case storage.ExecTransaction: - if len(bs) >= 6 && bs[5] == transaction.DummyVersion { - return nil, storage.ErrKeyNotFound - } - _ = r.ReadU32LE() - tx := &transaction.Transaction{} - tx.DecodeBinary(r) - default: - return nil, fmt.Errorf("%w: unexpected executable prefix %d", ErrInternalDBInconsistency, pref) - } - if r.Err != nil { - return nil, r.Err - } - result := make([]state.AppExecResult, 0, 2) - for { - aer := new(state.AppExecResult) - aer.DecodeBinary(r) - if r.Err != nil { - if r.Err == iocore.EOF { - break + result := make([]state.AppExecResult, 0, 2) + for { + aer := new(state.AppExecResult) + aer.DecodeBinary(r) + if r.Err != nil { + if r.Err == iocore.EOF { + break + } + return nil, r.Err } - return nil, r.Err + if aer.Trigger&trig != 0 { + result = append(result, *aer) + } + } + return result, nil + case storage.ExecTransaction: + _, _, aer, err := decodeTxAndExecResult(bs) + if err != nil { + return nil, err } if aer.Trigger&trig != 0 { - result = append(result, *aer) + return []state.AppExecResult{*aer}, nil } + return nil, nil + default: + return nil, fmt.Errorf("%w: unexpected executable prefix %d", ErrInternalDBInconsistency, bs[0]) } - return result, nil +} + +// GetTxExecResult gets application execution result of the specified transaction +// and returns the transaction itself, its height and its AppExecResult. +func (dao *Simple) GetTxExecResult(hash util.Uint256) (uint32, *transaction.Transaction, *state.AppExecResult, error) { + key := dao.makeExecutableKey(hash) + bs, err := dao.Store.Get(key) + if err != nil { + return 0, nil, nil, err + } + if len(bs) == 0 { + return 0, nil, nil, fmt.Errorf("%w: empty execution log", ErrInternalDBInconsistency) + } + if bs[0] != storage.ExecTransaction { + return 0, nil, nil, storage.ErrKeyNotFound + } + return decodeTxAndExecResult(bs) +} + +// decodeTxAndExecResult decodes transaction, its height and execution result from +// the given executable bytes. It performs no executable prefix check. +func decodeTxAndExecResult(buf []byte) (uint32, *transaction.Transaction, *state.AppExecResult, error) { + if len(buf) >= 6 && buf[5] == transaction.DummyVersion { + return 0, nil, nil, storage.ErrKeyNotFound + } + r := io.NewBinReaderFromBuf(buf) + _ = r.ReadB() + h := r.ReadU32LE() + tx := &transaction.Transaction{} + tx.DecodeBinary(r) + if r.Err != nil { + return 0, nil, nil, r.Err + } + aer := new(state.AppExecResult) + aer.DecodeBinary(r) + if r.Err != nil { + return 0, nil, nil, r.Err + } + + return h, tx, aer, nil } // -- end notification event. From b431e47d2a38c3e8442b373198f9f6a62eae390c Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 13:22:20 +0300 Subject: [PATCH 06/13] core: add GetTransactionVMState to native Ledger contract Close #2343. --- pkg/core/native/ledger.go | 19 +++++++++++++ pkg/core/native/native_test/ledger_test.go | 31 ++++++++++++++++++++-- pkg/interop/native/ledger/ledger.go | 20 ++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/pkg/core/native/ledger.go b/pkg/core/native/ledger.go index d82342373..e00923a71 100644 --- a/pkg/core/native/ledger.go +++ b/pkg/core/native/ledger.go @@ -14,6 +14,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" ) @@ -62,6 +63,11 @@ func newLedger() *Ledger { md = newMethodAndPrice(l.getTransactionFromBlock, 1<<16, callflag.ReadStates) l.AddMethod(md, desc) + desc = newDescriptor("getTransactionVMState", smartcontract.IntegerType, + manifest.NewParameter("hash", smartcontract.Hash256Type)) + md = newMethodAndPrice(l.getTransactionVMState, 1<<15, callflag.ReadStates) + l.AddMethod(md, desc) + return l } @@ -142,6 +148,19 @@ func (l *Ledger) getTransactionFromBlock(ic *interop.Context, params []stackitem return TransactionToStackItem(block.Transactions[index]) } +// getTransactionVMState returns VM state got after transaction invocation. +func (l *Ledger) getTransactionVMState(ic *interop.Context, params []stackitem.Item) stackitem.Item { + hash, err := getUint256FromItem(params[0]) + if err != nil { + panic(err) + } + h, _, aer, err := ic.DAO.GetTxExecResult(hash) + if err != nil || !isTraceableBlock(ic.Chain, h) { + return stackitem.Make(vm.NoneState) + } + return stackitem.Make(aer.VMState) +} + // isTraceableBlock defines whether we're able to give information about // the block with index specified. func isTraceableBlock(bc interop.Ledger, index uint32) bool { diff --git a/pkg/core/native/native_test/ledger_test.go b/pkg/core/native/native_test/ledger_test.go index ab71dbee0..9306f3008 100644 --- a/pkg/core/native/native_test/ledger_test.go +++ b/pkg/core/native/native_test/ledger_test.go @@ -5,11 +5,11 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/config" - "github.com/nspcc-dev/neo-go/pkg/neotest/chain" - "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/neotest" + "github.com/nspcc-dev/neo-go/pkg/neotest/chain" "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/stretchr/testify/require" @@ -44,6 +44,33 @@ func TestLedger_GetTransactionHeight(t *testing.T) { }) } +func TestLedger_GetTransactionState(t *testing.T) { + c := newLedgerClient(t) + e := c.Executor + ledgerInvoker := c.WithSigners(c.Committee) + + hash := e.InvokeScript(t, []byte{byte(opcode.RET)}, []neotest.Signer{c.Committee}) + + t.Run("unknown transaction", func(t *testing.T) { + ledgerInvoker.Invoke(t, vm.NoneState, "getTransactionVMState", util.Uint256{1, 2, 3}) + }) + t.Run("not a hash", func(t *testing.T) { + ledgerInvoker.InvokeFail(t, "expected []byte of size 32", "getTransactionVMState", []byte{1, 2, 3}) + }) + t.Run("good: HALT", func(t *testing.T) { + ledgerInvoker.Invoke(t, vm.HaltState, "getTransactionVMState", hash) + }) + t.Run("isn't traceable", func(t *testing.T) { + // Add more blocks so that tx becomes untraceable. + e.GenerateNewBlocks(t, int(e.Chain.GetConfig().MaxTraceableBlocks)) + ledgerInvoker.Invoke(t, vm.NoneState, "getTransactionVMState", hash) + }) + t.Run("good: FAULT", func(t *testing.T) { + faultedH := e.InvokeScript(t, []byte{byte(opcode.ABORT)}, []neotest.Signer{c.Committee}) + ledgerInvoker.Invoke(t, vm.FaultState, "getTransactionVMState", faultedH) + }) +} + func TestLedger_GetTransaction(t *testing.T) { c := newLedgerClient(t) e := c.Executor diff --git a/pkg/interop/native/ledger/ledger.go b/pkg/interop/native/ledger/ledger.go index 8de5deb4b..4b3c0ef2e 100644 --- a/pkg/interop/native/ledger/ledger.go +++ b/pkg/interop/native/ledger/ledger.go @@ -13,6 +13,21 @@ import ( // Hash represents Ledger contract hash. const Hash = "\xbe\xf2\x04\x31\x40\x36\x2a\x77\xc1\x50\x99\xc7\xe6\x4c\x12\xf7\x00\xb6\x65\xda" +// VMState represents VM execution state. +type VMState uint8 + +// Various VM execution states. +const ( + // NoneState represents NONE VM state. + NoneState VMState = 0 + // HaltState represents HALT VM state. + HaltState VMState = 1 + // FaultState represents FAULT VM state. + FaultState VMState = 2 + // BreakState represents BREAK VM state. + BreakState VMState = 4 +) + // CurrentHash represents `currentHash` method of Ledger native contract. func CurrentHash() interop.Hash256 { return neogointernal.CallWithToken(Hash, "currentHash", int(contract.ReadStates)).(interop.Hash256) @@ -43,3 +58,8 @@ func GetTransactionFromBlock(indexOrHash interface{}, txIndex int) *Transaction return neogointernal.CallWithToken(Hash, "getTransactionFromBlock", int(contract.ReadStates), indexOrHash, txIndex).(*Transaction) } + +// GetTransactionVMState represents `getTransactionVMState` method of Ledger native contract. +func GetTransactionVMState(hash interop.Hash256) VMState { + return neogointernal.CallWithToken(Hash, "getTransactionVMState", int(contract.ReadStates), hash).(VMState) +} From 5388c895d257c490be2de1e9a1c2b46a26c5da42 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 13:41:38 +0300 Subject: [PATCH 07/13] gomod: update interop version --- examples/engine/go.mod | 2 +- examples/engine/go.sum | 4 ++-- examples/events/go.mod | 2 +- examples/events/go.sum | 4 ++-- examples/iterator/go.mod | 2 +- examples/iterator/go.sum | 4 ++-- examples/nft-d/go.mod | 2 +- examples/nft-d/go.sum | 4 ++-- examples/nft-nd-nns/go.mod | 2 +- examples/nft-nd-nns/go.sum | 3 ++- examples/nft-nd/go.mod | 2 +- examples/nft-nd/go.sum | 4 ++-- examples/oracle/go.mod | 2 +- examples/oracle/go.sum | 4 ++-- examples/runtime/go.mod | 2 +- examples/runtime/go.sum | 4 ++-- examples/storage/go.mod | 2 +- examples/storage/go.sum | 4 ++-- examples/timer/go.mod | 2 +- examples/timer/go.sum | 4 ++-- examples/token/go.mod | 2 +- examples/token/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 24 files changed, 36 insertions(+), 35 deletions(-) diff --git a/examples/engine/go.mod b/examples/engine/go.mod index 3754a6cb2..df17bd7f8 100644 --- a/examples/engine/go.mod +++ b/examples/engine/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/engine go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/engine/go.sum b/examples/engine/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/engine/go.sum +++ b/examples/engine/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/events/go.mod b/examples/events/go.mod index 381d6ef2f..de6dc733c 100644 --- a/examples/events/go.mod +++ b/examples/events/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/events go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/events/go.sum b/examples/events/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/events/go.sum +++ b/examples/events/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/iterator/go.mod b/examples/iterator/go.mod index 2f2348875..f68480587 100644 --- a/examples/iterator/go.mod +++ b/examples/iterator/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/iterator go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/iterator/go.sum b/examples/iterator/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/iterator/go.sum +++ b/examples/iterator/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/nft-d/go.mod b/examples/nft-d/go.mod index e16655ba3..d53c3dce8 100644 --- a/examples/nft-d/go.mod +++ b/examples/nft-d/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/nft-d/go.sum b/examples/nft-d/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/nft-d/go.sum +++ b/examples/nft-d/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/nft-nd-nns/go.mod b/examples/nft-nd-nns/go.mod index 5d6beed10..71c68e524 100644 --- a/examples/nft-nd-nns/go.mod +++ b/examples/nft-nd-nns/go.mod @@ -4,6 +4,6 @@ go 1.16 require ( github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220321144433-3b639f518ebb - github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 github.com/stretchr/testify v1.7.0 ) diff --git a/examples/nft-nd-nns/go.sum b/examples/nft-nd-nns/go.sum index b27db7f64..d0200b208 100644 --- a/examples/nft-nd-nns/go.sum +++ b/examples/nft-nd-nns/go.sum @@ -178,8 +178,9 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1: github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220321144433-3b639f518ebb h1:NBswaBUXFAjIvlA1PjbTLh/A07co24DkXvKjz3ya78I= github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220321144433-3b639f518ebb/go.mod h1:ebS1+SqgUBck6nbJzVaf92CPtLhNt4rAYPlCzH71gNU= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= diff --git a/examples/nft-nd/go.mod b/examples/nft-nd/go.mod index d14390864..6c4217184 100644 --- a/examples/nft-nd/go.mod +++ b/examples/nft-nd/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/nft-nd/go.sum b/examples/nft-nd/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/nft-nd/go.sum +++ b/examples/nft-nd/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/oracle/go.mod b/examples/oracle/go.mod index 6b9a589a9..8d42a462f 100644 --- a/examples/oracle/go.mod +++ b/examples/oracle/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/oracle go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/oracle/go.sum b/examples/oracle/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/oracle/go.sum +++ b/examples/oracle/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/runtime/go.mod b/examples/runtime/go.mod index b6a397868..c5b878c06 100644 --- a/examples/runtime/go.mod +++ b/examples/runtime/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/runtime go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/runtime/go.sum b/examples/runtime/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/runtime/go.sum +++ b/examples/runtime/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/storage/go.mod b/examples/storage/go.mod index 0a6d83449..49884a724 100644 --- a/examples/storage/go.mod +++ b/examples/storage/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/storage go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/storage/go.sum b/examples/storage/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/storage/go.sum +++ b/examples/storage/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/timer/go.mod b/examples/timer/go.mod index 7b3742a01..3dd6ae53c 100644 --- a/examples/timer/go.mod +++ b/examples/timer/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/timer go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/timer/go.sum b/examples/timer/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/timer/go.sum +++ b/examples/timer/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/token/go.mod b/examples/token/go.mod index fcde98699..3f529a639 100644 --- a/examples/token/go.mod +++ b/examples/token/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 diff --git a/examples/token/go.sum b/examples/token/go.sum index d6c936018..2a7803ba6 100644 --- a/examples/token/go.sum +++ b/examples/token/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/go.mod b/go.mod index 21a4c20a9..3fc8e8ede 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/mr-tron/base58 v1.2.0 github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 - github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659 github.com/nspcc-dev/rfc6979 v0.2.0 github.com/pierrec/lz4 v2.6.1+incompatible diff --git a/go.sum b/go.sum index 46ccdaf09..9efed22f8 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,8 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af h1:QO3pU/jSYyX3EHBX8BPO01oRkVhGBXPrQaQEhn+4fv8= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= From 31aa90d6b5fcb75e109f70d1169c5ad5e2020072 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 5 Apr 2022 10:46:11 +0300 Subject: [PATCH 08/13] examples: update neo-go dependency --- examples/nft-nd-nns/go.mod | 2 +- examples/nft-nd-nns/go.sum | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/nft-nd-nns/go.mod b/examples/nft-nd-nns/go.mod index 71c68e524..526f58906 100644 --- a/examples/nft-nd-nns/go.mod +++ b/examples/nft-nd-nns/go.mod @@ -3,7 +3,7 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd-nns go 1.16 require ( - github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220321144433-3b639f518ebb + github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257 github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 github.com/stretchr/testify v1.7.0 ) diff --git a/examples/nft-nd-nns/go.sum b/examples/nft-nd-nns/go.sum index d0200b208..c7d8877ae 100644 --- a/examples/nft-nd-nns/go.sum +++ b/examples/nft-nd-nns/go.sum @@ -176,9 +176,8 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= -github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220321144433-3b639f518ebb h1:NBswaBUXFAjIvlA1PjbTLh/A07co24DkXvKjz3ya78I= -github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220321144433-3b639f518ebb/go.mod h1:ebS1+SqgUBck6nbJzVaf92CPtLhNt4rAYPlCzH71gNU= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257 h1:fBGQ1dYVq8z5F1EeHRV2hbkEZPDBhZf92x0xnV14440= +github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257/go.mod h1:mXlbOH7vVac9F7E131pI8VniP2T7lEzlvh394btP63o= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= @@ -208,6 +207,7 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 0e8bf83dda3bd809c6d71051da028407e9aa36df Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 13:41:54 +0300 Subject: [PATCH 09/13] compiler: add tests for GetTransactionVMState --- pkg/compiler/native_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/compiler/native_test.go b/pkg/compiler/native_test.go index e75beb8dc..a0dc6c2d4 100644 --- a/pkg/compiler/native_test.go +++ b/pkg/compiler/native_test.go @@ -89,6 +89,13 @@ func TestOracleContractValues(t *testing.T) { require.EqualValues(t, oracle.MinimumResponseGas, native.MinimumResponseGas) } +func TestLedgerVMStates(t *testing.T) { + require.EqualValues(t, ledger.NoneState, vm.NoneState) + require.EqualValues(t, ledger.HaltState, vm.HaltState) + require.EqualValues(t, ledger.FaultState, vm.FaultState) + require.EqualValues(t, ledger.BreakState, vm.BreakState) +} + type nativeTestCase struct { method string params []string @@ -151,6 +158,7 @@ func TestNativeHelpersCompile(t *testing.T) { {"getTransaction", []string{u256}}, {"getTransactionFromBlock", []string{u256, "1"}}, {"getTransactionHeight", []string{u256}}, + {"getTransactionVMState", []string{u256}}, }) runNativeTestCases(t, cs.Notary.ContractMD, "notary", []nativeTestCase{ {"lockDepositUntil", []string{u160, "123"}}, From 16f952270c1e6426b7ddff2c440b1800e62b428f Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 16:43:15 +0300 Subject: [PATCH 10/13] core: add murmur32 to CryptoLib native contract Close #2415. --- pkg/core/native/crypto.go | 20 ++++++++++++++++++++ pkg/core/native/crypto_test.go | 21 +++++++++++++++++++++ pkg/interop/native/crypto/crypto.go | 6 ++++++ 3 files changed, 47 insertions(+) diff --git a/pkg/core/native/crypto.go b/pkg/core/native/crypto.go index b377dd82e..0eb4d6add 100644 --- a/pkg/core/native/crypto.go +++ b/pkg/core/native/crypto.go @@ -2,6 +2,7 @@ package native import ( "crypto/elliptic" + "encoding/binary" "errors" "fmt" @@ -14,6 +15,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" + "github.com/twmb/murmur3" ) // Crypto represents CryptoLib contract. @@ -46,6 +48,12 @@ func newCrypto() *Crypto { md = newMethodAndPrice(c.ripemd160, 1<<15, callflag.NoneFlag) c.AddMethod(md, desc) + desc = newDescriptor("murmur32", smartcontract.ByteArrayType, + manifest.NewParameter("data", smartcontract.ByteArrayType), + manifest.NewParameter("seed", smartcontract.IntegerType)) + md = newMethodAndPrice(c.murmur32, 1<<13, callflag.NoneFlag) + c.AddMethod(md, desc) + desc = newDescriptor("verifyWithECDsa", smartcontract.BoolType, manifest.NewParameter("message", smartcontract.ByteArrayType), manifest.NewParameter("pubkey", smartcontract.ByteArrayType), @@ -72,6 +80,18 @@ func (c *Crypto) ripemd160(_ *interop.Context, args []stackitem.Item) stackitem. return stackitem.NewByteArray(hash.RipeMD160(bs).BytesBE()) } +func (c *Crypto) murmur32(_ *interop.Context, args []stackitem.Item) stackitem.Item { + bs, err := args[0].TryBytes() + if err != nil { + panic(err) + } + seed := toUint32(args[1]) + h := murmur3.SeedSum32(seed, bs) + result := make([]byte, 4) + binary.LittleEndian.PutUint32(result, h) + return stackitem.NewByteArray(result) +} + func (c *Crypto) verifyWithECDsa(_ *interop.Context, args []stackitem.Item) stackitem.Item { msg, err := args[0].TryBytes() if err != nil { diff --git a/pkg/core/native/crypto_test.go b/pkg/core/native/crypto_test.go index 6c20854d2..727c160a9 100644 --- a/pkg/core/native/crypto_test.go +++ b/pkg/core/native/crypto_test.go @@ -1,6 +1,7 @@ package native import ( + "encoding/binary" "encoding/hex" "math" "math/big" @@ -43,6 +44,26 @@ func TestRIPEMD160(t *testing.T) { }) } +func TestMurmur32(t *testing.T) { + c := newCrypto() + ic := &interop.Context{VM: vm.New()} + + t.Run("bad arg type", func(t *testing.T) { + require.Panics(t, func() { + c.murmur32(ic, []stackitem.Item{stackitem.NewInterop(nil), stackitem.Make(5)}) + }) + }) + t.Run("good", func(t *testing.T) { + // Example from the C# node: + // https://github.com/neo-project/neo/blob/2a64c1cc809d1ff4b3a573c7c22bffbbf69a738b/tests/neo.UnitTests/Cryptography/UT_Murmur32.cs#L18 + data := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1} + seed := 10 + expected := make([]byte, 4) + binary.LittleEndian.PutUint32(expected, 378574820) + require.Equal(t, expected, c.murmur32(ic, []stackitem.Item{stackitem.NewByteArray(data), stackitem.Make(seed)}).Value().([]byte)) + }) +} + func TestCryptoLibVerifyWithECDsa(t *testing.T) { t.Run("R1", func(t *testing.T) { testECDSAVerify(t, Secp256r1) diff --git a/pkg/interop/native/crypto/crypto.go b/pkg/interop/native/crypto/crypto.go index 8bf8acf6c..8374cc26d 100644 --- a/pkg/interop/native/crypto/crypto.go +++ b/pkg/interop/native/crypto/crypto.go @@ -32,6 +32,12 @@ func Ripemd160(b []byte) interop.Hash160 { return neogointernal.CallWithToken(Hash, "ripemd160", int(contract.NoneFlag), b).(interop.Hash160) } +// Murmur32 calls `murmur32` method of native CryptoLib contract and computes Murmur32 hash of b +// using the given seed. +func Murmur32(b []byte, seed int) []byte { + return neogointernal.CallWithToken(Hash, "murmur32", int(contract.NoneFlag), b, seed).([]byte) +} + // VerifyWithECDsa calls `verifyWithECDsa` method of native CryptoLib contract and checks that sig is // correct msg's signature for a given pub (serialized public key on a given curve). func VerifyWithECDsa(msg []byte, pub interop.PublicKey, sig interop.Signature, curve NamedCurve) bool { From 7b5ff25a40a9066490a3dc546b7b7ddfe93322ab Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 5 Apr 2022 10:48:41 +0300 Subject: [PATCH 11/13] gomod: update interop dependency --- examples/engine/go.mod | 2 +- examples/engine/go.sum | 4 ++-- examples/events/go.mod | 2 +- examples/events/go.sum | 4 ++-- examples/iterator/go.mod | 2 +- examples/iterator/go.sum | 4 ++-- examples/nft-d/go.mod | 2 +- examples/nft-d/go.sum | 4 ++-- examples/nft-nd-nns/go.mod | 2 +- examples/nft-nd-nns/go.sum | 3 ++- examples/nft-nd/go.mod | 2 +- examples/nft-nd/go.sum | 4 ++-- examples/oracle/go.mod | 2 +- examples/oracle/go.sum | 4 ++-- examples/runtime/go.mod | 2 +- examples/runtime/go.sum | 4 ++-- examples/storage/go.mod | 2 +- examples/storage/go.sum | 4 ++-- examples/timer/go.mod | 2 +- examples/timer/go.sum | 4 ++-- examples/token/go.mod | 2 +- examples/token/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 24 files changed, 36 insertions(+), 35 deletions(-) diff --git a/examples/engine/go.mod b/examples/engine/go.mod index df17bd7f8..cce98ba9e 100644 --- a/examples/engine/go.mod +++ b/examples/engine/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/engine go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/engine/go.sum b/examples/engine/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/engine/go.sum +++ b/examples/engine/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/events/go.mod b/examples/events/go.mod index de6dc733c..cfedb66db 100644 --- a/examples/events/go.mod +++ b/examples/events/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/events go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/events/go.sum b/examples/events/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/events/go.sum +++ b/examples/events/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/iterator/go.mod b/examples/iterator/go.mod index f68480587..9549879ee 100644 --- a/examples/iterator/go.mod +++ b/examples/iterator/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/iterator go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/iterator/go.sum b/examples/iterator/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/iterator/go.sum +++ b/examples/iterator/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/nft-d/go.mod b/examples/nft-d/go.mod index d53c3dce8..09f3882ea 100644 --- a/examples/nft-d/go.mod +++ b/examples/nft-d/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/nft-d/go.sum b/examples/nft-d/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/nft-d/go.sum +++ b/examples/nft-d/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/nft-nd-nns/go.mod b/examples/nft-nd-nns/go.mod index 526f58906..add8980d4 100644 --- a/examples/nft-nd-nns/go.mod +++ b/examples/nft-nd-nns/go.mod @@ -4,6 +4,6 @@ go 1.16 require ( github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257 - github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e github.com/stretchr/testify v1.7.0 ) diff --git a/examples/nft-nd-nns/go.sum b/examples/nft-nd-nns/go.sum index c7d8877ae..605b11754 100644 --- a/examples/nft-nd-nns/go.sum +++ b/examples/nft-nd-nns/go.sum @@ -178,8 +178,9 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1: github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257 h1:fBGQ1dYVq8z5F1EeHRV2hbkEZPDBhZf92x0xnV14440= github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257/go.mod h1:mXlbOH7vVac9F7E131pI8VniP2T7lEzlvh394btP63o= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= diff --git a/examples/nft-nd/go.mod b/examples/nft-nd/go.mod index 6c4217184..2ad7fd81f 100644 --- a/examples/nft-nd/go.mod +++ b/examples/nft-nd/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/nft-nd/go.sum b/examples/nft-nd/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/nft-nd/go.sum +++ b/examples/nft-nd/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/oracle/go.mod b/examples/oracle/go.mod index 8d42a462f..fefaa84d3 100644 --- a/examples/oracle/go.mod +++ b/examples/oracle/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/oracle go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/oracle/go.sum b/examples/oracle/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/oracle/go.sum +++ b/examples/oracle/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/runtime/go.mod b/examples/runtime/go.mod index c5b878c06..8061c8606 100644 --- a/examples/runtime/go.mod +++ b/examples/runtime/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/runtime go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/runtime/go.sum b/examples/runtime/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/runtime/go.sum +++ b/examples/runtime/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/storage/go.mod b/examples/storage/go.mod index 49884a724..4598d5b4d 100644 --- a/examples/storage/go.mod +++ b/examples/storage/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/storage go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/storage/go.sum b/examples/storage/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/storage/go.sum +++ b/examples/storage/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/timer/go.mod b/examples/timer/go.mod index 3dd6ae53c..a415c69a9 100644 --- a/examples/timer/go.mod +++ b/examples/timer/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/timer go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/timer/go.sum b/examples/timer/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/timer/go.sum +++ b/examples/timer/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/examples/token/go.mod b/examples/token/go.mod index 3f529a639..476d423b9 100644 --- a/examples/token/go.mod +++ b/examples/token/go.mod @@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token go 1.16 -require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 +require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e diff --git a/examples/token/go.sum b/examples/token/go.sum index 2a7803ba6..3320faba5 100644 --- a/examples/token/go.sum +++ b/examples/token/go.sum @@ -1,2 +1,2 @@ -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= diff --git a/go.mod b/go.mod index 3fc8e8ede..64a253de5 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/mr-tron/base58 v1.2.0 github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 - github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659 github.com/nspcc-dev/rfc6979 v0.2.0 github.com/pierrec/lz4 v2.6.1+incompatible diff --git a/go.sum b/go.sum index 9efed22f8..81e807815 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,8 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38 h1:O9a3dT1Ss9NUue6ngCCAzpMJej0mys9ksQpmpYUwRGM= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= From 9dcceadab6adca560194894073e659bc9b1aa265 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 5 Apr 2022 10:50:50 +0300 Subject: [PATCH 12/13] examples: update neo-go dependency --- examples/nft-nd-nns/go.mod | 2 +- examples/nft-nd-nns/go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/nft-nd-nns/go.mod b/examples/nft-nd-nns/go.mod index add8980d4..349290aff 100644 --- a/examples/nft-nd-nns/go.mod +++ b/examples/nft-nd-nns/go.mod @@ -3,7 +3,7 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd-nns go 1.16 require ( - github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257 + github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405074910-7b5ff25a40a9 github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e github.com/stretchr/testify v1.7.0 ) diff --git a/examples/nft-nd-nns/go.sum b/examples/nft-nd-nns/go.sum index 605b11754..36d963360 100644 --- a/examples/nft-nd-nns/go.sum +++ b/examples/nft-nd-nns/go.sum @@ -176,9 +176,8 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= -github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257 h1:fBGQ1dYVq8z5F1EeHRV2hbkEZPDBhZf92x0xnV14440= -github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405073958-5388c895d257/go.mod h1:mXlbOH7vVac9F7E131pI8VniP2T7lEzlvh394btP63o= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405073702-b431e47d2a38/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405074910-7b5ff25a40a9 h1:vZhVfrRRghbu+EbSvnCJLMnB68ndGQEhami7Yf28IWA= +github.com/nspcc-dev/neo-go v0.98.3-pre.0.20220405074910-7b5ff25a40a9/go.mod h1:CrxyjB/HEDbnU8yaWICPxowKxv5voeh6KLNxF413+ko= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e h1:LmVuj/p99qS2gDyogAkVpurdUMGRdiJBFe7bhTDI3wY= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220405074652-16f952270c1e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= From 72ec354039cb272a2b52f55304f8a2b77c0b896e Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 4 Apr 2022 17:04:34 +0300 Subject: [PATCH 13/13] compiler: add test for murmur32 interop API --- pkg/compiler/native_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/compiler/native_test.go b/pkg/compiler/native_test.go index a0dc6c2d4..adf907fc5 100644 --- a/pkg/compiler/native_test.go +++ b/pkg/compiler/native_test.go @@ -183,6 +183,7 @@ func TestNativeHelpersCompile(t *testing.T) { runNativeTestCases(t, cs.Crypto.ContractMD, "crypto", []nativeTestCase{ {"sha256", []string{"[]byte{1, 2, 3}"}}, {"ripemd160", []string{"[]byte{1, 2, 3}"}}, + {"murmur32", []string{"[]byte{1, 2, 3}", "123"}}, {"verifyWithECDsa", []string{"[]byte{1, 2, 3}", pub, sig, "crypto.Secp256k1"}}, }) runNativeTestCases(t, cs.Std.ContractMD, "std", []nativeTestCase{