Skip to content

Commit

Permalink
gas limit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Sep 27, 2024
1 parent 3425be0 commit 17d84da
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions x/crosschain/keeper/gas_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 17d84da

Please sign in to comment.