From e3bb6d4a8ec2780369e5bc3317f803d11b7d9055 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 28 Aug 2023 17:00:12 +0800 Subject: [PATCH] remove max-tx-gas-wanted related config --- CHANGELOG.md | 1 + app/ante/eth.go | 18 ++---------------- app/ante/eth_test.go | 3 +-- app/ante/handler_options.go | 3 +-- app/app.go | 5 ++--- app/simulation_test.go | 1 - server/config/config.go | 10 ++-------- server/config/toml.go | 3 --- server/flags/flags.go | 3 +-- server/start.go | 1 - tests/integration_tests/test_websockets.py | 6 ------ 11 files changed, 10 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3abed9b51..e64c68ba60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [#1773](https://github.com/evmos/ethermint/pull/1773) Avoid channel get changed when concurrent subscribe happens. - (rpc) [#1781](https://github.com/evmos/ethermint/pull/1781) Fix decode log for multi topics in websocket subscribe. * (mempool) [#310](https://github.com/crypto-org-chain/ethermint/pull/310) disable vesting messages in check tx mode. +* (ante) [#323](https://github.com/crypto-org-chain/ethermint/pull/323) remove MaxTxGasWanted configurable. ### Features diff --git a/app/ante/eth.go b/app/ante/eth.go index f688c4e76b..e55f46b456 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -146,18 +146,15 @@ func (avd EthAccountVerificationDecorator) AnteHandle( // EthGasConsumeDecorator validates enough intrinsic gas for the transaction and // gas consumption. type EthGasConsumeDecorator struct { - evmKeeper EVMKeeper - maxGasWanted uint64 + evmKeeper EVMKeeper } // NewEthGasConsumeDecorator creates a new EthGasConsumeDecorator func NewEthGasConsumeDecorator( evmKeeper EVMKeeper, - maxGasWanted uint64, ) EthGasConsumeDecorator { return EthGasConsumeDecorator{ evmKeeper, - maxGasWanted, } } @@ -201,18 +198,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula if err != nil { return ctx, sdkerrors.Wrap(err, "failed to unpack tx data") } - - if ctx.IsCheckTx() && egcd.maxGasWanted != 0 { - // We can't trust the tx gas limit, because we'll refund the unused gas. - if txData.GetGas() > egcd.maxGasWanted { - gasWanted += egcd.maxGasWanted - } else { - gasWanted += txData.GetGas() - } - } else { - gasWanted += txData.GetGas() - } - + gasWanted += txData.GetGas() fees, priority, err := egcd.evmKeeper.DeductTxCostsFromUserBalance( ctx, *msgEthTx, diff --git a/app/ante/eth_test.go b/app/ante/eth_test.go index d77b8ba8b3..fc0d1e31ee 100644 --- a/app/ante/eth_test.go +++ b/app/ante/eth_test.go @@ -7,7 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/evmos/ethermint/app/ante" - "github.com/evmos/ethermint/server/config" "github.com/evmos/ethermint/tests" "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" @@ -213,7 +212,7 @@ func (suite AnteTestSuite) TestEthNonceVerificationDecorator() { } func (suite AnteTestSuite) TestEthGasConsumeDecorator() { - dec := ante.NewEthGasConsumeDecorator(suite.app.EvmKeeper, config.DefaultMaxTxGasWanted) + dec := ante.NewEthGasConsumeDecorator(suite.app.EvmKeeper) addr := tests.GenerateAddress() diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index 80bd7c406c..b1fed70eef 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -25,7 +25,6 @@ type HandlerOptions struct { FeegrantKeeper ante.FeegrantKeeper SignModeHandler authsigning.SignModeHandler SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error - MaxTxGasWanted uint64 ExtensionOptionChecker ante.ExtensionOptionChecker TxFeeChecker ante.TxFeeChecker Blacklist []string @@ -60,7 +59,7 @@ func newEthAnteHandler(options HandlerOptions, extra sdk.AnteDecorator) sdk.Ante NewEthSigVerificationDecorator(options.EvmKeeper), NewEthAccountVerificationDecorator(options.AccountKeeper, options.EvmKeeper), NewCanTransferDecorator(options.EvmKeeper), - NewEthGasConsumeDecorator(options.EvmKeeper, options.MaxTxGasWanted), + NewEthGasConsumeDecorator(options.EvmKeeper), NewEthIncrementSenderSequenceDecorator(options.AccountKeeper), // innermost AnteDecorator. NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper), NewEthEmitEventDecorator(options.EvmKeeper), // emit eth tx hash and index at the very last ante handler. diff --git a/app/app.go b/app/app.go index a4dd4cd1c0..736ebd3d17 100644 --- a/app/app.go +++ b/app/app.go @@ -611,7 +611,7 @@ func NewEthermintApp( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - app.setAnteHandler(encodingConfig.TxConfig, cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))) + app.setAnteHandler(encodingConfig.TxConfig) // In v0.46, the SDK introduces _postHandlers_. PostHandlers are like // antehandlers, but are run _after_ the `runMsgs` execution. They are also // defined as a chain, and have the same signature as antehandlers. @@ -640,7 +640,7 @@ func NewEthermintApp( } // use Ethermint's custom AnteHandler -func (app *EthermintApp) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) { +func (app *EthermintApp) setAnteHandler(txConfig client.TxConfig) { anteHandler, err := ante.NewAnteHandler(ante.HandlerOptions{ AccountKeeper: app.AccountKeeper, BankKeeper: app.BankKeeper, @@ -650,7 +650,6 @@ func (app *EthermintApp) setAnteHandler(txConfig client.TxConfig, maxGasWanted u IBCKeeper: app.IBCKeeper, EvmKeeper: app.EvmKeeper, FeeMarketKeeper: app.FeeMarketKeeper, - MaxTxGasWanted: maxGasWanted, ExtensionOptionChecker: ethermint.HasDynamicFeeExtensionOption, TxFeeChecker: ante.NewDynamicFeeChecker(app.EvmKeeper), }) diff --git a/app/simulation_test.go b/app/simulation_test.go index 2f1d1b2231..516a842264 100644 --- a/app/simulation_test.go +++ b/app/simulation_test.go @@ -77,7 +77,6 @@ func NewSimApp(logger log.Logger, db dbm.DB) (*EthermintApp, error) { IBCKeeper: app.IBCKeeper, EvmKeeper: app.EvmKeeper, FeeMarketKeeper: app.FeeMarketKeeper, - MaxTxGasWanted: 0, }) if err != nil { return nil, err diff --git a/server/config/config.go b/server/config/config.go index 656235e715..c1b1ace23e 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -34,8 +34,6 @@ const ( // DefaultFixRevertGasRefundHeight is the default height at which to overwrite gas refund DefaultFixRevertGasRefundHeight = 0 - DefaultMaxTxGasWanted = 0 - DefaultGasCap uint64 = 25000000 DefaultFilterCap int32 = 200 @@ -82,8 +80,6 @@ type EVMConfig struct { // Tracer defines vm.Tracer type that the EVM will use if the node is run in // trace mode. Default: 'json'. Tracer string `mapstructure:"tracer"` - // MaxTxGasWanted defines the gas wanted for each eth tx returned in ante handler in check tx mode. - MaxTxGasWanted uint64 `mapstructure:"max-tx-gas-wanted"` } // JSONRPCConfig defines configuration for the EVM RPC server. @@ -186,8 +182,7 @@ func DefaultConfig() *Config { // DefaultEVMConfig returns the default EVM configuration func DefaultEVMConfig() *EVMConfig { return &EVMConfig{ - Tracer: DefaultEVMTracer, - MaxTxGasWanted: DefaultMaxTxGasWanted, + Tracer: DefaultEVMTracer, } } @@ -321,8 +316,7 @@ func GetConfig(v *viper.Viper) (Config, error) { return Config{ Config: cfg, EVM: EVMConfig{ - Tracer: v.GetString("evm.tracer"), - MaxTxGasWanted: v.GetUint64("evm.max-tx-gas-wanted"), + Tracer: v.GetString("evm.tracer"), }, JSONRPC: JSONRPCConfig{ Enable: v.GetBool("json-rpc.enable"), diff --git a/server/config/toml.go b/server/config/toml.go index e94423860e..da69500681 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -13,9 +13,6 @@ const DefaultConfigTemplate = ` # Valid types are: json|struct|access_list|markdown tracer = "{{ .EVM.Tracer }}" -# MaxTxGasWanted defines the gas wanted for each eth tx returned in ante handler in check tx mode. -max-tx-gas-wanted = {{ .EVM.MaxTxGasWanted }} - ############################################################################### ### JSON RPC Configuration ### ############################################################################### diff --git a/server/flags/flags.go b/server/flags/flags.go index faba4286ae..6bff541f7a 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -60,8 +60,7 @@ const ( // EVM flags const ( - EVMTracer = "evm.tracer" - EVMMaxTxGasWanted = "evm.max-tx-gas-wanted" + EVMTracer = "evm.tracer" ) // TLS flags diff --git a/server/start.go b/server/start.go index 07186e6198..537398b220 100644 --- a/server/start.go +++ b/server/start.go @@ -200,7 +200,6 @@ which accepts a path for the resulting pprof file. cmd.Flags().Bool(srvflags.JSONRPCEnableMetrics, false, "Define if EVM rpc metrics server should be enabled") cmd.Flags().String(srvflags.EVMTracer, config.DefaultEVMTracer, "the EVM tracer type to collect execution traces from the EVM transaction execution (json|struct|access_list|markdown)") //nolint:lll - cmd.Flags().Uint64(srvflags.EVMMaxTxGasWanted, config.DefaultMaxTxGasWanted, "the gas wanted for each eth tx returned in ante handler in check tx mode") //nolint:lll cmd.Flags().String(srvflags.TLSCertPath, "", "the cert.pem file path for the server TLS configuration") cmd.Flags().String(srvflags.TLSKeyPath, "", "the key.pem file path for the server TLS configuration") diff --git a/tests/integration_tests/test_websockets.py b/tests/integration_tests/test_websockets.py index b9732baab6..67ae4ac3dc 100644 --- a/tests/integration_tests/test_websockets.py +++ b/tests/integration_tests/test_websockets.py @@ -13,7 +13,6 @@ CONTRACTS, build_batch_tx, deploy_contract, - modify_command_in_supervisor_config, wait_for_new_blocks, wait_for_port, ) @@ -83,11 +82,6 @@ def test_subscribe_basic(ethermint: Ethermint): """ test basic subscribe and unsubscribe """ - modify_command_in_supervisor_config( - ethermint.base_dir / "tasks.ini", - lambda cmd: f"{cmd} --evm.max-tx-gas-wanted {0}", - ) - ethermint.supervisorctl("update") wait_for_port(ports.evmrpc_ws_port(ethermint.base_port(0))) cli = ethermint.cosmos_cli() loop = asyncio.get_event_loop()