diff --git a/CHANGELOG.md b/CHANGELOG.md index bd64e09d5f..c126d1bf84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,8 +48,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking -- [#1326](https://github.com/umee-network/umee/pull/1326) Setting protocol controlled min gas price. -- [#1401](https://github.com/umee-network/umee/pull/1401) Increased free gas oracle tx limit from 100k to 140k. +- [1326](https://github.com/umee-network/umee/pull/1326) Setting protocol controlled min gas price. +- [1401](https://github.com/umee-network/umee/pull/1401) Increased free gas oracle tx limit from 100k to 140k. +- [1411](https://github.com/umee-network/umee/pull/1411) Set min gas price to zero for v3 release ### API Breaking diff --git a/ante/fee.go b/ante/fee.go index 73bdcec30b..5c871bdf18 100644 --- a/ante/fee.go +++ b/ante/fee.go @@ -63,7 +63,10 @@ func checkFees(minGasPrices sdk.DecCoins, fees sdk.Coins, gasLimit uint64) error requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) } - if !fees.IsAnyGTE(requiredFees) { + // Clear any zero coins from requiredFees in the case of zero min gas price + requiredFees = sdk.NewCoins(requiredFees...) + + if !requiredFees.Empty() && !fees.IsAnyGTE(requiredFees) { return sdkerrors.ErrInsufficientFee.Wrapf( "insufficient fees; got: %s required: %s", fees, requiredFees) } @@ -105,16 +108,12 @@ func IsOracleOrGravityTx(msgs []sdk.Msg) bool { // AssertMinProtocolGasPrice returns an error if the provided gasPrices are lower then // the required by protocol. func AssertMinProtocolGasPrice(gasPrices sdk.DecCoins) error { - for _, c := range gasPrices { - if c.Denom == appparams.MinMinGasPrice.Denom { - if c.Amount.LT(appparams.MinMinGasPrice.Amount) { - break // go to error below - } - return nil - } + if gasPrices.AmountOf(appparams.MinMinGasPrice.Denom).LT(appparams.MinMinGasPrice.Amount) { + return sdkerrors.ErrInsufficientFee.Wrapf( + "gas price too small; got: %v required min: %v", gasPrices, appparams.MinMinGasPrice) } - return sdkerrors.ErrInsufficientFee.Wrapf( - "gas price too small; got: %v required min: %v", gasPrices, appparams.MinMinGasPrice) + + return nil } // getTxPriority returns naive tx priority based on the lowest fee amount (regardless of the diff --git a/ante/fee_test.go b/ante/fee_test.go index 3a8d6230fa..4d4433f97d 100644 --- a/ante/fee_test.go +++ b/ante/fee_test.go @@ -57,16 +57,17 @@ func (suite *IntegrationTestSuite) TestFeeAndPriority() { // should work when exact fee is provided suite.checkFeeAnte(tx, fee, ctx.WithMinGasPrices(mkGas("", "2"))) + // TODO: comment back in when min gas price is nonzero + // should fail when not enough fee is provided - suite.checkFeeFailed(tx, ctx.WithMinGasPrices(mkGas("", "3"))) + // suite.checkFeeFailed(tx, ctx.WithMinGasPrices(mkGas("", "3"))) // should fail when other denom is required - suite.checkFeeFailed(tx, ctx.WithMinGasPrices(mkGas("other", "1"))) + // suite.checkFeeFailed(tx, ctx.WithMinGasPrices(mkGas("other", "1"))) // should fail when some fee doesn't include all gas denoms - ctx = ctx.WithMinGasPrices(sdk.DecCoins{minGas, - sdk.NewDecCoinFromDec("other", sdk.NewDec(10))}) - suite.checkFeeFailed(tx, ctx) + // ctx = ctx.WithMinGasPrices(sdk.DecCoins{minGas,sdk.NewDecCoinFromDec("other", sdk.NewDec(10))}) + // suite.checkFeeFailed(tx, ctx) // // Test DeliverTx @@ -82,8 +83,8 @@ func (suite *IntegrationTestSuite) TestFeeAndPriority() { suite.checkFeeAnte(tx, fee, ctx.WithMinGasPrices(sdk.DecCoins{})) // should fail when not enough fee is provided - suite.checkFeeFailed(mkTx(mkFee("0.5")), ctx) - suite.checkFeeFailed(mkTx(sdk.Coins{}), ctx) + // suite.checkFeeFailed(mkTx(mkFee("0.5")), ctx) + // suite.checkFeeFailed(mkTx(sdk.Coins{}), ctx) // should work when more fees are applied fee = append(fee, sdk.NewInt64Coin("other", 10)) @@ -108,7 +109,7 @@ func (suite *IntegrationTestSuite) TestFeeAndPriority() { func (suite *IntegrationTestSuite) checkFeeFailed(tx sdk.Tx, ctx sdk.Context) { _, _, err := ante.FeeAndPriority(ctx, tx) - suite.Require().ErrorIs(sdkerrors.ErrInsufficientFee, err) + suite.Require().ErrorIs(err, sdkerrors.ErrInsufficientFee) } func (suite *IntegrationTestSuite) checkFeeAnte(tx sdk.Tx, feeExpected sdk.Coins, ctx sdk.Context) { diff --git a/app/params/app_settings.go b/app/params/app_settings.go index 5283de0bdd..fe3b821f86 100644 --- a/app/params/app_settings.go +++ b/app/params/app_settings.go @@ -21,10 +21,8 @@ const ( DefaultGasLimit = 200000 ) -var ( - // MinMinGasPrice is the minimum value a validator can set for `minimum-gas-prices` his app.toml config - MinMinGasPrice = sdk.NewDecCoinFromDec(BondDenom, sdk.MustNewDecFromStr("0.05")) -) +// MinMinGasPrice is the minimum value a validator can set for `minimum-gas-prices` his app.toml config +var MinMinGasPrice = sdk.NewDecCoinFromDec(BondDenom, sdk.MustNewDecFromStr("0.00")) func init() { // XXX: If other upstream or external application's depend on any of Umee's