diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index 4a48b39d87c..2df6c547358 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -142,8 +142,10 @@ func (k Keeper) IsSufficientFee(ctx sdk.Context, minBaseGasPrice osmomath.Dec, g // Determine the required fees by multiplying the required minimum gas // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). + // note we mutate this one line below, to avoid extra heap allocations. glDec := osmomath.NewDec(int64(gasRequested)) - requiredBaseFee := sdk.NewCoin(baseDenom, minBaseGasPrice.Mul(glDec).Ceil().RoundInt()) + baseFeeAmt := glDec.MulMut(minBaseGasPrice).Ceil().RoundInt() + requiredBaseFee := sdk.Coin{Denom: baseDenom, Amount: baseFeeAmt} convertedFee, err := k.ConvertToBaseToken(ctx, feeCoin) if err != nil { diff --git a/x/txfees/keeper/feetokens.go b/x/txfees/keeper/feetokens.go index d23d827ca94..d7533641f78 100644 --- a/x/txfees/keeper/feetokens.go +++ b/x/txfees/keeper/feetokens.go @@ -35,7 +35,7 @@ func (k Keeper) ConvertToBaseToken(ctx sdk.Context, inputFee sdk.Coin) (sdk.Coin // Note: spotPrice truncation is done here for maintaining state-compatibility with v19.x // It should be changed to support full spot price precision before // https://github.com/osmosis-labs/osmosis/issues/6064 is complete - return sdk.NewCoin(baseDenom, spotPrice.Dec().MulInt(inputFee.Amount).RoundInt()), nil + return sdk.NewCoin(baseDenom, spotPrice.Dec().MulIntMut(inputFee.Amount).RoundInt()), nil } // CalcFeeSpotPrice converts the provided tx fees into their equivalent value in the base denomination.