diff --git a/data/transaction.go b/data/transaction.go index d0b41a9f..76060d3b 100644 --- a/data/transaction.go +++ b/data/transaction.go @@ -48,7 +48,8 @@ type Transaction struct { GuardianSignature string `json:"guardianSignature,omitempty"` ErrorEvent bool `json:"errorEvent,omitempty"` CompletedEvent bool `json:"completedEvent,omitempty"` - RelayedAddr string `json:"relayed,omitempty"` + RelayedAddr string `json:"relayer,omitempty"` + RelayedSignature string `json:"relayerSignature,omitempty"` ExecutionOrder int `json:"-"` SmartContractResults []*ScResult `json:"-"` Hash string `json:"-"` diff --git a/go.mod b/go.mod index eb32dd80..b040e945 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/gin-contrib/cors v1.4.0 github.com/gin-gonic/gin v1.9.1 github.com/multiversx/mx-chain-communication-go v1.1.0 - github.com/multiversx/mx-chain-core-go v1.2.21 + github.com/multiversx/mx-chain-core-go v1.2.24-0.20241029140551-8ed69b598c83 github.com/multiversx/mx-chain-logger-go v1.0.15 github.com/multiversx/mx-chain-vm-common-go v1.5.13 github.com/prometheus/client_model v0.4.0 diff --git a/go.sum b/go.sum index 82f3a0f7..178af96b 100644 --- a/go.sum +++ b/go.sum @@ -249,8 +249,8 @@ 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-communication-go v1.1.0 h1:J7bX6HoN3HiHY7cUeEjG8AJWgQDDPcY+OPDOsSUOkRE= github.com/multiversx/mx-chain-communication-go v1.1.0/go.mod h1:WK6bP4pGEHGDDna/AYRIMtl6G9OA0NByI1Lw8PmOnRM= -github.com/multiversx/mx-chain-core-go v1.2.21 h1:+XVKznPTlUU5EFS1A8chtS8fStW60upRIyF4Pgml19I= -github.com/multiversx/mx-chain-core-go v1.2.21/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= +github.com/multiversx/mx-chain-core-go v1.2.24-0.20241029140551-8ed69b598c83 h1:VuFFYZ9hpMacAcqcKM0hg6j4D16qKAGihi3X6PaF8qs= +github.com/multiversx/mx-chain-core-go v1.2.24-0.20241029140551-8ed69b598c83/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE= github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk= github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc= github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ= diff --git a/process/elasticproc/transactions/transactionDBBuilder.go b/process/elasticproc/transactions/transactionDBBuilder.go index c22fd07d..6a522b7a 100644 --- a/process/elasticproc/transactions/transactionDBBuilder.go +++ b/process/elasticproc/transactions/transactionDBBuilder.go @@ -83,6 +83,10 @@ func (dtb *dbTransactionBuilder) prepareTransaction( if len(tx.GuardianAddr) > 0 { guardianAddress = dtb.addressPubkeyConverter.SilentEncode(tx.GuardianAddr, log) } + relayedAddress := "" + if len(tx.RelayerAddr) > 0 { + relayedAddress = dtb.addressPubkeyConverter.SilentEncode(tx.RelayerAddr, log) + } senderUserName := converters.TruncateFieldIfExceedsMaxLengthBase64(string(tx.SndUserName)) receiverUserName := converters.TruncateFieldIfExceedsMaxLengthBase64(string(tx.RcvUserName)) @@ -119,6 +123,8 @@ func (dtb *dbTransactionBuilder) prepareTransaction( GuardianSignature: hex.EncodeToString(tx.GuardianSignature), ExecutionOrder: int(txInfo.ExecutionOrder), Operation: res.Operation, + RelayedSignature: hex.EncodeToString(tx.RelayerSignature), + RelayedAddr: relayedAddress, } eTx.Function = converters.TruncateFieldIfExceedsMaxLength(res.Function) diff --git a/process/elasticproc/transactions/transactionDBBuilder_test.go b/process/elasticproc/transactions/transactionDBBuilder_test.go index ceeca3de..0e3c9080 100644 --- a/process/elasticproc/transactions/transactionDBBuilder_test.go +++ b/process/elasticproc/transactions/transactionDBBuilder_test.go @@ -135,6 +135,80 @@ func TestGetTransactionByType_RewardTx(t *testing.T) { require.Equal(t, expectedTx, resultTx) } +func TestRelayedV3Transaction(t *testing.T) { + t.Parallel() + + txHash := []byte("txHash") + mbHash := []byte("mbHash") + mb := &block.MiniBlock{TxHashes: [][]byte{txHash}, Type: block.InvalidBlock} + header := &block.Header{Nonce: 2} + status := transaction.TxStatusInvalid.String() + 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, + Data: []byte("data"), + ChainID: []byte("1"), + Version: 1, + Signature: []byte("signature"), + RcvUserName: []byte("rcv"), + SndUserName: []byte("snd"), + RelayerAddr: []byte("relayer"), + RelayerSignature: []byte("relayerSignature"), + } + + 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: cp.addressPubkeyConverter.SilentEncode(tx.RcvAddr, log), + Sender: cp.addressPubkeyConverter.SilentEncode(tx.SndAddr, log), + ReceiverShard: uint32(2), + SenderShard: mb.SenderShardID, + GasPrice: gasPrice, + GasLimit: gasLimit, + GasUsed: uint64(500), + InitialPaidFee: "100", + Data: tx.Data, + Signature: hex.EncodeToString(tx.Signature), + Timestamp: time.Duration(header.GetTimeStamp()), + Status: status, + Fee: "100", + FeeNum: 1e-16, + ReceiverUserName: []byte("rcv"), + SenderUserName: []byte("snd"), + Operation: "transfer", + Version: 1, + Receivers: []string{}, + ESDTValuesNum: []float64{}, + RelayedAddr: hex.EncodeToString(tx.RelayerAddr), + RelayedSignature: hex.EncodeToString(tx.RelayerSignature), + } + + txInfo := &outport.TxInfo{ + Transaction: tx, + FeeInfo: &outport.FeeInfo{ + GasUsed: 500, + Fee: big.NewInt(100), + InitialPaidFee: big.NewInt(100), + }, + ExecutionOrder: 0, + } + + dbTx := cp.prepareTransaction(txInfo, txHash, mbHash, mb, header, status, 3) + require.Equal(t, expectedTx, dbTx) +} + func TestGetMoveBalanceTransactionInvalid(t *testing.T) { t.Parallel()