Skip to content

Commit

Permalink
remove max-tx-gas-wanted related config
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Aug 28, 2023
1 parent 3fdb18b commit b28f525
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 35 deletions.
13 changes: 6 additions & 7 deletions app/ante/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
)

const MaxTxGasWanted uint64 = 500000

// EthSigVerificationDecorator validates an ethereum signatures
type EthSigVerificationDecorator struct {
evmKeeper EVMKeeper
Expand Down Expand Up @@ -146,18 +148,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,
}
}

Expand Down Expand Up @@ -202,10 +201,10 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
return ctx, sdkerrors.Wrap(err, "failed to unpack tx data")
}

if ctx.IsCheckTx() && egcd.maxGasWanted != 0 {
if ctx.IsCheckTx() {
// We can't trust the tx gas limit, because we'll refund the unused gas.
if txData.GetGas() > egcd.maxGasWanted {
gasWanted += egcd.maxGasWanted
if txData.GetGas() > MaxTxGasWanted {
gasWanted += MaxTxGasWanted
} else {
gasWanted += txData.GetGas()
}
Expand Down
14 changes: 12 additions & 2 deletions app/ante/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -298,6 +297,17 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() {
false, true,
0,
},
{
"success",
tx2,
ante.MaxTxGasWanted, // it's capped
func() {
vmdb.AddBalance(addr, big.NewInt(1000000))
suite.ctx = suite.ctx.WithBlockGasMeter(sdk.NewGasMeter(10000000000000000000))
},
true, false,
0,
},
{
"success - legacy tx",
tx2,
Expand Down
3 changes: 1 addition & 2 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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),
})
Expand Down
1 change: 0 additions & 1 deletion app/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 2 additions & 8 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -186,8 +182,7 @@ func DefaultConfig() *Config {
// DefaultEVMConfig returns the default EVM configuration
func DefaultEVMConfig() *EVMConfig {
return &EVMConfig{
Tracer: DefaultEVMTracer,
MaxTxGasWanted: DefaultMaxTxGasWanted,
Tracer: DefaultEVMTracer,
}
}

Expand Down Expand Up @@ -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"),
Expand Down
3 changes: 0 additions & 3 deletions server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
###############################################################################
Expand Down
3 changes: 1 addition & 2 deletions server/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ const (

// EVM flags
const (
EVMTracer = "evm.tracer"
EVMMaxTxGasWanted = "evm.max-tx-gas-wanted"
EVMTracer = "evm.tracer"
)

// TLS flags
Expand Down
1 change: 0 additions & 1 deletion server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 6 additions & 6 deletions tests/integration_tests/test_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CONTRACTS,
build_batch_tx,
deploy_contract,
modify_command_in_supervisor_config,
# modify_command_in_supervisor_config,
wait_for_new_blocks,
wait_for_port,
)
Expand Down Expand Up @@ -83,11 +83,11 @@ 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")
# 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()
Expand Down

0 comments on commit b28f525

Please sign in to comment.