From 4b05c05d1dc9b832683190cec43436d5e1c0346d Mon Sep 17 00:00:00 2001 From: yihuang Date: Mon, 8 Apr 2024 09:54:40 +0800 Subject: [PATCH] cleanup --- app/app.go | 8 ++++++-- server/config/config.go | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index e21ea27108..a8c30d666e 100644 --- a/app/app.go +++ b/app/app.go @@ -132,6 +132,7 @@ import ( "github.com/evmos/ethermint/app/ante" "github.com/evmos/ethermint/encoding" "github.com/evmos/ethermint/ethereum/eip712" + srvconfig "github.com/evmos/ethermint/server/config" srvflags "github.com/evmos/ethermint/server/flags" ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm" @@ -355,12 +356,15 @@ func NewEthermintApp( } executor := cast.ToString(appOpts.Get(srvflags.EVMBlockExecutor)) - if executor == "block-stm" { + switch executor { + case srvconfig.BlockExecutorBlockSTM: sdk.SetAddrCacheEnabled(false) workers := cast.ToInt(appOpts.Get(srvflags.EVMBlockSTMWorkers)) app.SetTxExecutor(STMTxExecutor(app.GetStoreKeys(), workers)) - } else { + case srvconfig.BlockExecutorSequential: app.SetTxExecutor(DefaultTxExecutor) + default: + panic(fmt.Errorf("unknown EVM block executor: %s", executor)) } // init params keeper and subspaces diff --git a/server/config/config.go b/server/config/config.go index eb5f6d3a29..926d45fb9b 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -97,6 +97,9 @@ const ( // DefaultRosettaDenomToSuggest defines the default denom for fee suggestion DefaultRosettaDenomToSuggest = "basecro" + + BlockExecutorSequential = "sequential" + BlockExecutorBlockSTM = "block-stm" ) var ( @@ -104,6 +107,8 @@ var ( DefaultRosettaGasPrices = sdk.NewDecCoins(sdk.NewDecCoin(DefaultRosettaDenomToSuggest, sdkmath.NewInt(4_000_000))) evmTracers = []string{"json", "markdown", "struct", "access_list"} + + blockExecutors = []string{"sequential", "block-stm"} ) // Config defines the server's top level configuration. It includes the default app config @@ -252,6 +257,10 @@ func (c EVMConfig) Validate() error { return fmt.Errorf("invalid tracer type %s, available types: %v", c.Tracer, evmTracers) } + if !strings.StringInSlice(c.BlockExecutor, blockExecutors) { + return fmt.Errorf("invalid block executor type %s, available types: %v", c.BlockExecutor, blockExecutors) + } + return nil }