diff --git a/changelog.md b/changelog.md index 78b9ab0b59..5de0dbd846 100644 --- a/changelog.md +++ b/changelog.md @@ -26,6 +26,7 @@ * [2826](https://github.com/zeta-chain/node/pull/2826) - remove unused code from emissions module and add new parameter for fixed block reward amount * [2890](https://github.com/zeta-chain/node/pull/2890) - refactor `MsgUpdateChainInfo` to accept a single chain, and add `MsgRemoveChainInfo` to remove a chain * [2899](https://github.com/zeta-chain/node/pull/2899) - remove btc deposit fee v1 and improve unit tests +* [2952](https://github.com/zeta-chain/node/pull/2952) - add error_message to cctx.status ### Tests diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index a8c0a2516e..461b8566cc 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -58446,6 +58446,14 @@ definitions: $ref: '#/definitions/crosschainCctxStatus' status_message: type: string + description: |- + status_message carries information about the status transitions: + why they were triggered, old and new status. + error_message: + type: string + description: |- + error_message carries information about the error that caused the tx + to be PendingRevert, Reverted or Aborted. lastUpdate_timestamp: type: string format: int64 diff --git a/e2e/e2etests/test_eth_deposit_call.go b/e2e/e2etests/test_eth_deposit_call.go index 570e7b05eb..46805f9f81 100644 --- a/e2e/e2etests/test_eth_deposit_call.go +++ b/e2e/e2etests/test_eth_deposit_call.go @@ -87,6 +87,6 @@ func TestEtherDepositAndCall(r *runner.E2ERunner, args []string) { r.Logger.Info("Cross-chain call to reverter reverted") - // check the status message contains revert error hash in case of revert - require.Contains(r, cctx.CctxStatus.StatusMessage, utils.ErrHashRevertFoo) + // Check the error carries the revert executed. + require.Contains(r, cctx.CctxStatus.ErrorMessage, "revert executed") } diff --git a/e2e/e2etests/test_solana_deposit_refund.go b/e2e/e2etests/test_solana_deposit_refund.go index e9155c9ddd..3176edee78 100644 --- a/e2e/e2etests/test_solana_deposit_refund.go +++ b/e2e/e2etests/test_solana_deposit_refund.go @@ -31,6 +31,6 @@ func TestSolanaDepositAndCallRefund(r *runner.E2ERunner, args []string) { r.Logger.CCTX(*cctx, "solana_deposit_and_refund") utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Reverted) - // check the status message contains revert error hash in case of revert - require.Contains(r, cctx.CctxStatus.StatusMessage, utils.ErrHashRevertFoo) + // Check the error carries the revert executed. + require.Contains(r, cctx.CctxStatus.ErrorMessage, "revert executed") } diff --git a/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto b/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto index 0ca1f56f7d..9b634a6378 100644 --- a/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto +++ b/proto/zetachain/zetacore/crosschain/cross_chain_tx.proto @@ -17,7 +17,7 @@ enum CctxStatus { Reverted = 5; // inbound reverted. Aborted = 6; // inbound tx error or invalid paramters and cannot revert; just abort. - // But the amount can be refunded to zetachain using and admin proposal + // But the amount can be refunded to zetachain using and admin proposal } enum TxFinalizationStatus { @@ -94,7 +94,12 @@ message OutboundParams { message Status { CctxStatus status = 1; + // status_message carries information about the status transitions: + // why they were triggered, old and new status. string status_message = 2; + // error_message carries information about the error that caused the tx + // to be PendingRevert, Reverted or Aborted. + string error_message = 6; int64 lastUpdate_timestamp = 3; bool isAbortRefunded = 4; // when the CCTX was created. only populated on new transactions. diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index 8f09271e23..ff17525734 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -191,6 +191,7 @@ func Status(t *testing.T, index string) *types.Status { return &types.Status{ Status: types.CctxStatus(r.Intn(100)), StatusMessage: String(), + ErrorMessage: String(), CreatedTimestamp: createdAt, LastUpdateTimestamp: createdAt, } 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 1ffa04eaca..e5295ee133 100644 --- a/typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.ts +++ b/typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.ts @@ -355,10 +355,21 @@ export declare class Status extends Message { status: CctxStatus; /** + * status_message carries information about the status transitions: + * why they were triggered, old and new status. + * * @generated from field: string status_message = 2; */ statusMessage: string; + /** + * error_message carries information about the error that caused the tx + * to be PendingRevert, Reverted or Aborted. + * + * @generated from field: string error_message = 6; + */ + errorMessage: string; + /** * @generated from field: int64 lastUpdate_timestamp = 3; */ diff --git a/x/crosschain/keeper/cctx_gateway_observers.go b/x/crosschain/keeper/cctx_gateway_observers.go index 39a33f4edc..9576bcfe32 100644 --- a/x/crosschain/keeper/cctx_gateway_observers.go +++ b/x/crosschain/keeper/cctx_gateway_observers.go @@ -75,7 +75,7 @@ func (c CCTXGatewayObservers) InitiateOutbound( }() if err != nil { // do not commit anything here as the CCTX should be aborted - config.CCTX.SetAbort(err.Error()) + config.CCTX.SetAbort("internal error", 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 81366d6af3..fc247ad7a4 100644 --- a/x/crosschain/keeper/cctx_gateway_zevm.go +++ b/x/crosschain/keeper/cctx_gateway_zevm.go @@ -28,7 +28,9 @@ func (c CCTXGatewayZEVM) InitiateOutbound( if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX - config.CCTX.SetAbort(err.Error()) + config.CCTX.SetAbort( + "error during deposit that is not smart contract revert", + 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 17c848613a..2f3acdd744 100644 --- a/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go +++ b/x/crosschain/keeper/cctx_orchestrator_validate_outbound.go @@ -53,7 +53,9 @@ func (k Keeper) ValidateOutboundZEVM( cctx.InboundParams.Amount, ) if err != nil { - cctx.SetAbort(fmt.Sprintf("%s : %s", depositErr, err.Error())) + cctx.SetAbort( + "revert failed", + fmt.Sprintf("deposit error: %s, processing error: %s", depositErr.Error(), err.Error())) return types.CctxStatus_Aborted } @@ -122,7 +124,7 @@ 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, cmd cctx reverted") + cctx.SetAbort("", "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 @@ -137,7 +139,7 @@ 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("", "outbound failed for non-ZETA cctx") } } } else { @@ -195,10 +197,10 @@ 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("", revertMsg) case types.CctxStatus_PendingRevert: cctx.GetCurrentOutboundParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.SetAbort("Outbound failed: revert failed; abort TX") + cctx.SetAbort("aborted while processing failed outbound", "outbound and revert failed") } return nil } @@ -225,9 +227,9 @@ func (k Keeper) processSuccessfulOutbound( oldStatus := cctx.CctxStatus.Status switch oldStatus { case types.CctxStatus_PendingRevert: - cctx.SetReverted("Outbound succeeded, revert executed") + cctx.SetReverted("", "revert executed") case types.CctxStatus_PendingOutbound: - cctx.SetOutboundMined("Outbound succeeded, mined") + cctx.SetOutboundMined("") default: return } @@ -256,7 +258,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("Outbound failed, trying revert") + cctx.SetPendingRevert("", "outbound failed") data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { return fmt.Errorf("failed decoding relayed message: %s", err.Error()) @@ -290,7 +292,7 @@ func (k Keeper) processFailedZETAOutboundOnZEVM(ctx sdk.Context, cctx *types.Cro return fmt.Errorf("failed ZETARevertAndCallContract: %s", err.Error()) } - cctx.SetReverted("Outbound failed, revert executed") + cctx.SetReverted("", "outbound failed") if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) @@ -336,7 +338,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT } // update status - cctx.SetPendingRevert("Outbound failed, trying revert") + cctx.SetPendingRevert("", "outbound failed") // process the revert on ZEVM if err := k.fungibleKeeper.ProcessV2RevertDeposit( @@ -354,7 +356,7 @@ func (k Keeper) processFailedOutboundV2(ctx sdk.Context, cctx *types.CrossChainT } // tx is reverted - cctx.SetReverted("Outbound failed, revert executed") + cctx.SetReverted("", "outbound failed") // add event for tendermint transaction hash format if len(ctx.TxBytes()) > 0 { @@ -367,7 +369,7 @@ 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("Outbound failed: revert failed; abort TX") + cctx.SetAbort("aborted while processing failed outbound", "outbound and revert failed") } return nil } diff --git a/x/crosschain/keeper/cctx_test.go b/x/crosschain/keeper/cctx_test.go index 8a51b4cf2a..d1e3f6fafc 100644 --- a/x/crosschain/keeper/cctx_test.go +++ b/x/crosschain/keeper/cctx_test.go @@ -170,7 +170,6 @@ func TestCCTXs(t *testing.T) { require.True(t, found) require.Equal(t, s, send) } - }) } } diff --git a/x/crosschain/keeper/initiate_outbound_test.go b/x/crosschain/keeper/initiate_outbound_test.go index 55ca3e36f8..204179bea5 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.StatusMessage) + require.Equal(t, "deposit error", cctx.CctxStatus.ErrorMessage) }) t.Run( @@ -111,7 +111,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.Equal(t, types.CctxStatus_Aborted, newStatus) require.Contains( t, - cctx.CctxStatus.StatusMessage, + cctx.CctxStatus.ErrorMessage, "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.StatusMessage, + cctx.CctxStatus.ErrorMessage, "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.StatusMessage, + cctx.CctxStatus.ErrorMessage, "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.StatusMessage, + cctx.CctxStatus.ErrorMessage, "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.StatusMessage, "cannot find receiver chain nonce") + require.Contains(t, cctx.CctxStatus.ErrorMessage, "cannot find receiver chain nonce") }) t.Run("unable to process zevm deposit HandleEVMDeposit revert successfully", func(t *testing.T) { @@ -321,7 +321,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.NoError(t, err) require.Equal(t, types.CctxStatus_PendingRevert, cctx.CctxStatus.Status) require.Equal(t, types.CctxStatus_PendingRevert, newStatus) - require.Equal(t, errDeposit.Error(), cctx.CctxStatus.StatusMessage) + require.Equal(t, errDeposit.Error(), cctx.CctxStatus.ErrorMessage) require.Equal(t, updatedNonce, cctx.GetCurrentOutboundParam().TssNonce) }) @@ -361,7 +361,7 @@ func TestKeeper_InitiateOutboundZEVMDeposit(t *testing.T) { require.Equal(t, types.CctxStatus_Aborted, newStatus) require.Contains( t, - cctx.CctxStatus.StatusMessage, + cctx.CctxStatus.ErrorMessage, "cannot revert a revert tx", ) }, @@ -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.StatusMessage) + require.Equal(t, observertypes.ErrSupportedChains.Error(), cctx.CctxStatus.ErrorMessage) }) t.Run("unable to process crosschain msg passing UpdateNonce fails", func(t *testing.T) { @@ -456,7 +456,7 @@ func TestKeeper_InitiateOutboundProcessCrosschainMsgPassing(t *testing.T) { require.ErrorContains(t, err, "cannot find receiver chain nonce") require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) require.Equal(t, types.CctxStatus_Aborted, newStatus) - require.Contains(t, cctx.CctxStatus.StatusMessage, "cannot find receiver chain nonce") + require.Contains(t, cctx.CctxStatus.ErrorMessage, "cannot find receiver chain nonce") }) } diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds.go b/x/crosschain/keeper/msg_server_migrate_tss_funds.go index c285033f02..8ecc4c47ff 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds.go @@ -9,7 +9,6 @@ import ( tmbytes "github.com/cometbft/cometbft/libs/bytes" tmtypes "github.com/cometbft/cometbft/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" authoritytypes "github.com/zeta-chain/node/x/authority/types" "github.com/zeta-chain/node/x/crosschain/types" @@ -26,7 +25,7 @@ func (k msgServer) MigrateTssFunds( // check if authorized err := k.GetAuthorityKeeper().CheckAuthorization(ctx, msg) if err != nil { - return nil, errors.Wrap(authoritytypes.ErrUnauthorized, err.Error()) + return nil, errorsmod.Wrap(authoritytypes.ErrUnauthorized, err.Error()) } if k.zetaObserverKeeper.IsInboundEnabled(ctx) { 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 e824a01707..5aa70be3bd 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -265,7 +265,7 @@ func TestKeeper_VoteInbound(t *testing.T) { }) } -func TestStatus_ChangeStatus(t *testing.T) { +func TestStatus_UpdateCctxStatus(t *testing.T) { tt := []struct { Name string Status types.Status @@ -302,7 +302,7 @@ func TestStatus_ChangeStatus(t *testing.T) { for _, test := range tt { test := test t.Run(test.Name, func(t *testing.T) { - test.Status.ChangeStatus(test.NonErrStatus, test.Msg) + test.Status.UpdateStatusAndErrorMessages(test.NonErrStatus, 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 6682c2c705..4bb65a3c8f 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -185,7 +185,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(errMessage) + cctx.SetAbort("", errMessage) ctx.Logger().Error(errMessage) k.SaveOutbound(ctx, cctx, tssPubkey) } diff --git a/x/crosschain/migrations/v5/migrate.go b/x/crosschain/migrations/v5/migrate.go index aeeb22451f..0f21d8646b 100644 --- a/x/crosschain/migrations/v5/migrate.go +++ b/x/crosschain/migrations/v5/migrate.go @@ -137,6 +137,7 @@ func SetZetaAccounting( return nil } + func GetAbortedAmount(cctx types.CrossChainTx) sdkmath.Uint { if cctx.OutboundParams != nil && !cctx.GetCurrentOutboundParam().Amount.IsZero() { return cctx.GetCurrentOutboundParam().Amount diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 0a235dffae..91004511d4 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -171,28 +171,28 @@ func (m *CrossChainTx) AddOutbound( } // SetAbort sets the CCTX status to Aborted with the given error message. -func (m CrossChainTx) SetAbort(message string) { - m.CctxStatus.ChangeStatus(CctxStatus_Aborted, message) +func (m CrossChainTx) SetAbort(statusMsg, errorMsg string) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_Aborted, statusMsg, errorMsg) } // SetPendingRevert sets the CCTX status to PendingRevert with the given error message. -func (m CrossChainTx) SetPendingRevert(message string) { - m.CctxStatus.ChangeStatus(CctxStatus_PendingRevert, message) +func (m CrossChainTx) SetPendingRevert(statusMsg, errorMsg string) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_PendingRevert, statusMsg, errorMsg) } // SetPendingOutbound sets the CCTX status to PendingOutbound with the given error message. -func (m CrossChainTx) SetPendingOutbound(message string) { - m.CctxStatus.ChangeStatus(CctxStatus_PendingOutbound, message) +func (m CrossChainTx) SetPendingOutbound(statusMsg string) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_PendingOutbound, statusMsg, "") } // SetOutboundMined sets the CCTX status to OutboundMined with the given error message. -func (m CrossChainTx) SetOutboundMined(message string) { - m.CctxStatus.ChangeStatus(CctxStatus_OutboundMined, message) +func (m CrossChainTx) SetOutboundMined(statusMsg string) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_OutboundMined, statusMsg, "") } // SetReverted sets the CCTX status to Reverted with the given error message. -func (m CrossChainTx) SetReverted(message string) { - m.CctxStatus.ChangeStatus(CctxStatus_Reverted, message) +func (m CrossChainTx) SetReverted(statusMsg, errorMsg string) { + m.CctxStatus.UpdateStatusAndErrorMessages(CctxStatus_Reverted, statusMsg, errorMsg) } func (m CrossChainTx) GetCCTXIndexBytes() ([32]byte, error) { @@ -259,6 +259,7 @@ func NewCCTX(ctx sdk.Context, msg MsgVoteInbound, tssPubkey string) (CrossChainT status := &Status{ Status: CctxStatus_PendingInbound, StatusMessage: "", + ErrorMessage: "", CreatedTimestamp: ctx.BlockHeader().Time.Unix(), LastUpdateTimestamp: ctx.BlockHeader().Time.Unix(), IsAbortRefunded: false, diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 00fbe2ac66..f49768f8a0 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -150,17 +150,20 @@ func Test_SetRevertOutboundValues(t *testing.T) { func TestCrossChainTx_SetAbort(t *testing.T) { cctx := sample.CrossChainTx(t, "test") - cctx.SetAbort("test") + cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound + cctx.SetAbort("test", "test") require.Equal(t, types.CctxStatus_Aborted, cctx.CctxStatus.Status) - require.Equal(t, "test", "test") + require.Contains(t, cctx.CctxStatus.StatusMessage, "test") + require.Contains(t, cctx.CctxStatus.ErrorMessage, "test") } func TestCrossChainTx_SetPendingRevert(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingOutbound - cctx.SetPendingRevert("test") + cctx.SetPendingRevert("test", "test") require.Equal(t, types.CctxStatus_PendingRevert, cctx.CctxStatus.Status) require.Contains(t, cctx.CctxStatus.StatusMessage, "test") + require.Contains(t, cctx.CctxStatus.ErrorMessage, "test") } func TestCrossChainTx_SetPendingOutbound(t *testing.T) { @@ -169,6 +172,7 @@ func TestCrossChainTx_SetPendingOutbound(t *testing.T) { cctx.SetPendingOutbound("test") require.Equal(t, types.CctxStatus_PendingOutbound, cctx.CctxStatus.Status) require.Contains(t, cctx.CctxStatus.StatusMessage, "test") + require.NotContains(t, cctx.CctxStatus.ErrorMessage, "test") } func TestCrossChainTx_SetOutboundMined(t *testing.T) { @@ -177,12 +181,14 @@ func TestCrossChainTx_SetOutboundMined(t *testing.T) { cctx.SetOutboundMined("test") require.Equal(t, types.CctxStatus_OutboundMined, cctx.CctxStatus.Status) require.Contains(t, cctx.CctxStatus.StatusMessage, "test") + require.NotContains(t, cctx.CctxStatus.ErrorMessage, "test") } func TestCrossChainTx_SetReverted(t *testing.T) { cctx := sample.CrossChainTx(t, "test") cctx.CctxStatus.Status = types.CctxStatus_PendingRevert - cctx.SetReverted("test") + cctx.SetReverted("test", "test") require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) require.Contains(t, cctx.CctxStatus.StatusMessage, "test") + require.Contains(t, cctx.CctxStatus.ErrorMessage, "test") } diff --git a/x/crosschain/types/cross_chain_tx.pb.go b/x/crosschain/types/cross_chain_tx.pb.go index 842ba310ba..23923a9cbf 100644 --- a/x/crosschain/types/cross_chain_tx.pb.go +++ b/x/crosschain/types/cross_chain_tx.pb.go @@ -488,10 +488,15 @@ func (m *OutboundParams) GetCallOptions() *CallOptions { } 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"` - 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"` + Status CctxStatus `protobuf:"varint,1,opt,name=status,proto3,enum=zetachain.zetacore.crosschain.CctxStatus" json:"status,omitempty"` + // status_message carries information about the status transitions: + // why they were triggered, old and new status. + StatusMessage string `protobuf:"bytes,2,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` + // error_message carries information about the error that caused the tx + // to be PendingRevert, Reverted or Aborted. + 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"` // 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"` } @@ -543,6 +548,13 @@ func (m *Status) GetStatusMessage() string { return "" } +func (m *Status) GetErrorMessage() string { + if m != nil { + return m.ErrorMessage + } + return "" +} + func (m *Status) GetLastUpdateTimestamp() int64 { if m != nil { return m.LastUpdateTimestamp @@ -753,92 +765,93 @@ func init() { } var fileDescriptor_d4c1966807fb5cb2 = []byte{ - // 1348 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, 0x51, 0xfc, 0xaa, - 0x75, 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, 0xfa, - 0x85, 0x70, 0x22, 0x7c, 0x99, 0xc9, 0x95, 0xdc, 0x4a, 0xed, 0x4f, 0x07, 0xb2, 0x06, 0x7f, 0x0b, - 0xb2, 0x26, 0x75, 0x47, 0xa5, 0x7e, 0xfb, 0x32, 0xe4, 0x50, 0x0c, 0x4d, 0xc2, 0xc6, 0x11, 0xad, - 0x43, 0x59, 0xaf, 0x82, 0x1e, 0xe1, 0x1c, 0x77, 0x88, 0xe2, 0x5f, 0xde, 0x2f, 0x69, 0xed, 0x43, - 0xad, 0x44, 0x77, 0xa0, 0x12, 0x63, 0x2e, 0x9e, 0xf4, 0x23, 0x2c, 0x48, 0x20, 0x68, 0x8f, 0x70, - 0x81, 0x7b, 0x7d, 0x45, 0xc4, 0x39, 0x7f, 0x79, 0x62, 0x3b, 0xb4, 0x26, 0x54, 0x07, 0x39, 0x1d, - 0xe4, 0xe4, 0xf1, 0xc9, 0xf1, 0x20, 0x89, 0x48, 0xa4, 0x58, 0xa7, 0x87, 0xc6, 0x59, 0x35, 0xfa, - 0x04, 0x96, 0xc2, 0x94, 0x60, 0x39, 0xed, 0x26, 0xc8, 0xf3, 0x0a, 0xd9, 0x35, 0x86, 0x31, 0x6c, - 0xed, 0x87, 0x59, 0x28, 0xf9, 0xe4, 0x94, 0xa4, 0xc2, 0x0e, 0xaf, 0x75, 0x28, 0xa7, 0x4a, 0x11, - 0xe0, 0x28, 0x4a, 0x09, 0xe7, 0x66, 0xcc, 0x94, 0xb4, 0x76, 0x4b, 0x2b, 0xd1, 0xc7, 0x50, 0xd6, - 0x87, 0x91, 0x04, 0xda, 0x60, 0x66, 0x98, 0x3a, 0xa2, 0xfd, 0x44, 0x63, 0xca, 0xcb, 0x4a, 0x4d, - 0xcb, 0x31, 0x96, 0xbe, 0x70, 0x8b, 0x4a, 0x69, 0xa1, 0x26, 0x11, 0x6d, 0xd1, 0xe4, 0x97, 0x15, - 0x6d, 0x44, 0x5b, 0xb4, 0xa7, 0x72, 0xba, 0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0x2c, 0xec, 0xa6, 0xfe, 0xff, 0x90, 0xb0, 0x88, 0x34, 0x87, 0x67, 0xff, 0xa6, 0x28, - 0x52, 0xb5, 0xb3, 0xea, 0xe0, 0xee, 0xfe, 0x15, 0x00, 0x00, 0xff, 0xff, 0x94, 0x4b, 0x30, 0xb4, - 0xd4, 0x0c, 0x00, 0x00, + // 1361 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6e, 0x1b, 0xb7, + 0x13, 0xf6, 0xda, 0xb2, 0x2c, 0x8d, 0xfe, 0x78, 0x4d, 0x2b, 0xce, 0xc6, 0x3f, 0x44, 0xf1, 0x4f, + 0xad, 0x13, 0xc5, 0xad, 0x25, 0x44, 0x01, 0x8a, 0xa2, 0x37, 0xdb, 0x88, 0x13, 0xb7, 0x4d, 0x6c, + 0x6c, 0x1c, 0x03, 0xc9, 0xa1, 0x5b, 0x6a, 0x97, 0x96, 0x08, 0xaf, 0x96, 0xea, 0x92, 0x32, 0xa4, + 0xa0, 0xb7, 0x9e, 0x0b, 0xf4, 0x15, 0x0a, 0xf4, 0xd0, 0x63, 0x1f, 0x23, 0xc7, 0x1c, 0x8b, 0x1e, + 0x82, 0x20, 0x79, 0x83, 0x3e, 0x41, 0xc1, 0x7f, 0x92, 0x15, 0xb8, 0x76, 0x9a, 0xf6, 0x24, 0xf2, + 0x1b, 0xf2, 0x9b, 0xd9, 0xe1, 0x7c, 0x43, 0x0a, 0x5a, 0xcf, 0x89, 0xc0, 0x61, 0x17, 0xd3, 0xa4, + 0xa9, 0x46, 0x2c, 0x25, 0xcd, 0x30, 0x65, 0x9c, 0x6b, 0x4c, 0x0d, 0x03, 0x35, 0x0e, 0xc4, 0xb0, + 0xd1, 0x4f, 0x99, 0x60, 0xe8, 0xfa, 0x78, 0x4f, 0xc3, 0xee, 0x69, 0x4c, 0xf6, 0xac, 0x56, 0x3a, + 0x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xf3, 0xeb, 0x2f, 0x55, 0x67, 0xe3, 0x2b, 0xa8, + 0x9c, 0xd7, 0xba, 0x91, 0x0b, 0xc5, 0x47, 0x4c, 0xec, 0xda, 0x27, 0xa0, 0x3b, 0x83, 0x4a, 0x90, + 0x9f, 0x4c, 0x1d, 0xc9, 0x7c, 0x6f, 0x48, 0xc2, 0x81, 0x24, 0x9b, 0x35, 0x64, 0x4d, 0xb8, 0xfa, + 0x37, 0x99, 0x45, 0x59, 0x98, 0x3d, 0xba, 0xe3, 0xce, 0xa8, 0xdf, 0x96, 0xeb, 0xe8, 0x0d, 0xdb, + 0xf7, 0x5f, 0xbc, 0xa9, 0x3a, 0x2f, 0xdf, 0x54, 0x9d, 0xd7, 0x6f, 0xaa, 0xce, 0x4f, 0x6f, 0xab, + 0x33, 0x2f, 0xdf, 0x56, 0x67, 0x7e, 0x7f, 0x5b, 0x9d, 0x79, 0xb6, 0x79, 0x46, 0x49, 0x32, 0xb1, + 0x9b, 0xfa, 0x4f, 0x46, 0xc2, 0x22, 0xd2, 0x1c, 0x9e, 0xfd, 0x2f, 0xa3, 0x44, 0xd5, 0xce, 0xaa, + 0x83, 0xbb, 0xfb, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x84, 0x70, 0x56, 0x74, 0xf9, 0x0c, 0x00, + 0x00, } func (m *InboundParams) Marshal() (dAtA []byte, err error) { @@ -1172,6 +1185,13 @@ func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ErrorMessage) > 0 { + i -= len(m.ErrorMessage) + copy(dAtA[i:], m.ErrorMessage) + i = encodeVarintCrossChainTx(dAtA, i, uint64(len(m.ErrorMessage))) + i-- + dAtA[i] = 0x32 + } if m.CreatedTimestamp != 0 { i = encodeVarintCrossChainTx(dAtA, i, uint64(m.CreatedTimestamp)) i-- @@ -1548,6 +1568,10 @@ func (m *Status) Size() (n int) { if m.CreatedTimestamp != 0 { n += 1 + sovCrossChainTx(uint64(m.CreatedTimestamp)) } + l = len(m.ErrorMessage) + if l > 0 { + n += 1 + l + sovCrossChainTx(uint64(l)) + } return n } @@ -2773,6 +2797,38 @@ func (m *Status) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", 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.ErrorMessage = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipCrossChainTx(dAtA[iNdEx:]) diff --git a/x/crosschain/types/keys.go b/x/crosschain/types/keys.go index d9fea4a77d..76d343dd3e 100644 --- a/x/crosschain/types/keys.go +++ b/x/crosschain/types/keys.go @@ -3,7 +3,7 @@ package types import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/math" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" ) @@ -29,8 +29,8 @@ const ( CCTXIndexLength = 66 ) -func GetProtocolFee() sdk.Uint { - return sdk.NewUint(ProtocolFee) +func GetProtocolFee() math.Uint { + return math.NewUint(ProtocolFee) } func KeyPrefix(p string) []byte { diff --git a/x/crosschain/types/rate_limiter_flags_test.go b/x/crosschain/types/rate_limiter_flags_test.go index 8531a34105..545ef708a7 100644 --- a/x/crosschain/types/rate_limiter_flags_test.go +++ b/x/crosschain/types/rate_limiter_flags_test.go @@ -6,7 +6,6 @@ import ( "testing" "cosmossdk.io/math" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -263,7 +262,7 @@ func TestConvertCctxValue(t *testing.T) { erc20AssetRates map[int64]map[string]types.AssetRate // output - expectedValue sdkmath.Int + expectedValue math.Int }{ { name: "should convert cctx ZETA value correctly", diff --git a/x/crosschain/types/status.go b/x/crosschain/types/status.go index cdaf5b0aae..00c08bf6f7 100644 --- a/x/crosschain/types/status.go +++ b/x/crosschain/types/status.go @@ -9,28 +9,45 @@ func (m *Status) AbortRefunded() { m.StatusMessage = "CCTX aborted and Refunded" } -// ChangeStatus changes the status of the cross chain transaction -// empty msg does not overwrite old status message -func (m *Status) ChangeStatus(newStatus CctxStatus, msg string) { - if len(msg) > 0 { - if m.StatusMessage != "" { - m.StatusMessage = fmt.Sprintf("%s : %s", m.StatusMessage, msg) - } else { - m.StatusMessage = msg - } +// UpdateStatusAndErrorMessages transitions the Status and Error messages. +func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, statusMsg, errorMsg string) { + m.UpdateStatus(newStatus, statusMsg) + + if newStatus == CctxStatus_Aborted || newStatus == CctxStatus_Reverted || newStatus == CctxStatus_PendingRevert { + m.UpdateErrorMessage(errorMsg) } - if !m.ValidateTransition(newStatus) { +} + +// 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 : OldStatus %s , NewStatus %s , MSG : %s :", + "Failed to transition status from %s to %s", m.Status.String(), newStatus.String(), - msg, ) + m.Status = CctxStatus_Aborted - return } - m.Status = newStatus -} //nolint:typecheck + + 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" + } + + m.ErrorMessage = errMsg +} func (m *Status) ValidateTransition(newStatus CctxStatus) bool { stateTransitionMap := stateTransitionMap() diff --git a/x/crosschain/types/status_test.go b/x/crosschain/types/status_test.go index 88013a41a9..5bb272d522 100644 --- a/x/crosschain/types/status_test.go +++ b/x/crosschain/types/status_test.go @@ -140,31 +140,35 @@ 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.ChangeStatus(types.CctxStatus_PendingOutbound, "msg") + s.UpdateStatus(types.CctxStatus_PendingOutbound, "msg") assert.Equal(t, s.Status, types.CctxStatus_PendingOutbound) - assert.Equal(t, s.StatusMessage, "msg") + 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.ChangeStatus(types.CctxStatus_PendingOutbound, "") + s.UpdateStatus(types.CctxStatus_PendingOutbound, "") + fmt.Printf("%+v\n", s) assert.Equal(t, s.Status, types.CctxStatus_PendingOutbound) - assert.Equal(t, s.StatusMessage, "") + 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.ChangeStatus(types.CctxStatus_PendingInbound, "msg") + s.UpdateStatus(types.CctxStatus_PendingInbound, "msg") assert.Equal(t, s.Status, types.CctxStatus_Aborted) assert.Equal( t, fmt.Sprintf( - "Failed to transition : OldStatus %s , NewStatus %s , MSG : %s :", + "Failed to transition status from %s to %s: msg", types.CctxStatus_PendingOutbound.String(), types.CctxStatus_PendingInbound.String(), - "msg", ), s.StatusMessage, )