From 21efccd30041a1ab78f08624fe68a670a4de7f4e Mon Sep 17 00:00:00 2001 From: Roman Khimov <roman@nspcc.ru> Date: Fri, 5 Jun 2020 16:07:04 +0300 Subject: [PATCH] transaction: remove type field, set Version to 0 Two changes being done here, because they require a lot of updates to tests. Now we're back into version 0 and we only have one type of transaction. It also removes GetType and GetScript interops, both are obsolete in Neo 3. --- integration/performance_test.go | 2 +- pkg/compiler/syscall.go | 2 - pkg/consensus/block_test.go | 2 +- pkg/consensus/consensus_test.go | 10 +- pkg/core/block/block_test.go | 2 +- pkg/core/blockchain.go | 162 +++++++++++----------- pkg/core/blockchain_test.go | 21 ++- pkg/core/dao/dao_test.go | 2 +- pkg/core/helper_test.go | 10 +- pkg/core/interop_neo.go | 29 ---- pkg/core/interop_neo_test.go | 27 +--- pkg/core/interops.go | 3 - pkg/core/interops_test.go | 2 - pkg/core/mempool/mem_pool_test.go | 36 ++--- pkg/core/native_contract_test.go | 2 +- pkg/core/transaction/invocation.go | 48 ------- pkg/core/transaction/invocation_test.go | 25 ---- pkg/core/transaction/transaction.go | 80 +++++------ pkg/core/transaction/transaction_test.go | 24 ++-- pkg/core/transaction/txer.go | 9 -- pkg/core/transaction/type.go | 51 ------- pkg/core/util.go | 2 +- pkg/core/util_test.go | 2 +- pkg/interop/transaction/transaction.go | 19 --- pkg/rpc/client/nep5.go | 2 +- pkg/rpc/client/rpc.go | 2 +- pkg/rpc/client/rpc_test.go | 22 +-- pkg/rpc/client/wsclient_test.go | 4 +- pkg/rpc/server/server.go | 8 +- pkg/rpc/server/server_test.go | 39 +++--- pkg/rpc/server/subscription_test.go | 14 +- pkg/rpc/server/testdata/testblocks.acc | Bin 6540 -> 6532 bytes pkg/smartcontract/context/context_test.go | 2 +- 33 files changed, 216 insertions(+), 449 deletions(-) delete mode 100644 pkg/core/transaction/invocation.go delete mode 100644 pkg/core/transaction/invocation_test.go delete mode 100644 pkg/core/transaction/txer.go delete mode 100644 pkg/core/transaction/type.go diff --git a/integration/performance_test.go b/integration/performance_test.go index d5e80e03b..68592cc87 100644 --- a/integration/performance_test.go +++ b/integration/performance_test.go @@ -77,7 +77,7 @@ func getTX(t *testing.B, wif *keys.WIF) *transaction.Transaction { fromAddressHash, err := address.StringToUint160(fromAddress) require.NoError(t, err) - tx := transaction.NewInvocationTX([]byte{0x51}, 1) + tx := transaction.New([]byte{0x51}, 1) tx.Version = 0 tx.Sender = fromAddressHash tx.Attributes = append(tx.Attributes, diff --git a/pkg/compiler/syscall.go b/pkg/compiler/syscall.go index c002d2bd7..9fa81cbbd 100644 --- a/pkg/compiler/syscall.go +++ b/pkg/compiler/syscall.go @@ -70,8 +70,6 @@ var syscalls = map[string]map[string]string{ "GetInputs": "Neo.Transaction.GetInputs", "GetOutputs": "Neo.Transaction.GetOutputs", "GetReferences": "Neo.Transaction.GetReferences", - "GetScript": "Neo.InvocationTransaction.GetScript", - "GetType": "Neo.Transaction.GetType", "GetUnspentCoins": "Neo.Transaction.GetUnspentCoins", "GetWitnesses": "Neo.Transaction.GetWitnesses", }, diff --git a/pkg/consensus/block_test.go b/pkg/consensus/block_test.go index 6aeb82328..312da1199 100644 --- a/pkg/consensus/block_test.go +++ b/pkg/consensus/block_test.go @@ -45,7 +45,7 @@ func TestNeoBlock_Setters(t *testing.T) { b.Block.PrevHash = util.Uint256{9, 8, 7} require.Equal(t, util.Uint256{9, 8, 7}, b.PrevHash()) - txx := []block.Transaction{transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 1)} + txx := []block.Transaction{transaction.New([]byte{byte(opcode.PUSH1)}, 1)} b.SetTransactions(txx) require.Equal(t, txx, b.Transactions()) } diff --git a/pkg/consensus/consensus_test.go b/pkg/consensus/consensus_test.go index 766201de5..44ef14532 100644 --- a/pkg/consensus/consensus_test.go +++ b/pkg/consensus/consensus_test.go @@ -23,7 +23,7 @@ import ( func TestNewService(t *testing.T) { srv := newTestService(t) - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.ValidUntilBlock = 1 addSender(t, tx) signTx(t, srv.Chain.FeePerByte(), tx) @@ -40,7 +40,7 @@ func TestService_GetVerified(t *testing.T) { srv := newTestService(t) var txs []*transaction.Transaction for i := 0; i < 4; i++ { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = 123 + uint32(i) tx.ValidUntilBlock = 1 txs = append(txs, tx) @@ -54,7 +54,7 @@ func TestService_GetVerified(t *testing.T) { p := new(Payload) p.message = &message{} p.SetType(payload.PrepareRequestType) - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = 999 p.SetPayload(&prepareRequest{transactionHashes: hashes}) p.SetValidatorIndex(1) @@ -121,7 +121,7 @@ func TestService_getTx(t *testing.T) { srv := newTestService(t) t.Run("transaction in mempool", func(t *testing.T) { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = 1234 tx.ValidUntilBlock = 1 addSender(t, tx) @@ -138,7 +138,7 @@ func TestService_getTx(t *testing.T) { }) t.Run("transaction in local cache", func(t *testing.T) { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = 4321 tx.ValidUntilBlock = 1 h := tx.Hash() diff --git a/pkg/core/block/block_test.go b/pkg/core/block/block_test.go index 715652b04..01a8d7b73 100644 --- a/pkg/core/block/block_test.go +++ b/pkg/core/block/block_test.go @@ -85,7 +85,7 @@ func newDumbBlock() *Block { Nonce: 1111, }, Transactions: []*transaction.Transaction{ - transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0), + transaction.New([]byte{byte(opcode.PUSH1)}, 0), }, } } diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index a7ff7d317..4af9caad1 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -363,20 +363,18 @@ func (bc *Blockchain) notificationDispatcher() { if len(txFeed) != 0 || len(notificationFeed) != 0 || len(executionFeed) != 0 { var aerIdx int for _, tx := range event.block.Transactions { - if tx.Type == transaction.InvocationType { - aer := event.appExecResults[aerIdx] - if !aer.TxHash.Equals(tx.Hash()) { - panic("inconsistent application execution results") - } - aerIdx++ - for ch := range executionFeed { - ch <- aer - } - if aer.VMState == "HALT" { - for i := range aer.Events { - for ch := range notificationFeed { - ch <- &aer.Events[i] - } + aer := event.appExecResults[aerIdx] + if !aer.TxHash.Equals(tx.Hash()) { + panic("inconsistent application execution results") + } + aerIdx++ + for ch := range executionFeed { + ch <- aer + } + if aer.VMState == "HALT" { + for i := range aer.Events { + for ch := range notificationFeed { + ch <- &aer.Events[i] } } } @@ -620,79 +618,75 @@ func (bc *Blockchain) storeBlock(block *block.Block) error { } } - // Process the underlying type of the TX. - switch t := tx.Data.(type) { - case *transaction.InvocationTX: - systemInterop := bc.newInteropContext(trigger.Application, cache, block, tx) - v := SpawnVM(systemInterop) - v.LoadScript(t.Script) - v.SetPriceGetter(getPrice) - if bc.config.FreeGasLimit > 0 { - v.SetGasLimit(bc.config.FreeGasLimit + tx.SystemFee) - } + systemInterop := bc.newInteropContext(trigger.Application, cache, block, tx) + v := SpawnVM(systemInterop) + v.LoadScript(tx.Script) + v.SetPriceGetter(getPrice) + if bc.config.FreeGasLimit > 0 { + v.SetGasLimit(bc.config.FreeGasLimit + tx.SystemFee) + } - err := v.Run() - if !v.HasFailed() { - _, err := systemInterop.DAO.Persist() - if err != nil { - return errors.Wrap(err, "failed to persist invocation results") - } - for _, note := range systemInterop.Notifications { - arr, ok := note.Item.Value().([]vm.StackItem) - if !ok || len(arr) != 4 { - continue - } - op, ok := arr[0].Value().([]byte) - if !ok || (string(op) != "transfer" && string(op) != "Transfer") { - continue - } - var from []byte - fromValue := arr[1].Value() - // we don't have `from` set when we are minting tokens - if fromValue != nil { - from, ok = fromValue.([]byte) - if !ok { - continue - } - } - var to []byte - toValue := arr[2].Value() - // we don't have `to` set when we are burning tokens - if toValue != nil { - to, ok = toValue.([]byte) - if !ok { - continue - } - } - amount, ok := arr[3].Value().(*big.Int) - if !ok { - bs, ok := arr[3].Value().([]byte) - if !ok { - continue - } - amount = emit.BytesToInt(bs) - } - bc.processNEP5Transfer(cache, tx, block, note.ScriptHash, from, to, amount.Int64()) - } - } else { - bc.log.Warn("contract invocation failed", - zap.String("tx", tx.Hash().StringLE()), - zap.Uint32("block", block.Index), - zap.Error(err)) - } - aer := &state.AppExecResult{ - TxHash: tx.Hash(), - Trigger: trigger.Application, - VMState: v.State(), - GasConsumed: v.GasConsumed(), - Stack: v.Estack().ToContractParameters(), - Events: systemInterop.Notifications, - } - appExecResults = append(appExecResults, aer) - err = cache.PutAppExecResult(aer) + err := v.Run() + if !v.HasFailed() { + _, err := systemInterop.DAO.Persist() if err != nil { - return errors.Wrap(err, "failed to Store notifications") + return errors.Wrap(err, "failed to persist invocation results") } + for _, note := range systemInterop.Notifications { + arr, ok := note.Item.Value().([]vm.StackItem) + if !ok || len(arr) != 4 { + continue + } + op, ok := arr[0].Value().([]byte) + if !ok || (string(op) != "transfer" && string(op) != "Transfer") { + continue + } + var from []byte + fromValue := arr[1].Value() + // we don't have `from` set when we are minting tokens + if fromValue != nil { + from, ok = fromValue.([]byte) + if !ok { + continue + } + } + var to []byte + toValue := arr[2].Value() + // we don't have `to` set when we are burning tokens + if toValue != nil { + to, ok = toValue.([]byte) + if !ok { + continue + } + } + amount, ok := arr[3].Value().(*big.Int) + if !ok { + bs, ok := arr[3].Value().([]byte) + if !ok { + continue + } + amount = emit.BytesToInt(bs) + } + bc.processNEP5Transfer(cache, tx, block, note.ScriptHash, from, to, amount.Int64()) + } + } else { + bc.log.Warn("contract invocation failed", + zap.String("tx", tx.Hash().StringLE()), + zap.Uint32("block", block.Index), + zap.Error(err)) + } + aer := &state.AppExecResult{ + TxHash: tx.Hash(), + Trigger: trigger.Application, + VMState: v.State(), + GasConsumed: v.GasConsumed(), + Stack: v.Estack().ToContractParameters(), + Events: systemInterop.Notifications, + } + appExecResults = append(appExecResults, aer) + err = cache.PutAppExecResult(aer) + if err != nil { + return errors.Wrap(err, "failed to Store notifications") } } diff --git a/pkg/core/blockchain_test.go b/pkg/core/blockchain_test.go index 3eb3c39be..1b50e88d9 100644 --- a/pkg/core/blockchain_test.go +++ b/pkg/core/blockchain_test.go @@ -102,7 +102,7 @@ func TestScriptFromWitness(t *testing.T) { func TestGetHeader(t *testing.T) { bc := newTestChain(t) - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.ValidUntilBlock = bc.BlockHeight() + 1 assert.Nil(t, addSender(tx)) assert.Nil(t, signTx(bc, tx)) @@ -267,7 +267,7 @@ func TestSubscriptions(t *testing.T) { emit.Bytes(script.BinWriter, []byte("yay!")) emit.Syscall(script.BinWriter, "Neo.Runtime.Notify") require.NoError(t, script.Err) - txGood1 := transaction.NewInvocationTX(script.Bytes(), 0) + txGood1 := transaction.New(script.Bytes(), 0) txGood1.Sender = neoOwner txGood1.Nonce = 1 txGood1.ValidUntilBlock = 100500 @@ -279,7 +279,7 @@ func TestSubscriptions(t *testing.T) { emit.Syscall(script.BinWriter, "Neo.Runtime.Notify") emit.Opcode(script.BinWriter, opcode.THROW) require.NoError(t, script.Err) - txBad := transaction.NewInvocationTX(script.Bytes(), 0) + txBad := transaction.New(script.Bytes(), 0) txBad.Sender = neoOwner txBad.Nonce = 2 txBad.ValidUntilBlock = 100500 @@ -289,7 +289,7 @@ func TestSubscriptions(t *testing.T) { emit.Bytes(script.BinWriter, []byte("yay! yay! yay!")) emit.Syscall(script.BinWriter, "Neo.Runtime.Notify") require.NoError(t, script.Err) - txGood2 := transaction.NewInvocationTX(script.Bytes(), 0) + txGood2 := transaction.New(script.Bytes(), 0) txGood2.Sender = neoOwner txGood2.Nonce = 3 txGood2.ValidUntilBlock = 100500 @@ -311,14 +311,11 @@ func TestSubscriptions(t *testing.T) { for _, txExpected := range invBlock.Transactions { tx := <-txCh require.Equal(t, txExpected, tx) - if txExpected.Type == transaction.InvocationType { - exec := <-executionCh - require.Equal(t, tx.Hash(), exec.TxHash) - if exec.VMState == "HALT" { - notif := <-notificationCh - inv := tx.Data.(*transaction.InvocationTX) - require.Equal(t, hash.Hash160(inv.Script), notif.ScriptHash) - } + exec := <-executionCh + require.Equal(t, tx.Hash(), exec.TxHash) + if exec.VMState == "HALT" { + notif := <-notificationCh + require.Equal(t, hash.Hash160(tx.Script), notif.ScriptHash) } } assert.Empty(t, txCh) diff --git a/pkg/core/dao/dao_test.go b/pkg/core/dao/dao_test.go index 725dd2766..77c62bc0f 100644 --- a/pkg/core/dao/dao_test.go +++ b/pkg/core/dao/dao_test.go @@ -220,7 +220,7 @@ func TestGetCurrentHeaderHeight_Store(t *testing.T) { func TestStoreAsTransaction(t *testing.T) { dao := NewSimple(storage.NewMemoryStore()) - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 1) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1) hash := tx.Hash() err := dao.StoreAsTransaction(tx, 0) require.NoError(t, err) diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index 521baf96e..06e394ca0 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -138,7 +138,7 @@ func newDumbBlock() *block.Block { Nonce: 1111, }, Transactions: []*transaction.Transaction{ - transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0), + transaction.New([]byte{byte(opcode.PUSH1)}, 0), }, } } @@ -240,7 +240,7 @@ func TestCreateBasicChain(t *testing.T) { txScript := script.Bytes() invFee := util.Fixed8FromFloat(100) - txDeploy := transaction.NewInvocationTX(txScript, invFee) + txDeploy := transaction.New(txScript, invFee) txDeploy.Nonce = getNextNonce() txDeploy.ValidUntilBlock = validUntilBlock txDeploy.Sender = priv0ScriptHash @@ -254,7 +254,7 @@ func TestCreateBasicChain(t *testing.T) { script = io.NewBufBinWriter() emit.AppCallWithOperationAndArgs(script.BinWriter, hash.Hash160(avm), "Put", "testkey", "testvalue") - txInv := transaction.NewInvocationTX(script.Bytes(), 0) + txInv := transaction.New(script.Bytes(), 0) txInv.Nonce = getNextNonce() txInv.ValidUntilBlock = validUntilBlock txInv.Sender = priv0ScriptHash @@ -285,7 +285,7 @@ func TestCreateBasicChain(t *testing.T) { sh := hash.Hash160(avm) w := io.NewBufBinWriter() emit.AppCallWithOperationAndArgs(w.BinWriter, sh, "init") - initTx := transaction.NewInvocationTX(w.Bytes(), 0) + initTx := transaction.New(w.Bytes(), 0) initTx.Nonce = getNextNonce() initTx.ValidUntilBlock = validUntilBlock initTx.Sender = priv0ScriptHash @@ -375,7 +375,7 @@ func newNEP5Transfer(sc, from, to util.Uint160, amount int64) *transaction.Trans emit.Opcode(w.BinWriter, opcode.ASSERT) script := w.Bytes() - return transaction.NewInvocationTX(script, 0) + return transaction.New(script, 0) } func addSender(txs ...*transaction.Transaction) error { diff --git a/pkg/core/interop_neo.go b/pkg/core/interop_neo.go index 74b5e364e..915fe5313 100644 --- a/pkg/core/interop_neo.go +++ b/pkg/core/interop_neo.go @@ -152,17 +152,6 @@ func txGetReferences(ic *interop.Context, v *vm.VM) error { return nil } -// txGetType returns current transaction type. -func txGetType(ic *interop.Context, v *vm.VM) error { - txInterface := v.Estack().Pop().Value() - tx, ok := txInterface.(*transaction.Transaction) - if !ok { - return errors.New("value is not a transaction") - } - v.Estack().PushVal(int(tx.Type)) - return nil -} - // txGetUnspentCoins returns current transaction unspent coins. func txGetUnspentCoins(ic *interop.Context, v *vm.VM) error { txInterface := v.Estack().Pop().Value() @@ -206,24 +195,6 @@ func txGetWitnesses(ic *interop.Context, v *vm.VM) error { return nil } -// invocationTx_GetScript returns invocation script from the current transaction. -func invocationTxGetScript(ic *interop.Context, v *vm.VM) error { - txInterface := v.Estack().Pop().Value() - tx, ok := txInterface.(*transaction.Transaction) - if !ok { - return errors.New("value is not a transaction") - } - inv, ok := tx.Data.(*transaction.InvocationTX) - if tx.Type != transaction.InvocationType || !ok { - return errors.New("value is not an invocation transaction") - } - // It's important not to share inv.Script slice with the code running in VM. - script := make([]byte, len(inv.Script)) - copy(script, inv.Script) - v.Estack().PushVal(script) - return nil -} - // witnessGetVerificationScript returns current witness' script. func witnessGetVerificationScript(ic *interop.Context, v *vm.VM) error { witInterface := v.Estack().Pop().Value() diff --git a/pkg/core/interop_neo_test.go b/pkg/core/interop_neo_test.go index e9ec0b2fe..3dd0065be 100644 --- a/pkg/core/interop_neo_test.go +++ b/pkg/core/interop_neo_test.go @@ -212,27 +212,6 @@ func TestTxGetOutputs(t *testing.T) { require.Equal(t, tx.Outputs[0], *value[0].Value().(*transaction.Output)) } -func TestTxGetType(t *testing.T) { - v, tx, context, chain := createVMAndPushTX(t) - defer chain.Close() - - err := txGetType(context, v) - require.NoError(t, err) - value := v.Estack().Pop().Value().(*big.Int) - require.Equal(t, big.NewInt(int64(tx.Type)), value) -} - -func TestInvocationTxGetScript(t *testing.T) { - v, tx, context, chain := createVMAndPushTX(t) - defer chain.Close() - - err := invocationTxGetScript(context, v) - require.NoError(t, err) - value := v.Estack().Pop().Value().([]byte) - inv := tx.Data.(*transaction.InvocationTX) - require.Equal(t, inv.Script, value) -} - func TestWitnessGetVerificationScript(t *testing.T) { v := vm.New() script := []byte{byte(opcode.PUSHM1), byte(opcode.RET)} @@ -290,14 +269,14 @@ func TestECDSAVerify(t *testing.T) { }) t.Run("signed interop item", func(t *testing.T) { - tx := transaction.NewInvocationTX([]byte{0, 1, 2}, 1) + tx := transaction.New([]byte{0, 1, 2}, 1) msg := tx.GetSignedPart() sign := priv.Sign(msg) runCase(t, false, true, sign, priv.PublicKey().Bytes(), vm.NewInteropItem(tx)) }) t.Run("signed script container", func(t *testing.T) { - tx := transaction.NewInvocationTX([]byte{0, 1, 2}, 1) + tx := transaction.New([]byte{0, 1, 2}, 1) msg := tx.GetSignedPart() sign := priv.Sign(msg) ic.Container = tx @@ -617,7 +596,7 @@ func createVMAndAccState(t *testing.T) (*vm.VM, *state.Account, *interop.Context func createVMAndTX(t *testing.T) (*vm.VM, *transaction.Transaction, *interop.Context, *Blockchain) { v := vm.New() script := []byte{byte(opcode.PUSH1), byte(opcode.RET)} - tx := transaction.NewInvocationTX(script, 0) + tx := transaction.New(script, 0) bytes := make([]byte, 1) attributes := append(tx.Attributes, transaction.Attribute{ diff --git a/pkg/core/interops.go b/pkg/core/interops.go index 3a6aba2ea..1548345cc 100644 --- a/pkg/core/interops.go +++ b/pkg/core/interops.go @@ -150,7 +150,6 @@ var neoInterops = []interop.Function{ {Name: "Neo.Header.GetVersion", Func: headerGetVersion, Price: 1}, {Name: "Neo.Input.GetHash", Func: inputGetHash, Price: 1}, {Name: "Neo.Input.GetIndex", Func: inputGetIndex, Price: 1}, - {Name: "Neo.InvocationTransaction.GetScript", Func: invocationTxGetScript, Price: 1}, {Name: "Neo.Iterator.Concat", Func: iterator.Concat, Price: 1}, {Name: "Neo.Iterator.Create", Func: iterator.Create, Price: 1}, {Name: "Neo.Iterator.Key", Func: iterator.Key, Price: 1}, @@ -179,7 +178,6 @@ var neoInterops = []interop.Function{ {Name: "Neo.Transaction.GetInputs", Func: txGetInputs, Price: 1}, {Name: "Neo.Transaction.GetOutputs", Func: txGetOutputs, Price: 1}, {Name: "Neo.Transaction.GetReferences", Func: txGetReferences, Price: 200}, - {Name: "Neo.Transaction.GetType", Func: txGetType, Price: 1}, {Name: "Neo.Transaction.GetUnspentCoins", Func: txGetUnspentCoins, Price: 200}, {Name: "Neo.Transaction.GetWitnesses", Func: txGetWitnesses, Price: 200}, {Name: "Neo.Witness.GetVerificationScript", Func: witnessGetVerificationScript, Price: 100}, @@ -241,7 +239,6 @@ var neoInterops = []interop.Function{ {Name: "AntShares.Transaction.GetInputs", Func: txGetInputs, Price: 1}, {Name: "AntShares.Transaction.GetOutputs", Func: txGetOutputs, Price: 1}, {Name: "AntShares.Transaction.GetReferences", Func: txGetReferences, Price: 200}, - {Name: "AntShares.Transaction.GetType", Func: txGetType, Price: 1}, } // initIDinInteropsSlice initializes IDs from names in one given diff --git a/pkg/core/interops_test.go b/pkg/core/interops_test.go index c1ca1bdfa..d1aa1b836 100644 --- a/pkg/core/interops_test.go +++ b/pkg/core/interops_test.go @@ -60,7 +60,6 @@ func TestUnexpectedNonInterops(t *testing.T) { headerGetVersion, inputGetHash, inputGetIndex, - invocationTxGetScript, outputGetAssetID, outputGetScriptHash, outputGetValue, @@ -75,7 +74,6 @@ func TestUnexpectedNonInterops(t *testing.T) { txGetInputs, txGetOutputs, txGetReferences, - txGetType, txGetUnspentCoins, txGetWitnesses, witnessGetVerificationScript, diff --git a/pkg/core/mempool/mem_pool_test.go b/pkg/core/mempool/mem_pool_test.go index e1b720420..5a1129a96 100644 --- a/pkg/core/mempool/mem_pool_test.go +++ b/pkg/core/mempool/mem_pool_test.go @@ -31,7 +31,7 @@ func (fs *FeerStub) GetUtilityTokenBalance(uint160 util.Uint160) util.Fixed8 { func testMemPoolAddRemoveWithFeer(t *testing.T, fs Feer) { mp := NewMemPool(10) - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = 0 _, _, ok := mp.TryGetValue(tx.Hash()) require.Equal(t, false, ok) @@ -65,7 +65,7 @@ func TestMemPoolAddRemoveWithInputs(t *testing.T) { mpLessInputs := func(i, j int) bool { return mp.inputs[i].Cmp(mp.inputs[j]) < 0 } - txm1 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + txm1 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) txm1.Nonce = 1 for i := 0; i < 5; i++ { txm1.Inputs = append(txm1.Inputs, transaction.Input{PrevHash: hash1, PrevIndex: uint16(100 - i)}) @@ -75,7 +75,7 @@ func TestMemPoolAddRemoveWithInputs(t *testing.T) { assert.Equal(t, len(txm1.Inputs), len(mp.inputs)) assert.True(t, sort.SliceIsSorted(mp.inputs, mpLessInputs)) - txm2 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + txm2 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) txm2.Nonce = 1 for i := 0; i < 10; i++ { txm2.Inputs = append(txm2.Inputs, transaction.Input{PrevHash: hash2, PrevIndex: uint16(i)}) @@ -104,21 +104,21 @@ func TestMemPoolAddRemoveWithInputs(t *testing.T) { func TestMemPoolVerifyInputs(t *testing.T) { mp := NewMemPool(10) - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = 1 inhash1 := random.Uint256() tx.Inputs = append(tx.Inputs, transaction.Input{PrevHash: inhash1, PrevIndex: 0}) require.Equal(t, true, mp.Verify(tx, &FeerStub{})) require.NoError(t, mp.Add(tx, &FeerStub{})) - tx2 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx2 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx2.Nonce = 2 inhash2 := random.Uint256() tx2.Inputs = append(tx2.Inputs, transaction.Input{PrevHash: inhash2, PrevIndex: 0}) require.Equal(t, true, mp.Verify(tx2, &FeerStub{})) require.NoError(t, mp.Add(tx2, &FeerStub{})) - tx3 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx3 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx3.Nonce = 3 // Different index number, but the same PrevHash as in tx1. tx3.Inputs = append(tx3.Inputs, transaction.Input{PrevHash: inhash1, PrevIndex: 1}) @@ -135,7 +135,7 @@ func TestOverCapacity(t *testing.T) { mp := NewMemPool(mempoolSize) for i := 0; i < mempoolSize; i++ { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = uint32(i) require.NoError(t, mp.Add(tx, fs)) } @@ -145,7 +145,7 @@ func TestOverCapacity(t *testing.T) { // Fees are also prioritized. for i := 0; i < mempoolSize; i++ { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Attributes = append(tx.Attributes, transaction.Attribute{ Usage: transaction.Hash1, Data: util.Uint256{1, 2, 3, 4}.BytesBE(), @@ -159,7 +159,7 @@ func TestOverCapacity(t *testing.T) { require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes))) } // Less prioritized txes are not allowed anymore. - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Attributes = append(tx.Attributes, transaction.Attribute{ Usage: transaction.Hash1, Data: util.Uint256{1, 2, 3, 4}.BytesBE(), @@ -172,7 +172,7 @@ func TestOverCapacity(t *testing.T) { require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes))) // Low net fee, but higher per-byte fee is still a better combination. - tx = transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx = transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = txcnt tx.NetworkFee = util.Fixed8FromFloat(0.00007) txcnt++ @@ -185,7 +185,7 @@ func TestOverCapacity(t *testing.T) { // High priority always wins over low priority. fs.lowPriority = false for i := 0; i < mempoolSize; i++ { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = txcnt txcnt++ require.NoError(t, mp.Add(tx, fs)) @@ -194,7 +194,7 @@ func TestOverCapacity(t *testing.T) { } // Good luck with low priority now. fs.lowPriority = true - tx = transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx = transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = txcnt require.Error(t, mp.Add(tx, fs)) require.Equal(t, mempoolSize, mp.Count()) @@ -208,7 +208,7 @@ func TestGetVerified(t *testing.T) { txes := make([]*transaction.Transaction, 0, mempoolSize) for i := 0; i < mempoolSize; i++ { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = uint32(i) txes = append(txes, tx) require.NoError(t, mp.Add(tx, fs)) @@ -234,7 +234,7 @@ func TestRemoveStale(t *testing.T) { txes1 := make([]*transaction.Transaction, 0, mempoolSize/2) txes2 := make([]*transaction.Transaction, 0, mempoolSize/2) for i := 0; i < mempoolSize; i++ { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = uint32(i) if i%2 == 0 { txes1 = append(txes1, tx) @@ -263,7 +263,7 @@ func TestRemoveStale(t *testing.T) { func TestMemPoolFees(t *testing.T) { mp := NewMemPool(10) sender0 := util.Uint160{1, 2, 3} - tx0 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx0 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx0.NetworkFee = util.Fixed8FromInt64(11000) tx0.Sender = sender0 // insufficient funds to add transaction, but balance should be stored @@ -276,7 +276,7 @@ func TestMemPoolFees(t *testing.T) { }, mp.fees[sender0]) // no problems with adding another transaction with lower fee - tx1 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx1 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx1.NetworkFee = util.Fixed8FromInt64(7000) tx1.Sender = sender0 require.NoError(t, mp.Add(tx1, &FeerStub{})) @@ -287,7 +287,7 @@ func TestMemPoolFees(t *testing.T) { }, mp.fees[sender0]) // balance shouldn't change after adding one more transaction - tx2 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx2 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx2.NetworkFee = util.Fixed8FromFloat(3000) tx2.Sender = sender0 require.NoError(t, mp.Add(tx2, &FeerStub{})) @@ -299,7 +299,7 @@ func TestMemPoolFees(t *testing.T) { }, mp.fees[sender0]) // can't add more transactions as we don't have enough GAS - tx3 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx3 := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx3.NetworkFee = util.Fixed8FromFloat(0.5) tx3.Sender = sender0 require.Equal(t, false, mp.Verify(tx3, &FeerStub{})) diff --git a/pkg/core/native_contract_test.go b/pkg/core/native_contract_test.go index fd2d10024..a95e8cd0b 100644 --- a/pkg/core/native_contract_test.go +++ b/pkg/core/native_contract_test.go @@ -92,7 +92,7 @@ func TestNativeContract_Invoke(t *testing.T) { w := io.NewBufBinWriter() emit.AppCallWithOperationAndArgs(w.BinWriter, tn.Metadata().Hash, "sum", int64(14), int64(28)) script := w.Bytes() - tx := transaction.NewInvocationTX(script, 0) + tx := transaction.New(script, 0) validUntil := chain.blockHeight + 1 tx.ValidUntilBlock = validUntil require.NoError(t, addSender(tx)) diff --git a/pkg/core/transaction/invocation.go b/pkg/core/transaction/invocation.go deleted file mode 100644 index f68929764..000000000 --- a/pkg/core/transaction/invocation.go +++ /dev/null @@ -1,48 +0,0 @@ -package transaction - -import ( - "errors" - "math/rand" - - "github.com/nspcc-dev/neo-go/pkg/io" - "github.com/nspcc-dev/neo-go/pkg/util" -) - -// InvocationTX represents a invocation transaction and is used to -// deploy smart contract to the NEO blockchain. -type InvocationTX struct { - // Script output of the smart contract. - Script []byte -} - -// NewInvocationTX returns a new invocation transaction. -func NewInvocationTX(script []byte, gas util.Fixed8) *Transaction { - return &Transaction{ - Type: InvocationType, - Version: 1, - Nonce: rand.Uint32(), - Data: &InvocationTX{ - Script: script, - }, - SystemFee: gas, - Attributes: []Attribute{}, - Cosigners: []Cosigner{}, - Inputs: []Input{}, - Outputs: []Output{}, - Scripts: []Witness{}, - } -} - -// DecodeBinary implements Serializable interface. -func (tx *InvocationTX) DecodeBinary(br *io.BinReader) { - tx.Script = br.ReadVarBytes() - if br.Err == nil && len(tx.Script) == 0 { - br.Err = errors.New("no script") - return - } -} - -// EncodeBinary implements Serializable interface. -func (tx *InvocationTX) EncodeBinary(bw *io.BinWriter) { - bw.WriteVarBytes(tx.Script) -} diff --git a/pkg/core/transaction/invocation_test.go b/pkg/core/transaction/invocation_test.go deleted file mode 100644 index 4efecbe96..000000000 --- a/pkg/core/transaction/invocation_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package transaction - -import ( - "encoding/hex" - "testing" - - "github.com/nspcc-dev/neo-go/pkg/internal/testserdes" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestInvocationZeroScript(t *testing.T) { - // Zero-length script. - in, err := hex.DecodeString("000000000000000000") - require.NoError(t, err) - - inv := &InvocationTX{} - assert.Error(t, testserdes.DecodeBinary(in, inv)) - - // PUSH1 script. - in, err = hex.DecodeString("01510000000000000000") - require.NoError(t, err) - - assert.NoError(t, testserdes.DecodeBinary(in, inv)) -} diff --git a/pkg/core/transaction/transaction.go b/pkg/core/transaction/transaction.go index b52cb1bc0..f3923b35f 100644 --- a/pkg/core/transaction/transaction.go +++ b/pkg/core/transaction/transaction.go @@ -4,7 +4,7 @@ import ( "encoding/hex" "encoding/json" "errors" - "fmt" + "math/rand" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/encoding/address" @@ -26,9 +26,6 @@ const ( // Transaction is a process recorded in the NEO blockchain. type Transaction struct { - // The type of the transaction. - Type TXType - // The trading version which is currently 0. Version uint8 @@ -48,9 +45,8 @@ type Transaction struct { // transaction should fail verification. ValidUntilBlock uint32 - // Data specific to the type of the transaction. - // This is always a pointer to a <Type>Transaction. - Data TXer + // Code to run in NeoVM for this transaction. + Script []byte // Transaction attributes. Attributes []Attribute @@ -89,6 +85,22 @@ func NewTrimmedTX(hash util.Uint256) *Transaction { } } +// New returns a new transaction to execute given script and pay given system +// fee. +func New(script []byte, gas util.Fixed8) *Transaction { + return &Transaction{ + Version: 0, + Nonce: rand.Uint32(), + Script: script, + SystemFee: gas, + Attributes: []Attribute{}, + Cosigners: []Cosigner{}, + Inputs: []Input{}, + Outputs: []Output{}, + Scripts: []Witness{}, + } +} + // Hash returns the hash of the transaction. func (t *Transaction) Hash() util.Uint256 { if t.hash.Equals(util.Uint256{}) { @@ -121,8 +133,11 @@ func (t *Transaction) AddInput(in *Input) { // DecodeBinary implements Serializable interface. func (t *Transaction) DecodeBinary(br *io.BinReader) { - t.Type = TXType(br.ReadB()) t.Version = uint8(br.ReadB()) + if t.Version > 0 { + br.Err = errors.New("only version 0 is supported") + return + } t.Nonce = br.ReadU32LE() t.Sender.DecodeBinary(br) t.SystemFee.DecodeBinary(br) @@ -140,7 +155,6 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) { return } t.ValidUntilBlock = br.ReadU32LE() - t.decodeData(br) br.ReadArray(&t.Attributes) @@ -154,6 +168,12 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) { } } + t.Script = br.ReadVarBytes() + if br.Err == nil && len(t.Script) == 0 { + br.Err = errors.New("no script") + return + } + br.ReadArray(&t.Inputs) br.ReadArray(&t.Outputs) for i := range t.Outputs { @@ -171,16 +191,6 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) { } } -func (t *Transaction) decodeData(r *io.BinReader) { - switch t.Type { - case InvocationType: - t.Data = &InvocationTX{} - t.Data.(*InvocationTX).DecodeBinary(r) - default: - r.Err = fmt.Errorf("invalid TX type %x", t.Type) - } -} - // EncodeBinary implements Serializable interface. func (t *Transaction) EncodeBinary(bw *io.BinWriter) { t.encodeHashableFields(bw) @@ -190,11 +200,10 @@ func (t *Transaction) EncodeBinary(bw *io.BinWriter) { // encodeHashableFields encodes the fields that are not used for // signing the transaction, which are all fields except the scripts. func (t *Transaction) encodeHashableFields(bw *io.BinWriter) { - if t.Data == nil { - bw.Err = errors.New("transaction has no data") + if len(t.Script) == 0 { + bw.Err = errors.New("transaction has no script") return } - bw.WriteB(byte(t.Type)) bw.WriteB(byte(t.Version)) bw.WriteU32LE(t.Nonce) t.Sender.EncodeBinary(bw) @@ -202,15 +211,13 @@ func (t *Transaction) encodeHashableFields(bw *io.BinWriter) { t.NetworkFee.EncodeBinary(bw) bw.WriteU32LE(t.ValidUntilBlock) - // Underlying TXer. - t.Data.EncodeBinary(bw) - // Attributes bw.WriteArray(t.Attributes) // Cosigners bw.WriteArray(t.Cosigners) + bw.WriteVarBytes(t.Script) // Inputs bw.WriteArray(t.Inputs) @@ -285,7 +292,6 @@ func (t *Transaction) FeePerByte() util.Fixed8 { type transactionJSON struct { TxID util.Uint256 `json:"txid"` Size int `json:"size"` - Type TXType `json:"type"` Version uint8 `json:"version"` Nonce uint32 `json:"nonce"` Sender string `json:"sender"` @@ -294,11 +300,10 @@ type transactionJSON struct { ValidUntilBlock uint32 `json:"valid_until_block"` Attributes []Attribute `json:"attributes"` Cosigners []Cosigner `json:"cosigners"` + Script string `json:"script"` Inputs []Input `json:"vin"` Outputs []Output `json:"vout"` Scripts []Witness `json:"scripts"` - - Script string `json:"script,omitempty"` } // MarshalJSON implements json.Marshaler interface. @@ -306,23 +311,19 @@ func (t *Transaction) MarshalJSON() ([]byte, error) { tx := transactionJSON{ TxID: t.Hash(), Size: io.GetVarSize(t), - Type: t.Type, Version: t.Version, Nonce: t.Nonce, Sender: address.Uint160ToString(t.Sender), ValidUntilBlock: t.ValidUntilBlock, Attributes: t.Attributes, Cosigners: t.Cosigners, + Script: hex.EncodeToString(t.Script), Inputs: t.Inputs, Outputs: t.Outputs, Scripts: t.Scripts, SystemFee: t.SystemFee, NetworkFee: t.NetworkFee, } - switch t.Type { - case InvocationType: - tx.Script = hex.EncodeToString(t.Data.(*InvocationTX).Script) - } return json.Marshal(tx) } @@ -332,7 +333,6 @@ func (t *Transaction) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, tx); err != nil { return err } - t.Type = tx.Type t.Version = tx.Version t.Nonce = tx.Nonce t.ValidUntilBlock = tx.ValidUntilBlock @@ -348,15 +348,9 @@ func (t *Transaction) UnmarshalJSON(data []byte) error { return errors.New("cannot unmarshal tx: bad sender") } t.Sender = sender - switch tx.Type { - case InvocationType: - bytes, err := hex.DecodeString(tx.Script) - if err != nil { - return err - } - t.Data = &InvocationTX{ - Script: bytes, - } + t.Script, err = hex.DecodeString(tx.Script) + if err != nil { + return err } if t.Hash() != tx.TxID { return errors.New("txid doesn't match transaction hash") diff --git a/pkg/core/transaction/transaction_test.go b/pkg/core/transaction/transaction_test.go index 47e37f093..2ea9bea19 100644 --- a/pkg/core/transaction/transaction_test.go +++ b/pkg/core/transaction/transaction_test.go @@ -61,30 +61,32 @@ func TestDecodeEncodeInvocationTX(t *testing.T) { } */ -func TestNewInvocationTX(t *testing.T) { +func TestNew(t *testing.T) { script := []byte{0x51} - tx := NewInvocationTX(script, 1) - txData := tx.Data.(*InvocationTX) - assert.Equal(t, InvocationType, tx.Type) + tx := New(script, 1) assert.Equal(t, util.Fixed8(1), tx.SystemFee) - assert.Equal(t, script, txData.Script) + assert.Equal(t, script, tx.Script) // Update hash fields to match tx2 that is gonna autoupdate them on decode. _ = tx.Hash() testserdes.EncodeDecodeBinary(t, tx, new(Transaction)) } -func TestEncodingTXWithNoData(t *testing.T) { +func TestEncodingTXWithNoScript(t *testing.T) { _, err := testserdes.EncodeBinary(new(Transaction)) require.Error(t, err) } +func TestDecodingTXWithNoScript(t *testing.T) { + txBin, err := hex.DecodeString("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + require.NoError(t, err) + err = testserdes.DecodeBinary(txBin, new(Transaction)) + require.Error(t, err) +} + func TestMarshalUnmarshalJSONInvocationTX(t *testing.T) { tx := &Transaction{ - Type: InvocationType, - Version: 3, - Data: &InvocationTX{ - Script: []byte{1, 2, 3, 4}, - }, + Version: 0, + Script: []byte{1, 2, 3, 4}, Attributes: []Attribute{}, Inputs: []Input{{ PrevHash: util.Uint256{5, 6, 7, 8}, diff --git a/pkg/core/transaction/txer.go b/pkg/core/transaction/txer.go deleted file mode 100644 index f48077f4d..000000000 --- a/pkg/core/transaction/txer.go +++ /dev/null @@ -1,9 +0,0 @@ -package transaction - -import "github.com/nspcc-dev/neo-go/pkg/io" - -// TXer is interface that can act as the underlying data of -// a transaction. -type TXer interface { - io.Serializable -} diff --git a/pkg/core/transaction/type.go b/pkg/core/transaction/type.go deleted file mode 100644 index df13a6d84..000000000 --- a/pkg/core/transaction/type.go +++ /dev/null @@ -1,51 +0,0 @@ -package transaction - -import ( - "strings" - - "github.com/pkg/errors" -) - -// TXType is the type of a transaction. -type TXType uint8 - -// Constants for all valid transaction types. -const ( - InvocationType TXType = 0xd1 -) - -// String implements the stringer interface. -func (t TXType) String() string { - switch t { - case InvocationType: - return "InvocationTransaction" - default: - return "UnknownTransaction" - } -} - -// MarshalJSON implements the json marshaller interface. -func (t TXType) MarshalJSON() ([]byte, error) { - return []byte(`"` + t.String() + `"`), nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface. -func (t *TXType) UnmarshalJSON(data []byte) error { - l := len(data) - if l < 2 || data[0] != '"' || data[l-1] != '"' { - return errors.New("wrong format") - } - var err error - *t, err = TXTypeFromString(string(data[1 : l-1])) - return err -} - -// TXTypeFromString searches for TXType by string name. -func TXTypeFromString(jsonString string) (TXType, error) { - switch jsonString = strings.TrimSpace(jsonString); jsonString { - case "InvocationTransaction": - return InvocationType, nil - default: - return 0, errors.New("unknown state") - } -} diff --git a/pkg/core/util.go b/pkg/core/util.go index c3bee9ff3..52362bc9d 100644 --- a/pkg/core/util.go +++ b/pkg/core/util.go @@ -77,7 +77,7 @@ func deployNativeContracts() *transaction.Transaction { buf := io.NewBufBinWriter() emit.Syscall(buf.BinWriter, "Neo.Native.Deploy") script := buf.Bytes() - tx := transaction.NewInvocationTX(script, 0) + tx := transaction.New(script, 0) tx.Nonce = 0 tx.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)}) tx.Scripts = []transaction.Witness{ diff --git a/pkg/core/util_test.go b/pkg/core/util_test.go index 7ddc937b8..b49bd3d49 100644 --- a/pkg/core/util_test.go +++ b/pkg/core/util_test.go @@ -20,7 +20,7 @@ func TestGenesisBlockMainNet(t *testing.T) { // have been changed. Consequently, hash of the genesis block has been changed. // Update expected genesis block hash for better times. // Old hash is "d42561e3d30e15be6400b6df2f328e02d2bf6354c41dce433bc57687c82144bf" - expect := "30b7e37836146ef63ffdc28411c6c22153b69d8fb10b1d5b96ea662cfb19d2e8" + expect := "2535d4b8b244c8a036ed356ee4448e041dc6e8f1d81abdcc7e3d0640c66f6cc8" assert.Equal(t, expect, block.Hash().StringLE()) } diff --git a/pkg/interop/transaction/transaction.go b/pkg/interop/transaction/transaction.go index 545a9b89f..4f975fd8e 100644 --- a/pkg/interop/transaction/transaction.go +++ b/pkg/interop/transaction/transaction.go @@ -21,18 +21,6 @@ func GetHash(t Transaction) []byte { return nil } -// GetType returns the type of the given transaction. Possible values: -// MinerTransaction = 0x00 -// EnrollmentTransaction = 0x20 -// StateType = 0x90 -// AgencyTransaction = 0xb0 -// PublishTransaction = 0xd0 -// InvocationTransaction = 0xd1 -// It uses `Neo.Transaction.GetType` syscall. -func GetType(t Transaction) byte { - return 0x00 -} - // GetAttributes returns a slice of attributes for agiven transaction. Refer to // attribute package on how to use them. This function uses // `Neo.Transaction.GetAttributes` syscall. @@ -69,13 +57,6 @@ func GetOutputs(t Transaction) []output.Output { return []output.Output{} } -// GetScript returns the script stored in a given Invocation transaction. -// Calling it for any other Transaction type would lead to failure. It uses -// `Neo.InvocationTransaction.GetScript` syscall. -func GetScript(t Transaction) []byte { - return nil -} - // GetWitnesses returns a slice of witnesses of a given Transaction. Refer to // witness package on how to use them. This function uses // `Neo.Transaction.GetWitnesses` syscall. diff --git a/pkg/rpc/client/nep5.go b/pkg/rpc/client/nep5.go index d04a085be..95fcf83ec 100644 --- a/pkg/rpc/client/nep5.go +++ b/pkg/rpc/client/nep5.go @@ -108,7 +108,7 @@ func (c *Client) CreateNEP5TransferTx(acc *wallet.Account, to util.Uint160, toke emit.Opcode(w.BinWriter, opcode.ASSERT) script := w.Bytes() - tx := transaction.NewInvocationTX(script, gas) + tx := transaction.New(script, gas) tx.Sender = from tx.Cosigners = []transaction.Cosigner{ { diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index b0d0a5987..d0d572e85 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -423,7 +423,7 @@ func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sys var txHash util.Uint256 var err error - tx := transaction.NewInvocationTX(script, sysfee) + tx := transaction.New(script, sysfee) tx.SystemFee = sysfee validUntilBlock, err := c.CalculateValidUntilBlock() diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 33077fd76..aa657036e 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -31,17 +31,17 @@ type rpcClientTestCase struct { check func(t *testing.T, c *Client, result interface{}) } -const hexB1 = "0000000028de4a34063483263ea9899827792bfdc4acf6b533e7294dbb4838b820e9a40b5a448a04e699901d0ed78a62d11e2d0754f152dce78e08c8227d95bdf1df932a3eefd85e0000000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae76294130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb03005704000000000000d10102000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000f66a0d0000000000b0040000590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001abec5362f11e75b6e02e407bb98d63675d14384101000001fd08010c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b694130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bbd10103000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000967a0d0000000000b00400005d0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b52380001abec5362f11e75b6e02e407bb98d63675d14384101000001fd08010c40cfb0f8c01f320069f8f826cc5e3a9538e4eee4d228f1f2c53028be61c2df99b4341005ff8f50bde0e4827c7b0828eab59faca6eb2315fd11cd802daf88354fc90c4022deeaf06116faad8d9665dbb504a0049bb9f5b57713c85bfd894e12d3d46a73617199ff0854e3d5dde0dece92d8f1fd496b78c71727cfc03819f1d109ef827e0c406f68afac9da6dc56172ae57f56c5f1f3767d12d1a0aee2fecae80133b8e725578639b2ab15f230ce528ed4c85dfcfa4b231d5ff4ecc48555e68adf45e2e475500c4042a504fae6914f86b1318a3e278e8ca18e92db7fa432f05364824ea96a95899a0b3c0b07a910a3782b17fc46bc2a6b31259d1d046fcc508d7873e90ec67cc70794130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb" +const hexB1 = "000000001409900d6f330df2624b9ad49e4e68c04bab6757b684b4ae46e995ec9278002d6aa5da3b3922db2ae0fb51e6058d123d441650db8a187e7b7a34c55927fae217b91274847201000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb030057040000000000000002000000abec5362f11e75b6e02e407bb98d63675d14384100000000000000000e670d0000000000b00400000001abec5362f11e75b6e02e407bb98d63675d14384101590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001fd08010c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb0003000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000ae760d0000000000b00400000001abec5362f11e75b6e02e407bb98d63675d143841015d0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b5238000001fd08010c4001c81faa8317a390c211d5e03451ed852ff02ec6c401c450558bc90c60a01912c3e1018de98e7458f6f96c68aad71ffb0e92327fcdfa4aabb5ea5834ec7afbf10c40a84e9bc36ffbf18a1ee79254182d2939dd3a7b9278e13893856f187ab44dec259c8a15d4f449a21aa6970234d79d81fee0aca1807341b977ff66d503a78c82920c4085495bb8d86b95a4afc1659ce1d993e1a7843e3dcb19696ce0422294dadddc73438780d5bc629560f576e0e75cff062c03e237d4e609dfaa9869135e23a487650c40ae25f2c563b978f931c3a8b5a18854d9bb77abf48c7554f2008f97696caca180cd40d4d0e47b3f4d86082e631547d1a4729c7ed60dda64fab9cd9a2270dd113294130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb" -const hexTxMoveNeo = "d10102000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000f66a0d0000000000b0040000590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001abec5362f11e75b6e02e407bb98d63675d14384101000001fd08010c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b694130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb" +const hexTxMoveNeo = "0002000000abec5362f11e75b6e02e407bb98d63675d14384100000000000000000e670d0000000000b00400000001abec5362f11e75b6e02e407bb98d63675d14384101590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001fd08010c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb" -const b1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"size":1687,"nextblockhash":"0x96a0856f49798732e6eae4026a5f3e919b96250d847bcb3560d03bbad895c740","confirmations":4,"hash":"0xf7c3cecbe8fb15560c3113dd03911e52858a233b32cdc761ca03bc0721553424","version":0,"previousblockhash":"0x0ba4e920b83848bb4d29e733b5f6acc4fd2b79279889a93e26833406344ade28","merkleroot":"0x2a93dff1bd957d22c8088ee7dc52f154072d1ed1628ad70e1d9099e6048a445a","time":1591275326,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae762","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xf93ae1dbd2167e9b4a06431741297b351ac6a8ea3ae8892785c49f690a40b2c0","size":578,"type":"InvocationTransaction","version":1,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087935","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b6","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238"},{"txid":"0xe2caf7a9ce32a0daad81fd76f67aa64ffbe7cedf0fdeb8c57c466b6f5833bf0b","size":582,"type":"InvocationTransaction","version":1,"nonce":3,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0088335","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cfb0f8c01f320069f8f826cc5e3a9538e4eee4d228f1f2c53028be61c2df99b4341005ff8f50bde0e4827c7b0828eab59faca6eb2315fd11cd802daf88354fc90c4022deeaf06116faad8d9665dbb504a0049bb9f5b57713c85bfd894e12d3d46a73617199ff0854e3d5dde0dece92d8f1fd496b78c71727cfc03819f1d109ef827e0c406f68afac9da6dc56172ae57f56c5f1f3767d12d1a0aee2fecae80133b8e725578639b2ab15f230ce528ed4c85dfcfa4b231d5ff4ecc48555e68adf45e2e475500c4042a504fae6914f86b1318a3e278e8ca18e92db7fa432f05364824ea96a95899a0b3c0b07a910a3782b17fc46bc2a6b31259d1d046fcc508d7873e90ec67cc707","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"script":"0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b5238"}]}}` +const b1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"size":1685,"nextblockhash":"0x14a61952de5bf47e2550bb97439de44ea60f79e052419e8b263b1b41d7065b0f","confirmations":4,"hash":"0xc826db8aa7a05fbd336eb0fca66efea7330cdc09cc8cf8e3cd9a3d9a87b751ac","version":0,"previousblockhash":"0x2d007892ec95e946aeb484b65767ab4bc0684e9ed49a4b62f20d336f0d900914","merkleroot":"0x17e2fa2759c5347a7b7e188adb5016443d128d05e651fbe02adb22393bdaa56a","time":1591360099001,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xd24f8ab43462f8a2f788fa9073b8b32b4417aeddea19dfcc8dfb543d68e90de5","size":577,"version":0,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087835","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}]},{"txid":"0xf3304d751f7f6e871a610644529aa4f8fcc60a31592352eea54b86be472614f1","size":581,"version":0,"nonce":3,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0088235","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"script":"0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c4001c81faa8317a390c211d5e03451ed852ff02ec6c401c450558bc90c60a01912c3e1018de98e7458f6f96c68aad71ffb0e92327fcdfa4aabb5ea5834ec7afbf10c40a84e9bc36ffbf18a1ee79254182d2939dd3a7b9278e13893856f187ab44dec259c8a15d4f449a21aa6970234d79d81fee0aca1807341b977ff66d503a78c82920c4085495bb8d86b95a4afc1659ce1d993e1a7843e3dcb19696ce0422294dadddc73438780d5bc629560f576e0e75cff062c03e237d4e609dfaa9869135e23a487650c40ae25f2c563b978f931c3a8b5a18854d9bb77abf48c7554f2008f97696caca180cd40d4d0e47b3f4d86082e631547d1a4729c7ed60dda64fab9cd9a2270dd1132","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}]}]}}` -const hexHeader1 = "0000000028de4a34063483263ea9899827792bfdc4acf6b533e7294dbb4838b820e9a40b5a448a04e699901d0ed78a62d11e2d0754f152dce78e08c8227d95bdf1df932a3eefd85e0000000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae76294130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb00" +const hexHeader1 = "000000001409900d6f330df2624b9ad49e4e68c04bab6757b684b4ae46e995ec9278002d6aa5da3b3922db2ae0fb51e6058d123d441650db8a187e7b7a34c55927fae217b91274847201000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb00" -const header1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"hash":"0xf7c3cecbe8fb15560c3113dd03911e52858a233b32cdc761ca03bc0721553424","size":518,"version":0,"previousblockhash":"0x0ba4e920b83848bb4d29e733b5f6acc4fd2b79279889a93e26833406344ade28","merkleroot":"0x2a93dff1bd957d22c8088ee7dc52f154072d1ed1628ad70e1d9099e6048a445a","time":1591275326,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae762","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"confirmations":6,"nextblockhash":"0x96a0856f49798732e6eae4026a5f3e919b96250d847bcb3560d03bbad895c740"}}` +const header1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"hash":"0xc826db8aa7a05fbd336eb0fca66efea7330cdc09cc8cf8e3cd9a3d9a87b751ac","size":518,"version":0,"previousblockhash":"0x2d007892ec95e946aeb484b65767ab4bc0684e9ed49a4b62f20d336f0d900914","merkleroot":"0x17e2fa2759c5347a7b7e188adb5016443d128d05e651fbe02adb22393bdaa56a","time":1591360099001,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"confirmations":6,"nextblockhash":"0x14a61952de5bf47e2550bb97439de44ea60f79e052419e8b263b1b41d7065b0f"}}` -const txMoveNeoVerbose = `{"id":5,"jsonrpc":"2.0","result":{"blockhash":"0xf7c3cecbe8fb15560c3113dd03911e52858a233b32cdc761ca03bc0721553424","confirmations":6,"blocktime":1591275326,"txid":"0xf93ae1dbd2167e9b4a06431741297b351ac6a8ea3ae8892785c49f690a40b2c0","size":578,"type":"InvocationTransaction","version":1,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087935","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b6","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238"}}` +const txMoveNeoVerbose = `{"id":5,"jsonrpc":"2.0","result":{"blockhash":"0xc826db8aa7a05fbd336eb0fca66efea7330cdc09cc8cf8e3cd9a3d9a87b751ac","confirmations":6,"blocktime":1591360099001,"txid":"0xd24f8ab43462f8a2f788fa9073b8b32b4417aeddea19dfcc8dfb543d68e90de5","size":577,"version":0,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087835","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}]}}` // getResultBlock1 returns data for block number 1 which is used by several tests. func getResultBlock1() *result.Block { @@ -54,14 +54,14 @@ func getResultBlock1() *result.Block { if err != nil { panic(err) } - b2Hash, err := util.Uint256DecodeStringLE("96a0856f49798732e6eae4026a5f3e919b96250d847bcb3560d03bbad895c740") + b2Hash, err := util.Uint256DecodeStringLE("14a61952de5bf47e2550bb97439de44ea60f79e052419e8b263b1b41d7065b0f") if err != nil { panic(err) } return &result.Block{ Block: b, BlockMetadata: result.BlockMetadata{ - Size: 1687, + Size: 1685, NextBlockHash: &b2Hash, Confirmations: 4, }, @@ -616,7 +616,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ { name: "positive", invoke: func(c *Client) (interface{}, error) { - return nil, c.SendRawTransaction(transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)) + return nil, c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0)) }, serverResponse: `{"jsonrpc":"2.0","id":1,"result":true}`, result: func(c *Client) interface{} { @@ -737,7 +737,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{ { name: "sendrawtransaction_bad_server_answer", invoke: func(c *Client) (interface{}, error) { - return nil, c.SendRawTransaction(transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)) + return nil, c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0)) }, }, { @@ -1063,7 +1063,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{ { name: "sendrawtransaction_unmarshalling_error", invoke: func(c *Client) (interface{}, error) { - return nil, c.SendRawTransaction(transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)) + return nil, c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0)) }, }, { diff --git a/pkg/rpc/client/wsclient_test.go b/pkg/rpc/client/wsclient_test.go index 879999712..445eb05e8 100644 --- a/pkg/rpc/client/wsclient_test.go +++ b/pkg/rpc/client/wsclient_test.go @@ -117,8 +117,8 @@ func TestWSClientEvents(t *testing.T) { var events = []string{ `{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","executions":[{"trigger":"Application","contract":"0x0000000000000000000000000000000000000000","vmstate":"HALT","gas_consumed":"2.291","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"7472616e73666572"},{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}}]}]}]}`, `{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}}]}`, - `{"jsonrpc":"2.0","method":"transaction_added","params":[{"txid":"0xd3c3104eb1c059985ddeacc3a149634c830b39cf3fa37f4a2f7af0e4980ff370","size":269,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036921","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cf193534761a987324a355749f5e4ef8499ff5948df6ee8a4b9834cbe025103ad08a74a00e1e248c73f3d967b23d09af0d200d9cb742ec0aa911f7f783cbd2e0","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}`, - `{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x3c99815f393807efd7a620a04eed66440a3c89d41ff18fd42c08f71784fc1c16","version":0,"previousblockhash":"0xb6533ac10e71fb02348af87c0a723131939ee08713a7f31075d24beb54100f1a","merkleroot":"0x7470df300c48107d36ffd3da09b155a35650f1020d019abb0c3abb7bf91a09e2","time":1590609889,"index":207,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c4095dfc789359ca154c07f1bfdc28e0ac512f78156825efafd9b31a6a8009cef6339de6f8331aad35f6dc8af9a7723a07fb9319ccad54c91ab9be155964efa5f920c4067ac11066db9e47f64cf876e3d6dd07e28324d51b53faf2a42ccafc371050efbe0b5809c80672ea116a557bfbdbf789b7bca008064834db80c7c91a768bcec760c40aefd42910ad6a6f9c3ba17a5b38e8de7188d0b36972c47d3054715209ca79d9811beff9a762ebd1c78584ff3110222419b2cdba6c22bbcbb554195bf9df09bb30c40368c314b35b051a4a258828d3327e8c22053166eeb749d50a9a33e2620ba156042124979a1554524daf9f7b371ec0da5b41404a1b5e0d42fe0032859e114833c","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xde4481fdbef5d3726d0052661f950e69e4594dd6589913c628e20c1413f85b74","size":196,"type":"InvocationTransaction","version":1,"nonce":8,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0029621","valid_until_block":1200,"attributes":[],"cosigners":[],"vin":[],"vout":[],"scripts":[{"invocation":"0c40b192490537d5ec2c747fdf6ad8d73d0e3aae105c3d9ed96e7e032b28018fa54996661b17aaa107adc7a73a8ca3916b61a4b2b673e1b2a30c3c7117a01cf937a1","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"10c00c04696e69740c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b52"},{"txid":"0xd3c3104eb1c059985ddeacc3a149634c830b39cf3fa37f4a2f7af0e4980ff370","size":269,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036921","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cf193534761a987324a355749f5e4ef8499ff5948df6ee8a4b9834cbe025103ad08a74a00e1e248c73f3d967b23d09af0d200d9cb742ec0aa911f7f783cbd2e0","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}]}`, + `{"jsonrpc":"2.0","method":"transaction_added","params":[{"txid":"0xe1e0200a69f3096010c75dd003653e5bd945e414d0b0a3b95e3dfe291534c8e5","size":267,"version":0,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036721","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"script":"007b0c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c40b61d89290451852143490194e09a547d79b8b6cda05691c085160cc0ddebc6e3a508defae7ac04e015c85af6b6fcb487a954c2a884d4cc147c9959f776844b3c","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}]}]}`, + `{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x73f4157bc918f0af115522380b13dadf505773f91e818288edb0de4fcce104b4","version":0,"previousblockhash":"0x3c664cf156f2f418e92fd24621ac3b56da4a4c1e56c443fe360d52324d8f060f","merkleroot":"0xfa9e8e7a506c1a38fa1f090237156debd055c8cf41d743ae4f37fe3c278ff2e0","time":1591360099006,"index":6,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40d7690b2335898b192d408f3565fb8da0f994a305999f1b7b87000934831f76d680442ea2c44200c2b154c12a0ee587046eeec45f749b73ce3bc97ac172487f350c400835fd349d184a691087b24a827d82bad3026ffa0e7f2841e85fb91f5c9549e6a1430883586cbbfba3a450a0198608e19c0b1630677bbd9495e3f48c8c4835c40c400fd2d4dfee36f99de6df35b1c857eb7c8b9b26574a781114081b066b806a1bcae129d05329298b0e6b4728da90928d4a375157dd7472fb37351a20d1a84996790c404b58d5f6374bf6c2ab12f51e6f78a07852e027279879a5fb25b5e6371ad9d89749127e7b8f8eae3df45bfe187ae226aa1aeead061006da7c4e665d97950c9a3e","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xe1e0200a69f3096010c75dd003653e5bd945e414d0b0a3b95e3dfe291534c8e5","size":267,"version":0,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036721","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"script":"007b0c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c40b61d89290451852143490194e09a547d79b8b6cda05691c085160cc0ddebc6e3a508defae7ac04e015c85af6b6fcb487a954c2a884d4cc147c9959f776844b3c","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}]}]}]}`, `{"jsonrpc":"2.0","method":"event_missed","params":[]}`, } srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 4145d7bf9..79fdeae1e 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -496,13 +496,7 @@ func (s *Server) getApplicationLog(reqParams request.Params) (interface{}, *resp return nil, response.NewRPCError("Error while getting transaction", "", nil) } - var scriptHash util.Uint160 - switch t := tx.Data.(type) { - case *transaction.InvocationTX: - scriptHash = hash.Hash160(t.Script) - default: - return nil, response.NewRPCError("Invalid transaction type", "", nil) - } + scriptHash := hash.Hash160(tx.Script) return result.NewApplicationLog(appExecResult, scriptHash), nil } diff --git a/pkg/rpc/server/server_test.go b/pkg/rpc/server/server_test.go index e66498e94..81afdc448 100644 --- a/pkg/rpc/server/server_test.go +++ b/pkg/rpc/server/server_test.go @@ -20,6 +20,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/internal/testchain" + "github.com/nspcc-dev/neo-go/pkg/internal/testserdes" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" @@ -54,12 +55,12 @@ var rpcTestCases = map[string][]rpcTestCase{ "getapplicationlog": { { name: "positive", - params: `["70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c"]`, + params: `["2a6bf372fb96d05735eeb685805396818ac3f21e748528f4d6ebdecfd07ddce4"]`, result: func(e *executor) interface{} { return &result.ApplicationLog{} }, check: func(t *testing.T, e *executor, acc interface{}) { res, ok := acc.(*result.ApplicationLog) require.True(t, ok) - expectedTxHash, err := util.Uint256DecodeStringLE("70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c") + expectedTxHash, err := util.Uint256DecodeStringLE("2a6bf372fb96d05735eeb685805396818ac3f21e748528f4d6ebdecfd07ddce4") require.NoError(t, err) assert.Equal(t, expectedTxHash, res.TxHash) assert.Equal(t, 1, len(res.Executions)) @@ -82,11 +83,6 @@ var rpcTestCases = map[string][]rpcTestCase{ params: `["d24cc1d52b5c0216cbf3835bb5bac8ccf32639fa1ab6627ec4e2b9f33f7ec02f"]`, fail: true, }, - { - name: "invalid tx type", - params: `["f9adfde059810f37b3d0686d67f6b29034e0c669537df7e59b40c14a0508b9ed"]`, - fail: true, - }, }, "getcontractstate": { { @@ -333,7 +329,6 @@ var rpcTestCases = map[string][]rpcTestCase{ for i, tx := range res.Transactions { actualTx := block.Transactions[i] require.True(t, ok) - require.Equal(t, actualTx.Type, tx.Type) require.Equal(t, actualTx.Nonce, tx.Nonce) require.Equal(t, block.Transactions[i].Hash(), tx.Hash()) } @@ -489,7 +484,7 @@ var rpcTestCases = map[string][]rpcTestCase{ "gettransactionheight": { { name: "positive", - params: `["70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c"]`, + params: `["2a6bf372fb96d05735eeb685805396818ac3f21e748528f4d6ebdecfd07ddce4"]`, result: func(e *executor) interface{} { h := 0 return &h @@ -683,7 +678,7 @@ var rpcTestCases = map[string][]rpcTestCase{ "sendrawtransaction": { { name: "positive", - params: `["d1010a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000aab9050000000000b00400005d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001316e851039019d39dfc2c37d6c3fee19fd58098701000001420c40fadd2f9ddbe9484ef3577f131b0dec21b46a0d1c2fedd498ec258e378683d35d7159fd21120d832c1bff891c36bd765b50546ac762db4f4735f2df23ba2ec84a290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`, + params: `["000a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000c2b5050000000000b00400000001316e851039019d39dfc2c37d6c3fee19fd580987015d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001420c4070b2b74b193b574fede47432a9bfa192726603a7f1ef6f6589f192943eb5978f47d25a7834ae7f42a0ebf4e013d1d1c2d1bb61417890335e9804ef26a94d2c00290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`, result: func(e *executor) interface{} { v := true return &v @@ -691,7 +686,7 @@ var rpcTestCases = map[string][]rpcTestCase{ }, { name: "negative", - params: `["d1010a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000aab9050000000000b00400005d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001316e851039019d39dfc2c37d6c3fee19fd58098701000001420c40fadd2f9ddbe9484ef3577f131b0dec21b46a0d1c2fedd498ec258e378683d35d7159fd21120d832c1bff891c36bd765b50546ac762db4f4735f2df23ba2ec84a290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad5"]`, + params: `["000a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000c2b5050000000000b00400000001316e851039019d39dfc2c37d6c3fee19fd580987015d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001420c4070b2b74b193b574fede47432a9bfa192726603a7f1ef6f6589f192943eb5978f47d25a7834ae7f42a0ebf4e013d1d1c2d1bb61417890335e9804ef26a94d2c00290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906aff"]`, fail: true, }, { @@ -821,7 +816,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) [] newTx := func() *transaction.Transaction { height := chain.BlockHeight() - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.Nonce = height + 1 tx.ValidUntilBlock = height + 10 tx.Sender = acc0.PrivateKey().GetScriptHash() @@ -848,26 +843,32 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) [] t.Run("getrawtransaction", func(t *testing.T) { block, _ := chain.GetBlock(chain.GetHeaderHash(0)) - TXHash := block.Transactions[0].Hash() - rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s"]}"`, TXHash.StringLE()) + tx := block.Transactions[0] + rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s"]}"`, tx.Hash().StringLE()) body := doRPCCall(rpc, httpSrv.URL, t) result := checkErrGetResult(t, body, false) var res string err := json.Unmarshal(result, &res) require.NoErrorf(t, err, "could not parse response: %s", result) - assert.Equal(t, "d10100000000ca61e52e881d41374e640f819cd118cc153b21a700000000000000000000000000000000000000000541123e7fe80000000001000111", res) + txBin, err := testserdes.EncodeBinary(tx) + require.NoError(t, err) + expected := hex.EncodeToString(txBin) + assert.Equal(t, expected, res) }) t.Run("getrawtransaction 2 arguments", func(t *testing.T) { block, _ := chain.GetBlock(chain.GetHeaderHash(0)) - TXHash := block.Transactions[0].Hash() - rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s", 0]}"`, TXHash.StringLE()) + tx := block.Transactions[0] + rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s", 0]}"`, tx.Hash().StringLE()) body := doRPCCall(rpc, httpSrv.URL, t) result := checkErrGetResult(t, body, false) var res string err := json.Unmarshal(result, &res) require.NoErrorf(t, err, "could not parse response: %s", result) - assert.Equal(t, "d10100000000ca61e52e881d41374e640f819cd118cc153b21a700000000000000000000000000000000000000000541123e7fe80000000001000111", res) + txBin, err := testserdes.EncodeBinary(tx) + require.NoError(t, err) + expected := hex.EncodeToString(txBin) + assert.Equal(t, expected, res) }) t.Run("getrawtransaction 2 arguments, verbose", func(t *testing.T) { @@ -945,7 +946,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) [] expected = append(expected, tx.Tx.Hash()) } for i := 0; i < 5; i++ { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) assert.NoError(t, mp.Add(tx, &FeerStub{})) expected = append(expected, tx.Hash()) } diff --git a/pkg/rpc/server/subscription_test.go b/pkg/rpc/server/subscription_test.go index ef0ba8155..c11265cfe 100644 --- a/pkg/rpc/server/subscription_test.go +++ b/pkg/rpc/server/subscription_test.go @@ -9,7 +9,6 @@ import ( "github.com/gorilla/websocket" "github.com/nspcc-dev/neo-go/pkg/core" - "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/internal/testchain" "github.com/nspcc-dev/neo-go/pkg/rpc/response" @@ -98,17 +97,12 @@ func TestSubscriptions(t *testing.T) { for _, b := range getTestBlocks(t) { require.NoError(t, chain.AddBlock(b)) - for _, tx := range b.Transactions { - var mayNotify bool - - if tx.Type == transaction.InvocationType { - resp := getNotification(t, respMsgs) - require.Equal(t, response.ExecutionEventID, resp.Event) - mayNotify = true - } + for range b.Transactions { + resp := getNotification(t, respMsgs) + require.Equal(t, response.ExecutionEventID, resp.Event) for { resp := getNotification(t, respMsgs) - if mayNotify && resp.Event == response.NotificationEventID { + if resp.Event == response.NotificationEventID { continue } require.Equal(t, response.TransactionEventID, resp.Event) diff --git a/pkg/rpc/server/testdata/testblocks.acc b/pkg/rpc/server/testdata/testblocks.acc index 9b244c9d131fc0f4074f5a2da4e8bc5033aa9c98..c8d5926be373db0ccdafc3a03fd2dacda3c28d8e 100644 GIT binary patch delta 3429 zcma);c{tSF|Hfwq(@Z|r?E8{sY*`Z;KK7UtlHH?-vSiQBShH`9iR@blDSOt*`q)WC zWJ{K^ME12WdcM!~`~CI%oj=ZX{yOKn?$>?a=N&B(BB2e3Kp^<D?R3!~<H;N)$bMO1 zQid~bJ$jERerQk~Qdz3@9l!F-6C!N;a$HV^YeHb=P-lT8h8nFxr#%tL;P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context_test.go +++ b/pkg/smartcontract/context/context_test.go @@ -165,7 +165,7 @@ func newParam(typ smartcontract.ParamType, name string) wallet.ContractParam { } func getContractTx() *transaction.Transaction { - tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0) + tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0) tx.AddInput(&transaction.Input{ PrevHash: util.Uint256{1, 2, 3, 4}, PrevIndex: 5,