Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilkumarpilli committed Aug 6, 2024
1 parent 1fe5674 commit 36e4aed
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,22 @@ func (c *Consensus[T]) checkTxFeeWithMinGasPrices(tx transaction.Tx) error {
gas := feeTx.GetGas()

minGasPrices := c.cfg.GetMinGasPrices()
if !minGasPrices.IsZero() {
requiredFees := make(sdk.Coins, len(minGasPrices))

// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
glDec := sdkmath.LegacyNewDec(int64(gas))
for i, gp := range minGasPrices {
fee := gp.Amount.Mul(glDec)
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
}
if minGasPrices.IsZero() {
return nil
}

if !feeCoins.IsAnyGTE(requiredFees) {
return errorsmod.Wrapf(cometerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
}
requiredFees := make(sdk.Coins, len(minGasPrices))

// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
glDec := sdkmath.LegacyNewDec(int64(gas))
for i, gp := range minGasPrices {
fee := gp.Amount.Mul(glDec)
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
}

if !feeCoins.IsAnyGTE(requiredFees) {
return errorsmod.Wrapf(cometerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
}

return nil
Expand Down

0 comments on commit 36e4aed

Please sign in to comment.