From 79ff38d6d74da2ed9c5d255e72c33ab731b98162 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 13 Mar 2025 14:22:53 -0400 Subject: [PATCH 1/3] improve log messages for out of gas errors --- x/crosschain/keeper/cctx_utils.go | 4 ++-- x/crosschain/keeper/gas_payment.go | 28 +++++++++++++++---------- x/crosschain/keeper/gas_payment_test.go | 2 +- x/crosschain/types/keys.go | 15 ------------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/x/crosschain/keeper/cctx_utils.go b/x/crosschain/keeper/cctx_utils.go index 3fedf03cef..213f0d5c4b 100644 --- a/x/crosschain/keeper/cctx_utils.go +++ b/x/crosschain/keeper/cctx_utils.go @@ -27,7 +27,7 @@ func (k Keeper) SetObserverOutboundInfo(ctx sdk.Context, receiveChainID int64, c if !found { return cosmoserrors.Wrapf( types.ErrCannotFindReceiverNonce, - "identifiers: %s (chain %q)", cctx.LogIdentifierForCCTX(), chain.Name, + "chain name %s", chain.Name, ) } // SET nonce @@ -36,7 +36,7 @@ func (k Keeper) SetObserverOutboundInfo(ctx sdk.Context, receiveChainID int64, c if !found { return cosmoserrors.Wrapf( types.ErrCannotFindTSSKeys, - "identifiers: %s (chain %q)", cctx.LogIdentifierForCCTX(), chain.Name, + "chain name %s", chain.Name, ) } diff --git a/x/crosschain/keeper/gas_payment.go b/x/crosschain/keeper/gas_payment.go index 4f87f872e1..d0cb2911ef 100644 --- a/x/crosschain/keeper/gas_payment.go +++ b/x/crosschain/keeper/gas_payment.go @@ -134,10 +134,12 @@ func (k Keeper) PayGasNativeAndUpdateCctx( if outTxGasFee.GT(inputAmount) { return cosmoserrors.Wrap( types.ErrNotEnoughGas, - fmt.Sprintf("outTxGasFee(%s) more than available gas for tx (%s) | Identifiers : %s ", + fmt.Sprintf( + "unable to pay for outbound tx using gas token, outbound chain: %d, required: %s, available: %s", + chainID, outTxGasFee, inputAmount, - cctx.LogIdentifierForCCTX()), + ), ) } ctx.Logger().Info("Subtracting amount from inbound tx", "amount", inputAmount.String(), "fee", outTxGasFee.String()) @@ -223,10 +225,12 @@ func (k Keeper) PayGasInERC20AndUpdateCctx( if sdkmath.NewUintFromBigInt(feeInZRC20).GT(inputAmount) { return cosmoserrors.Wrap( types.ErrNotEnoughGas, - fmt.Sprintf("feeInZRC20(%s) more than available gas for tx (%s) | Identifiers : %s ", - feeInZRC20, + fmt.Sprintf( + "unable to pay for outbound tx using zrc20 token, outbound chain: %d, required: %s, available: %s", + chainID, + outTxGasFee, inputAmount, - cctx.LogIdentifierForCCTX()), + ), ) } newAmount := inputAmount.Sub(sdkmath.NewUintFromBigInt(feeInZRC20)) @@ -347,9 +351,8 @@ func (k Keeper) PayGasInZetaAndUpdateCctx( gasPrice, priorityFee, isFound := k.GetMedianGasValues(ctx, chainID) if !isFound { return cosmoserrors.Wrapf(types.ErrUnableToGetGasPrice, - "chain %d; identifiers %q", + "chain %d", chainID, - cctx.LogIdentifierForCCTX(), ) } // overpays gas price @@ -377,14 +380,17 @@ func (k Keeper) PayGasInZetaAndUpdateCctx( return cosmoserrors.Wrap(err, "PayGasInZetaAndUpdateCctx: unable to QueryUniswapV2RouterGetZetaAmountsIn") } feeInZeta := types.GetProtocolFee().Add(sdkmath.NewUintFromBigInt(outTxGasFeeInZeta)) + // reduce the amount of the outbound tx if feeInZeta.GT(zetaBurnt) { return cosmoserrors.Wrap( - types.ErrNotEnoughZetaBurnt, - fmt.Sprintf("feeInZeta(%s) more than zetaBurnt (%s) | Identifiers : %s ", - feeInZeta, + types.ErrNotEnoughGas, + fmt.Sprintf( + "unable to pay for outbound tx using zeta token, outbound chain: %d, required: %s, available: %s", + chainID, + outTxGasFee, zetaBurnt, - cctx.LogIdentifierForCCTX()), + ), ) } ctx.Logger().Info("Subtracting amount from inbound tx", diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index 9f91ffc8d1..2458d02007 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -642,6 +642,6 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { // set input amount lower than total zeta fee inputAmount := expectedFeeInZeta.Sub(math.NewUint(1)) err = k.PayGasInZetaAndUpdateCctx(ctx, chainID, &cctx, inputAmount, false) - require.ErrorIs(t, err, types.ErrNotEnoughZetaBurnt) + require.ErrorIs(t, err, types.ErrNotEnoughGas) }) } diff --git a/x/crosschain/types/keys.go b/x/crosschain/types/keys.go index c148744ecb..8e9b2a523a 100644 --- a/x/crosschain/types/keys.go +++ b/x/crosschain/types/keys.go @@ -82,21 +82,6 @@ func OutboundTrackerKey( return key } -func (m CrossChainTx) LogIdentifierForCCTX() string { - if len(m.OutboundParams) == 0 { - return fmt.Sprintf("%s-%d", m.InboundParams.Sender, m.InboundParams.SenderChainId) - } - i := len(m.OutboundParams) - 1 - outTx := m.OutboundParams[i] - return fmt.Sprintf( - "%s-%d-%d-%d", - m.InboundParams.Sender, - m.InboundParams.SenderChainId, - outTx.ReceiverChainId, - outTx.TssNonce, - ) -} - func FinalizedInboundKey(inboundHash string, chainID int64, eventIndex uint64) string { return fmt.Sprintf("%d-%s-%d", chainID, inboundHash, eventIndex) } From 1c8ecbe38491839e1fd01dd36efda5038e6b93d9 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 13 Mar 2025 14:31:12 -0400 Subject: [PATCH 2/3] add changelog --- changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.md b/changelog.md index 9cb0c90e44..129ea5bc57 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,10 @@ * [3672](https://github.com/zeta-chain/node/pull/3672) - zetaclient: cache tss signatures for performance. +### Refactor + +* [3709](https://github.com/zeta-chain/node/pull/3709) - improve cctx error message for out of gas errrors when creating outbound + # CHANGELOG ## Unreleased From 96241e1acd75cf762ede09a41a3384095e85d155 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 14 Mar 2025 11:25:09 -0400 Subject: [PATCH 3/3] fix changelog --- changelog.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 129ea5bc57..4ab639438f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,22 +1,17 @@ -# UNRELEASED - -### Features - -* [3672](https://github.com/zeta-chain/node/pull/3672) - zetaclient: cache tss signatures for performance. - -### Refactor - -* [3709](https://github.com/zeta-chain/node/pull/3709) - improve cctx error message for out of gas errrors when creating outbound - # CHANGELOG ## Unreleased ### Features +* [3672](https://github.com/zeta-chain/node/pull/3672) - zetaclient: cache tss signatures for performance. * [3671](https://github.com/zeta-chain/node/pull/3671) - use gas budget argument to refund TSS for Sui withdraw cost * [3699](https://github.com/zeta-chain/node/pull/3699) - use real gas usage for TON withdrawals +### Refactor + +* [3709](https://github.com/zeta-chain/node/pull/3709) - improve cctx error message for out of gas errors when creating outbound + ## v29.0.0 ### Breaking Changes