Skip to content

Commit aa3f592

Browse files
authored
Add tx idempotency key to EVM Service SubmitTransaction reply (#1527)
1 parent ee42d6f commit aa3f592

5 files changed

Lines changed: 29 additions & 15 deletions

File tree

pkg/chains/evm/evm.pb.go

Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/chains/evm/evm.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ message SubmitTransactionRequest {
322322
message SubmitTransactionReply {
323323
bytes txHash = 1;
324324
TxStatus txStatus = 2;
325+
string tx_idempotency_key = 3; // idempotency key generated for this transaction
325326
}
326327

327328
// TransactionStatus is an enum for the status of a transaction.

pkg/loop/internal/relayer/evm.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ func (e *EVMClient) SubmitTransaction(ctx context.Context, txRequest evmtypes.Su
5656
}
5757

5858
return &evmtypes.TransactionResult{
59-
TxStatus: evmpb.ConvertTxStatusFromProto(reply.TxStatus),
60-
TxHash: evmtypes.Hash(reply.TxHash),
59+
TxStatus: evmpb.ConvertTxStatusFromProto(reply.TxStatus),
60+
TxHash: evmtypes.Hash(reply.TxHash),
61+
TxIdempotencyKey: reply.TxIdempotencyKey,
6162
}, nil
6263
}
6364

@@ -514,8 +515,9 @@ func (e *evmServer) SubmitTransaction(ctx context.Context, request *evmpb.Submit
514515
return nil, err
515516
}
516517
return &evmpb.SubmitTransactionReply{
517-
TxHash: txResult.TxHash[:],
518-
TxStatus: evmpb.ConvertTxStatusToProto(txResult.TxStatus),
518+
TxHash: txResult.TxHash[:],
519+
TxStatus: evmpb.ConvertTxStatusToProto(txResult.TxStatus),
520+
TxIdempotencyKey: txResult.TxIdempotencyKey,
519521
}, nil
520522
}
521523

pkg/loop/internal/relayerset/evm.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,9 @@ func (s *Server) SubmitTransaction(ctx context.Context, request *evmpb.SubmitTra
411411
}
412412

413413
return &evmpb.SubmitTransactionReply{
414-
TxHash: txResult.TxHash[:],
415-
TxStatus: evmpb.ConvertTxStatusToProto(txResult.TxStatus),
414+
TxHash: txResult.TxHash[:],
415+
TxStatus: evmpb.ConvertTxStatusToProto(txResult.TxStatus),
416+
TxIdempotencyKey: txResult.TxIdempotencyKey,
416417
}, nil
417418
}
418419

pkg/types/chains/evm/evm.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ func (e *TxError) Error() string {
147147

148148
// PLEX-1524 - Refactor this to return the Tx Hash in a Transaction type and a second return value for the TxStatus. We may even be able to return the whole transaction object instead of just the hash.
149149
type TransactionResult struct {
150-
TxStatus TransactionStatus
151-
TxHash Hash
150+
TxStatus TransactionStatus
151+
TxHash Hash
152+
TxIdempotencyKey string // Idempotency key used for tracking purposes of transactions.
152153
}
153154

154155
type GasConfig struct {

0 commit comments

Comments
 (0)