From 583b8174c4d9bb67855e08b56c3a277260c86421 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Fri, 18 Oct 2024 18:49:05 +0300 Subject: [PATCH 1/2] reverted relayed v3 --- data/transaction.go | 35 ++++--- go.mod | 2 +- go.sum | 4 +- process/testdata/pendingSCROfRelayedV3.json | 101 -------------------- process/transactionProcessor.go | 16 ---- process/transactionProcessor_test.go | 8 -- 6 files changed, 20 insertions(+), 146 deletions(-) delete mode 100644 process/testdata/pendingSCROfRelayedV3.json diff --git a/data/transaction.go b/data/transaction.go index e283e468..09ededda 100644 --- a/data/transaction.go +++ b/data/transaction.go @@ -11,24 +11,23 @@ import ( // Transaction represents the structure that maps and validates user input for publishing a new transaction type Transaction struct { // This field is used to tag transactions for send-multiple route - Index int `json:"-"` - Nonce uint64 `json:"nonce"` - Value string `json:"value"` - Receiver string `json:"receiver"` - Sender string `json:"sender"` - SenderUsername []byte `json:"senderUsername,omitempty"` - ReceiverUsername []byte `json:"receiverUsername,omitempty"` - GasPrice uint64 `json:"gasPrice"` - GasLimit uint64 `json:"gasLimit"` - Data []byte `json:"data,omitempty"` - Signature string `json:"signature,omitempty"` - ChainID string `json:"chainID"` - Version uint32 `json:"version"` - Options uint32 `json:"options,omitempty"` - GuardianAddr string `json:"guardian,omitempty"` - GuardianSignature string `json:"guardianSignature,omitempty"` - Relayer string `json:"relayer,omitempty"` - InnerTransactions []*Transaction `json:"innerTransactions,omitempty"` + Index int `json:"-"` + Nonce uint64 `json:"nonce"` + Value string `json:"value"` + Receiver string `json:"receiver"` + Sender string `json:"sender"` + SenderUsername []byte `json:"senderUsername,omitempty"` + ReceiverUsername []byte `json:"receiverUsername,omitempty"` + GasPrice uint64 `json:"gasPrice"` + GasLimit uint64 `json:"gasLimit"` + Data []byte `json:"data,omitempty"` + Signature string `json:"signature,omitempty"` + ChainID string `json:"chainID"` + Version uint32 `json:"version"` + Options uint32 `json:"options,omitempty"` + GuardianAddr string `json:"guardian,omitempty"` + GuardianSignature string `json:"guardianSignature,omitempty"` + Relayer string `json:"relayer,omitempty"` } // GetTransactionResponseData follows the format of the data field of get transaction response diff --git a/go.mod b/go.mod index d578cbd1..c9df7f31 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/gin-contrib/pprof v1.4.0 github.com/gin-contrib/static v0.0.1 github.com/gin-gonic/gin v1.9.1 - github.com/multiversx/mx-chain-core-go v1.2.22 + github.com/multiversx/mx-chain-core-go v1.2.23-0.20241018134424-75bab2a9058c github.com/multiversx/mx-chain-crypto-go v1.2.12 github.com/multiversx/mx-chain-es-indexer-go v1.7.8 github.com/multiversx/mx-chain-logger-go v1.0.15 diff --git a/go.sum b/go.sum index 5e15844f..08f1a422 100644 --- a/go.sum +++ b/go.sum @@ -129,8 +129,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/multiversx/mx-chain-core-go v1.2.22 h1:yDYrvoQOBbsDerEp7L3+de5AfMy3pTF333gWPpd+FNk= -github.com/multiversx/mx-chain-core-go v1.2.22/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= +github.com/multiversx/mx-chain-core-go v1.2.23-0.20241018134424-75bab2a9058c h1:hPCfMSj2vd9xNkARNxB1b3b9k8taFb+Xfja+WK97jno= +github.com/multiversx/mx-chain-core-go v1.2.23-0.20241018134424-75bab2a9058c/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk= github.com/multiversx/mx-chain-crypto-go v1.2.12/go.mod h1:HzcPpCm1zanNct/6h2rIh+MFrlXbjA5C8+uMyXj3LI4= github.com/multiversx/mx-chain-es-indexer-go v1.7.8 h1:ZDKTXkQhQ7lLi6huVrBTUssVEqCvaCxGH4Y52GapboQ= diff --git a/process/testdata/pendingSCROfRelayedV3.json b/process/testdata/pendingSCROfRelayedV3.json deleted file mode 100644 index d27da23e..00000000 --- a/process/testdata/pendingSCROfRelayedV3.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "transaction": { - "type": "normal", - "processingTypeOnSource": "RelayedTxV3", - "processingTypeOnDestination": "RelayedTxV3", - "hash": "98f2a122f8bc1c87401d184b4bfa292dee6010033837e7b2927ada345e0e82ca", - "nonce": 0, - "round": 360, - "epoch": 7, - "value": "0", - "receiver": "erd15uchpdmkn90qxd9add6npnst3mckkapkq7zmn5l8rlkwnvk7k0ese9q8z5", - "sender": "erd15uchpdmkn90qxd9add6npnst3mckkapkq7zmn5l8rlkwnvk7k0ese9q8z5", - "gasPrice": 1000000000, - "gasLimit": 55050000, - "gasUsed": 55050000, - "signature": "629d9ed05630e9a9ae637ae920d33f0118e1fb067d4a986ebaee147867a62f12a07e64195113ea513e6c2b51a9881f9deefbcc50269511471d2ba6778a672b01", - "sourceShard": 1, - "destinationShard": 1, - "blockNonce": 360, - "blockHash": "92661989d434e60faee1a8c4f97e82f858e035f58252e9842238b150beb61739", - "miniblockType": "TxBlock", - "miniblockHash": "8ec424450f436c00d20d6fc5fec97a739892e44027587f57ea703457e925ce16", - "timestamp": 1721997247, - "smartContractResults": [ - { - "hash": "208d3b73ebcefba5565f3f7c1f4435040f2a8bd7efbe30498c65afaa40ff4a34", - "nonce": 0, - "value": 5000000000000000000000, - "receiver": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l", - "sender": "erd10vn8cuug0wx6anj84g7ukzlm06fullcjadetvmusqzv039x04f3supvc4v", - "relayerAddress": "erd15uchpdmkn90qxd9add6npnst3mckkapkq7zmn5l8rlkwnvk7k0ese9q8z5", - "relayedValue": 0, - "data": "stake@02@d690d1419e7667c59c5f70277bb92764518fc472d9418ae7b1c53ca90959da6abc3a188d9e9fd5ea03ed9d5fbef8fa0cc47d0e632105e1ba2f2abd6685a50be1c4af50d1ec8cfc083d2264714a1a9339f6d1e48cadc556f6efd451bf447b5619@dc49b56485ab67ab8a82659ef43339bbaa35839eb2011bbf79c02204d83127638ebd448d49412863057d4da20b6b0d14@19d2d21b2a5a22d91e6308d79c57dda4dde41c266a0e999c506f1f8b894509b1b5a1cb2e573feda1e771cf88672e2e11ae1c4a79a7dbcb19698984e27bd07b2c93c0919091ec9514fed26e15bb1bfdfe82e922fa6d6b626118a4f56c19d4408b@2b1c53e18ef0b6166b423c87bf0fe8b5800a3174f1b176d80b7633cf6debc96ef2142f35d2b3e93416887101a40df787", - "prevTxHash": "98f2a122f8bc1c87401d184b4bfa292dee6010033837e7b2927ada345e0e82ca", - "originalTxHash": "98f2a122f8bc1c87401d184b4bfa292dee6010033837e7b2927ada345e0e82ca", - "gasLimit": 54068000, - "gasPrice": 1000000000, - "callType": 0, - "operation": "transfer", - "function": "stake" - } - ], - "status": "success", - "receivers": [ - "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l" - ], - "receiversShardIDs": [ - 4294967295 - ], - "operation": "transfer", - "initiallyPaidFee": "1522680000000000", - "fee": "1522680000000000", - "isRelayed": true, - "chainID": "chain", - "version": 2, - "options": 0, - "innerTransactions": [ - { - "nonce": 0, - "value": "5000000000000000000000", - "receiver": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l", - "sender": "erd10vn8cuug0wx6anj84g7ukzlm06fullcjadetvmusqzv039x04f3supvc4v", - "gasPrice": 1000000000, - "gasLimit": 55000000, - "data": "c3Rha2VAMDJAZDY5MGQxNDE5ZTc2NjdjNTljNWY3MDI3N2JiOTI3NjQ1MThmYzQ3MmQ5NDE4YWU3YjFjNTNjYTkwOTU5ZGE2YWJjM2ExODhkOWU5ZmQ1ZWEwM2VkOWQ1ZmJlZjhmYTBjYzQ3ZDBlNjMyMTA1ZTFiYTJmMmFiZDY2ODVhNTBiZTFjNGFmNTBkMWVjOGNmYzA4M2QyMjY0NzE0YTFhOTMzOWY2ZDFlNDhjYWRjNTU2ZjZlZmQ0NTFiZjQ0N2I1NjE5QGRjNDliNTY0ODVhYjY3YWI4YTgyNjU5ZWY0MzMzOWJiYWEzNTgzOWViMjAxMWJiZjc5YzAyMjA0ZDgzMTI3NjM4ZWJkNDQ4ZDQ5NDEyODYzMDU3ZDRkYTIwYjZiMGQxNEAxOWQyZDIxYjJhNWEyMmQ5MWU2MzA4ZDc5YzU3ZGRhNGRkZTQxYzI2NmEwZTk5OWM1MDZmMWY4Yjg5NDUwOWIxYjVhMWNiMmU1NzNmZWRhMWU3NzFjZjg4NjcyZTJlMTFhZTFjNGE3OWE3ZGJjYjE5Njk4OTg0ZTI3YmQwN2IyYzkzYzA5MTkwOTFlYzk1MTRmZWQyNmUxNWJiMWJmZGZlODJlOTIyZmE2ZDZiNjI2MTE4YTRmNTZjMTlkNDQwOGJAMmIxYzUzZTE4ZWYwYjYxNjZiNDIzYzg3YmYwZmU4YjU4MDBhMzE3NGYxYjE3NmQ4MGI3NjMzY2Y2ZGViYzk2ZWYyMTQyZjM1ZDJiM2U5MzQxNjg4NzEwMWE0MGRmNzg3", - "signature": "4c075c5ee550931e9b64b6db5974a4a1c0c48c9e7f48ac792949bb87e4861addb774310506a313b8d0fc062cadcba010449707bf34b7adeb2f4da67e8b2db602", - "chainID": "chain", - "version": 2, - "relayer": "erd15uchpdmkn90qxd9add6npnst3mckkapkq7zmn5l8rlkwnvk7k0ese9q8z5" - } - ] - }, - "scrs": [ - { - "type": "unsigned", - "processingTypeOnSource": "SCInvoking", - "processingTypeOnDestination": "SCInvoking", - "hash": "208d3b73ebcefba5565f3f7c1f4435040f2a8bd7efbe30498c65afaa40ff4a34", - "nonce": 0, - "round": 0, - "epoch": 0, - "value": "5000000000000000000000", - "receiver": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l", - "sender": "erd10vn8cuug0wx6anj84g7ukzlm06fullcjadetvmusqzv039x04f3supvc4v", - "gasPrice": 1000000000, - "gasLimit": 54068000, - "gasUsed": 932000, - "data": "c3Rha2VAMDJAZDY5MGQxNDE5ZTc2NjdjNTljNWY3MDI3N2JiOTI3NjQ1MThmYzQ3MmQ5NDE4YWU3YjFjNTNjYTkwOTU5ZGE2YWJjM2ExODhkOWU5ZmQ1ZWEwM2VkOWQ1ZmJlZjhmYTBjYzQ3ZDBlNjMyMTA1ZTFiYTJmMmFiZDY2ODVhNTBiZTFjNGFmNTBkMWVjOGNmYzA4M2QyMjY0NzE0YTFhOTMzOWY2ZDFlNDhjYWRjNTU2ZjZlZmQ0NTFiZjQ0N2I1NjE5QGRjNDliNTY0ODVhYjY3YWI4YTgyNjU5ZWY0MzMzOWJiYWEzNTgzOWViMjAxMWJiZjc5YzAyMjA0ZDgzMTI3NjM4ZWJkNDQ4ZDQ5NDEyODYzMDU3ZDRkYTIwYjZiMGQxNEAxOWQyZDIxYjJhNWEyMmQ5MWU2MzA4ZDc5YzU3ZGRhNGRkZTQxYzI2NmEwZTk5OWM1MDZmMWY4Yjg5NDUwOWIxYjVhMWNiMmU1NzNmZWRhMWU3NzFjZjg4NjcyZTJlMTFhZTFjNGE3OWE3ZGJjYjE5Njk4OTg0ZTI3YmQwN2IyYzkzYzA5MTkwOTFlYzk1MTRmZWQyNmUxNWJiMWJmZGZlODJlOTIyZmE2ZDZiNjI2MTE4YTRmNTZjMTlkNDQwOGJAMmIxYzUzZTE4ZWYwYjYxNjZiNDIzYzg3YmYwZmU4YjU4MDBhMzE3NGYxYjE3NmQ4MGI3NjMzY2Y2ZGViYzk2ZWYyMTQyZjM1ZDJiM2U5MzQxNjg4NzEwMWE0MGRmNzg3", - "previousTransactionHash": "98f2a122f8bc1c87401d184b4bfa292dee6010033837e7b2927ada345e0e82ca", - "originalTransactionHash": "98f2a122f8bc1c87401d184b4bfa292dee6010033837e7b2927ada345e0e82ca", - "sourceShard": 1, - "destinationShard": 4294967295, - "status": "pending", - "fee": "0", - "callType": "directCall", - "relayerAddress": "erd15uchpdmkn90qxd9add6npnst3mckkapkq7zmn5l8rlkwnvk7k0ese9q8z5", - "relayedValue": "0", - "options": 0 - } - ] -} diff --git a/process/transactionProcessor.go b/process/transactionProcessor.go index d2d85ba8..b91cf6c2 100644 --- a/process/transactionProcessor.go +++ b/process/transactionProcessor.go @@ -45,7 +45,6 @@ const ( moveBalanceDescriptor = "MoveBalance" relayedV1TransactionDescriptor = "RelayedTx" relayedV2TransactionDescriptor = "RelayedTxV2" - relayedV3TransactionDescriptor = "RelayedTxV3" emptyDataStr = "" ) @@ -491,13 +490,6 @@ func (tp *TransactionProcessor) computeTransactionStatus(tx *transaction.ApiTran } } - isRelayedV3, status := checkIfRelayedV3Completed(tx) - if isRelayedV3 { - return &data.ProcessStatusResponse{ - Status: status, - } - } - failed, reason = checkIfFailed(allLogs) if failed { return &data.ProcessStatusResponse{ @@ -588,14 +580,6 @@ func checkIfCompleted(logs []*transaction.ApiLogs) bool { return found } -func checkIfRelayedV3Completed(tx *transaction.ApiTransactionResult) (bool, string) { - if len(tx.InnerTransactions) == 0 { - return false, string(transaction.TxStatusPending) - } - - return true, string(transaction.TxStatusSuccess) -} - func checkIfMoveBalanceNotarized(tx *transaction.ApiTransactionResult) bool { isNotarized := tx.NotarizedAtSourceInMetaNonce > 0 && tx.NotarizedAtDestinationInMetaNonce > 0 if !isNotarized { diff --git a/process/transactionProcessor_test.go b/process/transactionProcessor_test.go index 4e551aff..aba0ceb1 100644 --- a/process/transactionProcessor_test.go +++ b/process/transactionProcessor_test.go @@ -2001,14 +2001,6 @@ func TestTransactionProcessor_computeTransactionStatus(t *testing.T) { status := tp.ComputeTransactionStatus(testData.Transaction, withResults) require.Equal(t, string(transaction.TxStatusSuccess), status.Status) }) - t.Run("pending scr of relayed v3 should return pending", func(t *testing.T) { - t.Parallel() - - testData := loadJsonIntoTxAndScrs(t, "./testdata/pendingSCROfRelayedV3.json") - tp := createTestProcessorFromScenarioData(testData) - status := tp.ComputeTransactionStatus(testData.Transaction, true) - require.Equal(t, string(transaction.TxStatusPending), status.Status) - }) }) t.Run("reward transaction", func(t *testing.T) { t.Parallel() From 5a567ac58ae653dba2dc7b7723e787d28b6ea9da Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Mon, 21 Oct 2024 11:23:11 +0300 Subject: [PATCH 2/2] fixes after review --- data/transaction.go | 1 - 1 file changed, 1 deletion(-) diff --git a/data/transaction.go b/data/transaction.go index 09ededda..757c59fd 100644 --- a/data/transaction.go +++ b/data/transaction.go @@ -27,7 +27,6 @@ type Transaction struct { Options uint32 `json:"options,omitempty"` GuardianAddr string `json:"guardian,omitempty"` GuardianSignature string `json:"guardianSignature,omitempty"` - Relayer string `json:"relayer,omitempty"` } // GetTransactionResponseData follows the format of the data field of get transaction response