diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1d19baad..79c50f6ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - (ante) [#1435](https://github.com/evmos/evmos/pull/1435) Add block gas limit check for cosmos transactions - (evm) [#1452](https://github.com/evmos/evmos/pull/1452) Consider refund amount on `gasUsed` calculation - (evm) [#1466](https://github.com/evmos/evmos/pull/1466) Add `gasUsed` field in Ethereum transaction receipt +- (cli) [#1467](https://github.com/evmos/evmos/pull/1467) Rollback fees `auto` flag logic ## [v11.0.2] - 2023-02-10 diff --git a/app/ante/cosmos/min_price.go b/app/ante/cosmos/min_price.go index d068fb0220..d8fac85bdd 100644 --- a/app/ante/cosmos/min_price.go +++ b/app/ante/cosmos/min_price.go @@ -79,7 +79,9 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate // Fees not provided (or flag "auto"). Then use the base fee to make the check pass if feeCoins == nil { - feeCoins = requiredFees + return ctx, errorsmod.Wrapf(errortypes.ErrInsufficientFee, + "fee not provided. Please use the --fees flag or the --gas-price flag along with the --gas flag to estimate the fee. The minimun global fee for this tx is: %s", + requiredFees) } if !feeCoins.IsAnyGTE(requiredFees) { diff --git a/app/ante/cosmos/min_price_test.go b/app/ante/cosmos/min_price_test.go index edd3fae2a8..ab38b527bf 100644 --- a/app/ante/cosmos/min_price_test.go +++ b/app/ante/cosmos/min_price_test.go @@ -118,26 +118,6 @@ func (suite *AnteTestSuite) TestMinGasPriceDecorator() { "provided fee < minimum global fee", true, }, - { - "valid cosmos tx without specified fee with MinGasPrices = 10, gasPrice = 10", // when fee is not provided, the requiredFee is used by default - func() sdk.Tx { - params := suite.app.FeeMarketKeeper.GetParams(suite.ctx) - params.MinGasPrice = sdk.NewDec(10) - err := suite.app.FeeMarketKeeper.SetParams(suite.ctx, params) - suite.Require().NoError(err) - - txBuilder := suite.clientCtx.TxConfig.NewTxBuilder() - txBuilder.SetGasLimit(TestGasLimit) - // fee is nil - txBuilder.SetFeeAmount(nil) - err = txBuilder.SetMsgs(&testMsg) - suite.Require().NoError(err) - return txBuilder.GetTx() - }, - true, - "", - false, - }, } for _, et := range execTypes { diff --git a/app/ante/evm/fee_checker.go b/app/ante/evm/fee_checker.go index 7b3943d889..cbed5f7b2c 100644 --- a/app/ante/evm/fee_checker.go +++ b/app/ante/evm/fee_checker.go @@ -79,11 +79,6 @@ func NewDynamicFeeChecker(k DynamicFeeEVMKeeper) anteutils.TxFeeChecker { feeCap := fee.Quo(sdkmath.NewIntFromUint64(gas)) baseFeeInt := sdkmath.NewIntFromBigInt(baseFee) - // Fees not provided (or flag "auto"). Then use the base fee to make the check pass - if feeCoins == nil { - feeCap = baseFeeInt - } - if feeCap.LT(baseFeeInt) { return nil, 0, errorsmod.Wrapf(errortypes.ErrInsufficientFee, "got: %s%s required: %s%s. Please retry using the --gas-prices or --fees flag", feeCap, denom, baseFeeInt, denom) } @@ -131,11 +126,6 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.FeeTx) (sdk.Coi requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) } - // Fees not provided (or flag "auto"). Then use the base fee to make the check pass - if feeCoins == nil { - feeCoins = requiredFees - } - if !feeCoins.IsAnyGTE(requiredFees) { return nil, 0, errorsmod.Wrapf(errortypes.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) } diff --git a/app/ante/evm/fee_checker_test.go b/app/ante/evm/fee_checker_test.go index b639472d87..ce87ff6f5f 100644 --- a/app/ante/evm/fee_checker_test.go +++ b/app/ante/evm/fee_checker_test.go @@ -114,7 +114,7 @@ func TestSDKTxFeeChecker(t *testing.T) { true, }, { - "success, dynamic fee - no fee amount specified, uses requiredFees", + "fail, dynamic fee", deliverTxCtx, MockEVMKeeper{ EnableLondonHF: true, BaseFee: big.NewInt(1), @@ -124,9 +124,9 @@ func TestSDKTxFeeChecker(t *testing.T) { txBuilder.SetGasLimit(1) return txBuilder.GetTx() }, - "1aevmos", + "", 0, - true, + false, }, { "success, dynamic fee", diff --git a/app/ante/evm/fees.go b/app/ante/evm/fees.go index ef6b53d4c8..a117c01f66 100644 --- a/app/ante/evm/fees.go +++ b/app/ante/evm/fees.go @@ -108,14 +108,7 @@ func (empd EthMinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul gasLimit := sdk.NewDecFromBigInt(new(big.Int).SetUint64(ethMsg.GetGas())) requiredFee := minGasPrice.Mul(gasLimit) - - // Fees not provided (or flag "auto"). Then use the base fee to make the check pass - var fee sdk.Dec - if feeAmt == nil { - fee = requiredFee - } else { - fee = sdk.NewDecFromBigInt(feeAmt) - } + fee := sdk.NewDecFromBigInt(feeAmt) if fee.LT(requiredFee) { return ctx, errorsmod.Wrapf( diff --git a/go.mod b/go.mod index 2ab6961547..563d7680db 100644 --- a/go.mod +++ b/go.mod @@ -220,7 +220,7 @@ replace ( // use cosmos fork of keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 // use Cosmos-SDK fork to enable Ledger functionality - github.com/cosmos/cosmos-sdk => github.com/evmos/cosmos-sdk v0.46.11-ledger + github.com/cosmos/cosmos-sdk => github.com/evmos/cosmos-sdk v0.46.13-ledger // use Evmos geth fork github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26 // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq diff --git a/go.sum b/go.sum index cd82c50025..4daa0ece77 100644 --- a/go.sum +++ b/go.sum @@ -473,8 +473,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evmos/cosmos-sdk v0.46.11-ledger h1:kx6vR+c55HV0or32tjgDenqOTAwfYB3FRDIJGqKqCuI= -github.com/evmos/cosmos-sdk v0.46.11-ledger/go.mod h1:opDBTPiPrOo781a1zT1Tadh2Runcm5Ko/KXI1hZCzRo= +github.com/evmos/cosmos-sdk v0.46.13-ledger h1:10plFZO/LQH9dk7dn9b9RPlHriDRbINlpFg3w3ieZ9w= +github.com/evmos/cosmos-sdk v0.46.13-ledger/go.mod h1:opDBTPiPrOo781a1zT1Tadh2Runcm5Ko/KXI1hZCzRo= github.com/evmos/evmos-ledger-go v0.3.0-rc0 h1:QbfTCOxAxvaHbdwmkEPewr0BwWy9hnQEc6kXZ6gij/I= github.com/evmos/evmos-ledger-go v0.3.0-rc0/go.mod h1:w2llvjRGkc7u/S1FQfznebxAwrc+wCOIqXcDFUWVkKQ= github.com/evmos/go-ethereum v1.10.26 h1:7wlczxUWTwhzJJUyh3Kkqt3/5fdSJzh8c42boc9GuII= diff --git a/server/flags/flags.go b/server/flags/flags.go index fe6a4a5e33..5880f650fa 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -16,8 +16,6 @@ package flags import ( - "fmt" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/spf13/cobra" @@ -90,7 +88,7 @@ const ( func AddTxFlags(cmd *cobra.Command) (*cobra.Command, error) { cmd.PersistentFlags().String(flags.FlagChainID, "testnet", "Specify Chain ID for sending Tx") cmd.PersistentFlags().String(flags.FlagFrom, "", "Name or address of private key with which to sign") - cmd.PersistentFlags().String(flags.FlagFees, "", fmt.Sprintf("Fees to pay along with transaction; eg: 10aevmos. By default, uses the required fees. Set to %q to calculate sufficient fees and gas automatically", flags.FlagAuto)) + cmd.PersistentFlags().String(flags.FlagFees, "", "Fees to pay along with transaction; eg: 10aevmos") cmd.PersistentFlags().String(flags.FlagGasPrices, "", "Gas prices to determine the transaction fee (e.g. 10aevmos)") cmd.PersistentFlags().String(flags.FlagNode, "tcp://localhost:26657", ": to tendermint rpc interface for this chain") //nolint:lll cmd.PersistentFlags().Float64(flags.FlagGasAdjustment, flags.DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") //nolint:lll diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 4cda553dda..d9fefe58c6 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -57,7 +57,7 @@ func (s *IntegrationTestSuite) TestCLITxs() { expErrMsg: "cannot provide both fees and gas prices", }, { - name: "fail - submit upgrade proposal, no fees (defaults to required fees) & insufficient gas", + name: "fail - submit upgrade proposal, no fees & insufficient gas", cmd: func() (string, error) { return s.upgradeManager.CreateSubmitProposalExec( "v11.0.0", @@ -100,18 +100,6 @@ func (s *IntegrationTestSuite) TestCLITxs() { expPass: false, expErrMsg: "out of gas", }, - { - name: "success - submit upgrade proposal, no fees (defaults to required fees) & default gas", - cmd: func() (string, error) { - return s.upgradeManager.CreateSubmitProposalExec( - "v11.0.0", - s.upgradeParams.ChainID, - 5000, - true, - ) - }, - expPass: true, - }, { name: "success - submit upgrade proposal, defined fees & gas", cmd: func() (string, error) { @@ -140,45 +128,6 @@ func (s *IntegrationTestSuite) TestCLITxs() { }, expPass: true, }, - { - name: "success - submit upgrade proposal, no fees (defaults to required fees) & sufficient gas", - cmd: func() (string, error) { - return s.upgradeManager.CreateSubmitProposalExec( - "v11.0.0", - s.upgradeParams.ChainID, - 5000, - true, - "--gas=1500000", - ) - }, - expPass: true, - }, - { - name: "success - submit upgrade proposal, gas 'auto'", - cmd: func() (string, error) { - return s.upgradeManager.CreateSubmitProposalExec( - "v11.0.0", - s.upgradeParams.ChainID, - 5000, - true, - "--gas=auto", - ) - }, - expPass: true, - }, - { - name: "success - submit upgrade proposal, fees 'auto'", - cmd: func() (string, error) { - return s.upgradeManager.CreateSubmitProposalExec( - "v11.0.0", - s.upgradeParams.ChainID, - 5000, - true, - "--fees=auto", - ) - }, - expPass: true, - }, { name: "fail - vote upgrade proposal, insufficient fees", cmd: func() (string, error) { @@ -193,41 +142,16 @@ func (s *IntegrationTestSuite) TestCLITxs() { expErrMsg: "insufficient fee", }, { - name: "fail - vote upgrade proposal, incorrect flag combination (using fees 'auto' and specific gas)", - cmd: func() (string, error) { - return s.upgradeManager.CreateVoteProposalExec( - s.upgradeParams.ChainID, - 1, - "--fees=auto", - "--gas=500000", - ) - }, - expPass: false, - expErrMsg: "you are using the --fees \"auto\" flag. It is not allowed to specify other flags", - }, - { - name: "fail - vote upgrade proposal, incorrect flag combination (using gas 'auto' and specific fees)", + name: "success - vote upgrade proposal (using gas 'auto' and specific fees)", cmd: func() (string, error) { return s.upgradeManager.CreateVoteProposalExec( s.upgradeParams.ChainID, 1, "--gas=auto", + "--gas-adjustment=1.4", "--fees=500000aevmos", ) }, - expPass: false, - expErrMsg: "you are using the --gas \"auto\" flag. It is not allowed to specify other flags", - }, - { - name: "success - vote upgrade proposal, fees 'auto'", - cmd: func() (string, error) { - return s.upgradeManager.CreateVoteProposalExec( - s.upgradeParams.ChainID, - 1, - "--fees=auto", - "--gas-adjustment=1.3", - ) - }, expPass: true, }, }