Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* [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

### Fixes
* [3711](https://github.com/zeta-chain/node/pull/3711) - fix TON call_data parsing

Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/cctx_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
}

Expand Down
28 changes: 17 additions & 11 deletions x/crosschain/keeper/gas_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/gas_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
15 changes: 0 additions & 15 deletions x/crosschain/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down