From 17d84da7d4cccfdb86d652480ee10ffceb6e6739 Mon Sep 17 00:00:00 2001 From: skosito Date: Fri, 27 Sep 2024 13:30:47 +0200 Subject: [PATCH] gas limit fixes --- x/crosschain/keeper/gas_payment.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/x/crosschain/keeper/gas_payment.go b/x/crosschain/keeper/gas_payment.go index 2caa964fc9..ed1417b405 100644 --- a/x/crosschain/keeper/gas_payment.go +++ b/x/crosschain/keeper/gas_payment.go @@ -121,6 +121,12 @@ func (k Keeper) PayGasNativeAndUpdateCctx( return cosmoserrors.Wrap(types.ErrCannotFindGasParams, err.Error()) } + // with V2 protocol, reverts on connected chains can eventually call a onRevert function which can require a higher gas limit + if cctx.ProtocolContractVersion == types.ProtocolContractVersion_V2 && cctx.RevertOptions.CallOnRevert && + !cctx.RevertOptions.RevertGasLimit.IsZero() { + gas.GasLimit = cctx.RevertOptions.RevertGasLimit + } + // calculate the final gas fee outTxGasFee := gas.GasLimit.Mul(gas.GasPrice).Add(gas.ProtocolFlatFee) @@ -139,10 +145,7 @@ func (k Keeper) PayGasNativeAndUpdateCctx( // update cctx cctx.GetCurrentOutboundParam().Amount = newAmount - currentGasLimit := cctx.GetCurrentOutboundParam().CallOptions.GasLimit - if currentGasLimit < gas.GasLimit.Uint64() { - cctx.GetCurrentOutboundParam().CallOptions.GasLimit = gas.GasLimit.Uint64() - } + cctx.GetCurrentOutboundParam().CallOptions.GasLimit = gas.GasLimit.Uint64() cctx.GetCurrentOutboundParam().GasPrice = gas.GasPrice.String() cctx.GetCurrentOutboundParam().GasPriorityFee = gas.PriorityFee.String() @@ -299,10 +302,7 @@ func (k Keeper) PayGasInERC20AndUpdateCctx( // update cctx cctx.GetCurrentOutboundParam().Amount = newAmount - currentGasLimit := cctx.GetCurrentOutboundParam().CallOptions.GasLimit - if currentGasLimit < gas.GasLimit.Uint64() { - cctx.GetCurrentOutboundParam().CallOptions.GasLimit = gas.GasLimit.Uint64() - } + cctx.GetCurrentOutboundParam().CallOptions.GasLimit = gas.GasLimit.Uint64() cctx.GetCurrentOutboundParam().GasPrice = gas.GasPrice.String() cctx.GetCurrentOutboundParam().GasPriorityFee = gas.PriorityFee.String()