8000 fix(cli) rollback fees auto calculation by GAtom22 · Pull Request #1467 · evmos/evmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(cli) rollback fees auto calculation #1467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion app/ante/cosmos/min_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 0 additions & 20 deletions app/ante/cosmos/min_price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 0 additions & 10 deletions app/ante/evm/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions app/ante/evm/fee_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -124,9 +124,9 @@ func TestSDKTxFeeChecker(t *testing.T) {
txBuilder.SetGasLimit(1)
return txBuilder.GetTx()
},
"1aevmos",
"",
0,
true,
false,
},
{
"success, dynamic fee",
Expand Down
9 changes: 1 addition & 8 deletions app/ante/evm/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 1 addition & 3 deletions server/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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", "<host>:<port> 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
Expand Down
82 changes: 3 additions & 79 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
)
F194 },
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) {
Expand All @@ -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,
},
}
Expand Down
0