diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f1c92f70258..f0a420346760 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +<<<<<<< HEAD +======= +* [#12589](https://github.com/cosmos/cosmos-sdk/pull/12589) Allow zero gas in simulation mode. +* [#12576](https://github.com/cosmos/cosmos-sdk/pull/12576) Remove dependency on cosmos/keyring and upgrade to 99designs/keyring v1.2.1 +* [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Mark the `TipDecorator` as beta, don't include it in simapp by default. +* [#12153](https://github.com/cosmos/cosmos-sdk/pull/12153) Add a new `NewSimulationManagerFromAppModules` constructor, to simplify simulation wiring. +* [#12187](https://github.com/cosmos/cosmos-sdk/pull/12187) Add batch operation for x/nft module. +>>>>>>> 0a3c597ce (fix: auto gas don't work (#12590)) * [#12453](https://github.com/cosmos/cosmos-sdk/pull/12453) Add `NewInMemoryWithKeyring` function which allows the creation of in memory `keystore` instances with a specified set of existing items. * [#11390](https://github.com/cosmos/cosmos-sdk/pull/11390) `LatestBlockResponse` & `BlockByHeightResponse` types' `Block` filed has been deprecated and they now contains new field `sdk_block` with `proposer_address` as `string` diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 2325fc5f672e..b6927eababe0 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -42,13 +42,21 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") } - if ctx.BlockHeight() > 0 && feeTx.GetGas() == 0 { + if !simulate && ctx.BlockHeight() > 0 && feeTx.GetGas() == 0 { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidGasLimit, "must provide positive gas") } - fee, priority, err := dfd.txFeeChecker(ctx, tx) - if err != nil { - return ctx, err + var ( + priority int64 + err error + ) + + fee := feeTx.GetFee() + if !simulate { + fee, priority, err = dfd.txFeeChecker(ctx, tx) + if err != nil { + return ctx, err + } } if err := dfd.checkDeductFee(ctx, tx, fee); err != nil { return ctx, err diff --git a/x/auth/ante/fee_test.go b/x/auth/ante/fee_test.go index 9ecd75cbed45..a182b4fa15b1 100644 --- a/x/auth/ante/fee_test.go +++ b/x/auth/ante/fee_test.go @@ -36,6 +36,10 @@ func (s *AnteTestSuite) TestDeductFeeDecorator_ZeroGas() { _, err = antehandler(s.ctx, tx, false) s.Require().Error(err) + + // zero gas is accepted in simulation mode + _, err = antehandler(s.ctx, tx, true) + s.Require().NoError(err) } func (s *AnteTestSuite) TestEnsureMempoolFees() { @@ -74,6 +78,11 @@ func (s *AnteTestSuite) TestEnsureMempoolFees() { _, err = antehandler(s.ctx, tx, false) s.Require().NotNil(err, "Decorator should have errored on too low fee for local gasPrice") + // antehandler should not error since we do not check minGasPrice in simulation mode + cacheCtx, _ := s.ctx.CacheContext() + _, err = antehandler(cacheCtx, tx, true) + s.Require().Nil(err, "Decorator should not have errored in simulation mode") + // Set IsCheckTx to false s.ctx = s.ctx.WithIsCheckTx(false)