Skip to content

Commit

Permalink
Minor state compatible speedups to txfees (#7535)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored Feb 19, 2024
1 parent a80c00e commit d563553
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion x/txfees/keeper/feedecorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion x/txfees/keeper/feetokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d563553

Please sign in to comment.