From dd6aa99729a773f83a6b730df55d6271803f758f Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 23 Dec 2024 10:39:12 -0500 Subject: [PATCH 01/13] update status object --- docs/openapi/openapi.swagger.yaml | 5 + .../zetacore/crosschain/cross_chain_tx.proto | 12 + .../crosschain/cross_chain_tx_pb.d.ts | 46 ++ x/crosschain/keeper/cctx_gateway_observers.go | 5 +- x/crosschain/keeper/cctx_gateway_zevm.go | 7 +- .../cctx_orchestrator_validate_outbound.go | 57 +- x/crosschain/keeper/initiate_outbound.go | 2 +- x/crosschain/keeper/initiate_outbound_test.go | 12 +- .../keeper/msg_server_abort_stuck_cctx.go | 5 +- .../keeper/msg_server_vote_inbound_tx_test.go | 2 +- .../keeper/msg_server_vote_outbound_tx.go | 5 +- x/crosschain/types/cctx.go | 20 +- x/crosschain/types/cctx_test.go | 55 +- x/crosschain/types/cross_chain_tx.pb.go | 511 +++++++++++++++--- x/crosschain/types/status.go | 51 +- x/crosschain/types/status_test.go | 24 +- x/crosschain/types/tx.pb.go | 4 +- 17 files changed, 644 insertions(+), 179 deletions(-) diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 65f305da0f..39c60864ae 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -58504,6 +58504,11 @@ definitions: type: string format: int64 description: when the CCTX was created. only populated on new transactions. + error_message_revert: + type: string + title: |- + error_message_revert carries information about the revert outbound tx , + which is created if the first outbound tx fails zetacoreemissionsParams: type: object properties: diff --git a/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto b/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto index 8feb44d382..a9a60da102 100644 --- a/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto +++ b/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto @@ -108,6 +108,18 @@ message Status { bool isAbortRefunded = 4; // when the CCTX was created. only populated on new transactions. int64 created_timestamp = 5; + // error_message_revert carries information about the revert outbound tx , + // which is created if the first outbound tx fails + string error_message_revert = 7; +} + +// StatusMessages is a message that carries status and error messages for a +// cctx Currently this is only used internally to pass messages when updating +// the status +message StatusMessages { + string status_message = 1; + string error_message_outbound = 2; + string error_message_revert = 3; } // ProtocolContractVersion represents the version of the protocol contract used diff --git a/typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.ts b/typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.ts index 4ac84ac5e7..b0c6cf34fd 100644 --- a/typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.ts +++ b/typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.ts @@ -395,6 +395,14 @@ export declare class Status extends Message { */ createdTimestamp: bigint; + /** + * error_message_revert carries information about the revert outbound tx , + * which is created if the first outbound tx fails + * + * @generated from field: string error_message_revert = 7; + */ + errorMessageRevert: string; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; @@ -410,6 +418,44 @@ export declare class Status extends Message { static equals(a: Status | PlainMessage | undefined, b: Status | PlainMessage | undefined): boolean; } +/** + * StatusMessages is a message that carries status and error messages for a + * cctx Currently this is only used internally to pass messages when updating + * the status + * + * @generated from message zetachain.zetacore.crosschain.StatusMessages + */ +export declare class StatusMessages extends Message { + /** + * @generated from field: string status_message = 1; + */ + statusMessage: string; + + /** + * @generated from field: string error_message_outbound = 2; + */ + errorMessageOutbound: string; + + /** + * @generated from field: string error_message_revert = 3; + */ + errorMessageRevert: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.StatusMessages"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): StatusMessages; + + static fromJson(jsonValue: JsonValue, options?: Partial): StatusMessages; + + static fromJsonString(jsonString: string, options?: Partial): StatusMessages; + + static equals(a: StatusMessages | PlainMessage | undefined, b: StatusMessages | PlainMessage | undefined): boolean; +} + /** * RevertOptions represents the options for reverting a cctx * diff --git a/x/crosschain/keeper/cctx_gateway_observers.go b/x/crosschain/keeper/cctx_gateway_observers.go index 9576bcfe32..8224b8c3a8 100644 --- a/x/crosschain/keeper/cctx_gateway_observers.go +++ b/x/crosschain/keeper/cctx_gateway_observers.go @@ -75,7 +75,10 @@ func (c CCTXGatewayObservers) InitiateOutbound( }() if err != nil { // do not commit anything here as the CCTX should be aborted - config.CCTX.SetAbort("internal error", err.Error()) + config.CCTX.SetAbort(types.StatusMessages{ + StatusMessage: "Outbound preprocessing failed for cctx when initiating outbound", + ErrorMessageOutbound: err.Error(), + }) return types.CctxStatus_Aborted, err } commit() diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index fc247ad7a4..2949355e3a 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -28,9 +28,10 @@ func (c CCTXGatewayZEVM) InitiateOutbound( if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX - config.CCTX.SetAbort( - "error during deposit that is not smart contract revert", - err.Error()) + config.CCTX.SetAbort(types.StatusMessages{ + StatusMessage: "Error processing outbound to ZEVM , but contract call did not revert", + ErrorMessageOutbound: err.Error(), + }) return types.CctxStatus_Aborted, err } diff --git a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go index 173093c771..4d10dfb355 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go @@ -52,13 +52,17 @@ func (k Keeper) ValidateOutboundZEVM( depositErr.Error(), cctx.InboundParams.Amount, ) + if err != nil { + // Error here would mean the outbound tx failed and we also failed to create a revert tx. + // In this case the cctx can be aborted directly cctx.SetAbort( - "revert failed", - fmt.Sprintf("deposit error: %s, processing error: %s", depositErr.Error(), err.Error())) + types.StatusMessages{ + StatusMessage: fmt.Sprintf("Revert failed , Error : %s", depositErr.Error()), + ErrorMessageRevert: fmt.Sprintf("Processing error: %s", err.Error()), + }) return types.CctxStatus_Aborted } - commitRevert() return types.CctxStatus_PendingRevert } @@ -124,7 +128,9 @@ func (k Keeper) processFailedOutboundObservers(ctx sdk.Context, cctx *types.Cros if cctx.InboundParams.CoinType == coin.CoinType_Cmd { // if the cctx is of coin type cmd or the sender chain is zeta chain, then we do not revert, the cctx is aborted cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.SetAbort("", "outbound failed for admin tx") + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "outbound failed for admin tx", + }) } else if chains.IsZetaChain(cctx.InboundParams.SenderChainId, k.GetAuthorityKeeper().GetAdditionalChainList(ctx)) { switch cctx.InboundParams.CoinType { // Try revert if the coin-type is ZETA @@ -139,7 +145,10 @@ func (k Keeper) processFailedOutboundObservers(ctx sdk.Context, cctx *types.Cros default: { cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.SetAbort("", "outbound failed for non-ZETA cctx") + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "outbound failed for non-ZETA cctx", + ErrorMessageOutbound: fmt.Sprintf("coin type %s not supported for revert when source chain is Zetachain", cctx.InboundParams.CoinType), + }) } } } else { @@ -210,10 +219,16 @@ func (k Keeper) processFailedOutboundOnExternalChain( return err } // Not setting the finalization status here, the required changes have been made while creating the revert tx - cctx.SetPendingRevert("", revertMsg) + cctx.SetPendingRevert(types.StatusMessages{ + StatusMessage: "Outbound failed", + ErrorMessageOutbound: revertMsg, + }) case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.SetAbort("aborted while processing failed outbound", "outbound and revert failed") + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "Revert failed", + ErrorMessageRevert: revertMsg, + }) } return nil } @@ -240,9 +255,9 @@ func (k Keeper) processSuccessfulOutbound( oldStatus := cctx.CctxStatus.Status switch oldStatus { case types.CctxStatus_PendingRevert: - cctx.SetReverted("", "") + cctx.SetReverted(types.StatusMessages{StatusMessage: "Revert successful"}) case types.CctxStatus_PendingOutbound: - cctx.SetOutboundMined("") + cctx.SetOutboundMined(types.StatusMessages{StatusMessage: "Outbound mined successfully"}) default: return } @@ -271,7 +286,10 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro } // Trying to revert the transaction this would get set to a finalized status in the same block as this does not need a TSS singing - cctx.SetPendingRevert("", "outbound failed") + cctx.SetPendingRevert(types.StatusMessages{ + StatusMessage: "Outbound failed", + ErrorMessageOutbound: "outbound failed to external chain ,start revert", + }) data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { return fmt.Errorf("failed decoding relayed message: %s", err.Error()) @@ -305,7 +323,10 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro return fmt.Errorf("failed ZETARevertAndCallContract: %s", err.Error()) } - cctx.SetReverted("", "outbound failed") + cctx.SetReverted(types.StatusMessages{ + StatusMessage: "Reverted to ZEVM", + }) + if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) @@ -350,7 +371,10 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT } // update status - cctx.SetPendingRevert("", "outbound failed") + cctx.SetPendingRevert(types.StatusMessages{ + StatusMessage: "Outbound failed", + ErrorMessageOutbound: "outbound failed to external chain", + }) // process the revert on ZEVM if err := k.fungibleKeeper.ProcessV2RevertDeposit( @@ -368,7 +392,9 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT } // tx is reverted - cctx.SetReverted("", "outbound failed") + cctx.SetReverted(types.StatusMessages{ + StatusMessage: "Reverted to ZEVM", + }) // add event for tendermint transaction hash format if len(ctx.TxBytes()) > 0 { @@ -381,7 +407,10 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.SetAbort("aborted while processing failed outbound", "outbound and revert failed") + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "Revert failed", + ErrorMessageRevert: "outbound and revert failed", + }) } return nil } diff --git a/x/crosschain/keeper/initiate_outbound.go b/x/crosschain/keeper/initiate_outbound.go index 5339cd4150..d1cd7ea064 100644 --- a/x/crosschain/keeper/initiate_outbound.go +++ b/x/crosschain/keeper/initiate_outbound.go @@ -38,6 +38,6 @@ func (k Keeper) InitiateOutbound(ctx sdk.Context, config InitiateOutboundConfig) ) } - config.CCTX.SetPendingOutbound("") + config.CCTX.SetPendingOutbound(types.StatusMessages{StatusMessage: "Initiating outbound"}) return cctxGateway.InitiateOutbound(ctx, config) } diff --git a/x/crosschain/keeper/initiate_outbound_test.go b/x/crosschain/keeper/initiate_outbound_test.go index 204179bea5..5466b902c7 100644 --- a/x/crosschain/keeper/initiate_outbound_test.go +++ b/x/crosschain/keeper/initiate_outbound_test.go @@ -111,7 +111,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.Equal(t, types.CctxStatus_Aborted, newStatus) require.Contains( t, - cctx.CctxStatus.ErrorMessage, + cctx.CctxStatus.ErrorMessageRevert, "chain not supported", ) }, @@ -151,7 +151,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.Equal(t, types.CctxStatus_Aborted, newStatus) require.Contains( t, - cctx.CctxStatus.ErrorMessage, + cctx.CctxStatus.ErrorMessageRevert, "GetRevertGasLimit: foreign coin not found for sender chain", ) }) @@ -194,7 +194,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.Equal(t, types.CctxStatus_Aborted, newStatus) require.Contains( t, - cctx.CctxStatus.ErrorMessage, + cctx.CctxStatus.ErrorMessageRevert, "chain not supported", ) }, @@ -239,7 +239,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.Equal(t, types.CctxStatus_Aborted, newStatus) require.Contains( t, - cctx.CctxStatus.ErrorMessage, + cctx.CctxStatus.ErrorMessageRevert, "chain not supported", ) }, @@ -284,7 +284,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.NoError(t, err) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, types.CctxStatus_Aborted, newStatus) - require.Contains(t, cctx.CctxStatus.ErrorMessage, "cannot find receiver chain nonce") + require.Contains(t, cctx.CctxStatus.ErrorMessageRevert, "cannot find receiver chain nonce") }) t.Run("unable to process zevm deposit HandleEVMDeposit revert successfully", func(t *testing.T) { @@ -361,7 +361,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.Equal(t, types.CctxStatus_Aborted, newStatus) require.Contains( t, - cctx.CctxStatus.ErrorMessage, + cctx.CctxStatus.ErrorMessageRevert, "cannot revert a revert tx", ) }, diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go index 7e2505b01e..a0289de91a 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go @@ -41,7 +41,10 @@ func (k msgServer) AbortStuckCCTX( } // update the status - cctx.CctxStatus.UpdateStatusAndErrorMessages(types.CctxStatus_Aborted, AbortMessage, "") + cctx.CctxStatus.UpdateStatusAndErrorMessages( + types.CctxStatus_Aborted, + types.StatusMessages{StatusMessage: AbortMessage}, + ) // Save out outbound, // We do not need to provide the tss-pubkey as NonceToCctx is not updated / New outbound is not added diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index 7fc5c9be99..8607bcf0f0 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -304,7 +304,7 @@ func TestStatus_UpdateCctxStatus(t *testing.T) { for _, test := range tt { test := test t.Run(test.Name, func(t *testing.T) { - test.Status.UpdateStatusAndErrorMessages(test.NonErrStatus, test.Msg, "") + test.Status.UpdateStatusAndErrorMessages(test.NonErrStatus, types.StatusMessages{StatusMessage: test.Msg}) if test.IsErr { require.Equal(t, test.ErrStatus, test.Status.Status) } else { diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index a940c9c7db..d187eb4e57 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -193,7 +193,10 @@ SaveFailedOutbound saves a failed outbound transaction.It does the following thi */ func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, tssPubkey string) { - cctx.SetAbort("", errMessage) + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "Outbound Failed", + ErrorMessageOutbound: errMessage, + }) ctx.Logger().Error(errMessage) k.SaveOutbound(ctx, cctx, tssPubkey) } diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index b2354a79e1..222615c172 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -183,28 +183,28 @@ func (m *CrossChainTx) AddOutbound( } // SetAbort sets the CCTX status to Aborted with the given error message. -func (m CrossChainTx) SetAbort(statusMsg, errorMsg string) { - m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_Aborted, statusMsg, errorMsg) +func (m CrossChainTx) SetAbort(messages StatusMessages) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_Aborted, messages) } // SetPendingRevert sets the CCTX status to PendingRevert with the given error message. -func (m CrossChainTx) SetPendingRevert(statusMsg, errorMsg string) { - m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_PendingRevert, statusMsg, errorMsg) +func (m CrossChainTx) SetPendingRevert(messages StatusMessages) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_PendingRevert, messages) } // SetPendingOutbound sets the CCTX status to PendingOutbound with the given error message. -func (m CrossChainTx) SetPendingOutbound(statusMsg string) { - m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_PendingOutbound, statusMsg, "") +func (m CrossChainTx) SetPendingOutbound(messages StatusMessages) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_PendingOutbound, messages) } // SetOutboundMined sets the CCTX status to OutboundMined with the given error message. -func (m CrossChainTx) SetOutboundMined(statusMsg string) { - m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_OutboundMined, statusMsg, "") +func (m CrossChainTx) SetOutboundMined(messages StatusMessages) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_OutboundMined, messages) } // SetReverted sets the CCTX status to Reverted with the given error message. -func (m CrossChainTx) SetReverted(statusMsg, errorMsg string) { - m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_Reverted, statusMsg, errorMsg) +func (m CrossChainTx) SetReverted(messages StatusMessages) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_Reverted, messages) } func (m CrossChainTx) GetCCTXIndexBytes() ([32]byte, error) { diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 1369e2dee0..c9a707b987 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -186,44 +186,69 @@ func Test_SetRevertOutboundValues(t *testing.T) { func TestCrossChainTx_SetAbort(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound - cctx.SetAbort("test", "test") + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageOutbound: "error outbound", + ErrorMessageRevert: "error revert", + }) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) - require.Contains(t, cctx.CctxStatus.StatusMessage, "test") - require.Contains(t, cctx.CctxStatus.ErrorMessage, "test") + require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") + require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") + require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetPendingRevert(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound - cctx.SetPendingRevert("test", "test") + cctx.SetPendingRevert(types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageOutbound: "error outbound", + ErrorMessageRevert: "error revert", + }) require.Equal(t, types.CctxStatus_PendingRevert, cctx.CctxStatus.Status) - require.Contains(t, cctx.CctxStatus.StatusMessage, "test") - require.Contains(t, cctx.CctxStatus.ErrorMessage, "test") + require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") + require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") + require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetPendingOutbound(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingInbound - cctx.SetPendingOutbound("test") + cctx.SetPendingOutbound(types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageOutbound: "error outbound", + ErrorMessageRevert: "error revert", + }) require.Equal(t, types.CctxStatus_PendingOutbound, cctx.CctxStatus.Status) - require.Contains(t, cctx.CctxStatus.StatusMessage, "test") - require.NotContains(t, cctx.CctxStatus.ErrorMessage, "test") + require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") + require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") + require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetOutboundMined(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound - cctx.SetOutboundMined("test") + cctx.SetOutboundMined(types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageOutbound: "error outbound", + ErrorMessageRevert: "error revert", + }) require.Equal(t, types.CctxStatus_OutboundMined, cctx.CctxStatus.Status) - require.Contains(t, cctx.CctxStatus.StatusMessage, "test") - require.NotContains(t, cctx.CctxStatus.ErrorMessage, "test") + require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") + require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") + require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetReverted(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingRevert - cctx.SetReverted("test", "test") + cctx.SetReverted(types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageOutbound: "error outbound", + ErrorMessageRevert: "error revert", + }) require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) - require.Contains(t, cctx.CctxStatus.StatusMessage, "test") - require.Contains(t, cctx.CctxStatus.ErrorMessage, "test") + require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") + require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") + require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } diff --git a/x/crosschain/types/cross_chain_tx.pb.go b/x/crosschain/types/cross_chain_tx.pb.go index 11ebc77bb3..71954e9201 100644 --- a/x/crosschain/types/cross_chain_tx.pb.go +++ b/x/crosschain/types/cross_chain_tx.pb.go @@ -509,6 +509,9 @@ type Status struct { IsAbortRefunded bool `protobuf:"varint,4,opt,name=isAbortRefunded,proto3" json:"isAbortRefunded,omitempty"` // when the CCTX was created. only populated on new transactions. CreatedTimestamp int64 `protobuf:"varint,5,opt,name=created_timestamp,json=createdTimestamp,proto3" json:"created_timestamp,omitempty"` + // error_message_revert carries information about the revert outbound tx , + // which is created if the first outbound tx fails + ErrorMessageRevert string `protobuf:"bytes,7,opt,name=error_message_revert,json=errorMessageRevert,proto3" json:"error_message_revert,omitempty"` } func (m *Status) Reset() { *m = Status{} } @@ -586,6 +589,76 @@ func (m *Status) GetCreatedTimestamp() int64 { return 0 } +func (m *Status) GetErrorMessageRevert() string { + if m != nil { + return m.ErrorMessageRevert + } + return "" +} + +// StatusMessages is a message that carries status and error messages for a +// cctx Currently this is only used internally to pass messages when updating +// the status +type StatusMessages struct { + StatusMessage string `protobuf:"bytes,1,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` + ErrorMessageOutbound string `protobuf:"bytes,2,opt,name=error_message_outbound,json=errorMessageOutbound,proto3" json:"error_message_outbound,omitempty"` + ErrorMessageRevert string `protobuf:"bytes,3,opt,name=error_message_revert,json=errorMessageRevert,proto3" json:"error_message_revert,omitempty"` +} + +func (m *StatusMessages) Reset() { *m = StatusMessages{} } +func (m *StatusMessages) String() string { return proto.CompactTextString(m) } +func (*StatusMessages) ProtoMessage() {} +func (*StatusMessages) Descriptor() ([]byte, []int) { + return fileDescriptor_d4c1966807fb5cb2, []int{5} +} +func (m *StatusMessages) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StatusMessages) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StatusMessages.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StatusMessages) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatusMessages.Merge(m, src) +} +func (m *StatusMessages) XXX_Size() int { + return m.Size() +} +func (m *StatusMessages) XXX_DiscardUnknown() { + xxx_messageInfo_StatusMessages.DiscardUnknown(m) +} + +var xxx_messageInfo_StatusMessages proto.InternalMessageInfo + +func (m *StatusMessages) GetStatusMessage() string { + if m != nil { + return m.StatusMessage + } + return "" +} + +func (m *StatusMessages) GetErrorMessageOutbound() string { + if m != nil { + return m.ErrorMessageOutbound + } + return "" +} + +func (m *StatusMessages) GetErrorMessageRevert() string { + if m != nil { + return m.ErrorMessageRevert + } + return "" +} + // RevertOptions represents the options for reverting a cctx type RevertOptions struct { RevertAddress string `protobuf:"bytes,1,opt,name=revert_address,json=revertAddress,proto3" json:"revert_address,omitempty"` @@ -599,7 +672,7 @@ func (m *RevertOptions) Reset() { *m = RevertOptions{} } func (m *RevertOptions) String() string { return proto.CompactTextString(m) } func (*RevertOptions) ProtoMessage() {} func (*RevertOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_d4c1966807fb5cb2, []int{5} + return fileDescriptor_d4c1966807fb5cb2, []int{6} } func (m *RevertOptions) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -672,7 +745,7 @@ func (m *CrossChainTx) Reset() { *m = CrossChainTx{} } func (m *CrossChainTx) String() string { return proto.CompactTextString(m) } func (*CrossChainTx) ProtoMessage() {} func (*CrossChainTx) Descriptor() ([]byte, []int) { - return fileDescriptor_d4c1966807fb5cb2, []int{6} + return fileDescriptor_d4c1966807fb5cb2, []int{7} } func (m *CrossChainTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -766,6 +839,7 @@ func init() { proto.RegisterType((*CallOptions)(nil), "zetachain.zetacore.crosschain.CallOptions") proto.RegisterType((*OutboundParams)(nil), "zetachain.zetacore.crosschain.OutboundParams") proto.RegisterType((*Status)(nil), "zetachain.zetacore.crosschain.Status") + proto.RegisterType((*StatusMessages)(nil), "zetachain.zetacore.crosschain.StatusMessages") proto.RegisterType((*RevertOptions)(nil), "zetachain.zetacore.crosschain.RevertOptions") proto.RegisterType((*CrossChainTx)(nil), "zetachain.zetacore.crosschain.CrossChainTx") } @@ -775,94 +849,97 @@ func init() { } var fileDescriptor_d4c1966807fb5cb2 = []byte{ - // 1378 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4d, 0x6f, 0x1b, 0x37, - 0x13, 0xf6, 0xda, 0xb2, 0x2c, 0x8d, 0x3e, 0xbc, 0xa6, 0x15, 0x67, 0xe3, 0x17, 0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, 0x96, - 0x75, 0xc8, 0x24, 0x24, 0x24, 0xf4, 0x6c, 0xac, 0x97, 0xf1, 0x1c, 0xdd, 0x06, 0xd7, 0x8e, 0x75, - 0xa2, 0xf6, 0xad, 0x64, 0x96, 0x2d, 0x6e, 0x45, 0x33, 0xa3, 0x8b, 0x85, 0x0f, 0xd3, 0xc5, 0x44, - 0x01, 0xa9, 0x7f, 0xa7, 0x00, 0xa9, 0x60, 0xce, 0x83, 0x98, 0xc5, 0x21, 0x51, 0x22, 0x4b, 0xf9, - 0x19, 0xc1, 0xf9, 0x23, 0x39, 0x9f, 0x4d, 0x66, 0xfa, 0x9d, 0x64, 0x1a, 0x63, 0x3f, 0xa1, 0x21, - 0x31, 0xba, 0x91, 0xc6, 0x43, 0x39, 0x47, 0x35, 0x70, 0x8d, 0x91, 0x25, 0x54, 0x8c, 0x82, 0x13, - 0x42, 0xbc, 0xab, 0x6a, 0x4d, 0x51, 0xaf, 0x51, 0xf0, 0x1e, 0x21, 0x08, 0x41, 0x4a, 0x29, 0x2f, - 0xa3, 0xac, 0x6a, 0xfc, 0x3e, 0xba, 0xb9, 0x48, 0x94, 0x70, 0xa1, 0x28, 0xaf, 0x81, 0x0c, 0x33, - 0x18, 0x70, 0x12, 0x79, 0x25, 0xb5, 0x72, 0xa9, 0x8d, 0xf9, 0x13, 0x4e, 0x22, 0xf4, 0x0d, 0xac, - 0x92, 0x93, 0x13, 0x12, 0x0a, 0x7a, 0x46, 0x82, 0xc9, 0xc7, 0x5d, 0x51, 0x29, 0xae, 0x9b, 0x14, - 0xdf, 0x7c, 0x8f, 0x14, 0xef, 0xcb, 0x5a, 0x1d, 0x53, 0xdd, 0xb7, 0x59, 0xa9, 0xbf, 0xcb, 0xaf, - 0x33, 0xbb, 0xa6, 0xa2, 0x98, 0x59, 0xaf, 0x53, 0x7c, 0x1d, 0x40, 0x1e, 0x4e, 0x7f, 0xd0, 0x3a, - 0x25, 0x23, 0x25, 0xee, 0xac, 0x2f, 0x8f, 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x71, 0xe7, 0xd4, 0x6f, 0xd3, 0x75, 0xf4, - 0x86, 0x9d, 0xfb, 0x2f, 0xde, 0x94, 0x9d, 0x97, 0x6f, 0xca, 0xce, 0xeb, 0x37, 0x65, 0xe7, 0xa7, - 0xb7, 0xe5, 0xb9, 0x97, 0x6f, 0xcb, 0x73, 0xbf, 0xbd, 0x2d, 0xcf, 0x3d, 0xdb, 0x9a, 0x52, 0x92, - 0x4c, 0xec, 0x96, 0xfe, 0x4f, 0x12, 0xb3, 0x88, 0x34, 0x86, 0xd3, 0x7f, 0x7d, 0x94, 0xa8, 0x5a, - 0x69, 0x75, 0x70, 0x77, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xa1, 0xdc, 0x72, 0x48, 0x28, 0x0d, - 0x00, 0x00, + // 1425 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcd, 0x6e, 0x5b, 0xc5, + 0x17, 0xcf, 0x4d, 0x1c, 0xc7, 0x3e, 0xfe, 0xc8, 0xcd, 0xc4, 0x4d, 0x6f, 0xf3, 0x57, 0xd3, 0xfc, + 0x0d, 0x69, 0xdd, 0x40, 0x6c, 0xea, 0x22, 0x84, 0xd8, 0x25, 0x51, 0xd3, 0x06, 0x68, 0x13, 0xdd, + 0xa6, 0x91, 0xda, 0x05, 0x97, 0xf1, 0xbd, 0x13, 0x7b, 0x14, 0xfb, 0x8e, 0xb9, 0x33, 0x8e, 0xec, + 0x8a, 0x1d, 0x6b, 0x24, 0xde, 0x80, 0x0d, 0x0b, 0x1e, 0xa5, 0xcb, 0x4a, 0x6c, 0x10, 0x8b, 0x52, + 0xb5, 0x6f, 0xc0, 0x13, 0xa0, 0xf9, 0xf2, 0x47, 0xe5, 0x26, 0xa5, 0xb0, 0xf2, 0xf9, 0x98, 0xf3, + 0x3b, 0xe7, 0x9e, 0x99, 0xdf, 0x99, 0x31, 0xd4, 0x9f, 0x12, 0x81, 0xc3, 0x16, 0xa6, 0x71, 0x4d, + 0x49, 0x2c, 0x21, 0xb5, 0x30, 0x61, 0x9c, 0x6b, 0x9b, 0x12, 0x03, 0x25, 0x07, 0xa2, 0x5f, 0xed, + 0x26, 0x4c, 0x30, 0x74, 0x75, 0x18, 0x53, 0xb5, 0x31, 0xd5, 0x51, 0xcc, 0x6a, 0xa9, 0xc9, 0x9a, + 0x4c, 0xad, 0xac, 0x49, 0x49, 0x07, 0xad, 0x5e, 0x9f, 0x92, 0xa8, 0x7b, 0xda, 0xac, 0x85, 0x4c, + 0xa6, 0x61, 0x34, 0xd6, 0xeb, 0xca, 0x7f, 0xa6, 0xa0, 0xb0, 0x1f, 0x37, 0x58, 0x2f, 0x8e, 0x0e, + 0x71, 0x82, 0x3b, 0x1c, 0xad, 0x40, 0x9a, 0x93, 0x38, 0x22, 0x89, 0xe7, 0xac, 0x3b, 0x95, 0xac, + 0x6f, 0x34, 0x74, 0x1d, 0x16, 0xb5, 0x64, 0xea, 0xa3, 0x91, 0x37, 0xbb, 0xee, 0x54, 0xe6, 0xfc, + 0x82, 0x36, 0xef, 0x4a, 0xeb, 0x7e, 0x84, 0xfe, 0x07, 0x59, 0xd1, 0x0f, 0x58, 0x42, 0x9b, 0x34, + 0xf6, 0xe6, 0x14, 0x44, 0x46, 0xf4, 0x0f, 0x94, 0x8e, 0x76, 0x20, 0x2b, 0x93, 0x07, 0x62, 0xd0, + 0x25, 0x5e, 0x6a, 0xdd, 0xa9, 0x14, 0xeb, 0x1b, 0xd5, 0x29, 0xdf, 0xd7, 0x3d, 0x6d, 0x56, 0x55, + 0x95, 0xbb, 0x8c, 0xc6, 0x47, 0x83, 0x2e, 0xf1, 0x33, 0xa1, 0x91, 0x50, 0x09, 0xe6, 0x31, 0xe7, + 0x44, 0x78, 0xf3, 0x0a, 0x5c, 0x2b, 0xe8, 0x2e, 0xa4, 0x71, 0x87, 0xf5, 0x62, 0xe1, 0xa5, 0xa5, + 0x79,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7b, 0xf9, 0x75, 0xa7, 0x92, 0xf1, 0x5d, 0xca, 0x77, 0xa5, 0x47, + 0x9d, 0x86, 0x5d, 0xdc, 0x6e, 0x97, 0xbf, 0x83, 0xa2, 0xac, 0x73, 0x3b, 0x0c, 0x65, 0x7b, 0x69, + 0xdc, 0x44, 0x01, 0x2c, 0xe3, 0x06, 0x4b, 0x84, 0xfd, 0x3a, 0xb3, 0x6f, 0xce, 0xfb, 0xed, 0xdb, + 0x92, 0xc1, 0x52, 0x49, 0x14, 0x52, 0xf9, 0x18, 0x72, 0x32, 0xf5, 0x41, 0x57, 0x56, 0xcd, 0xe5, + 0x89, 0x6c, 0x62, 0x1e, 0xb4, 0x69, 0x87, 0xea, 0x2c, 0x29, 0x3f, 0xd3, 0xc4, 0xfc, 0x6b, 0xa9, + 0xa3, 0x4d, 0x58, 0xa2, 0x3c, 0xc0, 0x49, 0x83, 0x8a, 0x04, 0x27, 0x03, 0xfd, 0x2d, 0xb3, 0xea, + 0x5b, 0x16, 0x29, 0xdf, 0xb6, 0x76, 0xf5, 0x29, 0x2f, 0xd3, 0x50, 0x3c, 0xe8, 0x89, 0x71, 0xb6, + 0xac, 0x42, 0x26, 0x21, 0x21, 0xa1, 0x67, 0x43, 0xbe, 0x0c, 0x75, 0x74, 0x13, 0x5c, 0x2b, 0xeb, + 0x46, 0xed, 0x5b, 0xca, 0x2c, 0x5a, 0xbb, 0x25, 0xcd, 0x04, 0x2f, 0xe6, 0xde, 0x8f, 0x17, 0x23, + 0x06, 0xa4, 0xfe, 0x1d, 0x03, 0x24, 0x83, 0x39, 0x0f, 0x62, 0x16, 0x87, 0x44, 0x91, 0x2c, 0xe5, + 0x67, 0x04, 0xe7, 0x0f, 0xa4, 0x3e, 0xd9, 0xcc, 0xf4, 0x1b, 0xcd, 0x34, 0xce, 0x6e, 0x42, 0x43, + 0x62, 0x78, 0x23, 0x9d, 0x87, 0x52, 0x47, 0x15, 0x70, 0x8d, 0x93, 0x25, 0x54, 0x0c, 0x82, 0x13, + 0x42, 0xbc, 0xcb, 0x6a, 0x4d, 0x51, 0xaf, 0x51, 0xe6, 0x3d, 0x42, 0x10, 0x82, 0x94, 0x62, 0x5e, + 0x46, 0x79, 0x95, 0xfc, 0x2e, 0xbc, 0x39, 0x8f, 0x94, 0x70, 0x2e, 0x29, 0xaf, 0x80, 0x2c, 0x33, + 0xe8, 0x71, 0x12, 0x79, 0x25, 0xb5, 0x72, 0xa1, 0x89, 0xf9, 0x23, 0x4e, 0x22, 0xf4, 0x0d, 0x2c, + 0x93, 0x93, 0x13, 0x12, 0x0a, 0x7a, 0x46, 0x82, 0xd1, 0xc7, 0x5d, 0x52, 0x2d, 0xae, 0x9a, 0x16, + 0x5f, 0x7f, 0x87, 0x16, 0xef, 0xcb, 0xb3, 0x3a, 0x84, 0xba, 0x6b, 0xbb, 0x52, 0x7d, 0x13, 0x5f, + 0x77, 0x76, 0x45, 0x55, 0x31, 0xb1, 0x5e, 0xb7, 0xf8, 0x2a, 0x80, 0xdc, 0x9c, 0x6e, 0xaf, 0x71, + 0x4a, 0x06, 0x8a, 0xdc, 0x59, 0x5f, 0x6e, 0xd7, 0xa1, 0x32, 0x9c, 0x33, 0x07, 0xf2, 0xff, 0xf5, + 0x1c, 0xb8, 0x0f, 0x79, 0x49, 0x96, 0x80, 0x69, 0x9a, 0x79, 0xde, 0xba, 0x53, 0xc9, 0xd5, 0x37, + 0x2f, 0x48, 0x30, 0x46, 0x4c, 0x3f, 0x17, 0x8e, 0x94, 0x2f, 0x53, 0x99, 0x82, 0x5b, 0x2a, 0xff, + 0x36, 0x0b, 0x69, 0x83, 0xbf, 0x0d, 0x69, 0x53, 0xba, 0xa3, 0x4a, 0xbf, 0x79, 0x11, 0x72, 0x28, + 0xfa, 0xa6, 0x60, 0x13, 0x88, 0x36, 0xa0, 0xa8, 0xa5, 0xa0, 0x43, 0x38, 0xc7, 0x4d, 0xa2, 0xf8, + 0x97, 0xf5, 0x0b, 0xda, 0x7a, 0x5f, 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5, 0x99, 0x27, 0x5b, 0x63, 0x4c, 0x92, 0x8d, + 0xdd, 0xd2, 0xff, 0xb3, 0x62, 0x16, 0x91, 0x5a, 0x7f, 0xfc, 0xef, 0x9c, 0x22, 0x55, 0x23, 0xad, + 0x36, 0xee, 0xf6, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x71, 0x5e, 0xf4, 0xef, 0xfc, 0x0d, 0x00, + 0x00, } func (m *InboundParams) Marshal() (dAtA []byte, err error) { @@ -1206,6 +1283,13 @@ func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ErrorMessageRevert) > 0 { + i -= len(m.ErrorMessageRevert) + copy(dAtA[i:], m.ErrorMessageRevert) + i = encodeVarintCrossChainTx(dAtA, i, uint64(len(m.ErrorMessageRevert))) + i-- + dAtA[i] = 0x3a + } if len(m.ErrorMessage) > 0 { i -= len(m.ErrorMessage) copy(dAtA[i:], m.ErrorMessage) @@ -1248,6 +1332,50 @@ func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StatusMessages) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StatusMessages) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StatusMessages) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ErrorMessageRevert) > 0 { + i -= len(m.ErrorMessageRevert) + copy(dAtA[i:], m.ErrorMessageRevert) + i = encodeVarintCrossChainTx(dAtA, i, uint64(len(m.ErrorMessageRevert))) + i-- + dAtA[i] = 0x1a + } + if len(m.ErrorMessageOutbound) > 0 { + i -= len(m.ErrorMessageOutbound) + copy(dAtA[i:], m.ErrorMessageOutbound) + i = encodeVarintCrossChainTx(dAtA, i, uint64(len(m.ErrorMessageOutbound))) + i-- + dAtA[i] = 0x12 + } + if len(m.StatusMessage) > 0 { + i -= len(m.StatusMessage) + copy(dAtA[i:], m.StatusMessage) + i = encodeVarintCrossChainTx(dAtA, i, uint64(len(m.StatusMessage))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *RevertOptions) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1596,6 +1724,31 @@ func (m *Status) Size() (n int) { if l > 0 { n += 1 + l + sovCrossChainTx(uint64(l)) } + l = len(m.ErrorMessageRevert) + if l > 0 { + n += 1 + l + sovCrossChainTx(uint64(l)) + } + return n +} + +func (m *StatusMessages) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StatusMessage) + if l > 0 { + n += 1 + l + sovCrossChainTx(uint64(l)) + } + l = len(m.ErrorMessageOutbound) + if l > 0 { + n += 1 + l + sovCrossChainTx(uint64(l)) + } + l = len(m.ErrorMessageRevert) + if l > 0 { + n += 1 + l + sovCrossChainTx(uint64(l)) + } return n } @@ -2873,6 +3026,184 @@ func (m *Status) Unmarshal(dAtA []byte) error { } m.ErrorMessage = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessageRevert", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrossChainTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCrossChainTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCrossChainTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrorMessageRevert = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCrossChainTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCrossChainTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StatusMessages) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrossChainTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StatusMessages: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatusMessages: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusMessage", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrossChainTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCrossChainTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCrossChainTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StatusMessage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessageOutbound", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrossChainTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCrossChainTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCrossChainTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrorMessageOutbound = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessageRevert", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrossChainTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCrossChainTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCrossChainTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ErrorMessageRevert = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipCrossChainTx(dAtA[iNdEx:]) diff --git a/x/crosschain/types/status.go b/x/crosschain/types/status.go index 5ebdf5391c..3a8be26fdc 100644 --- a/x/crosschain/types/status.go +++ b/x/crosschain/types/status.go @@ -9,19 +9,23 @@ func (m *Status) AbortRefunded() { m.StatusMessage = "CCTX aborted and Refunded" } -// UpdateStatusAndErrorMessages transitions the Status and Error messages. -func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, statusMsg, errorMsg string) { - m.UpdateStatus(newStatus, statusMsg) +//// UpdateStatusAndErrorMessages transitions the Status and Error messages. +//func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, statusMsg, errorMsg string) { +// m.UpdateStatus(newStatus) +// +// if errorMsg != "" { +// m.UpdateErrorMessage(errorMsg) +// } +//} - if errorMsg != "" { - m.UpdateErrorMessage(errorMsg) - } +func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, messages StatusMessages) { + m.UpdateStatus(newStatus) + m.UpdateErrorMessages(messages) } -// UpdateStatus updates the cctx status and cctx.status.status_message. -func (m *Status) UpdateStatus(newStatus CctxStatus, statusMsg string) { +// UpdateStatus updates the cctx status +func (m *Status) UpdateStatus(newStatus CctxStatus) { if m.ValidateTransition(newStatus) { - m.StatusMessage = fmt.Sprintf("Status changed from %s to %s", m.Status.String(), newStatus.String()) m.Status = newStatus } else { m.StatusMessage = fmt.Sprintf( @@ -29,15 +33,36 @@ func (m *Status) UpdateStatus(newStatus CctxStatus, statusMsg string) { m.Status.String(), newStatus.String(), ) - m.Status = CctxStatus_Aborted } +} - if statusMsg != "" { - m.StatusMessage += fmt.Sprintf(": %s", statusMsg) - } +func (m *Status) UpdateErrorMessages(messages StatusMessages) { + m.StatusMessage = messages.StatusMessage + m.ErrorMessage = messages.ErrorMessageOutbound + m.ErrorMessageRevert = messages.ErrorMessageRevert } +//// UpdateStatus updates the cctx status and cctx.status.status_message. +//func (m *Status) UpdateStatus(newStatus CctxStatus, statusMsg string) { +// if m.ValidateTransition(newStatus) { +// m.StatusMessage = fmt.Sprintf("Status changed from %s to %s", m.Status.String(), newStatus.String()) +// m.Status = newStatus +// } else { +// m.StatusMessage = fmt.Sprintf( +// "Failed to transition status from %s to %s", +// m.Status.String(), +// newStatus.String(), +// ) +// +// m.Status = CctxStatus_Aborted +// } +// +// if statusMsg != "" { +// m.StatusMessage += fmt.Sprintf(": %s", statusMsg) +// } +//} + // UpdateErrorMessage updates cctx.status.error_message. func (m *Status) UpdateErrorMessage(errorMsg string) { errMsg := errorMsg diff --git a/x/crosschain/types/status_test.go b/x/crosschain/types/status_test.go index f808f6e296..ef94d916e0 100644 --- a/x/crosschain/types/status_test.go +++ b/x/crosschain/types/status_test.go @@ -1,7 +1,6 @@ package types_test import ( - "fmt" "testing" "github.com/stretchr/testify/assert" @@ -140,38 +139,21 @@ func TestStatus_ChangeStatus(t *testing.T) { t.Run("should change status and msg if transition is valid", func(t *testing.T) { s := types.Status{Status: types.CctxStatus_PendingInbound} - s.UpdateStatus(types.CctxStatus_PendingOutbound, "msg") + s.UpdateStatus(types.CctxStatus_PendingOutbound) assert.Equal(t, s.Status, types.CctxStatus_PendingOutbound) - assert.Equal(t, s.StatusMessage, "Status changed from PendingInbound to PendingOutbound: msg") }) t.Run("should change status if transition is valid", func(t *testing.T) { s := types.Status{Status: types.CctxStatus_PendingInbound} - s.UpdateStatus(types.CctxStatus_PendingOutbound, "") - fmt.Printf("%+v\n", s) + s.UpdateStatus(types.CctxStatus_PendingOutbound) assert.Equal(t, s.Status, types.CctxStatus_PendingOutbound) - assert.Equal(t, s.StatusMessage, fmt.Sprintf( - "Status changed from %s to %s", - types.CctxStatus_PendingInbound.String(), - types.CctxStatus_PendingOutbound.String()), - ) }) t.Run("should change status to aborted and msg if transition is invalid", func(t *testing.T) { s := types.Status{Status: types.CctxStatus_PendingOutbound} - - s.UpdateStatus(types.CctxStatus_PendingInbound, "msg") + s.UpdateStatus(types.CctxStatus_PendingInbound) assert.Equal(t, s.Status, types.CctxStatus_Aborted) - assert.Equal( - t, - fmt.Sprintf( - "Failed to transition status from %s to %s: msg", - types.CctxStatus_PendingOutbound.String(), - types.CctxStatus_PendingInbound.String(), - ), - s.StatusMessage, - ) }) } diff --git a/x/crosschain/types/tx.pb.go b/x/crosschain/types/tx.pb.go index bd4c1845ac..00fd7dd6bd 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -1001,9 +1001,9 @@ type MsgVoteInbound struct { SenderChainId int64 `protobuf:"varint,3,opt,name=sender_chain_id,json=senderChainId,proto3" json:"sender_chain_id,omitempty"` Receiver string `protobuf:"bytes,4,opt,name=receiver,proto3" json:"receiver,omitempty"` ReceiverChain int64 `protobuf:"varint,5,opt,name=receiver_chain,json=receiverChain,proto3" json:"receiver_chain,omitempty"` - // string zeta_burnt = 6; + // string zeta_burnt = 6; Amount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,6,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"amount"` - // string mMint = 7; + // string mMint = 7; Message string `protobuf:"bytes,8,opt,name=message,proto3" json:"message,omitempty"` InboundHash string `protobuf:"bytes,9,opt,name=inbound_hash,json=inboundHash,proto3" json:"inbound_hash,omitempty"` InboundBlockHeight uint64 `protobuf:"varint,10,opt,name=inbound_block_height,json=inboundBlockHeight,proto3" json:"inbound_block_height,omitempty"` From 7380d27cc5c1ef71610791df70176b3ec9828f83 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 3 Jan 2025 13:04:14 -0500 Subject: [PATCH 02/13] update test to use new status message fields --- ...tcoin_deposit_and_call_revert_with_dust.go | 5 +- .../keeper/msg_server_abort_stuck_cctx.go | 8 +-- x/crosschain/types/cctx_test.go | 52 +++++++------- x/crosschain/types/status.go | 51 +++---------- x/crosschain/types/status_test.go | 71 +++++++++++++++++++ 5 files changed, 115 insertions(+), 72 deletions(-) diff --git a/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go index 9e3606759b..b223ebcc78 100644 --- a/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go +++ b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go @@ -52,5 +52,8 @@ func TestBitcoinDepositAndCallRevertWithDust(r *runner.E2ERunner, args []string) cctx := utils.WaitCctxAbortedByInboundHash(r.Ctx, r, txHash.String(), r.CctxClient) require.True(r, cctx.GetCurrentOutboundParam().Amount.Uint64() < constant.BTCWithdrawalDustAmount) - require.True(r, strings.Contains(cctx.CctxStatus.ErrorMessage, crosschaintypes.ErrInvalidWithdrawalAmount.Error())) + require.True( + r, + strings.Contains(cctx.CctxStatus.ErrorMessageRevert, crosschaintypes.ErrInvalidWithdrawalAmount.Error()), + ) } diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go index a0289de91a..f97b85dd8a 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go @@ -41,10 +41,10 @@ func (k msgServer) AbortStuckCCTX( } // update the status - cctx.CctxStatus.UpdateStatusAndErrorMessages( - types.CctxStatus_Aborted, - types.StatusMessages{StatusMessage: AbortMessage}, - ) + + cctx.SetAbort(types.StatusMessages{ + StatusMessage: AbortMessage, + }) // Save out outbound, // We do not need to provide the tss-pubkey as NonceToCctx is not updated / New outbound is not added diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index c9a707b987..12ec17c48b 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -184,17 +184,29 @@ func Test_SetRevertOutboundValues(t *testing.T) { } func TestCrossChainTx_SetAbort(t *testing.T) { - cctx := sample.CrossChainTx(t, "test") - cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound - cctx.SetAbort(types.StatusMessages{ - StatusMessage: "status message", - ErrorMessageOutbound: "error outbound", - ErrorMessageRevert: "error revert", + t.Run("set abort from pending revert", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + cctx.CctxStatus.Status = types.CctxStatus_PendingRevert + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageRevert: "error revert", + }) + require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) + require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") + require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") + }) + + t.Run("set abort from pending outbound", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound + cctx.SetAbort(types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageOutbound: "error outbound", + }) + require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) + require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") + require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") }) - require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) - require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") - require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") - require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetPendingRevert(t *testing.T) { @@ -203,52 +215,40 @@ func TestCrossChainTx_SetPendingRevert(t *testing.T) { cctx.SetPendingRevert(types.StatusMessages{ StatusMessage: "status message", ErrorMessageOutbound: "error outbound", - ErrorMessageRevert: "error revert", }) require.Equal(t, types.CctxStatus_PendingRevert, cctx.CctxStatus.Status) require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") - require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetPendingOutbound(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingInbound cctx.SetPendingOutbound(types.StatusMessages{ - StatusMessage: "status message", - ErrorMessageOutbound: "error outbound", - ErrorMessageRevert: "error revert", + StatusMessage: "status message", }) require.Equal(t, types.CctxStatus_PendingOutbound, cctx.CctxStatus.Status) require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") - require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") - require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetOutboundMined(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound cctx.SetOutboundMined(types.StatusMessages{ - StatusMessage: "status message", - ErrorMessageOutbound: "error outbound", - ErrorMessageRevert: "error revert", + StatusMessage: "status message", }) require.Equal(t, types.CctxStatus_OutboundMined, cctx.CctxStatus.Status) require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") - require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") - require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } func TestCrossChainTx_SetReverted(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingRevert cctx.SetReverted(types.StatusMessages{ - StatusMessage: "status message", - ErrorMessageOutbound: "error outbound", - ErrorMessageRevert: "error revert", + StatusMessage: "status message", + ErrorMessageRevert: "error revert", }) require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) require.Equal(t, cctx.CctxStatus.StatusMessage, "status message") - require.Equal(t, cctx.CctxStatus.ErrorMessage, "error outbound") require.Equal(t, cctx.CctxStatus.ErrorMessageRevert, "error revert") } diff --git a/x/crosschain/types/status.go b/x/crosschain/types/status.go index 3a8be26fdc..ff1c14920e 100644 --- a/x/crosschain/types/status.go +++ b/x/crosschain/types/status.go @@ -9,15 +9,6 @@ func (m *Status) AbortRefunded() { m.StatusMessage = "CCTX aborted and Refunded" } -//// UpdateStatusAndErrorMessages transitions the Status and Error messages. -//func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, statusMsg, errorMsg string) { -// m.UpdateStatus(newStatus) -// -// if errorMsg != "" { -// m.UpdateErrorMessage(errorMsg) -// } -//} - func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, messages StatusMessages) { m.UpdateStatus(newStatus) m.UpdateErrorMessages(messages) @@ -37,41 +28,19 @@ func (m *Status) UpdateStatus(newStatus CctxStatus) { } } +// UpdateErrorMessages updates cctx.status.error_message and cctx.status.error_message_revert. func (m *Status) UpdateErrorMessages(messages StatusMessages) { + // Always update the status message , status should contain only the most recent update m.StatusMessage = messages.StatusMessage - m.ErrorMessage = messages.ErrorMessageOutbound - m.ErrorMessageRevert = messages.ErrorMessageRevert -} - -//// UpdateStatus updates the cctx status and cctx.status.status_message. -//func (m *Status) UpdateStatus(newStatus CctxStatus, statusMsg string) { -// if m.ValidateTransition(newStatus) { -// m.StatusMessage = fmt.Sprintf("Status changed from %s to %s", m.Status.String(), newStatus.String()) -// m.Status = newStatus -// } else { -// m.StatusMessage = fmt.Sprintf( -// "Failed to transition status from %s to %s", -// m.Status.String(), -// newStatus.String(), -// ) -// -// m.Status = CctxStatus_Aborted -// } -// -// if statusMsg != "" { -// m.StatusMessage += fmt.Sprintf(": %s", statusMsg) -// } -//} - -// UpdateErrorMessage updates cctx.status.error_message. -func (m *Status) UpdateErrorMessage(errorMsg string) { - errMsg := errorMsg - - if errMsg == "" { - errMsg = "unknown error" + // We should be updating only one of these two messages at a time + if messages.ErrorMessageOutbound != "" { + m.ErrorMessage = messages.ErrorMessageOutbound + return + } + if messages.ErrorMessageRevert != "" { + m.ErrorMessageRevert = messages.ErrorMessageRevert + return } - - m.ErrorMessage = errMsg } func (m *Status) ValidateTransition(newStatus CctxStatus) bool { diff --git a/x/crosschain/types/status_test.go b/x/crosschain/types/status_test.go index ef94d916e0..a73a1b5cb7 100644 --- a/x/crosschain/types/status_test.go +++ b/x/crosschain/types/status_test.go @@ -198,3 +198,74 @@ func TestCctxStatus_IsPendingStatus(t *testing.T) { }) } } + +func TestStatus_UpdateErrorMessages(t *testing.T) { + t.Run("should update only status message if error message outbound is empty", func(t *testing.T) { + m := types.Status{ + StatusMessage: "old status message", + ErrorMessage: "old error message", + ErrorMessageRevert: "old error message revert", + } + messages := types.StatusMessages{ + StatusMessage: "status message", + } + m.UpdateErrorMessages(messages) + require.Equal(t, messages.StatusMessage, m.StatusMessage) + require.Equal(t, "old error message", m.ErrorMessage) + require.Equal(t, "old error message revert", m.ErrorMessageRevert) + }) + + t.Run("should update only status message and revert message if outbound message is empty", func(t *testing.T) { + m := types.Status{ + StatusMessage: "old status message", + ErrorMessage: "old error message", + ErrorMessageRevert: "old error message revert", + } + messages := types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageRevert: "error message revert", + } + m.UpdateErrorMessages(messages) + require.Equal(t, messages.StatusMessage, m.StatusMessage) + require.Equal(t, "old error message", m.ErrorMessage) + require.Equal(t, messages.ErrorMessageRevert, m.ErrorMessageRevert) + }) + + t.Run("should update only status message and outbound message if revert message is empty", func(t *testing.T) { + m := types.Status{ + StatusMessage: "old status message", + ErrorMessage: "old error message", + ErrorMessageRevert: "old error message revert", + } + messages := types.StatusMessages{ + StatusMessage: "status message", + ErrorMessageOutbound: "error message outbound", + } + m.UpdateErrorMessages(messages) + require.Equal(t, messages.StatusMessage, m.StatusMessage) + require.Equal(t, messages.ErrorMessageOutbound, m.ErrorMessage) + require.Equal(t, "old error message revert", m.ErrorMessageRevert) + }) + + t.Run("multiple updates to status message should only keep the most recent one", func(t *testing.T) { + m := types.Status{ + StatusMessage: "old status message", + } + messages := types.StatusMessages{ + StatusMessage: "new status message 1", + ErrorMessageOutbound: "new error message outbound", + } + m.UpdateErrorMessages(messages) + require.Equal(t, messages.StatusMessage, m.StatusMessage) + require.Equal(t, messages.ErrorMessageOutbound, m.ErrorMessage) + require.Equal(t, "", m.ErrorMessageRevert) + messages2 := types.StatusMessages{ + StatusMessage: "new status message 2", + ErrorMessageRevert: "new error message revert", + } + m.UpdateErrorMessages(messages2) + require.Equal(t, messages2.StatusMessage, m.StatusMessage) + require.Equal(t, messages.ErrorMessageOutbound, m.ErrorMessage) + require.Equal(t, messages2.ErrorMessageRevert, m.ErrorMessageRevert) + }) +} From 66170ae9f422efe9fea0bb44b6c6b08d8aeaada9 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 6 Jan 2025 14:46:23 -0500 Subject: [PATCH 03/13] add function to create evm error message --- x/fungible/types/evm_error_message.go | 24 +++++++++++++++++ x/fungible/types/evm_error_message_test.go | 30 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 x/fungible/types/evm_error_message.go create mode 100644 x/fungible/types/evm_error_message_test.go diff --git a/x/fungible/types/evm_error_message.go b/x/fungible/types/evm_error_message.go new file mode 100644 index 0000000000..37eaea537f --- /dev/null +++ b/x/fungible/types/evm_error_message.go @@ -0,0 +1,24 @@ +package types + +import ( + "fmt" + + "github.com/ethereum/go-ethereum/common" +) + +func EvmErrorMessage(method string, contract common.Address, args interface{}) string { + return fmt.Sprintf( + "contract call failed: method '%s', contract '%s', args: %v", + method, + contract.Hex(), + args, + ) +} + +func EvmErrorMessageWithRevertError(errorMessage string, reason interface{}) string { + return fmt.Sprintf( + "%s, reason: %v", + errorMessage, + reason, + ) +} diff --git a/x/fungible/types/evm_error_message_test.go b/x/fungible/types/evm_error_message_test.go new file mode 100644 index 0000000000..f0cacf458f --- /dev/null +++ b/x/fungible/types/evm_error_message_test.go @@ -0,0 +1,30 @@ +package types_test + +import ( + "fmt" + strings2 "strings" + "testing" +) + +func TestEvmErrorMessage(t *testing.T) { + msg := "'deposit error: contract call failed: method ''depositAndCall''," + + "contract ''0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B'', " + + "args: [{[116 98 49 113 97 106 120 113 100 97 118 103 55 113 101 48 115 54 99 48 117 113 53 120" + + "106 119 109 114 99 110 109 102 108 122 113 107 118 54 119 114 120 106] " + + "0x0000000000000000000000000000000000000000 18332} 0x65a45c57636f9BcCeD4fe193A602008578BcA90b 63200 0xE869b85987D86d8fBb8913f97A705B4741edE86E" + + " [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" + + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0" + + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 31 8 114 173 89 103 28 32 216 199 223" + + "23 218 144 178 97 227 198 29 206 71 31 177 222 58 199 57 100 26 67 128 175 0" + + "0 0 0 0 0 0 0 0 0 0 0 218 36 85 178 188 153 144 104 42 30 240 191 138 190 201" + + "21 130 93 66 147 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 53 201 173" + + "197 222 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" + + "0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65 46 162" + + " 174 30 134 233 247 163 75 144 111 131 184 223 203 158 35 65 101 101 0 0 145" + + "201 152 4 164 227 47 62 58 31 93 187 156 163 80 241 90 43 228 232 154 218 235 128 16 101 154 240 57 245 109 126 166 4 110 64 228 217 198 230 231 192 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]" + + ": execution reverted:ret 0x2cdcef78000000000000000000000000e869b85987d86d8fbb8913f97a705b4741ede86e000000000000000000000000da2455b2bc9990682a1ef0bf8abec915825d42930000000000000000000000000000000000000000000000000000000000001b59:evm transaction execution failed, processing error: outTxGasFee(127200) more than available gas for tx (63200) | Identifiers : tb1qajxqdavg7qe0s6c0uq5xjwmrcnmflzqkv6wrxj-18332-18332-0: not enough gas'" + strings := strings2.Split(msg, ",") + for i, s := range strings { + fmt.Println(i, s) + } +} From 542b4484557d4df833c169360cf0f31612942720 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 6 Jan 2025 18:44:36 -0500 Subject: [PATCH 04/13] add error message for abort zevm deposit --- docs/zetacore/status_message.md | 68 +++++++++++++++++++ x/crosschain/keeper/cctx_gateway_zevm.go | 6 +- .../cctx_orchestrator_validate_outbound.go | 17 +++-- x/crosschain/keeper/evm_deposit.go | 2 +- x/crosschain/keeper/initiate_outbound_test.go | 2 +- x/crosschain/types/cctx.go | 1 + x/crosschain/types/errors.go | 9 +-- x/crosschain/types/status.go | 5 +- x/fungible/keeper/evm.go | 27 ++++---- .../keeper/zevm_message_passing_test.go | 2 +- x/fungible/keeper/zevm_msg_passing.go | 10 ++- x/fungible/types/errors.go | 11 +++ x/fungible/types/evm_error_message.go | 37 +++++++--- x/fungible/types/evm_error_message_test.go | 42 ++++++------ 14 files changed, 175 insertions(+), 64 deletions(-) create mode 100644 docs/zetacore/status_message.md diff --git a/docs/zetacore/status_message.md b/docs/zetacore/status_message.md new file mode 100644 index 0000000000..0c61f85cbe --- /dev/null +++ b/docs/zetacore/status_message.md @@ -0,0 +1,68 @@ +# CCTX status message + +The cctx object contains a field `cctx_status` , which has the following structure +```go +type Status struct { + Status CctxStatus `protobuf:"varint,1,opt,name=status,proto3,enum=zetachain.zetacore.crosschain.CctxStatus" json:"status,omitempty"` + StatusMessage string `protobuf:"bytes,2,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` + ErrorMessage string `protobuf:"bytes,6,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` + LastUpdateTimestamp int64 `protobuf:"varint,3,opt,name=lastUpdate_timestamp,json=lastUpdateTimestamp,proto3" json:"lastUpdate_timestamp,omitempty"` + IsAbortRefunded bool `protobuf:"varint,4,opt,name=isAbortRefunded,proto3" json:"isAbortRefunded,omitempty"` + CreatedTimestamp int64 `protobuf:"varint,5,opt,name=created_timestamp,json=createdTimestamp,proto3" json:"created_timestamp,omitempty"` + ErrorMessageRevert string `protobuf:"bytes,7,opt,name=error_message_revert,json=errorMessageRevert,proto3" json:"error_message_revert,omitempty"` +} +``` + +## Status +This is the most updated status for the cctx . This can be one of the following values +- `PendingInbound` : The cctx is pending for the inbound to be finalized , this is an intermediately status used by the protocol only +- `PendingOutbound` : This means that the inbound has been finalzied, and the outbound is pending +- `OutboundMined` : The outbound has been successfully mined. This is a terminal status +- `Aborted` : The cctx has been aborted. This is a terminal status +- `PendingRevert` : The the cctx failed at some step and is pending for the revert to be finalized +- `Reverted` : The cctx has been successfully reverted. This is a terminal status + +### StatusMessage +The status message provides a some details about the current status.This is primiary meant for the user to quickly understand the status of the cctx. +### LastUpdateTimestamp +The last time the status was updated +### IsAbortRefunded +This is a boolean value which is true if the cctx has been refunded after being aborted or not . +### CreatedTimestamp +The time when the cctx was created +### ErrorMessage and ErrorMessageRevert +A cctx can have a maximum of two outbound params. +- A normal flow for a cctx is to go from `PendingOutbound` -> `OutboundMined` , which creates a single outbound +- A cctx where the outbound fails has the transition `PendingOutbound` -> `PendingRevert` -> `Reverted` , which creates two outbounds +- Any of the above two flows can abort the cctx at some point that can create either one or two outbounds + + - The `ErrorMessage` field only contains a value if the original outbound failed. It contains details about the error that caused the outbound to fail + - The `ErrorMessageRevert` field only contains a value if the revert outbound failed. It contains details about the error that caused the revert outbound to fail. + +### Example values for StatusMessage field and how to interpret them +- `Error processing outbound to ZEVM, but contract call did not revert` : The outbound/deposit failed but the contract did not revert , this is most likely caused by an internal error in the protocol +- `Revert failed` : The revert failed. This message also means that the initial outbound has failed. +- `Outbound failed` : The outbound failed, The protocol would try to create a revert either in the same block or schedule one to be picked up by zetaclient +- `outbound failed for non-ZETA cctx` : Special case of outbound failed where we do not try to revert the cctx +- `outbound failed for admin tx` : The outbound failed for an admin transaction, in this case we do not revert the cctx +- `Reverted to ZEVM` : The outbound failed , and the revert back to ZEVM was successful +- `CCTX aborted with admin cmd` : The cctx was aborted manually by an admin command +- `Revert Successful` : The outbound faild , but the revert was successful +- `Initiating outbound` : The inbound votes have been successfully finalized, and the protocol is starting the outbound process +- `Outbound mined successfully` : The outbound was successfully mined + +### Example values for ErrorMessage and ErrorMessageRevert fields and how to interpret them + +- For a failed deposit the ErrorMessage would contain the following fields. The fields tagged as internal are generated by the protocol. +``` + - description[Internal]: This is message created by the protocol to provide a high level description of what caused the error + - method: The method that was called by the protocol, + - contract: The contract that his method was called on, + - args:The argumets that were used for this call, + - errorMessage[Internal]: Error message from the ZEVM call, + - revertReason: Revert reason from the smart contract, +``` + +- `Outbound failed to external chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. +- `coin type [CoinType] not supported for revert when source chain is Zetachain` : The coin type is not supported for revert when the source chain is Zetachain. +- `Error from EVMDeposit: [Error_String]` : Error returned by the protocol when trying to deposit tokens( and optionally call a contract) on ZEVM. The error string should explain the cause diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index 2949355e3a..22be8ad119 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/node/x/crosschain/types" @@ -29,8 +31,8 @@ func (c CCTXGatewayZEVM) InitiateOutbound( if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX config.CCTX.SetAbort(types.StatusMessages{ - StatusMessage: "Error processing outbound to ZEVM , but contract call did not revert", - ErrorMessageOutbound: err.Error(), + StatusMessage: "Error processing outbound to ZEVM, but contract call did not revert", + ErrorMessageOutbound: fmt.Sprintf("Error from EVMDeposit: %s", err.Error()), }) return types.CctxStatus_Aborted, err } diff --git a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go index 4d10dfb355..7ba34277c4 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go @@ -45,21 +45,24 @@ func (k Keeper) ValidateOutboundZEVM( if depositErr != nil && isContractReverted { tmpCtxRevert, commitRevert := ctx.CacheContext() // contract call reverted; should refund via a revert tx - err := k.processFailedOutboundOnExternalChain( + reverErr := k.processFailedOutboundOnExternalChain( tmpCtxRevert, cctx, types.CctxStatus_PendingOutbound, depositErr.Error(), cctx.InboundParams.Amount, ) + // In this case the outbound and revert both fail in the same block ,so we should update status for both together. + // A status revert failed indicates that the outbound has already failed before this. - if err != nil { + if reverErr != nil { // Error here would mean the outbound tx failed and we also failed to create a revert tx. - // In this case the cctx can be aborted directly + // This is the only case where we set outbound and revert messages, as both the outbound and the revert failed in the same block cctx.SetAbort( types.StatusMessages{ - StatusMessage: fmt.Sprintf("Revert failed , Error : %s", depositErr.Error()), - ErrorMessageRevert: fmt.Sprintf("Processing error: %s", err.Error()), + StatusMessage: fmt.Sprintf("Revert failed"), + ErrorMessageOutbound: depositErr.Error(), + ErrorMessageRevert: reverErr.Error(), }) return types.CctxStatus_Aborted } @@ -146,7 +149,7 @@ func (k Keeper) processFailedOutboundObservers(ctx sdk.Context, cctx *types.Cros { cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "outbound failed for non-ZETA cctx", + StatusMessage: "Outbound failed for non-ZETA cctx", ErrorMessageOutbound: fmt.Sprintf("coin type %s not supported for revert when source chain is Zetachain", cctx.InboundParams.CoinType), }) } @@ -373,7 +376,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // update status cctx.SetPendingRevert(types.StatusMessages{ StatusMessage: "Outbound failed", - ErrorMessageOutbound: "outbound failed to external chain", + ErrorMessageOutbound: "Outbound failed to external chain ,start revert", }) // process the revert on ZEVM diff --git a/x/crosschain/keeper/evm_deposit.go b/x/crosschain/keeper/evm_deposit.go index e57dc16d1b..b7cb95da12 100644 --- a/x/crosschain/keeper/evm_deposit.go +++ b/x/crosschain/keeper/evm_deposit.go @@ -48,7 +48,7 @@ func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (boo // - Return false will abort the cctx indexBytes, err := cctx.GetCCTXIndexBytes() if err != nil { - return false, err + return false, errors.Wrap(types.ErrUnableToParseCCTXIndexBytes, err.Error()) } data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { diff --git a/x/crosschain/keeper/initiate_outbound_test.go b/x/crosschain/keeper/initiate_outbound_test.go index 5466b902c7..a9d621f307 100644 --- a/x/crosschain/keeper/initiate_outbound_test.go +++ b/x/crosschain/keeper/initiate_outbound_test.go @@ -96,7 +96,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { errDeposit := fmt.Errorf("deposit failed") // Setup expected calls - // mock unsuccessful HandleEVMDeposit which reverts , i.e returns err and isContractReverted = true + // mock unsuccessful HandleEVMDeposit which reverts, i.e returns err and isContractReverted = true keepertest.MockRevertForHandleEVMDeposit(fungibleMock, receiver, amount, senderChain.ChainId, errDeposit) // mock unsuccessful GetSupportedChainFromChainID diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 222615c172..799022ba24 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -145,6 +145,7 @@ func (m *CrossChainTx) AddRevertOutbound(gasLimit uint64) error { GasLimit: gasLimit, }, TssPubkey: m.GetCurrentOutboundParam().TssPubkey, + CoinType: m.InboundParams.CoinType, } // The original outbound has been finalized, the new outbound is pending m.GetCurrentOutboundParam().TxFinalizationStatus = TxFinalizationStatus_Executed diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index ca217bd537..fb72b8096b 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -55,8 +55,9 @@ var ( 1156, "migration tx from an old tss address detected", ) - ErrValidatingInbound = errorsmod.Register(ModuleName, 1157, "unable to validate inbound") - ErrInvalidGasLimit = errorsmod.Register(ModuleName, 1158, "invalid gas limit") - ErrUnableToSetOutboundInfo = errorsmod.Register(ModuleName, 1159, "unable to set outbound info") - ErrCCTXAlreadyFinalized = errorsmod.Register(ModuleName, 1160, "cctx already finalized") + ErrValidatingInbound = errorsmod.Register(ModuleName, 1157, "unable to validate inbound") + ErrInvalidGasLimit = errorsmod.Register(ModuleName, 1158, "invalid gas limit") + ErrUnableToSetOutboundInfo = errorsmod.Register(ModuleName, 1159, "unable to set outbound info") + ErrCCTXAlreadyFinalized = errorsmod.Register(ModuleName, 1160, "cctx already finalized") + ErrUnableToParseCCTXIndexBytes = errorsmod.Register(ModuleName, 1161, "unable to parse cctx index bytes") ) diff --git a/x/crosschain/types/status.go b/x/crosschain/types/status.go index ff1c14920e..5c37a1e4ed 100644 --- a/x/crosschain/types/status.go +++ b/x/crosschain/types/status.go @@ -30,16 +30,13 @@ func (m *Status) UpdateStatus(newStatus CctxStatus) { // UpdateErrorMessages updates cctx.status.error_message and cctx.status.error_message_revert. func (m *Status) UpdateErrorMessages(messages StatusMessages) { - // Always update the status message , status should contain only the most recent update + // Always update the status message, status should contain only the most recent update m.StatusMessage = messages.StatusMessage - // We should be updating only one of these two messages at a time if messages.ErrorMessageOutbound != "" { m.ErrorMessage = messages.ErrorMessageOutbound - return } if messages.ErrorMessageRevert != "" { m.ErrorMessageRevert = messages.ErrorMessageRevert - return } } diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 6abd4444d9..49c6fac299 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -367,12 +367,12 @@ func (k Keeper) CallOnReceiveZevmConnector(ctx sdk.Context, zevmConnectorAbi, err := zevmconnectorcontract.ZetaConnectorZEVMMetaData.GetAbi() if err != nil { - return nil, err + return nil, cosmoserrors.Wrap(types.ErrABIGet, err.Error()) } err = k.DepositCoinsToFungibleModule(ctx, zetaValue) if err != nil { - return nil, err + return nil, cosmoserrors.Wrap(types.ErrDepositZetaToFungibleAccount, err.Error()) } return k.CallEVM( @@ -665,26 +665,25 @@ func (k Keeper) CallEVM( if err != nil { return nil, cosmoserrors.Wrap( types.ErrABIPack, - cosmoserrors.Wrap(err, "failed to create transaction data").Error(), + fmt.Sprintf("failed to create transaction data: %s", err.Error()), ) } k.Logger(ctx).Debug("calling EVM", "from", from, "contract", contract, "value", value, "method", method) resp, err := k.CallEVMWithData(ctx, from, &contract, data, commit, noEthereumTxEvent, value, gasLimit) if err != nil { - errMes := fmt.Sprintf( - "contract call failed: method '%s', contract '%s', args: %v", - method, - contract.Hex(), - args, - ) - - // if it is a revert error then add the revert reason to the error message - revertErr, ok := err.(*evmtypes.RevertError) + errMessage := types.EvmErrorMessage(fmt.Sprintf("contract call failed"), method, contract, args) + errMessage = types.EvmErrorMessageAddErrorString(errMessage, err.Error()) + // if it is a revert error then add the revert reason + var revertErr *evmtypes.RevertError + ok := errors.As(err, &revertErr) if ok { - errMes = fmt.Sprintf("%s, reason: %v", errMes, revertErr.ErrorData()) + errMessage = types.EvmErrorMessageAddRevertReason( + errMessage, + fmt.Sprintf("revert reason: %s", revertErr.ErrorData()), + ) } - return resp, cosmoserrors.Wrap(err, errMes) + return resp, cosmoserrors.Wrap(types.ErrCallEvmWithData, errMessage) } return resp, nil } diff --git a/x/fungible/keeper/zevm_message_passing_test.go b/x/fungible/keeper/zevm_message_passing_test.go index f633773e8e..506a0a871e 100644 --- a/x/fungible/keeper/zevm_message_passing_test.go +++ b/x/fungible/keeper/zevm_message_passing_test.go @@ -161,7 +161,7 @@ func TestKeeper_ZEVMDepositAndCallContract(t *testing.T) { data, cctxIndexBytes, ) - require.ErrorIs(t, err, errorMint) + require.ErrorContains(t, err, errorMint.Error()) }) } diff --git a/x/fungible/keeper/zevm_msg_passing.go b/x/fungible/keeper/zevm_msg_passing.go index 675118dec5..5be04609a5 100644 --- a/x/fungible/keeper/zevm_msg_passing.go +++ b/x/fungible/keeper/zevm_msg_passing.go @@ -1,11 +1,15 @@ package keeper import ( + "fmt" "math/big" sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/pkg/errors" evmtypes "github.com/zeta-chain/ethermint/x/evm/types" + + "github.com/zeta-chain/node/x/fungible/types" ) // ZETADepositAndCallContract deposits native ZETA to the to address if its an account or if the account does not exist yet @@ -18,10 +22,14 @@ func (k Keeper) ZETADepositAndCallContract(ctx sdk.Context, data []byte, indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { acc := k.evmKeeper.GetAccount(ctx, to) + if acc == nil || !acc.IsContract() { err := k.DepositCoinZeta(ctx, to, inboundAmount) if err != nil { - return nil, err + return nil, errors.Wrap( + types.ErrDepositZetaToEvmAccount, + fmt.Sprintf("to: %s, amount: %sm err %s", to.String(), inboundAmount.String(), err.Error()), + ) } return nil, nil } diff --git a/x/fungible/types/errors.go b/x/fungible/types/errors.go index cb152f7ffe..53967e0f53 100644 --- a/x/fungible/types/errors.go +++ b/x/fungible/types/errors.go @@ -35,4 +35,15 @@ var ( ErrZeroAddress = cosmoserrors.Register(ModuleName, 1133, "address cannot be zero") ErrInvalidAmount = cosmoserrors.Register(ModuleName, 1134, "invalid amount") ErrMaxSupplyReached = cosmoserrors.Register(ModuleName, 1135, "max supply reached") + ErrCallEvmWithData = cosmoserrors.Register(ModuleName, 1136, "error calling EVM with data") + ErrDepositZetaToEvmAccount = cosmoserrors.Register( + ModuleName, + 1137, + "error depositing ZETA to users EVM account", + ) + ErrDepositZetaToFungibleAccount = cosmoserrors.Register( + ModuleName, + 1138, + "error depositing ZETA to fungible module account", + ) ) diff --git a/x/fungible/types/evm_error_message.go b/x/fungible/types/evm_error_message.go index 37eaea537f..1e2ecf8769 100644 --- a/x/fungible/types/evm_error_message.go +++ b/x/fungible/types/evm_error_message.go @@ -6,19 +6,40 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func EvmErrorMessage(method string, contract common.Address, args interface{}) string { +const ( + MessageKey = "message" + MethodKey = "method" + ContractKey = "contract" + ArgsKey = "args" + ErrorKey = "error" + RevertReasonKey = "revertReason" +) + +func EvmErrorMessage(errorMessage string, method string, contract common.Address, args interface{}) string { return fmt.Sprintf( - "contract call failed: method '%s', contract '%s', args: %v", + "%s:%s,%s:%s,%s:%s,%s:%v", + MessageKey, + errorMessage, + MethodKey, method, + ContractKey, contract.Hex(), - args, - ) + ArgsKey, + args) +} + +func EvmErrorMessageAddErrorString(errorMessage string, error string) string { + return fmt.Sprintf( + "%s,%s:%s", + errorMessage, + ErrorKey, + error) } -func EvmErrorMessageWithRevertError(errorMessage string, reason interface{}) string { +func EvmErrorMessageAddRevertReason(errorMessage string, revertReason interface{}) string { return fmt.Sprintf( - "%s, reason: %v", + "%s,%s:%v", errorMessage, - reason, - ) + RevertReasonKey, + revertReason) } diff --git a/x/fungible/types/evm_error_message_test.go b/x/fungible/types/evm_error_message_test.go index f0cacf458f..8bf0165323 100644 --- a/x/fungible/types/evm_error_message_test.go +++ b/x/fungible/types/evm_error_message_test.go @@ -2,29 +2,29 @@ package types_test import ( "fmt" - strings2 "strings" "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/testutil/sample" + "github.com/zeta-chain/node/x/fungible/types" ) func TestEvmErrorMessage(t *testing.T) { - msg := "'deposit error: contract call failed: method ''depositAndCall''," + - "contract ''0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B'', " + - "args: [{[116 98 49 113 97 106 120 113 100 97 118 103 55 113 101 48 115 54 99 48 117 113 53 120" + - "106 119 109 114 99 110 109 102 108 122 113 107 118 54 119 114 120 106] " + - "0x0000000000000000000000000000000000000000 18332} 0x65a45c57636f9BcCeD4fe193A602008578BcA90b 63200 0xE869b85987D86d8fBb8913f97A705B4741edE86E" + - " [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 31 8 114 173 89 103 28 32 216 199 223" + - "23 218 144 178 97 227 198 29 206 71 31 177 222 58 199 57 100 26 67 128 175 0" + - "0 0 0 0 0 0 0 0 0 0 0 218 36 85 178 188 153 144 104 42 30 240 191 138 190 201" + - "21 130 93 66 147 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 53 201 173" + - "197 222 160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" + - "0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65 46 162" + - " 174 30 134 233 247 163 75 144 111 131 184 223 203 158 35 65 101 101 0 0 145" + - "201 152 4 164 227 47 62 58 31 93 187 156 163 80 241 90 43 228 232 154 218 235 128 16 101 154 240 57 245 109 126 166 4 110 64 228 217 198 230 231 192 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]" + - ": execution reverted:ret 0x2cdcef78000000000000000000000000e869b85987d86d8fbb8913f97a705b4741ede86e000000000000000000000000da2455b2bc9990682a1ef0bf8abec915825d42930000000000000000000000000000000000000000000000000000000000001b59:evm transaction execution failed, processing error: outTxGasFee(127200) more than available gas for tx (63200) | Identifiers : tb1qajxqdavg7qe0s6c0uq5xjwmrcnmflzqkv6wrxj-18332-18332-0: not enough gas'" - strings := strings2.Split(msg, ",") - for i, s := range strings { - fmt.Println(i, s) - } + t.Run("TestEvmErrorMessage", func(t *testing.T) { + address := sample.EthAddress() + msg := types.EvmErrorMessage("errorMsg", "method", address, "args") + msg = types.EvmErrorMessageAddErrorString(msg, "error_cause") + msg = types.EvmErrorMessageAddRevertReason(msg, "revert_reason") + + require.Equal(t, fmt.Sprintf( + "message:%s,method:%s,contract:%s,args:%s,error:%s,revertReason:%s", + "errorMsg", + "method", + address.String(), + "args", + "error_cause", + "revert_reason", + ), msg) + }) + } From 9e20402b13638650450f1d825287d403a154b27b Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 10 Jan 2025 13:36:10 -0500 Subject: [PATCH 05/13] add lower case for error messages --- docs/zetacore/status_message.md | 25 +++++++++++-------- x/crosschain/keeper/cctx_gateway_observers.go | 4 +-- x/crosschain/keeper/cctx_gateway_zevm.go | 4 +-- .../cctx_orchestrator_validate_outbound.go | 20 +++++++-------- x/crosschain/keeper/initiate_outbound.go | 2 +- .../keeper/msg_server_abort_stuck_cctx.go | 2 +- .../keeper/msg_server_vote_outbound_tx.go | 2 +- 7 files changed, 31 insertions(+), 28 deletions(-) diff --git a/docs/zetacore/status_message.md b/docs/zetacore/status_message.md index 0c61f85cbe..110bfbea4a 100644 --- a/docs/zetacore/status_message.md +++ b/docs/zetacore/status_message.md @@ -40,20 +40,23 @@ A cctx can have a maximum of two outbound params. - The `ErrorMessageRevert` field only contains a value if the revert outbound failed. It contains details about the error that caused the revert outbound to fail. ### Example values for StatusMessage field and how to interpret them -- `Error processing outbound to ZEVM, but contract call did not revert` : The outbound/deposit failed but the contract did not revert , this is most likely caused by an internal error in the protocol -- `Revert failed` : The revert failed. This message also means that the initial outbound has failed. -- `Outbound failed` : The outbound failed, The protocol would try to create a revert either in the same block or schedule one to be picked up by zetaclient +- `initiating outbound` : The inbound votes have been successfully finalized, and the protocol is starting the outbound process +- `outbound mined successfully` : The outbound was successfully mined +- `revert successful` : The outbound failed , but the revert was successful +- `revert failed` : The revert failed. This message also means that the initial outbound has failed. + +- `outbound failed` : The outbound failed, The protocol would try to create a revert either in the same block or schedule one to be picked up by zetaclient - `outbound failed for non-ZETA cctx` : Special case of outbound failed where we do not try to revert the cctx - `outbound failed for admin tx` : The outbound failed for an admin transaction, in this case we do not revert the cctx -- `Reverted to ZEVM` : The outbound failed , and the revert back to ZEVM was successful -- `CCTX aborted with admin cmd` : The cctx was aborted manually by an admin command -- `Revert Successful` : The outbound faild , but the revert was successful -- `Initiating outbound` : The inbound votes have been successfully finalized, and the protocol is starting the outbound process -- `Outbound mined successfully` : The outbound was successfully mined +- `outbound failed deposit to ZEVM failed but contract call did not revert` : Special case of outbound failed The outbound/deposit failed, but the contract did not revert, + this is most likely caused by an internal error in the protocol.The CCTX is this case is aborted. Users can try connecting with the zetachain team to get a refund + +- `cctx aborted with admin cmd` : The cctx was aborted manually by an admin command + ### Example values for ErrorMessage and ErrorMessageRevert fields and how to interpret them -- For a failed deposit the ErrorMessage would contain the following fields. The fields tagged as internal are generated by the protocol. +- For a failed deposit, the ErrorMessage would contain the following fields. The protocol generates the fields tagged as internal. ``` - description[Internal]: This is message created by the protocol to provide a high level description of what caused the error - method: The method that was called by the protocol, @@ -63,6 +66,6 @@ A cctx can have a maximum of two outbound params. - revertReason: Revert reason from the smart contract, ``` -- `Outbound failed to external chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. +- `outbound failed to external chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. - `coin type [CoinType] not supported for revert when source chain is Zetachain` : The coin type is not supported for revert when the source chain is Zetachain. -- `Error from EVMDeposit: [Error_String]` : Error returned by the protocol when trying to deposit tokens( and optionally call a contract) on ZEVM. The error string should explain the cause +- `error from EVMDeposit: [Error_String]` : Error returned by the protocol when trying to deposit tokens( and optionally call a contract) on ZEVM. The error string should explain the cause diff --git a/x/crosschain/keeper/cctx_gateway_observers.go b/x/crosschain/keeper/cctx_gateway_observers.go index 8224b8c3a8..f7bfa0d179 100644 --- a/x/crosschain/keeper/cctx_gateway_observers.go +++ b/x/crosschain/keeper/cctx_gateway_observers.go @@ -76,8 +76,8 @@ func (c CCTXGatewayObservers) InitiateOutbound( if err != nil { // do not commit anything here as the CCTX should be aborted config.CCTX.SetAbort(types.StatusMessages{ - StatusMessage: "Outbound preprocessing failed for cctx when initiating outbound", - ErrorMessageOutbound: err.Error(), + StatusMessage: "Outbound pre-processing failed", + ErrorMessageOutbound: fmt.Sprintf("unable to create outbound: %s", err.Error()), }) return types.CctxStatus_Aborted, err } diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index 22be8ad119..083f74bf39 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -31,8 +31,8 @@ func (c CCTXGatewayZEVM) InitiateOutbound( if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX config.CCTX.SetAbort(types.StatusMessages{ - StatusMessage: "Error processing outbound to ZEVM, but contract call did not revert", - ErrorMessageOutbound: fmt.Sprintf("Error from EVMDeposit: %s", err.Error()), + StatusMessage: "outbound failed deposit to ZEVM failed but contract call did not revert", + ErrorMessageOutbound: fmt.Sprintf("error from EVMDeposit: %s", err.Error()), }) return types.CctxStatus_Aborted, err } diff --git a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go index 7ba34277c4..2d6dd6b785 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go @@ -60,7 +60,7 @@ func (k Keeper) ValidateOutboundZEVM( // This is the only case where we set outbound and revert messages, as both the outbound and the revert failed in the same block cctx.SetAbort( types.StatusMessages{ - StatusMessage: fmt.Sprintf("Revert failed"), + StatusMessage: fmt.Sprintf("revert failed"), ErrorMessageOutbound: depositErr.Error(), ErrorMessageRevert: reverErr.Error(), }) @@ -223,7 +223,7 @@ func (k Keeper) processFailedOutboundOnExternalChain( } // Not setting the finalization status here, the required changes have been made while creating the revert tx cctx.SetPendingRevert(types.StatusMessages{ - StatusMessage: "Outbound failed", + StatusMessage: "outbound failed", ErrorMessageOutbound: revertMsg, }) case types.CctxStatus_PendingRevert: @@ -258,9 +258,9 @@ func (k Keeper) processSuccessfulOutbound( oldStatus := cctx.CctxStatus.Status switch oldStatus { case types.CctxStatus_PendingRevert: - cctx.SetReverted(types.StatusMessages{StatusMessage: "Revert successful"}) + cctx.SetReverted(types.StatusMessages{StatusMessage: "revert successful"}) case types.CctxStatus_PendingOutbound: - cctx.SetOutboundMined(types.StatusMessages{StatusMessage: "Outbound mined successfully"}) + cctx.SetOutboundMined(types.StatusMessages{StatusMessage: "outbound mined successfully"}) default: return } @@ -290,7 +290,7 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro // Trying to revert the transaction this would get set to a finalized status in the same block as this does not need a TSS singing cctx.SetPendingRevert(types.StatusMessages{ - StatusMessage: "Outbound failed", + StatusMessage: "outbound failed", ErrorMessageOutbound: "outbound failed to external chain ,start revert", }) data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) @@ -327,7 +327,7 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro } cctx.SetReverted(types.StatusMessages{ - StatusMessage: "Reverted to ZEVM", + StatusMessage: "reverted successfull", }) if len(ctx.TxBytes()) > 0 { @@ -375,8 +375,8 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // update status cctx.SetPendingRevert(types.StatusMessages{ - StatusMessage: "Outbound failed", - ErrorMessageOutbound: "Outbound failed to external chain ,start revert", + StatusMessage: "outbound failed", + ErrorMessageOutbound: "outbound failed to external chain ,start revert", }) // process the revert on ZEVM @@ -396,7 +396,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // tx is reverted cctx.SetReverted(types.StatusMessages{ - StatusMessage: "Reverted to ZEVM", + StatusMessage: "revert successful", }) // add event for tendermint transaction hash format @@ -411,7 +411,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "Revert failed", + StatusMessage: "revert failed", ErrorMessageRevert: "outbound and revert failed", }) } diff --git a/x/crosschain/keeper/initiate_outbound.go b/x/crosschain/keeper/initiate_outbound.go index d1cd7ea064..c8c42ea637 100644 --- a/x/crosschain/keeper/initiate_outbound.go +++ b/x/crosschain/keeper/initiate_outbound.go @@ -38,6 +38,6 @@ func (k Keeper) InitiateOutbound(ctx sdk.Context, config InitiateOutboundConfig) ) } - config.CCTX.SetPendingOutbound(types.StatusMessages{StatusMessage: "Initiating outbound"}) + config.CCTX.SetPendingOutbound(types.StatusMessages{StatusMessage: "initiating outbound"}) return cctxGateway.InitiateOutbound(ctx, config) } diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go index f97b85dd8a..9fdb7bf713 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go @@ -12,7 +12,7 @@ import ( const ( // AbortMessage is the message to abort a stuck CCTX - AbortMessage = "CCTX aborted with admin cmd" + AbortMessage = "cctx aborted with admin cmd" ) // AbortStuckCCTX aborts a stuck CCTX diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index d187eb4e57..3f5f31f4c4 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -194,7 +194,7 @@ SaveFailedOutbound saves a failed outbound transaction.It does the following thi func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, tssPubkey string) { cctx.SetAbort(types.StatusMessages{ - StatusMessage: "Outbound Failed", + StatusMessage: "outbound Failed", ErrorMessageOutbound: errMessage, }) ctx.Logger().Error(errMessage) From 889a8154fc108a3f5e2c7446ca0a938d7745535c Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 10 Jan 2025 13:36:10 -0500 Subject: [PATCH 06/13] add lower case for error messages --- docs/zetacore/status_message.md | 27 +++++++------ x/crosschain/keeper/cctx_gateway_observers.go | 4 +- x/crosschain/keeper/cctx_gateway_zevm.go | 4 +- .../cctx_orchestrator_validate_outbound.go | 39 +++++++++---------- x/crosschain/keeper/initiate_outbound.go | 2 +- .../keeper/msg_server_abort_stuck_cctx.go | 2 +- .../keeper/msg_server_vote_outbound_tx.go | 2 +- x/fungible/keeper/evm_test.go | 2 +- 8 files changed, 42 insertions(+), 40 deletions(-) diff --git a/docs/zetacore/status_message.md b/docs/zetacore/status_message.md index 0c61f85cbe..e833b6a467 100644 --- a/docs/zetacore/status_message.md +++ b/docs/zetacore/status_message.md @@ -31,7 +31,7 @@ This is a boolean value which is true if the cctx has been refunded after being ### CreatedTimestamp The time when the cctx was created ### ErrorMessage and ErrorMessageRevert -A cctx can have a maximum of two outbound params. +A cctx can have a maximum of two outbound params. We can refer to the first outbound as `outbound` and the second as `revert`. - A normal flow for a cctx is to go from `PendingOutbound` -> `OutboundMined` , which creates a single outbound - A cctx where the outbound fails has the transition `PendingOutbound` -> `PendingRevert` -> `Reverted` , which creates two outbounds - Any of the above two flows can abort the cctx at some point that can create either one or two outbounds @@ -40,20 +40,23 @@ A cctx can have a maximum of two outbound params. - The `ErrorMessageRevert` field only contains a value if the revert outbound failed. It contains details about the error that caused the revert outbound to fail. ### Example values for StatusMessage field and how to interpret them -- `Error processing outbound to ZEVM, but contract call did not revert` : The outbound/deposit failed but the contract did not revert , this is most likely caused by an internal error in the protocol -- `Revert failed` : The revert failed. This message also means that the initial outbound has failed. -- `Outbound failed` : The outbound failed, The protocol would try to create a revert either in the same block or schedule one to be picked up by zetaclient +- `initiating outbound` : The inbound votes have been successfully finalized, and the protocol is starting the outbound process +- `outbound mined successfully` : The outbound was successfully mined +- `revert successful` : The outbound failed , but the revert was successful +- `revert failed` : The revert failed. This message also means that the initial outbound has failed. + +- `outbound failed` : The outbound failed, The protocol would try to create a revert either in the same block or schedule one to be picked up by zetaclient - `outbound failed for non-ZETA cctx` : Special case of outbound failed where we do not try to revert the cctx - `outbound failed for admin tx` : The outbound failed for an admin transaction, in this case we do not revert the cctx -- `Reverted to ZEVM` : The outbound failed , and the revert back to ZEVM was successful -- `CCTX aborted with admin cmd` : The cctx was aborted manually by an admin command -- `Revert Successful` : The outbound faild , but the revert was successful -- `Initiating outbound` : The inbound votes have been successfully finalized, and the protocol is starting the outbound process -- `Outbound mined successfully` : The outbound was successfully mined +- `outbound failed deposit to ZEVM failed but contract call did not revert` : Special case of outbound failed The outbound/deposit failed, but the contract did not revert, + this is most likely caused by an internal error in the protocol.The CCTX is this case is aborted. Users can try connecting with the zetachain team to get a refund +- `outbound pre-processing failed` : The outbound failed during the pre-processing step. This means the outbound is never created. In this case the cctx is aborted +- `cctx aborted with admin cmd` : The cctx was aborted manually by an admin command + ### Example values for ErrorMessage and ErrorMessageRevert fields and how to interpret them -- For a failed deposit the ErrorMessage would contain the following fields. The fields tagged as internal are generated by the protocol. +- For a failed deposit, the ErrorMessage would contain the following fields. The protocol generates the fields tagged as internal. ``` - description[Internal]: This is message created by the protocol to provide a high level description of what caused the error - method: The method that was called by the protocol, @@ -63,6 +66,6 @@ A cctx can have a maximum of two outbound params. - revertReason: Revert reason from the smart contract, ``` -- `Outbound failed to external chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. +- `outbound failed to external chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. - `coin type [CoinType] not supported for revert when source chain is Zetachain` : The coin type is not supported for revert when the source chain is Zetachain. -- `Error from EVMDeposit: [Error_String]` : Error returned by the protocol when trying to deposit tokens( and optionally call a contract) on ZEVM. The error string should explain the cause +- `error from EVMDeposit: [Error_String]` : Error returned by the protocol when trying to deposit tokens( and optionally call a contract) on ZEVM. The error string should explain the cause diff --git a/x/crosschain/keeper/cctx_gateway_observers.go b/x/crosschain/keeper/cctx_gateway_observers.go index 8224b8c3a8..043c84ecd2 100644 --- a/x/crosschain/keeper/cctx_gateway_observers.go +++ b/x/crosschain/keeper/cctx_gateway_observers.go @@ -76,8 +76,8 @@ func (c CCTXGatewayObservers) InitiateOutbound( if err != nil { // do not commit anything here as the CCTX should be aborted config.CCTX.SetAbort(types.StatusMessages{ - StatusMessage: "Outbound preprocessing failed for cctx when initiating outbound", - ErrorMessageOutbound: err.Error(), + StatusMessage: "outbound pre-processing failed", + ErrorMessageOutbound: fmt.Sprintf("unable to create outbound: %s", err.Error()), }) return types.CctxStatus_Aborted, err } diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index 22be8ad119..083f74bf39 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -31,8 +31,8 @@ func (c CCTXGatewayZEVM) InitiateOutbound( if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX config.CCTX.SetAbort(types.StatusMessages{ - StatusMessage: "Error processing outbound to ZEVM, but contract call did not revert", - ErrorMessageOutbound: fmt.Sprintf("Error from EVMDeposit: %s", err.Error()), + StatusMessage: "outbound failed deposit to ZEVM failed but contract call did not revert", + ErrorMessageOutbound: fmt.Sprintf("error from EVMDeposit: %s", err.Error()), }) return types.CctxStatus_Aborted, err } diff --git a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go index 7ba34277c4..f335ee1331 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go @@ -52,15 +52,13 @@ func (k Keeper) ValidateOutboundZEVM( depositErr.Error(), cctx.InboundParams.Amount, ) - // In this case the outbound and revert both fail in the same block ,so we should update status for both together. - // A status revert failed indicates that the outbound has already failed before this. - if reverErr != nil { // Error here would mean the outbound tx failed and we also failed to create a revert tx. - // This is the only case where we set outbound and revert messages, as both the outbound and the revert failed in the same block + // This is the only case where we set outbound and revert messages, + // as both the outbound and the revert failed in the same block cctx.SetAbort( types.StatusMessages{ - StatusMessage: fmt.Sprintf("Revert failed"), + StatusMessage: fmt.Sprintf("revert failed"), ErrorMessageOutbound: depositErr.Error(), ErrorMessageRevert: reverErr.Error(), }) @@ -149,7 +147,7 @@ func (k Keeper) processFailedOutboundObservers(ctx sdk.Context, cctx *types.Cros { cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "Outbound failed for non-ZETA cctx", + StatusMessage: "outbound failed for non-ZETA cctx", ErrorMessageOutbound: fmt.Sprintf("coin type %s not supported for revert when source chain is Zetachain", cctx.InboundParams.CoinType), }) } @@ -170,7 +168,7 @@ func (k Keeper) processFailedOutboundOnExternalChain( ctx sdk.Context, cctx *types.CrossChainTx, oldStatus types.CctxStatus, - revertMsg string, + errorMsg string, inputAmount math.Uint, ) error { switch oldStatus { @@ -223,14 +221,14 @@ func (k Keeper) processFailedOutboundOnExternalChain( } // Not setting the finalization status here, the required changes have been made while creating the revert tx cctx.SetPendingRevert(types.StatusMessages{ - StatusMessage: "Outbound failed", - ErrorMessageOutbound: revertMsg, + StatusMessage: "outbound failed", + ErrorMessageOutbound: errorMsg, }) case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "Revert failed", - ErrorMessageRevert: revertMsg, + StatusMessage: "revert failed", + ErrorMessageRevert: errorMsg, }) } return nil @@ -258,9 +256,9 @@ func (k Keeper) processSuccessfulOutbound( oldStatus := cctx.CctxStatus.Status switch oldStatus { case types.CctxStatus_PendingRevert: - cctx.SetReverted(types.StatusMessages{StatusMessage: "Revert successful"}) + cctx.SetReverted(types.StatusMessages{StatusMessage: "revert successful"}) case types.CctxStatus_PendingOutbound: - cctx.SetOutboundMined(types.StatusMessages{StatusMessage: "Outbound mined successfully"}) + cctx.SetOutboundMined(types.StatusMessages{StatusMessage: "outbound mined successfully"}) default: return } @@ -288,9 +286,10 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro return fmt.Errorf("failed AddRevertOutbound: %s", err.Error()) } - // Trying to revert the transaction this would get set to a finalized status in the same block as this does not need a TSS singing + // Trying to revert the transaction, this would get set to a finalized status in the same block as this does not need a TSS singing + // The outbound failed due to majority of observer voting failure.We do not have the exact reason for the failure available on chain. cctx.SetPendingRevert(types.StatusMessages{ - StatusMessage: "Outbound failed", + StatusMessage: "outbound failed", ErrorMessageOutbound: "outbound failed to external chain ,start revert", }) data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) @@ -327,7 +326,7 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro } cctx.SetReverted(types.StatusMessages{ - StatusMessage: "Reverted to ZEVM", + StatusMessage: "revert successful", }) if len(ctx.TxBytes()) > 0 { @@ -375,8 +374,8 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // update status cctx.SetPendingRevert(types.StatusMessages{ - StatusMessage: "Outbound failed", - ErrorMessageOutbound: "Outbound failed to external chain ,start revert", + StatusMessage: "outbound failed", + ErrorMessageOutbound: "outbound failed to external chain ,start revert", }) // process the revert on ZEVM @@ -396,7 +395,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // tx is reverted cctx.SetReverted(types.StatusMessages{ - StatusMessage: "Reverted to ZEVM", + StatusMessage: "revert successful", }) // add event for tendermint transaction hash format @@ -411,7 +410,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "Revert failed", + StatusMessage: "revert failed", ErrorMessageRevert: "outbound and revert failed", }) } diff --git a/x/crosschain/keeper/initiate_outbound.go b/x/crosschain/keeper/initiate_outbound.go index d1cd7ea064..c8c42ea637 100644 --- a/x/crosschain/keeper/initiate_outbound.go +++ b/x/crosschain/keeper/initiate_outbound.go @@ -38,6 +38,6 @@ func (k Keeper) InitiateOutbound(ctx sdk.Context, config InitiateOutboundConfig) ) } - config.CCTX.SetPendingOutbound(types.StatusMessages{StatusMessage: "Initiating outbound"}) + config.CCTX.SetPendingOutbound(types.StatusMessages{StatusMessage: "initiating outbound"}) return cctxGateway.InitiateOutbound(ctx, config) } diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go index f97b85dd8a..9fdb7bf713 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go @@ -12,7 +12,7 @@ import ( const ( // AbortMessage is the message to abort a stuck CCTX - AbortMessage = "CCTX aborted with admin cmd" + AbortMessage = "cctx aborted with admin cmd" ) // AbortStuckCCTX aborts a stuck CCTX diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index d187eb4e57..9cf161a5bd 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -194,7 +194,7 @@ SaveFailedOutbound saves a failed outbound transaction.It does the following thi func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, tssPubkey string) { cctx.SetAbort(types.StatusMessages{ - StatusMessage: "Outbound Failed", + StatusMessage: "outbound failed", ErrorMessageOutbound: errMessage, }) ctx.Logger().Error(errMessage) diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 7c0ef0bf00..96e44c50ab 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -730,7 +730,7 @@ func TestKeeper_CallEVMWithData(t *testing.T) { require.False(t, types.IsContractReverted(res, err)) require.NotContains(t, err.Error(), "reason:") - // No revert with successfull call + // No revert with successful call res, err = k.CallEVM( ctx, *abi, From 3a26b7e89ada18e97690beb7dd12eb1119fd01e0 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 10 Jan 2025 15:06:39 -0500 Subject: [PATCH 07/13] remove duplicate description for call evm error --- docs/zetacore/status_message.md | 11 +++++------ x/fungible/keeper/evm.go | 2 +- x/fungible/types/errors.go | 2 +- x/fungible/types/evm_error_message.go | 7 ++----- x/fungible/types/evm_error_message_test.go | 5 ++--- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/docs/zetacore/status_message.md b/docs/zetacore/status_message.md index e833b6a467..d356cab558 100644 --- a/docs/zetacore/status_message.md +++ b/docs/zetacore/status_message.md @@ -58,12 +58,11 @@ A cctx can have a maximum of two outbound params. We can refer to the first outb - For a failed deposit, the ErrorMessage would contain the following fields. The protocol generates the fields tagged as internal. ``` - - description[Internal]: This is message created by the protocol to provide a high level description of what caused the error - - method: The method that was called by the protocol, - - contract: The contract that his method was called on, - - args:The argumets that were used for this call, - - errorMessage[Internal]: Error message from the ZEVM call, - - revertReason: Revert reason from the smart contract, + - method: The method that was called by the protocol + - contract: The contract that his method was called on + - args:The argumets that were used for this call + - errorMessage[Internal]: Error message from the ZEVM call + - revertReason: Revert reason from the smart contract ``` - `outbound failed to external chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 49c6fac299..55bf09f023 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -672,7 +672,7 @@ func (k Keeper) CallEVM( k.Logger(ctx).Debug("calling EVM", "from", from, "contract", contract, "value", value, "method", method) resp, err := k.CallEVMWithData(ctx, from, &contract, data, commit, noEthereumTxEvent, value, gasLimit) if err != nil { - errMessage := types.EvmErrorMessage(fmt.Sprintf("contract call failed"), method, contract, args) + errMessage := types.EvmErrorMessage(method, contract, args) errMessage = types.EvmErrorMessageAddErrorString(errMessage, err.Error()) // if it is a revert error then add the revert reason var revertErr *evmtypes.RevertError diff --git a/x/fungible/types/errors.go b/x/fungible/types/errors.go index 53967e0f53..4bfe8b3a33 100644 --- a/x/fungible/types/errors.go +++ b/x/fungible/types/errors.go @@ -35,7 +35,7 @@ var ( ErrZeroAddress = cosmoserrors.Register(ModuleName, 1133, "address cannot be zero") ErrInvalidAmount = cosmoserrors.Register(ModuleName, 1134, "invalid amount") ErrMaxSupplyReached = cosmoserrors.Register(ModuleName, 1135, "max supply reached") - ErrCallEvmWithData = cosmoserrors.Register(ModuleName, 1136, "error calling EVM with data") + ErrCallEvmWithData = cosmoserrors.Register(ModuleName, 1136, "contract call failed when calling EVM with data") ErrDepositZetaToEvmAccount = cosmoserrors.Register( ModuleName, 1137, diff --git a/x/fungible/types/evm_error_message.go b/x/fungible/types/evm_error_message.go index 1e2ecf8769..4a0cfcb342 100644 --- a/x/fungible/types/evm_error_message.go +++ b/x/fungible/types/evm_error_message.go @@ -7,7 +7,6 @@ import ( ) const ( - MessageKey = "message" MethodKey = "method" ContractKey = "contract" ArgsKey = "args" @@ -15,11 +14,9 @@ const ( RevertReasonKey = "revertReason" ) -func EvmErrorMessage(errorMessage string, method string, contract common.Address, args interface{}) string { +func EvmErrorMessage(method string, contract common.Address, args interface{}) string { return fmt.Sprintf( - "%s:%s,%s:%s,%s:%s,%s:%v", - MessageKey, - errorMessage, + "%s:%s,%s:%s,%s:%v", MethodKey, method, ContractKey, diff --git a/x/fungible/types/evm_error_message_test.go b/x/fungible/types/evm_error_message_test.go index 8bf0165323..5ad0d557a2 100644 --- a/x/fungible/types/evm_error_message_test.go +++ b/x/fungible/types/evm_error_message_test.go @@ -12,13 +12,12 @@ import ( func TestEvmErrorMessage(t *testing.T) { t.Run("TestEvmErrorMessage", func(t *testing.T) { address := sample.EthAddress() - msg := types.EvmErrorMessage("errorMsg", "method", address, "args") + msg := types.EvmErrorMessage("method", address, "args") msg = types.EvmErrorMessageAddErrorString(msg, "error_cause") msg = types.EvmErrorMessageAddRevertReason(msg, "revert_reason") require.Equal(t, fmt.Sprintf( - "message:%s,method:%s,contract:%s,args:%s,error:%s,revertReason:%s", - "errorMsg", + "method:%s,contract:%s,args:%s,error:%s,revertReason:%s", "method", address.String(), "args", From acf97935b5016cb8e1c76237d6f7019a22255e7a Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 10 Jan 2025 15:10:47 -0500 Subject: [PATCH 08/13] add changelog --- changelog.md | 6 ++++++ x/fungible/types/errors.go | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 44c0a2765c..47a392bca1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # CHANGELOG +### Unreleases + +### Refactor + +* [3326](https://github.com/zeta-chain/node/pull/3326) - improve error messages for cctx status object + ## v25.0.0 ### Features diff --git a/x/fungible/types/errors.go b/x/fungible/types/errors.go index 4bfe8b3a33..009bd2ce98 100644 --- a/x/fungible/types/errors.go +++ b/x/fungible/types/errors.go @@ -35,7 +35,11 @@ var ( ErrZeroAddress = cosmoserrors.Register(ModuleName, 1133, "address cannot be zero") ErrInvalidAmount = cosmoserrors.Register(ModuleName, 1134, "invalid amount") ErrMaxSupplyReached = cosmoserrors.Register(ModuleName, 1135, "max supply reached") - ErrCallEvmWithData = cosmoserrors.Register(ModuleName, 1136, "contract call failed when calling EVM with data") + ErrCallEvmWithData = cosmoserrors.Register( + ModuleName, + 1136, + "contract call failed when calling EVM with data", + ) ErrDepositZetaToEvmAccount = cosmoserrors.Register( ModuleName, 1137, From a72b3ef5f2420a9ac9ff3043c28fa53bc453005d Mon Sep 17 00:00:00 2001 From: Tanmay Date: Sun, 12 Jan 2025 18:09:34 -0500 Subject: [PATCH 09/13] refactor error strings --- x/crosschain/keeper/initiate_outbound_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/crosschain/keeper/initiate_outbound_test.go b/x/crosschain/keeper/initiate_outbound_test.go index a9d621f307..2b150d2406 100644 --- a/x/crosschain/keeper/initiate_outbound_test.go +++ b/x/crosschain/keeper/initiate_outbound_test.go @@ -76,7 +76,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.ErrorContains(t, err, "deposit error") require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, types.CctxStatus_Aborted, newStatus) - require.Equal(t, "deposit error", cctx.CctxStatus.ErrorMessage) + require.Contains(t, cctx.CctxStatus.ErrorMessage, "deposit error") }) t.Run( @@ -427,7 +427,7 @@ func TestKeeper_InitiateOutboundProcessCrosschainMsgPassing(t *testing.T) { require.ErrorIs(t, err, observertypes.ErrSupportedChains) require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, types.CctxStatus_Aborted, newStatus) - require.Equal(t, observertypes.ErrSupportedChains.Error(), cctx.CctxStatus.ErrorMessage) + require.Contains(t, cctx.CctxStatus.ErrorMessage, observertypes.ErrSupportedChains.Error()) }) t.Run("unable to process crosschain msg passing UpdateNonce fails", func(t *testing.T) { From 2fb8d5d20598de53c744eea6b7f24b3d505ff2c2 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Sun, 12 Jan 2025 19:33:31 -0500 Subject: [PATCH 10/13] refactor error strings --- x/fungible/keeper/evm.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 55bf09f023..a42f4c0ddc 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -675,8 +675,7 @@ func (k Keeper) CallEVM( errMessage := types.EvmErrorMessage(method, contract, args) errMessage = types.EvmErrorMessageAddErrorString(errMessage, err.Error()) // if it is a revert error then add the revert reason - var revertErr *evmtypes.RevertError - ok := errors.As(err, &revertErr) + revertErr, ok := err.(*evmtypes.RevertError) if ok { errMessage = types.EvmErrorMessageAddRevertReason( errMessage, From 2045d3d588c9a07f5aebf991cb0d4c3721f3b4ab Mon Sep 17 00:00:00 2001 From: Tanmay Date: Sun, 12 Jan 2025 19:53:30 -0500 Subject: [PATCH 11/13] add check for outbound cointype in cctx_test.go --- x/crosschain/types/cctx.go | 5 ++++- x/crosschain/types/cctx_test.go | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 799022ba24..6e2aec5024 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -145,7 +145,10 @@ func (m *CrossChainTx) AddRevertOutbound(gasLimit uint64) error { GasLimit: gasLimit, }, TssPubkey: m.GetCurrentOutboundParam().TssPubkey, - CoinType: m.InboundParams.CoinType, + } + + if m.InboundParams != nil { + revertTxParams.CoinType = m.InboundParams.CoinType } // The original outbound has been finalized, the new outbound is pending m.GetCurrentOutboundParam().TxFinalizationStatus = TxFinalizationStatus_Executed diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 12ec17c48b..686e3b16b5 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -134,6 +134,7 @@ func Test_SetRevertOutboundValues(t *testing.T) { require.Equal(t, cctx.GetCurrentOutboundParam().CallOptions.GasLimit, uint64(100)) require.Equal(t, cctx.GetCurrentOutboundParam().TssPubkey, cctx.OutboundParams[0].TssPubkey) require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundParams[0].TxFinalizationStatus) + require.Equal(t, cctx.GetCurrentOutboundParam().CoinType, cctx.InboundParams.CoinType) }) t.Run("successfully set BTC revert address V1", func(t *testing.T) { @@ -151,6 +152,7 @@ func Test_SetRevertOutboundValues(t *testing.T) { require.Equal(t, cctx.GetCurrentOutboundParam().CallOptions.GasLimit, uint64(100)) require.Equal(t, cctx.GetCurrentOutboundParam().TssPubkey, cctx.OutboundParams[0].TssPubkey) require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundParams[0].TxFinalizationStatus) + require.Equal(t, cctx.GetCurrentOutboundParam().CoinType, cctx.InboundParams.CoinType) }) t.Run("successfully set EVM revert address V2", func(t *testing.T) { @@ -167,6 +169,7 @@ func Test_SetRevertOutboundValues(t *testing.T) { require.Equal(t, cctx.GetCurrentOutboundParam().CallOptions.GasLimit, uint64(100)) require.Equal(t, cctx.GetCurrentOutboundParam().TssPubkey, cctx.OutboundParams[0].TssPubkey) require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundParams[0].TxFinalizationStatus) + require.Equal(t, cctx.GetCurrentOutboundParam().CoinType, cctx.InboundParams.CoinType) }) t.Run("failed to set revert outbound values if revert outbound already exists", func(t *testing.T) { From afe7be13e978d893c4a763ded202e1634e44974f Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 13 Jan 2025 13:04:20 -0500 Subject: [PATCH 12/13] resolve comments --- docs/zetacore/status_message.md | 6 +++--- x/crosschain/keeper/cctx_gateway_zevm.go | 2 +- .../keeper/cctx_orchestrator_validate_outbound.go | 12 ++++++------ x/crosschain/keeper/msg_server_abort_stuck_cctx.go | 2 +- x/crosschain/types/cctx.go | 1 + 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/zetacore/status_message.md b/docs/zetacore/status_message.md index d356cab558..029c5b639d 100644 --- a/docs/zetacore/status_message.md +++ b/docs/zetacore/status_message.md @@ -48,10 +48,10 @@ A cctx can have a maximum of two outbound params. We can refer to the first outb - `outbound failed` : The outbound failed, The protocol would try to create a revert either in the same block or schedule one to be picked up by zetaclient - `outbound failed for non-ZETA cctx` : Special case of outbound failed where we do not try to revert the cctx - `outbound failed for admin tx` : The outbound failed for an admin transaction, in this case we do not revert the cctx -- `outbound failed deposit to ZEVM failed but contract call did not revert` : Special case of outbound failed The outbound/deposit failed, but the contract did not revert, +- `outbound failed but the universal contract did not revert` : Special case of outbound failed The outbound/deposit failed, but the contract did not revert, this is most likely caused by an internal error in the protocol.The CCTX is this case is aborted. Users can try connecting with the zetachain team to get a refund - `outbound pre-processing failed` : The outbound failed during the pre-processing step. This means the outbound is never created. In this case the cctx is aborted -- `cctx aborted with admin cmd` : The cctx was aborted manually by an admin command +- `cctx aborted through MsgAbortStuckCCTX` : The cctx was aborted manually by an admin command ### Example values for ErrorMessage and ErrorMessageRevert fields and how to interpret them @@ -65,6 +65,6 @@ A cctx can have a maximum of two outbound params. We can refer to the first outb - revertReason: Revert reason from the smart contract ``` -- `outbound failed to external chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. +- `outbound failed to connected chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. - `coin type [CoinType] not supported for revert when source chain is Zetachain` : The coin type is not supported for revert when the source chain is Zetachain. - `error from EVMDeposit: [Error_String]` : Error returned by the protocol when trying to deposit tokens( and optionally call a contract) on ZEVM. The error string should explain the cause diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index 083f74bf39..89a5dba387 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -31,7 +31,7 @@ func (c CCTXGatewayZEVM) InitiateOutbound( if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX config.CCTX.SetAbort(types.StatusMessages{ - StatusMessage: "outbound failed deposit to ZEVM failed but contract call did not revert", + StatusMessage: "outbound failed but the universal contract did not revert", ErrorMessageOutbound: fmt.Sprintf("error from EVMDeposit: %s", err.Error()), }) return types.CctxStatus_Aborted, err diff --git a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go index f335ee1331..2b7ff56a18 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go @@ -45,14 +45,14 @@ func (k Keeper) ValidateOutboundZEVM( if depositErr != nil && isContractReverted { tmpCtxRevert, commitRevert := ctx.CacheContext() // contract call reverted; should refund via a revert tx - reverErr := k.processFailedOutboundOnExternalChain( + revertErr := k.processFailedOutboundOnExternalChain( tmpCtxRevert, cctx, types.CctxStatus_PendingOutbound, depositErr.Error(), cctx.InboundParams.Amount, ) - if reverErr != nil { + if revertErr != nil { // Error here would mean the outbound tx failed and we also failed to create a revert tx. // This is the only case where we set outbound and revert messages, // as both the outbound and the revert failed in the same block @@ -60,7 +60,7 @@ func (k Keeper) ValidateOutboundZEVM( types.StatusMessages{ StatusMessage: fmt.Sprintf("revert failed"), ErrorMessageOutbound: depositErr.Error(), - ErrorMessageRevert: reverErr.Error(), + ErrorMessageRevert: revertErr.Error(), }) return types.CctxStatus_Aborted } @@ -148,7 +148,7 @@ func (k Keeper) processFailedOutboundObservers(ctx sdk.Context, cctx *types.Cros cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ StatusMessage: "outbound failed for non-ZETA cctx", - ErrorMessageOutbound: fmt.Sprintf("coin type %s not supported for revert when source chain is Zetachain", cctx.InboundParams.CoinType), + ErrorMessageOutbound: fmt.Sprintf("revert on ZetaChain is not supported for cctx v1 with coin type %s", cctx.InboundParams.CoinType), }) } } @@ -290,7 +290,7 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro // The outbound failed due to majority of observer voting failure.We do not have the exact reason for the failure available on chain. cctx.SetPendingRevert(types.StatusMessages{ StatusMessage: "outbound failed", - ErrorMessageOutbound: "outbound failed to external chain ,start revert", + ErrorMessageOutbound: "outbound failed to connected chain ,start revert", }) data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { @@ -375,7 +375,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // update status cctx.SetPendingRevert(types.StatusMessages{ StatusMessage: "outbound failed", - ErrorMessageOutbound: "outbound failed to external chain ,start revert", + ErrorMessageOutbound: "outbound failed to connected chain ,start revert", }) // process the revert on ZEVM diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go index 9fdb7bf713..6983dcdc21 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go @@ -12,7 +12,7 @@ import ( const ( // AbortMessage is the message to abort a stuck CCTX - AbortMessage = "cctx aborted with admin cmd" + AbortMessage = "cctx aborted through MsgAbortStuckCCTX" ) // AbortStuckCCTX aborts a stuck CCTX diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 6e2aec5024..9385eebf85 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -147,6 +147,7 @@ func (m *CrossChainTx) AddRevertOutbound(gasLimit uint64) error { TssPubkey: m.GetCurrentOutboundParam().TssPubkey, } + // TODO : Refactor to move CoinType field to the CCTX object directly : https://github.com/zeta-chain/node/issues/1943 if m.InboundParams != nil { revertTxParams.CoinType = m.InboundParams.CoinType } From af8fa7d6689011e0ca59d73c7644dcb8d894f5c0 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 16 Jan 2025 13:26:30 -0500 Subject: [PATCH 13/13] refactor naming --- docs/zetacore/status_message.md | 13 ++++----- x/crosschain/keeper/cctx_gateway_observers.go | 2 +- x/crosschain/keeper/cctx_gateway_zevm.go | 2 +- .../cctx_orchestrator_validate_outbound.go | 29 ++++++++++--------- .../keeper/msg_server_vote_outbound_tx.go | 17 ++++++----- .../msg_server_vote_outbound_tx_test.go | 12 ++++---- 6 files changed, 39 insertions(+), 36 deletions(-) diff --git a/docs/zetacore/status_message.md b/docs/zetacore/status_message.md index 029c5b639d..41dcf27398 100644 --- a/docs/zetacore/status_message.md +++ b/docs/zetacore/status_message.md @@ -41,16 +41,15 @@ A cctx can have a maximum of two outbound params. We can refer to the first outb ### Example values for StatusMessage field and how to interpret them - `initiating outbound` : The inbound votes have been successfully finalized, and the protocol is starting the outbound process -- `outbound mined successfully` : The outbound was successfully mined -- `revert successful` : The outbound failed , but the revert was successful -- `revert failed` : The revert failed. This message also means that the initial outbound has failed. +- `outbound successfully mined` : The outbound was successfully mined +- `revert successfully processed` : The outbound failed , but the revert was successful +- `revert failed to be processed` : The revert failed. This message also means that the initial outbound has failed. - `outbound failed` : The outbound failed, The protocol would try to create a revert either in the same block or schedule one to be picked up by zetaclient -- `outbound failed for non-ZETA cctx` : Special case of outbound failed where we do not try to revert the cctx - `outbound failed for admin tx` : The outbound failed for an admin transaction, in this case we do not revert the cctx -- `outbound failed but the universal contract did not revert` : Special case of outbound failed The outbound/deposit failed, but the contract did not revert, +- `outbound failed unable to process` : The outbound processing failed at the protocol level. When this happens, the protocol sets the cctx to aborted. +- `outbound failed but the universal contract did not revert` : The outbound/deposit failed, but the contract did not revert, this is most likely caused by an internal error in the protocol.The CCTX is this case is aborted. Users can try connecting with the zetachain team to get a refund -- `outbound pre-processing failed` : The outbound failed during the pre-processing step. This means the outbound is never created. In this case the cctx is aborted - `cctx aborted through MsgAbortStuckCCTX` : The cctx was aborted manually by an admin command @@ -65,6 +64,6 @@ A cctx can have a maximum of two outbound params. We can refer to the first outb - revertReason: Revert reason from the smart contract ``` -- `outbound failed to connected chain ,start revert` : withdraw failed to an external chain, and the protocol is starting the revert process back to ZEVM. +- `outbound tx failed to be executed on connected chain` : `revert tx failed to be executed on connected chain` : The outbound/revert transaction failed to be executed on the connected chain. - `coin type [CoinType] not supported for revert when source chain is Zetachain` : The coin type is not supported for revert when the source chain is Zetachain. - `error from EVMDeposit: [Error_String]` : Error returned by the protocol when trying to deposit tokens( and optionally call a contract) on ZEVM. The error string should explain the cause diff --git a/x/crosschain/keeper/cctx_gateway_observers.go b/x/crosschain/keeper/cctx_gateway_observers.go index 043c84ecd2..cc9d9fac9f 100644 --- a/x/crosschain/keeper/cctx_gateway_observers.go +++ b/x/crosschain/keeper/cctx_gateway_observers.go @@ -76,7 +76,7 @@ func (c CCTXGatewayObservers) InitiateOutbound( if err != nil { // do not commit anything here as the CCTX should be aborted config.CCTX.SetAbort(types.StatusMessages{ - StatusMessage: "outbound pre-processing failed", + StatusMessage: "outbound failed unable to process", ErrorMessageOutbound: fmt.Sprintf("unable to create outbound: %s", err.Error()), }) return types.CctxStatus_Aborted, err diff --git a/x/crosschain/keeper/cctx_gateway_zevm.go b/x/crosschain/keeper/cctx_gateway_zevm.go index 89a5dba387..639661cef7 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -32,7 +32,7 @@ func (c CCTXGatewayZEVM) InitiateOutbound( // exceptional case; internal error; should abort CCTX config.CCTX.SetAbort(types.StatusMessages{ StatusMessage: "outbound failed but the universal contract did not revert", - ErrorMessageOutbound: fmt.Sprintf("error from EVMDeposit: %s", err.Error()), + ErrorMessageOutbound: fmt.Sprintf("failed to deposit tokens in ZEVM: %s", err.Error()), }) return types.CctxStatus_Aborted, err } diff --git a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go index 2b7ff56a18..d991a331a6 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go @@ -58,7 +58,7 @@ func (k Keeper) ValidateOutboundZEVM( // as both the outbound and the revert failed in the same block cctx.SetAbort( types.StatusMessages{ - StatusMessage: fmt.Sprintf("revert failed"), + StatusMessage: fmt.Sprintf("revert failed to be processed"), ErrorMessageOutbound: depositErr.Error(), ErrorMessageRevert: revertErr.Error(), }) @@ -113,7 +113,7 @@ func (k Keeper) ValidateOutboundObservers( // 4. Set the finalization status of the current outbound tx to executed. If a revert tx is is created, the finalization status is not set, it would get set when the revert is processed via a subsequent transaction // // This function sets CCTX status , in cases where the outbound tx is successful, but tx itself fails -// This is done because SaveSuccessfulOutbound does not set the cctx status +// This is done because HandleValidOutbound does not set the cctx status // For cases where the outbound tx is unsuccessful, the cctx status is automatically set to Aborted in the processFailedOutboundObservers function, so we can just return and error to trigger that func (k Keeper) processFailedOutboundObservers(ctx sdk.Context, cctx *types.CrossChainTx, valueReceived string) error { oldStatus := cctx.CctxStatus.Status @@ -147,8 +147,9 @@ func (k Keeper) processFailedOutboundObservers(ctx sdk.Context, cctx *types.Cros { cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "outbound failed for non-ZETA cctx", - ErrorMessageOutbound: fmt.Sprintf("revert on ZetaChain is not supported for cctx v1 with coin type %s", cctx.InboundParams.CoinType), + StatusMessage: "outbound failed", + ErrorMessageOutbound: "outbound tx failed to be executed on connected chain", + ErrorMessageRevert: fmt.Sprintf("revert on ZetaChain is not supported for cctx v1 with coin type %s", cctx.InboundParams.CoinType), }) } } @@ -227,7 +228,7 @@ func (k Keeper) processFailedOutboundOnExternalChain( case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "revert failed", + StatusMessage: "revert failed to be processed", ErrorMessageRevert: errorMsg, }) } @@ -245,7 +246,7 @@ func (k Keeper) processFailedOutboundOnExternalChain( // 3. Emit an event for the successful outbound transaction if flag is provided // // This function sets CCTX status, in cases where the outbound tx is successful, but tx itself fails -// This is done because SaveSuccessfulOutbound does not set the cctx status +// This is done because HandleValidOutbound does not set the cctx status // For cases where the outbound tx is unsuccessful, the cctx status is automatically set to Aborted in the processFailedOutboundObservers function, so we can just return and error to trigger that func (k Keeper) processSuccessfulOutbound( ctx sdk.Context, @@ -256,9 +257,9 @@ func (k Keeper) processSuccessfulOutbound( oldStatus := cctx.CctxStatus.Status switch oldStatus { case types.CctxStatus_PendingRevert: - cctx.SetReverted(types.StatusMessages{StatusMessage: "revert successful"}) + cctx.SetReverted(types.StatusMessages{StatusMessage: "revert successfully processed"}) case types.CctxStatus_PendingOutbound: - cctx.SetOutboundMined(types.StatusMessages{StatusMessage: "outbound mined successfully"}) + cctx.SetOutboundMined(types.StatusMessages{StatusMessage: "outbound successfully mined"}) default: return } @@ -290,7 +291,7 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro // The outbound failed due to majority of observer voting failure.We do not have the exact reason for the failure available on chain. cctx.SetPendingRevert(types.StatusMessages{ StatusMessage: "outbound failed", - ErrorMessageOutbound: "outbound failed to connected chain ,start revert", + ErrorMessageOutbound: "outbound failed to be executed on connected chain", }) data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { @@ -326,7 +327,7 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro } cctx.SetReverted(types.StatusMessages{ - StatusMessage: "revert successful", + StatusMessage: "revert successfully processed", }) if len(ctx.TxBytes()) > 0 { @@ -375,7 +376,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // update status cctx.SetPendingRevert(types.StatusMessages{ StatusMessage: "outbound failed", - ErrorMessageOutbound: "outbound failed to connected chain ,start revert", + ErrorMessageOutbound: "outbound tx failed to be executed on connected chain", }) // process the revert on ZEVM @@ -395,7 +396,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT // tx is reverted cctx.SetReverted(types.StatusMessages{ - StatusMessage: "revert successful", + StatusMessage: "revert successfully processed", }) // add event for tendermint transaction hash format @@ -410,8 +411,8 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed cctx.SetAbort(types.StatusMessages{ - StatusMessage: "revert failed", - ErrorMessageRevert: "outbound and revert failed", + StatusMessage: "revert failed to be processed", + ErrorMessageRevert: "revert tx failed to be executed on connected chain", }) } return nil diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index 9cf161a5bd..63caa39447 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -123,10 +123,13 @@ func (k msgServer) VoteOutbound( // We use the current TSS pubkey to finalize the outbound. err = k.ValidateOutboundObservers(ctx, &cctx, ballot.BallotStatus, msg.ValueReceived.String()) if err != nil { - k.SaveFailedOutbound(ctx, &cctx, err.Error(), tss.TssPubkey) + // The validate function for the outbound returns and error , which means that the outbound is invalid and should instead be aborted directly + // Irrespective of what the Ballot status is + k.HandleInvalidOutbound(ctx, &cctx, err.Error(), tss.TssPubkey) return &types.MsgVoteOutboundResponse{}, nil } - k.SaveSuccessfulOutbound(ctx, &cctx, tss.TssPubkey) + // The outbound s valid, the HandleValidOutbound function would save the required status changes + k.HandleValidOutbound(ctx, &cctx, tss.TssPubkey) return &types.MsgVoteOutboundResponse{}, nil } @@ -185,26 +188,26 @@ func percentOf(n *big.Int, percent int64) *big.Int { } /* -SaveFailedOutbound saves a failed outbound transaction.It does the following things in one function: +HandleInvalidOutbound saves a failed outbound transaction.It does the following things in one function: 1. Change the status of the CCTX to Aborted 2. Save the outbound */ -func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, tssPubkey string) { +func (k Keeper) HandleInvalidOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, tssPubkey string) { cctx.SetAbort(types.StatusMessages{ - StatusMessage: "outbound failed", + StatusMessage: "outbound failed unable to process", ErrorMessageOutbound: errMessage, }) ctx.Logger().Error(errMessage) k.SaveOutbound(ctx, cctx, tssPubkey) } -// SaveSuccessfulOutbound saves a successful outbound transaction. +// HandleValidOutbound saves a successful outbound transaction. // This function does not set the CCTX status, therefore all successful outbound transactions need // to have their status set during processing -func (k Keeper) SaveSuccessfulOutbound(ctx sdk.Context, cctx *types.CrossChainTx, tssPubkey string) { +func (k Keeper) HandleValidOutbound(ctx sdk.Context, cctx *types.CrossChainTx, tssPubkey string) { k.SaveOutbound(ctx, cctx, tssPubkey) } diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go index 5c1415d2df..1f84eec079 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go @@ -146,7 +146,7 @@ func TestKeeper_VoteOutbound(t *testing.T) { // Successfully mock VoteOnOutboundBallot keepertest.MockVoteOnOutboundSuccessBallot(observerMock, ctx, cctx, senderChain, observer) - // Successfully mock SaveSuccessfulOutbound + // Successfully mock HandleValidOutbound expectedNumberOfOutboundParams := 1 keepertest.MockSaveOutbound(observerMock, ctx, cctx, tss, expectedNumberOfOutboundParams) @@ -452,7 +452,7 @@ func TestKeeper_VoteOutbound(t *testing.T) { // Successfully mock GetSupportedChainFromChainID keepertest.MockGetSupportedChainFromChainID(observerMock, senderChain) - //Successfully mock SaveFailedOutbound + //Successfully mock HandleInvalidOutbound expectedNumberOfOutboundParams := 1 keepertest.MockSaveOutbound(observerMock, ctx, cctx, tss, expectedNumberOfOutboundParams) @@ -592,7 +592,7 @@ func TestKeeper_SaveFailedOutbound(t *testing.T) { cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound //ACT - k.SaveFailedOutbound(ctx, cctx, sample.String(), sample.Tss().TssPubkey) + k.HandleInvalidOutbound(ctx, cctx, sample.String(), sample.Tss().TssPubkey) //ASSERT require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_Aborted) @@ -619,7 +619,7 @@ func TestKeeper_SaveFailedOutbound(t *testing.T) { cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound //ACT - k.SaveFailedOutbound(ctx, cctx, sample.String(), sample.Tss().TssPubkey) + k.HandleInvalidOutbound(ctx, cctx, sample.String(), sample.Tss().TssPubkey) //ASSERT require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_Aborted) @@ -648,7 +648,7 @@ func TestKeeper_SaveSuccessfulOutbound(t *testing.T) { cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound //ACT - k.SaveSuccessfulOutbound(ctx, cctx, sample.Tss().TssPubkey) + k.HandleValidOutbound(ctx, cctx, sample.Tss().TssPubkey) //ASSERT _, found := k.GetOutboundTracker( @@ -674,7 +674,7 @@ func TestKeeper_SaveSuccessfulOutbound(t *testing.T) { cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound //ACT - k.SaveSuccessfulOutbound(ctx, cctx, sample.Tss().TssPubkey) + k.HandleValidOutbound(ctx, cctx, sample.Tss().TssPubkey) //ASSERT for _, outboundParams := range cctx.OutboundParams {