From e2187c0a9663454e6f47fe9e2b6a32976dc2a78f Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 9 Jun 2020 12:29:09 +0300 Subject: [PATCH] core: remove Block.GetTransaction interops Removed Neo.Block.GetTransaction and System.Block.GetTransaction interops. These interops were replaced by new System.Blockchain.GetTransactionFromBlock interop. --- pkg/compiler/syscall.go | 1 - pkg/core/interop_system.go | 17 ----------------- pkg/core/interops.go | 2 -- pkg/core/interops_test.go | 1 - pkg/interop/block/block.go | 6 ------ 5 files changed, 27 deletions(-) diff --git a/pkg/compiler/syscall.go b/pkg/compiler/syscall.go index 9d719dec4..0c4135b59 100644 --- a/pkg/compiler/syscall.go +++ b/pkg/compiler/syscall.go @@ -58,7 +58,6 @@ var syscalls = map[string]map[string]string{ "block": { "GetTransactionCount": "Neo.Block.GetTransactionCount", "GetTransactions": "Neo.Block.GetTransactions", - "GetTransaction": "Neo.Block.GetTransaction", }, "contract": { "GetScript": "Neo.Contract.GetScript", diff --git a/pkg/core/interop_system.go b/pkg/core/interop_system.go index 18be5a935..de1503a21 100644 --- a/pkg/core/interop_system.go +++ b/pkg/core/interop_system.go @@ -265,23 +265,6 @@ func blockGetTransactions(ic *interop.Context, v *vm.VM) error { return nil } -// blockGetTransaction returns transaction with the given number from the given -// block. -func blockGetTransaction(ic *interop.Context, v *vm.VM) error { - blockInterface := v.Estack().Pop().Value() - block, ok := blockInterface.(*block.Block) - if !ok { - return errors.New("value is not a block") - } - index := v.Estack().Pop().BigInt().Int64() - if index < 0 || index >= int64(len(block.Transactions)) { - return errors.New("wrong transaction index") - } - tx := block.Transactions[index] - v.Estack().PushVal(stackitem.NewInterop(tx)) - return nil -} - // engineGetScriptContainer returns transaction that contains the script being // run. func engineGetScriptContainer(ic *interop.Context, v *vm.VM) error { diff --git a/pkg/core/interops.go b/pkg/core/interops.go index 104df3834..068534d19 100644 --- a/pkg/core/interops.go +++ b/pkg/core/interops.go @@ -62,7 +62,6 @@ func getInteropFromSlice(ic *interop.Context, slice []interop.Function) func(uin // All lists are sorted, keep 'em this way, please. var systemInterops = []interop.Function{ - {Name: "System.Block.GetTransaction", Func: blockGetTransaction, Price: 1}, {Name: "System.Block.GetTransactionCount", Func: blockGetTransactionCount, Price: 1}, {Name: "System.Block.GetTransactions", Func: blockGetTransactions, Price: 1}, {Name: "System.Blockchain.GetBlock", Func: bcGetBlock, Price: 200}, @@ -105,7 +104,6 @@ var neoInterops = []interop.Function{ {Name: "Neo.Account.GetBalance", Func: accountGetBalance, Price: 1}, {Name: "Neo.Account.GetScriptHash", Func: accountGetScriptHash, Price: 1}, {Name: "Neo.Account.IsStandard", Func: accountIsStandard, Price: 100}, - {Name: "Neo.Block.GetTransaction", Func: blockGetTransaction, Price: 1}, {Name: "Neo.Block.GetTransactionCount", Func: blockGetTransactionCount, Price: 1}, {Name: "Neo.Block.GetTransactions", Func: blockGetTransactions, Price: 1}, {Name: "Neo.Blockchain.GetAccount", Func: bcGetAccount, Price: 100}, diff --git a/pkg/core/interops_test.go b/pkg/core/interops_test.go index 20f818c8e..4b1168ff9 100644 --- a/pkg/core/interops_test.go +++ b/pkg/core/interops_test.go @@ -34,7 +34,6 @@ func TestUnexpectedNonInterops(t *testing.T) { funcs := []func(*interop.Context, *vm.VM) error{ accountGetBalance, accountGetScriptHash, - blockGetTransaction, blockGetTransactionCount, blockGetTransactions, contractGetScript, diff --git a/pkg/interop/block/block.go b/pkg/interop/block/block.go index c3295163f..b47d25158 100644 --- a/pkg/interop/block/block.go +++ b/pkg/interop/block/block.go @@ -22,9 +22,3 @@ func GetTransactionCount(b Block) int { func GetTransactions(b Block) []blockchain.Transaction { return []blockchain.Transaction{} } - -// GetTransaction returns transaction from the given block by its index. It -// uses `Neo.Block.GetTransaction` syscall internally. -func GetTransaction(b Block, index int) blockchain.Transaction { - return blockchain.Transaction{} -}