Skip to content

Commit

Permalink
fix: set 0 min gas prices (#1411)
Browse files Browse the repository at this point in the history
* set MinMinGasPrice to 0.00 to keep keplr working

* checkFees comparison

* fix AssertMinProtocolGasPrice

* comment out tests that fail on zero min gas price

* changelog

Co-authored-by: toteki <63419657+toteki@users.noreply.github.com>
  • Loading branch information
adamewozniak and toteki committed Sep 19, 2022
1 parent b42395a commit fd05708
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 9 additions & 10 deletions ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions app/params/app_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd05708

Please sign in to comment.