From c6b93e6bba9a8f169174324ba6748a8ad2ee45af Mon Sep 17 00:00:00 2001 From: miiu Date: Fri, 18 Oct 2024 15:59:25 +0300 Subject: [PATCH 1/2] remove relayed v3 support --- data/transaction.go | 95 +++-- integrationtests/relayedTxV3_test.go | 369 ------------------ .../relayed-tx-v3-with-events.json | 70 ---- .../testdata/relayedTxV3/relayed-tx-v3.json | 54 --- .../relayed-v3-execution-scr-on-dest.json | 58 --- .../relayed-v3-execution-source.json | 57 --- .../transactions/transactionDBBuilder.go | 54 --- .../transactions/transactionDBBuilder_test.go | 127 ------ templates/noKibana/operations.go | 56 --- templates/noKibana/transactions.go | 56 --- 10 files changed, 46 insertions(+), 950 deletions(-) delete mode 100644 integrationtests/relayedTxV3_test.go delete mode 100644 integrationtests/testdata/relayedTxV3/relayed-tx-v3-with-events.json delete mode 100644 integrationtests/testdata/relayedTxV3/relayed-tx-v3.json delete mode 100644 integrationtests/testdata/relayedTxV3/relayed-v3-execution-scr-on-dest.json delete mode 100644 integrationtests/testdata/relayedTxV3/relayed-v3-execution-source.json diff --git a/data/transaction.go b/data/transaction.go index 2a85ce52..d0b41a9f 100644 --- a/data/transaction.go +++ b/data/transaction.go @@ -2,61 +2,58 @@ package data import ( "time" - - "github.com/multiversx/mx-chain-core-go/data/transaction" ) // Transaction is a structure containing all the fields that need // to be saved for a transaction. It has all the default fields // plus some extra information for ease of search and filter type Transaction struct { - MBHash string `json:"miniBlockHash"` - Nonce uint64 `json:"nonce"` - Round uint64 `json:"round"` - Value string `json:"value"` - ValueNum float64 `json:"valueNum"` - Receiver string `json:"receiver"` - Sender string `json:"sender"` - ReceiverShard uint32 `json:"receiverShard"` - SenderShard uint32 `json:"senderShard"` - GasPrice uint64 `json:"gasPrice"` - GasLimit uint64 `json:"gasLimit"` - GasUsed uint64 `json:"gasUsed"` - Fee string `json:"fee"` - FeeNum float64 `json:"feeNum"` - InitialPaidFee string `json:"initialPaidFee,omitempty"` - Data []byte `json:"data"` - Signature string `json:"signature"` - Timestamp time.Duration `json:"timestamp"` - Status string `json:"status"` - SearchOrder uint32 `json:"searchOrder"` - SenderUserName []byte `json:"senderUserName,omitempty"` - ReceiverUserName []byte `json:"receiverUserName,omitempty"` - HasSCR bool `json:"hasScResults,omitempty"` - IsScCall bool `json:"isScCall,omitempty"` - HasOperations bool `json:"hasOperations,omitempty"` - HasLogs bool `json:"hasLogs,omitempty"` - Tokens []string `json:"tokens,omitempty"` - ESDTValues []string `json:"esdtValues,omitempty"` - ESDTValuesNum []float64 `json:"esdtValuesNum,omitempty"` - Receivers []string `json:"receivers,omitempty"` - ReceiversShardIDs []uint32 `json:"receiversShardIDs,omitempty"` - Type string `json:"type,omitempty"` - Operation string `json:"operation,omitempty"` - Function string `json:"function,omitempty"` - IsRelayed bool `json:"isRelayed,omitempty"` - Version uint32 `json:"version,omitempty"` - GuardianAddress string `json:"guardian,omitempty"` - GuardianSignature string `json:"guardianSignature,omitempty"` - ErrorEvent bool `json:"errorEvent,omitempty"` - CompletedEvent bool `json:"completedEvent,omitempty"` - RelayedAddr string `json:"relayed,omitempty"` - InnerTransactions []*transaction.FrontendTransaction `json:"innerTransactions,omitempty"` - ExecutionOrder int `json:"-"` - SmartContractResults []*ScResult `json:"-"` - Hash string `json:"-"` - BlockHash string `json:"-"` - HadRefund bool `json:"-"` + MBHash string `json:"miniBlockHash"` + Nonce uint64 `json:"nonce"` + Round uint64 `json:"round"` + Value string `json:"value"` + ValueNum float64 `json:"valueNum"` + Receiver string `json:"receiver"` + Sender string `json:"sender"` + ReceiverShard uint32 `json:"receiverShard"` + SenderShard uint32 `json:"senderShard"` + GasPrice uint64 `json:"gasPrice"` + GasLimit uint64 `json:"gasLimit"` + GasUsed uint64 `json:"gasUsed"` + Fee string `json:"fee"` + FeeNum float64 `json:"feeNum"` + InitialPaidFee string `json:"initialPaidFee,omitempty"` + Data []byte `json:"data"` + Signature string `json:"signature"` + Timestamp time.Duration `json:"timestamp"` + Status string `json:"status"` + SearchOrder uint32 `json:"searchOrder"` + SenderUserName []byte `json:"senderUserName,omitempty"` + ReceiverUserName []byte `json:"receiverUserName,omitempty"` + HasSCR bool `json:"hasScResults,omitempty"` + IsScCall bool `json:"isScCall,omitempty"` + HasOperations bool `json:"hasOperations,omitempty"` + HasLogs bool `json:"hasLogs,omitempty"` + Tokens []string `json:"tokens,omitempty"` + ESDTValues []string `json:"esdtValues,omitempty"` + ESDTValuesNum []float64 `json:"esdtValuesNum,omitempty"` + Receivers []string `json:"receivers,omitempty"` + ReceiversShardIDs []uint32 `json:"receiversShardIDs,omitempty"` + Type string `json:"type,omitempty"` + Operation string `json:"operation,omitempty"` + Function string `json:"function,omitempty"` + IsRelayed bool `json:"isRelayed,omitempty"` + Version uint32 `json:"version,omitempty"` + GuardianAddress string `json:"guardian,omitempty"` + GuardianSignature string `json:"guardianSignature,omitempty"` + ErrorEvent bool `json:"errorEvent,omitempty"` + CompletedEvent bool `json:"completedEvent,omitempty"` + RelayedAddr string `json:"relayed,omitempty"` + ExecutionOrder int `json:"-"` + SmartContractResults []*ScResult `json:"-"` + Hash string `json:"-"` + BlockHash string `json:"-"` + HadRefund bool `json:"-"` } // Receipt is a structure containing all the fields that need to be safe for a Receipt diff --git a/integrationtests/relayedTxV3_test.go b/integrationtests/relayedTxV3_test.go deleted file mode 100644 index e440c215..00000000 --- a/integrationtests/relayedTxV3_test.go +++ /dev/null @@ -1,369 +0,0 @@ -//go:build integrationtests - -package integrationtests - -import ( - "context" - "encoding/hex" - "math/big" - "testing" - - "github.com/multiversx/mx-chain-core-go/core" - dataBlock "github.com/multiversx/mx-chain-core-go/data/block" - "github.com/multiversx/mx-chain-core-go/data/outport" - "github.com/multiversx/mx-chain-core-go/data/smartContractResult" - "github.com/multiversx/mx-chain-core-go/data/transaction" - indexerdata "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" - "github.com/stretchr/testify/require" -) - -func TestRelayedTxV3(t *testing.T) { - setLogLevelDebug() - - esClient, err := createESClient(esURL) - require.Nil(t, err) - - esProc, err := CreateElasticProcessor(esClient) - require.Nil(t, err) - - txHash := []byte("relayedTxV3") - header := &dataBlock.Header{ - Round: 50, - TimeStamp: 5040, - } - - body := &dataBlock.Body{ - MiniBlocks: dataBlock.MiniBlockSlice{ - { - Type: dataBlock.TxBlock, - SenderShardID: 0, - ReceiverShardID: 0, - TxHashes: [][]byte{txHash}, - }, - }, - } - - address1 := "erd1k7j6ewjsla4zsgv8v6f6fe3dvrkgv3d0d9jerczw45hzedhyed8sh2u34u" - address2 := "erd14eyayfrvlrhzfrwg5zwleua25mkzgncggn35nvc6xhv5yxwml2es0f3dht" - initialTx := &transaction.Transaction{ - Nonce: 1000, - SndAddr: decodeAddress(address1), - RcvAddr: decodeAddress(address2), - GasLimit: 15406000, - GasPrice: 1000000000, - Value: big.NewInt(0), - InnerTransactions: []*transaction.Transaction{ - { - Nonce: 10, - SndAddr: decodeAddress(address1), - RcvAddr: decodeAddress(address2), - GasLimit: 15406000, - GasPrice: 1000000000, - Value: big.NewInt(0), - }, - { - Nonce: 20, - SndAddr: decodeAddress(address1), - RcvAddr: decodeAddress(address2), - GasLimit: 15406000, - GasPrice: 1000000000, - Value: big.NewInt(1000), - }, - }, - } - - txInfo := &outport.TxInfo{ - Transaction: initialTx, - FeeInfo: &outport.FeeInfo{ - GasUsed: 10556000, - Fee: big.NewInt(2257820000000000), - InitialPaidFee: big.NewInt(2306320000000000), - }, - ExecutionOrder: 0, - } - - pool := &outport.TransactionPool{ - Transactions: map[string]*outport.TxInfo{ - hex.EncodeToString(txHash): txInfo, - }, - } - err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards)) - require.Nil(t, err) - - ids := []string{hex.EncodeToString(txHash)} - genericResponse := &GenericResponse{} - err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TransactionsIndex, true, genericResponse) - require.Nil(t, err) - - require.JSONEq(t, - readExpectedResult("./testdata/relayedTxV3/relayed-tx-v3.json"), - string(genericResponse.Docs[0].Source), - ) -} - -func TestRelayedTxV3WithSignalErrorAndCompletedEvent(t *testing.T) { - setLogLevelDebug() - - esClient, err := createESClient(esURL) - require.Nil(t, err) - - esProc, err := CreateElasticProcessor(esClient) - require.Nil(t, err) - - txHash := []byte("relayedTxV3WithSignalErrorAndCompletedEvent") - header := &dataBlock.Header{ - Round: 50, - TimeStamp: 5040, - } - - body := &dataBlock.Body{ - MiniBlocks: dataBlock.MiniBlockSlice{ - { - Type: dataBlock.TxBlock, - SenderShardID: 0, - ReceiverShardID: 0, - TxHashes: [][]byte{txHash}, - }, - }, - } - - initialTx := &transaction.Transaction{ - Nonce: 1000, - SndAddr: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - RcvAddr: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - GasLimit: 300_000, - GasPrice: 1000000000, - Value: big.NewInt(0), - InnerTransactions: []*transaction.Transaction{ - { - Nonce: 5, - SndAddr: decodeAddress("erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8"), - RcvAddr: decodeAddress("erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r"), - GasLimit: 50_000, - GasPrice: 1000000000, - Value: big.NewInt(10000000000000000), - }, - { - Nonce: 3, - SndAddr: decodeAddress("erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8"), - RcvAddr: decodeAddress("erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r"), - GasLimit: 50_000, - GasPrice: 1000000000, - Value: big.NewInt(10000000000000000), - }, - { - Nonce: 4, - SndAddr: decodeAddress("erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8"), - RcvAddr: decodeAddress("erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r"), - GasLimit: 50_000, - GasPrice: 1000000000, - Value: big.NewInt(10000000000000000), - }, - }, - } - - txInfo := &outport.TxInfo{ - Transaction: initialTx, - FeeInfo: &outport.FeeInfo{ - GasUsed: 10556000, - Fee: big.NewInt(2257820000000000), - InitialPaidFee: big.NewInt(2306320000000000), - }, - ExecutionOrder: 0, - } - - pool := &outport.TransactionPool{ - Transactions: map[string]*outport.TxInfo{ - hex.EncodeToString(txHash): txInfo, - }, - Logs: []*outport.LogData{ - { - TxHash: hex.EncodeToString(txHash), - Log: &transaction.Log{ - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Events: []*transaction.Event{ - { - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Identifier: []byte(core.CompletedTxEventIdentifier), - Topics: [][]byte{[]byte("t1"), []byte("t2")}, - }, - nil, - }, - }, - }, - { - TxHash: hex.EncodeToString(txHash), - Log: &transaction.Log{ - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Events: []*transaction.Event{ - { - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Identifier: []byte(core.SignalErrorOperation), - Topics: [][]byte{[]byte("t1"), []byte("t2")}, - }, - nil, - }, - }, - }, - }, - } - err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards)) - require.Nil(t, err) - - ids := []string{hex.EncodeToString(txHash)} - genericResponse := &GenericResponse{} - err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TransactionsIndex, true, genericResponse) - require.Nil(t, err) - - require.JSONEq(t, - readExpectedResult("./testdata/relayedTxV3/relayed-tx-v3-with-events.json"), - string(genericResponse.Docs[0].Source), - ) -} - -func TestRelayedV3WithSCRCross(t *testing.T) { - setLogLevelDebug() - - esClient, err := createESClient(esURL) - require.Nil(t, err) - - esProc, err := CreateElasticProcessor(esClient) - require.Nil(t, err) - - txHash := []byte("relayedTxV3WithScrCross") - header := &dataBlock.Header{ - Round: 50, - TimeStamp: 5040, - } - - body := &dataBlock.Body{ - MiniBlocks: dataBlock.MiniBlockSlice{ - { - Type: dataBlock.TxBlock, - SenderShardID: 0, - ReceiverShardID: 0, - TxHashes: [][]byte{txHash}, - }, - }, - } - - initialTx := &transaction.Transaction{ - Nonce: 1000, - SndAddr: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - RcvAddr: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - GasLimit: 300_000, - GasPrice: 1000000000, - Value: big.NewInt(0), - InnerTransactions: []*transaction.Transaction{ - { - Nonce: 5, - SndAddr: decodeAddress("erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8"), - RcvAddr: decodeAddress("erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r"), - GasLimit: 50_000, - GasPrice: 1000000000, - Value: big.NewInt(10000000000000000), - }, - { - Nonce: 3, - SndAddr: decodeAddress("erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8"), - RcvAddr: decodeAddress("erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r"), - GasLimit: 50_000, - GasPrice: 1000000000, - Value: big.NewInt(10000000000000000), - }, - }, - } - - txInfo := &outport.TxInfo{ - Transaction: initialTx, - FeeInfo: &outport.FeeInfo{ - GasUsed: 10556000, - Fee: big.NewInt(2257820000000000), - InitialPaidFee: big.NewInt(2306320000000000), - }, - ExecutionOrder: 0, - } - - pool := &outport.TransactionPool{ - Transactions: map[string]*outport.TxInfo{ - hex.EncodeToString(txHash): txInfo, - }, - Logs: []*outport.LogData{ - { - TxHash: hex.EncodeToString(txHash), - Log: &transaction.Log{ - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Events: []*transaction.Event{ - { - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Identifier: []byte(core.CompletedTxEventIdentifier), - Topics: [][]byte{[]byte("t1"), []byte("t2")}, - }, - nil, - }, - }, - }, - }, - } - err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards)) - require.Nil(t, err) - - ids := []string{hex.EncodeToString(txHash)} - genericResponse := &GenericResponse{} - err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TransactionsIndex, true, genericResponse) - require.Nil(t, err) - - require.JSONEq(t, - readExpectedResult("./testdata/relayedTxV3/relayed-v3-execution-source.json"), - string(genericResponse.Docs[0].Source), - ) - - // execute scr on destination - header = &dataBlock.Header{ - Round: 60, - TimeStamp: 6040, - } - - scrInfo := &outport.SCRInfo{ - SmartContractResult: &smartContractResult.SmartContractResult{ - OriginalTxHash: txHash, - }, - FeeInfo: &outport.FeeInfo{ - Fee: big.NewInt(0), - InitialPaidFee: big.NewInt(0), - }, - ExecutionOrder: 0, - } - - pool = &outport.TransactionPool{ - SmartContractResults: map[string]*outport.SCRInfo{ - hex.EncodeToString([]byte("scr")): scrInfo, - }, - Logs: []*outport.LogData{ - { - TxHash: hex.EncodeToString([]byte("scr")), - Log: &transaction.Log{ - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Events: []*transaction.Event{ - { - Address: decodeAddress("erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a"), - Identifier: []byte(core.SignalErrorOperation), - Topics: [][]byte{[]byte("t1"), []byte("t2")}, - }, - nil, - }, - }, - }, - }, - } - err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards)) - require.Nil(t, err) - - err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TransactionsIndex, true, genericResponse) - require.Nil(t, err) - - require.JSONEq(t, - readExpectedResult("./testdata/relayedTxV3/relayed-v3-execution-scr-on-dest.json"), - string(genericResponse.Docs[0].Source), - ) -} diff --git a/integrationtests/testdata/relayedTxV3/relayed-tx-v3-with-events.json b/integrationtests/testdata/relayedTxV3/relayed-tx-v3-with-events.json deleted file mode 100644 index f60cafb2..00000000 --- a/integrationtests/testdata/relayedTxV3/relayed-tx-v3-with-events.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "miniBlockHash": "2b8a2e2b21d1cf1c5e3d782552810a07818e6b179dd196e901466bb588fc387a", - "nonce": 1000, - "round": 50, - "value": "0", - "valueNum": 0, - "receiver": "erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a", - "sender": "erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a", - "receiverShard": 0, - "senderShard": 0, - "gasPrice": 1000000000, - "gasLimit": 300000, - "gasUsed": 10556000, - "fee": "2257820000000000", - "feeNum": 0.00225782, - "initialPaidFee": "2306320000000000", - "data": null, - "signature": "", - "timestamp": 5040, - "status": "success", - "searchOrder": 0, - "hasOperations": true, - "hasLogs": true, - "receivers": [ - "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r" - ], - "receiversShardIDs": [ - 1, - 1, - 1 - ], - "operation": "transfer", - "isRelayed": true, - "errorEvent": true, - "completedEvent": true, - "innerTransactions": [ - { - "nonce": 5, - "value": "10000000000000000", - "receiver": "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "sender": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8", - "gasPrice": 1000000000, - "gasLimit": 50000, - "chainID": "", - "version": 0 - }, - { - "nonce": 3, - "value": "10000000000000000", - "receiver": "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "sender": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8", - "gasPrice": 1000000000, - "gasLimit": 50000, - "chainID": "", - "version": 0 - }, - { - "nonce": 4, - "value": "10000000000000000", - "receiver": "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "sender": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8", - "gasPrice": 1000000000, - "gasLimit": 50000, - "chainID": "", - "version": 0 - } - ] -} diff --git a/integrationtests/testdata/relayedTxV3/relayed-tx-v3.json b/integrationtests/testdata/relayedTxV3/relayed-tx-v3.json deleted file mode 100644 index 210df682..00000000 --- a/integrationtests/testdata/relayedTxV3/relayed-tx-v3.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "miniBlockHash": "b3222be4506429fa237393c56b732a283eea5ccab465deb66b6348083793b6c9", - "nonce": 1000, - "round": 50, - "value": "0", - "valueNum": 0, - "receiver": "erd14eyayfrvlrhzfrwg5zwleua25mkzgncggn35nvc6xhv5yxwml2es0f3dht", - "sender": "erd1k7j6ewjsla4zsgv8v6f6fe3dvrkgv3d0d9jerczw45hzedhyed8sh2u34u", - "receiverShard": 0, - "senderShard": 0, - "gasPrice": 1000000000, - "gasLimit": 15406000, - "gasUsed": 10556000, - "fee": "2257820000000000", - "feeNum": 0.00225782, - "initialPaidFee": "2306320000000000", - "data": null, - "signature": "", - "timestamp": 5040, - "status": "success", - "searchOrder": 0, - "receivers": [ - "erd14eyayfrvlrhzfrwg5zwleua25mkzgncggn35nvc6xhv5yxwml2es0f3dht", - "erd14eyayfrvlrhzfrwg5zwleua25mkzgncggn35nvc6xhv5yxwml2es0f3dht" - ], - "receiversShardIDs": [ - 1, - 1 - ], - "operation": "transfer", - "isRelayed": true, - "innerTransactions": [ - { - "nonce": 10, - "value": "0", - "receiver": "erd14eyayfrvlrhzfrwg5zwleua25mkzgncggn35nvc6xhv5yxwml2es0f3dht", - "sender": "erd1k7j6ewjsla4zsgv8v6f6fe3dvrkgv3d0d9jerczw45hzedhyed8sh2u34u", - "gasPrice": 1000000000, - "gasLimit": 15406000, - "chainID": "", - "version": 0 - }, - { - "nonce": 20, - "value": "1000", - "receiver": "erd14eyayfrvlrhzfrwg5zwleua25mkzgncggn35nvc6xhv5yxwml2es0f3dht", - "sender": "erd1k7j6ewjsla4zsgv8v6f6fe3dvrkgv3d0d9jerczw45hzedhyed8sh2u34u", - "gasPrice": 1000000000, - "gasLimit": 15406000, - "chainID": "", - "version": 0 - } - ] -} diff --git a/integrationtests/testdata/relayedTxV3/relayed-v3-execution-scr-on-dest.json b/integrationtests/testdata/relayedTxV3/relayed-v3-execution-scr-on-dest.json deleted file mode 100644 index e525f876..00000000 --- a/integrationtests/testdata/relayedTxV3/relayed-v3-execution-scr-on-dest.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "miniBlockHash": "5fba08d48700058cf2789651a50ebaa35ee559ce51ee43a709943c6a4f763d25", - "nonce": 1000, - "round": 50, - "value": "0", - "valueNum": 0, - "receiver": "erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a", - "sender": "erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a", - "receiverShard": 0, - "senderShard": 0, - "gasPrice": 1000000000, - "gasLimit": 300000, - "gasUsed": 10556000, - "fee": "2257820000000000", - "feeNum": 0.00225782, - "initialPaidFee": "2306320000000000", - "data": null, - "signature": "", - "timestamp": 5040, - "status": "success", - "searchOrder": 0, - "hasOperations": true, - "hasLogs": true, - "receivers": [ - "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r" - ], - "receiversShardIDs": [ - 1, - 1 - ], - "operation": "transfer", - "isRelayed": true, - "completedEvent": true, - "errorEvent": true, - "innerTransactions": [ - { - "nonce": 5, - "value": "10000000000000000", - "receiver": "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "sender": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8", - "gasPrice": 1000000000, - "gasLimit": 50000, - "chainID": "", - "version": 0 - }, - { - "nonce": 3, - "value": "10000000000000000", - "receiver": "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "sender": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8", - "gasPrice": 1000000000, - "gasLimit": 50000, - "chainID": "", - "version": 0 - } - ] -} diff --git a/integrationtests/testdata/relayedTxV3/relayed-v3-execution-source.json b/integrationtests/testdata/relayedTxV3/relayed-v3-execution-source.json deleted file mode 100644 index e9d692b7..00000000 --- a/integrationtests/testdata/relayedTxV3/relayed-v3-execution-source.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "miniBlockHash": "5fba08d48700058cf2789651a50ebaa35ee559ce51ee43a709943c6a4f763d25", - "nonce": 1000, - "round": 50, - "value": "0", - "valueNum": 0, - "receiver": "erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a", - "sender": "erd1ykqd64fxxpp4wsz0v7sjqem038wfpzlljhx4mhwx8w9lcxmdzcfszrp64a", - "receiverShard": 0, - "senderShard": 0, - "gasPrice": 1000000000, - "gasLimit": 300000, - "gasUsed": 10556000, - "fee": "2257820000000000", - "feeNum": 0.00225782, - "initialPaidFee": "2306320000000000", - "data": null, - "signature": "", - "timestamp": 5040, - "status": "success", - "searchOrder": 0, - "hasOperations": true, - "hasLogs": true, - "receivers": [ - "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r" - ], - "receiversShardIDs": [ - 1, - 1 - ], - "operation": "transfer", - "isRelayed": true, - "completedEvent": true, - "innerTransactions": [ - { - "nonce": 5, - "value": "10000000000000000", - "receiver": "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "sender": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8", - "gasPrice": 1000000000, - "gasLimit": 50000, - "chainID": "", - "version": 0 - }, - { - "nonce": 3, - "value": "10000000000000000", - "receiver": "erd1aduqqezzw0u3j7tywlq3mrl0yn4z6f6vytdju8gg0neq38fauyzsa5yy6r", - "sender": "erd10ksryjr065ad5475jcg82pnjfg9j9qtszjsrp24anl6ym7cmeddshwnru8", - "gasPrice": 1000000000, - "gasLimit": 50000, - "chainID": "", - "version": 0 - } - ] -} diff --git a/process/elasticproc/transactions/transactionDBBuilder.go b/process/elasticproc/transactions/transactionDBBuilder.go index f22e1a31..c22fd07d 100644 --- a/process/elasticproc/transactions/transactionDBBuilder.go +++ b/process/elasticproc/transactions/transactionDBBuilder.go @@ -11,7 +11,6 @@ import ( "github.com/multiversx/mx-chain-core-go/data/block" "github.com/multiversx/mx-chain-core-go/data/outport" "github.com/multiversx/mx-chain-core-go/data/receipt" - "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/multiversx/mx-chain-es-indexer-go/data" "github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer" "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters" @@ -122,13 +121,6 @@ func (dtb *dbTransactionBuilder) prepareTransaction( Operation: res.Operation, } - isRelayedV3 := len(tx.InnerTransactions) > 0 - if isRelayedV3 { - dtb.addRelayedV3InfoInIndexerTx(tx, eTx, numOfShards) - - return eTx - } - eTx.Function = converters.TruncateFieldIfExceedsMaxLength(res.Function) eTx.Tokens = converters.TruncateSliceElementsIfExceedsMaxLength(res.Tokens) eTx.ReceiversShardIDs = res.ReceiversShardID @@ -137,52 +129,6 @@ func (dtb *dbTransactionBuilder) prepareTransaction( return eTx } -func (dtb *dbTransactionBuilder) addRelayedV3InfoInIndexerTx(tx *transaction.Transaction, indexerTx *data.Transaction, numOfShards uint32) { - if len(tx.InnerTransactions) == 0 { - return - } - - innerTxs := make([]*transaction.FrontendTransaction, 0, len(tx.InnerTransactions)) - receivers := make([]string, 0, len(tx.InnerTransactions)) - receiversShardIDs := make([]uint32, 0, len(tx.InnerTransactions)) - for _, innerTx := range tx.InnerTransactions { - frontEndTx := &transaction.FrontendTransaction{ - Nonce: innerTx.Nonce, - Value: innerTx.Value.String(), - Receiver: dtb.addressPubkeyConverter.SilentEncode(innerTx.RcvAddr, log), - Sender: dtb.addressPubkeyConverter.SilentEncode(innerTx.SndAddr, log), - SenderUsername: innerTx.SndUserName, - ReceiverUsername: innerTx.RcvUserName, - GasPrice: innerTx.GasPrice, - GasLimit: innerTx.GasLimit, - Data: innerTx.Data, - Signature: hex.EncodeToString(innerTx.Signature), - ChainID: string(innerTx.ChainID), - Version: innerTx.Version, - Options: innerTx.Options, - } - - if len(innerTx.GuardianAddr) > 0 { - frontEndTx.GuardianAddr = dtb.addressPubkeyConverter.SilentEncode(innerTx.GuardianAddr, log) - frontEndTx.GuardianSignature = hex.EncodeToString(innerTx.GuardianSignature) - } - - if len(innerTx.RelayerAddr) > 0 { - frontEndTx.Relayer = dtb.addressPubkeyConverter.SilentEncode(innerTx.RelayerAddr, log) - } - - receivers = append(receivers, frontEndTx.Receiver) - receiversShardIDs = append(receiversShardIDs, sharding.ComputeShardID(innerTx.RcvAddr, numOfShards)) - - innerTxs = append(innerTxs, frontEndTx) - } - - indexerTx.InnerTransactions = innerTxs - indexerTx.IsRelayed = true - indexerTx.Receivers = receivers - indexerTx.ReceiversShardIDs = receiversShardIDs -} - func (dtb *dbTransactionBuilder) prepareRewardTransaction( rTxInfo *outport.RewardInfo, txHash []byte, diff --git a/process/elasticproc/transactions/transactionDBBuilder_test.go b/process/elasticproc/transactions/transactionDBBuilder_test.go index b892166e..ceeca3de 100644 --- a/process/elasticproc/transactions/transactionDBBuilder_test.go +++ b/process/elasticproc/transactions/transactionDBBuilder_test.go @@ -204,130 +204,3 @@ func TestGetMoveBalanceTransactionInvalid(t *testing.T) { dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3) require.Equal(t, expectedTx, dbTx) } - -func TestTxsDatabaseProcessor_PrepareTransactionRelayedV3(t *testing.T) { - t.Parallel() - - txHash := []byte("txHash") - mbHash := []byte("mbHash") - mb := &block.MiniBlock{TxHashes: [][]byte{txHash}} - header := &block.Header{Nonce: 2} - status := "Success" - gasPrice := uint64(1000) - gasLimit := uint64(1000) - cp := createCommonProcessor() - - tx := &transaction.Transaction{ - Nonce: 1, - Value: big.NewInt(1000), - RcvAddr: []byte("receiver"), - SndAddr: []byte("sender"), - GasPrice: gasPrice, - GasLimit: gasLimit, - ChainID: []byte("1"), - Version: 1, - Signature: []byte("signature"), - RcvUserName: []byte("rcv"), - SndUserName: []byte("snd"), - InnerTransactions: []*transaction.Transaction{ - { - Nonce: 2, - Value: big.NewInt(1000), - SndAddr: []byte("inner1"), - RcvAddr: []byte("rcv1"), - Data: []byte("data1"), - Signature: []byte("signature1"), - GasPrice: gasPrice, - GasLimit: gasLimit, - ChainID: []byte("1"), - Version: 1, - }, - { - Nonce: 3, - Value: big.NewInt(1), - SndAddr: []byte("inner2"), - RcvAddr: []byte("rcv2"), - Data: []byte("data2"), - Signature: []byte("signature2"), - GasPrice: gasPrice, - GasLimit: gasLimit, - ChainID: []byte("1"), - Version: 1, - }, - }, - } - - txInfo := &outport.TxInfo{ - Transaction: tx, - FeeInfo: &outport.FeeInfo{ - GasUsed: 500, - Fee: big.NewInt(100), - InitialPaidFee: big.NewInt(100), - }, - ExecutionOrder: 0, - } - - senderAddr, err := cp.addressPubkeyConverter.Encode(tx.RcvAddr) - require.Nil(t, err) - receiverAddr, err := cp.addressPubkeyConverter.Encode(tx.SndAddr) - require.Nil(t, err) - - expectedTx := &data.Transaction{ - Hash: hex.EncodeToString(txHash), - MBHash: hex.EncodeToString(mbHash), - Nonce: tx.Nonce, - Round: header.Round, - Value: tx.Value.String(), - ValueNum: 1e-15, - Receiver: senderAddr, - Sender: receiverAddr, - ReceiverShard: mb.ReceiverShardID, - SenderShard: mb.SenderShardID, - GasPrice: gasPrice, - GasLimit: gasLimit, - GasUsed: uint64(500), - InitialPaidFee: "100", - Signature: hex.EncodeToString(tx.Signature), - Timestamp: time.Duration(header.GetTimeStamp()), - Status: status, - Fee: "100", - FeeNum: 1e-16, - ReceiverUserName: []byte("rcv"), - SenderUserName: []byte("snd"), - ESDTValuesNum: []float64{}, - Operation: "transfer", - Version: 1, - Receivers: []string{"72637631", "72637632"}, - ReceiversShardIDs: []uint32{1, 2}, - InnerTransactions: []*transaction.FrontendTransaction{ - { - Nonce: 2, - Value: "1000", - Sender: "696e6e657231", - Receiver: "72637631", - GasPrice: gasPrice, - GasLimit: gasLimit, - Signature: "7369676e617475726531", - Data: []byte("data1"), - Version: 1, - ChainID: "1", - }, - { - Nonce: 3, - Value: "1", - Sender: "696e6e657232", - Receiver: "72637632", - GasPrice: gasPrice, - GasLimit: gasLimit, - Signature: "7369676e617475726532", - Data: []byte("data2"), - Version: 1, - ChainID: "1", - }, - }, - IsRelayed: true, - } - - dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3) - require.Equal(t, expectedTx, dbTx) -} diff --git a/templates/noKibana/operations.go b/templates/noKibana/operations.go index 9834f19b..8c734d9d 100644 --- a/templates/noKibana/operations.go +++ b/templates/noKibana/operations.go @@ -169,62 +169,6 @@ var Operations = Object{ "index": "false", "type": "keyword", }, - "innerTransactions": Object{ - "properties": Object{ - "nonce": Object{ - "type": "double", - }, - "value": Object{ - "type": "keyword", - }, - "sender": Object{ - "type": "keyword", - }, - "receiver": Object{ - "type": "keyword", - }, - "senderUserName": Object{ - "type": "keyword", - }, - "receiverUsername": Object{ - "type": "keyword", - }, - "gasLimit": Object{ - "index": "false", - "type": "double", - }, - "gasPrice": Object{ - "index": "false", - "type": "double", - }, - "data": Object{ - "type": "text", - }, - "signature": Object{ - "index": "false", - "type": "keyword", - }, - "chainID": Object{ - "type": "keyword", - }, - "version": Object{ - "type": "long", - }, - "options": Object{ - "type": "long", - }, - "guardian": Object{ - "type": "keyword", - }, - "guardianSignature": Object{ - "index": "false", - "type": "keyword", - }, - "relayer": Object{ - "type": "keyword", - }, - }, - }, }, }, } diff --git a/templates/noKibana/transactions.go b/templates/noKibana/transactions.go index 16ddef08..91ebea75 100644 --- a/templates/noKibana/transactions.go +++ b/templates/noKibana/transactions.go @@ -135,62 +135,6 @@ var Transactions = Object{ "index": "false", "type": "keyword", }, - "innerTransactions": Object{ - "properties": Object{ - "nonce": Object{ - "type": "double", - }, - "value": Object{ - "type": "keyword", - }, - "sender": Object{ - "type": "keyword", - }, - "receiver": Object{ - "type": "keyword", - }, - "senderUserName": Object{ - "type": "keyword", - }, - "receiverUsername": Object{ - "type": "keyword", - }, - "gasLimit": Object{ - "index": "false", - "type": "double", - }, - "gasPrice": Object{ - "index": "false", - "type": "double", - }, - "data": Object{ - "type": "text", - }, - "signature": Object{ - "index": "false", - "type": "keyword", - }, - "chainID": Object{ - "type": "keyword", - }, - "version": Object{ - "type": "long", - }, - "options": Object{ - "type": "long", - }, - "guardian": Object{ - "type": "keyword", - }, - "guardianSignature": Object{ - "index": "false", - "type": "keyword", - }, - "relayer": Object{ - "type": "keyword", - }, - }, - }, }, }, } From f48c7282690b934731564bea3b75e17fc78e92f4 Mon Sep 17 00:00:00 2001 From: miiu Date: Fri, 18 Oct 2024 16:02:18 +0300 Subject: [PATCH 2/2] remove extra mappings for inner txs --- .../templatesAndPolicies/noKibana.go | 14 +---- templates/noKibana/innerTx.go | 63 ------------------- 2 files changed, 1 insertion(+), 76 deletions(-) delete mode 100644 templates/noKibana/innerTx.go diff --git a/process/elasticproc/templatesAndPolicies/noKibana.go b/process/elasticproc/templatesAndPolicies/noKibana.go index d87acaba..3840c71c 100644 --- a/process/elasticproc/templatesAndPolicies/noKibana.go +++ b/process/elasticproc/templatesAndPolicies/noKibana.go @@ -49,17 +49,5 @@ func (tr *templatesAndPolicyReaderNoKibana) GetElasticTemplatesAndPolicies() (ma // GetExtraMappings will return an array of indices extra mappings func (tr *templatesAndPolicyReaderNoKibana) GetExtraMappings() ([]templates.ExtraMapping, error) { - transactionsExtraMappings := templates.ExtraMapping{ - Index: indexer.TransactionsIndex, - Mappings: noKibana.InnerTxs.ToBuffer(), - } - operationsExtraMappings := templates.ExtraMapping{ - Index: indexer.OperationsIndex, - Mappings: noKibana.InnerTxs.ToBuffer(), - } - - return []templates.ExtraMapping{ - transactionsExtraMappings, - operationsExtraMappings, - }, nil + return []templates.ExtraMapping{}, nil } diff --git a/templates/noKibana/innerTx.go b/templates/noKibana/innerTx.go deleted file mode 100644 index c97f5cbe..00000000 --- a/templates/noKibana/innerTx.go +++ /dev/null @@ -1,63 +0,0 @@ -package noKibana - -// InnerTxs will hold the configuration for the inner transaction structure -var InnerTxs = Object{ - "properties": Object{ - "innerTransactions": Object{ - "properties": Object{ - "nonce": Object{ - "type": "double", - }, - "value": Object{ - "type": "keyword", - }, - "sender": Object{ - "type": "keyword", - }, - "receiver": Object{ - "type": "keyword", - }, - "senderUserName": Object{ - "type": "keyword", - }, - "receiverUsername": Object{ - "type": "keyword", - }, - "gasLimit": Object{ - "index": "false", - "type": "double", - }, - "gasPrice": Object{ - "index": "false", - "type": "double", - }, - "data": Object{ - "type": "text", - }, - "signature": Object{ - "index": "false", - "type": "keyword", - }, - "chainID": Object{ - "type": "keyword", - }, - "version": Object{ - "type": "long", - }, - "options": Object{ - "type": "long", - }, - "guardian": Object{ - "type": "keyword", - }, - "guardianSignature": Object{ - "index": "false", - "type": "keyword", - }, - "relayer": Object{ - "type": "keyword", - }, - }, - }, - }, -}