Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor state compatible speedups to txfees #7535

Merged
merged 1 commit into from
Feb 19, 2024
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: 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