Skip to content

Commit 2c143e9

Browse files
Drop legacy logic: "extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError".
1 parent 57f16bf commit 2c143e9

File tree

2 files changed

+1
-195
lines changed

2 files changed

+1
-195
lines changed

server/services/transactionsTransformer.go

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,6 @@ func (transformer *transactionsTransformer) normalTxToRosetta(tx *transaction.Ap
230230
Amount: transformer.extension.valueToNativeAmount("-" + tx.InitiallyPaidFee),
231231
})
232232

233-
innerTxOperationsIfRelayedCompletelyIntrashardWithSignalError, err := transformer.extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError(tx)
234-
if err != nil {
235-
return nil, err
236-
}
237-
238-
operations = append(operations, innerTxOperationsIfRelayedCompletelyIntrashardWithSignalError...)
239-
240233
return &types.Transaction{
241234
TransactionIdentifier: hashToTransactionIdentifier(tx.Hash),
242235
Operations: operations,
@@ -252,57 +245,6 @@ func (transformer *transactionsTransformer) decideFeePayer(tx *transaction.ApiTr
252245
return tx.Sender
253246
}
254247

255-
// extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError recovers the inner transaction operations (native balance transfers)
256-
// for a transaction that is relayed and completely intrashard, and has a signal error, and was processed before the activation of Sirius features.
257-
// Before Sirius, such a transaction is accompanied by an SCR with the value refund, thus Rosetta has to recover the inner transaction operations, as well,
258-
// to show the complete picture (that the operations cancel each other out).
259-
// After Sirius, the protocol does not generate an SCR with the value refund for such transactions, so this workaround is not needed.
260-
// Additional references:
261-
// - https://github.com/multiversx/mx-chain-rosetta/pull/81/files
262-
// - https://console.cloud.google.com/bigquery?sq=667383445384:bfeb7de9aeec453192612ddc7fa9d94e
263-
func (transformer *transactionsTransformer) extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError(tx *transaction.ApiTransactionResult) ([]*types.Operation, error) {
264-
if transformer.provider.IsReleaseSiriusActive(tx.Epoch) {
265-
return []*types.Operation{}, nil
266-
}
267-
268-
// Only relayed V1 is handled. Relayed V2 cannot bear native value in the inner transaction.
269-
isRelayedTransaction := isRelayedV1Transaction(tx)
270-
if !isRelayedTransaction {
271-
return []*types.Operation{}, nil
272-
}
273-
274-
innerTx, err := parseInnerTxOfRelayedV1(tx)
275-
if err != nil {
276-
return []*types.Operation{}, err
277-
}
278-
279-
if isZeroBigIntOrNil(&innerTx.Value) {
280-
return []*types.Operation{}, nil
281-
}
282-
283-
if !transformer.featuresDetector.isRelayedV1TransactionCompletelyIntrashardWithSignalError(tx, innerTx) {
284-
return []*types.Operation{}, nil
285-
}
286-
287-
log.Info("extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError", "tx", tx.Hash)
288-
289-
senderAddress := transformer.provider.ConvertPubKeyToAddress(innerTx.SenderPubKey)
290-
receiverAddress := transformer.provider.ConvertPubKeyToAddress(innerTx.ReceiverPubKey)
291-
292-
return []*types.Operation{
293-
{
294-
Type: opTransfer,
295-
Account: addressToAccountIdentifier(senderAddress),
296-
Amount: transformer.extension.valueToNativeAmount("-" + innerTx.Value.String()),
297-
},
298-
{
299-
Type: opTransfer,
300-
Account: addressToAccountIdentifier(receiverAddress),
301-
Amount: transformer.extension.valueToNativeAmount(innerTx.Value.String()),
302-
},
303-
}, nil
304-
}
305-
306248
func (transformer *transactionsTransformer) refundReceiptToRosettaTx(receipt *transaction.ApiReceipt) (*types.Transaction, error) {
307249
receiptHash, err := transformer.provider.ComputeReceiptHash(receipt)
308250
if err != nil {

server/services/transactionsTransformer_test.go

Lines changed: 1 addition & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -131,57 +131,7 @@ func TestTransactionsTransformer_NormalTxToRosettaTx(t *testing.T) {
131131
require.Equal(t, expectedRosettaTx, rosettaTx)
132132
})
133133

134-
t.Run("relayed tx, completely intrashard, with signal error (before Sirius)", func(t *testing.T) {
135-
tx := &transaction.ApiTransactionResult{
136-
Epoch: 41,
137-
Type: string(transaction.TxTypeNormal),
138-
ProcessingTypeOnSource: transactionProcessingTypeRelayedV1,
139-
ProcessingTypeOnDestination: transactionProcessingTypeRelayedV1,
140-
Hash: "aaaa",
141-
Sender: testscommon.TestUserAShard0.Address,
142-
Receiver: testscommon.TestUserBShard0.Address,
143-
SourceShard: 0,
144-
DestinationShard: 0,
145-
InitiallyPaidFee: "50000000000000",
146-
// Has non-zero value
147-
Data: []byte("relayedTx@7b226e6f6e6365223a372c2273656e646572223a226e69424758747949504349644a78793373796c6c455a474c78506a503148734a45646e43732b6d726577413d222c227265636569766572223a224141414141414141414141464145356c3079623173734a3933504433672f4b396f48384579366d576958513d222c2276616c7565223a313030303030303030303030303030303030302c226761735072696365223a313030303030303030302c226761734c696d6974223a35303030302c2264617461223a22222c227369676e6174757265223a226e6830743338585a77614b6a725878446969716f6d364d6a5671724d612f6b70767474696a33692b5a6d43492f3778626830596762363548424151445744396f7036575567674541755430756e5253595736455341413d3d222c22636861696e4944223a224d513d3d222c2276657273696f6e223a327d"),
148-
Logs: &transaction.ApiLogs{
149-
Events: []*transaction.Events{
150-
{
151-
Identifier: transactionEventSignalError,
152-
},
153-
},
154-
},
155-
}
156-
157-
expectedRosettaTx := &types.Transaction{
158-
TransactionIdentifier: hashToTransactionIdentifier("aaaa"),
159-
Operations: []*types.Operation{
160-
{
161-
Type: opFee,
162-
Account: addressToAccountIdentifier(testscommon.TestUserAShard0.Address),
163-
Amount: extension.valueToNativeAmount("-50000000000000"),
164-
},
165-
{
166-
Type: opTransfer,
167-
Account: addressToAccountIdentifier(testscommon.TestUserCShard0.Address),
168-
Amount: extension.valueToNativeAmount("-1000000000000000000"),
169-
},
170-
{
171-
Type: opTransfer,
172-
Account: addressToAccountIdentifier(testscommon.TestAddressOfContract),
173-
Amount: extension.valueToNativeAmount("1000000000000000000"),
174-
},
175-
},
176-
Metadata: extractTransactionMetadata(tx),
177-
}
178-
179-
rosettaTx, err := transformer.normalTxToRosetta(tx)
180-
require.NoError(t, err)
181-
require.Equal(t, expectedRosettaTx, rosettaTx)
182-
})
183-
184-
t.Run("relayed tx, completely intrashard, with signal error (after Sirius)", func(t *testing.T) {
134+
t.Run("relayed tx, completely intrashard, with signal error", func(t *testing.T) {
185135
tx := &transaction.ApiTransactionResult{
186136
Epoch: 43,
187137
Type: string(transaction.TxTypeNormal),
@@ -289,92 +239,6 @@ func TestTransactionsTransformer_decideFeePayer(t *testing.T) {
289239
})
290240
}
291241

292-
func TestTransactionsTransformer_ExtractInnerTxOperationsIfRelayedCompletelyIntrashardWithSignalError(t *testing.T) {
293-
networkProvider := testscommon.NewNetworkProviderMock()
294-
extension := newNetworkProviderExtension(networkProvider)
295-
transformer := newTransactionsTransformer(networkProvider)
296-
297-
networkProvider.MockActivationEpochSirius = 42
298-
299-
t.Run("non-relayed tx", func(t *testing.T) {
300-
tx := &transaction.ApiTransactionResult{
301-
Type: string(transaction.TxTypeNormal),
302-
}
303-
304-
operations, err := transformer.extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError(tx)
305-
require.NoError(t, err)
306-
require.Len(t, operations, 0)
307-
})
308-
309-
t.Run("relayed tx (badly formatted)", func(t *testing.T) {
310-
tx := &transaction.ApiTransactionResult{
311-
Type: string(transaction.TxTypeNormal),
312-
ProcessingTypeOnSource: transactionProcessingTypeRelayedV1,
313-
ProcessingTypeOnDestination: transactionProcessingTypeRelayedV1,
314-
Data: []byte("bad"),
315-
}
316-
317-
operations, err := transformer.extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError(tx)
318-
require.ErrorIs(t, err, errCannotParseRelayedV1)
319-
require.Empty(t, operations)
320-
})
321-
322-
t.Run("relayed tx, completely intrashard, with signal error, inner tx has non-zero value", func(t *testing.T) {
323-
tx := &transaction.ApiTransactionResult{
324-
Type: string(transaction.TxTypeNormal),
325-
ProcessingTypeOnSource: transactionProcessingTypeRelayedV1,
326-
ProcessingTypeOnDestination: transactionProcessingTypeRelayedV1,
327-
SourceShard: 0,
328-
DestinationShard: 0,
329-
Data: []byte("relayedTx@7b226e6f6e6365223a372c2273656e646572223a226e69424758747949504349644a78793373796c6c455a474c78506a503148734a45646e43732b6d726577413d222c227265636569766572223a224141414141414141414141464145356c3079623173734a3933504433672f4b396f48384579366d576958513d222c2276616c7565223a313030303030303030303030303030303030302c226761735072696365223a313030303030303030302c226761734c696d6974223a35303030302c2264617461223a22222c227369676e6174757265223a226e6830743338585a77614b6a725878446969716f6d364d6a5671724d612f6b70767474696a33692b5a6d43492f3778626830596762363548424151445744396f7036575567674541755430756e5253595736455341413d3d222c22636861696e4944223a224d513d3d222c2276657273696f6e223a327d"),
330-
Logs: &transaction.ApiLogs{
331-
Events: []*transaction.Events{
332-
{
333-
Identifier: transactionEventSignalError,
334-
},
335-
},
336-
},
337-
}
338-
339-
operations, err := transformer.extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError(tx)
340-
require.NoError(t, err)
341-
require.Equal(t, []*types.Operation{
342-
{
343-
Type: opTransfer,
344-
Account: addressToAccountIdentifier(testscommon.TestUserCShard0.Address),
345-
Amount: extension.valueToNativeAmount("-1000000000000000000"),
346-
},
347-
{
348-
Type: opTransfer,
349-
Account: addressToAccountIdentifier(testscommon.TestAddressOfContract),
350-
Amount: extension.valueToNativeAmount("1000000000000000000"),
351-
},
352-
}, operations)
353-
})
354-
355-
t.Run("relayed tx, completely intrashard, with signal error, inner tx has zero value", func(t *testing.T) {
356-
tx := &transaction.ApiTransactionResult{
357-
Type: string(transaction.TxTypeNormal),
358-
ProcessingTypeOnSource: transactionProcessingTypeRelayedV1,
359-
ProcessingTypeOnDestination: transactionProcessingTypeRelayedV1,
360-
SourceShard: 0,
361-
DestinationShard: 0,
362-
Data: []byte("relayedTx@7b226e6f6e6365223a372c2273656e646572223a226e69424758747949504349644a78793373796c6c455a474c78506a503148734a45646e43732b6d726577413d222c227265636569766572223a224141414141414141414141464145356c3079623173734a3933504433672f4b396f48384579366d576958513d222c2276616c7565223a302c226761735072696365223a313030303030303030302c226761734c696d6974223a35303030302c2264617461223a22222c227369676e6174757265223a22336c644e7a32435734416143675069495863636c466b4654324149586a4a4757316a526a306c542b4f3161736b6241394a744e365a764173396e394f58716d343130574a49665332332b4168666e48793267446c41773d3d222c22636861696e4944223a224d513d3d222c2276657273696f6e223a327d"),
363-
Logs: &transaction.ApiLogs{
364-
Events: []*transaction.Events{
365-
{
366-
Identifier: transactionEventSignalError,
367-
},
368-
},
369-
},
370-
}
371-
372-
operations, err := transformer.extractInnerTxOperationsIfBeforeSiriusRelayedCompletelyIntrashardWithSignalError(tx)
373-
require.NoError(t, err)
374-
require.Len(t, operations, 0)
375-
})
376-
}
377-
378242
func TestTransactionsTransformer_UnsignedTxToRosettaTx(t *testing.T) {
379243
networkProvider := testscommon.NewNetworkProviderMock()
380244
extension := newNetworkProviderExtension(networkProvider)

0 commit comments

Comments
 (0)