diff --git a/app/app.go b/app/app.go index 4339cde64c..2c07fb517d 100644 --- a/app/app.go +++ b/app/app.go @@ -796,7 +796,8 @@ func NewEthermintApp( case srvconfig.BlockExecutorBlockSTM: sdk.SetAddrCacheEnabled(false) workers := cast.ToInt(appOpts.Get(srvflags.EVMBlockSTMWorkers)) - app.SetTxExecutor(STMTxExecutor(app.GetStoreKeys(), workers, true, app.EvmKeeper, txConfig.TxDecoder())) + preEstimate := cast.ToBool(appOpts.Get(srvflags.EVMBlockSTMPreEstimate)) + app.SetTxExecutor(STMTxExecutor(app.GetStoreKeys(), workers, preEstimate, app.EvmKeeper, txConfig.TxDecoder())) case "", srvconfig.BlockExecutorSequential: app.SetTxExecutor(DefaultTxExecutor) default: diff --git a/server/config/config.go b/server/config/config.go index 4182ef85e5..7fb16d37a5 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -134,6 +134,8 @@ type EVMConfig struct { BlockExecutor string `mapstructure:"block-executor"` // BlockSTMWorkers is the number of workers for block-stm execution, `0` means using all available CPUs. BlockSTMWorkers int `mapstructure:"block-stm-workers"` + // BlockSTMPreEstimate is the flag to enable pre-estimation for block-stm execution. + BlockSTMPreEstimate bool `mapstructure:"block-stm-pre-estimate"` } // JSONRPCConfig defines configuration for the EVM RPC server. @@ -407,10 +409,11 @@ 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"), - BlockExecutor: v.GetString("evm.block-executor"), - BlockSTMWorkers: v.GetInt("evm.block-stm-workers"), + Tracer: v.GetString("evm.tracer"), + MaxTxGasWanted: v.GetUint64("evm.max-tx-gas-wanted"), + BlockExecutor: v.GetString("evm.block-executor"), + BlockSTMWorkers: v.GetInt("evm.block-stm-workers"), + BlockSTMPreEstimate: v.GetBool("evm.block-stm-pre-estimate"), }, JSONRPC: JSONRPCConfig{ Enable: v.GetBool("json-rpc.enable"), diff --git a/server/config/toml.go b/server/config/toml.go index b82d492c7f..31b07d50a1 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -35,6 +35,8 @@ max-tx-gas-wanted = {{ .EVM.MaxTxGasWanted }} block-executor = "{{ .EVM.BlockExecutor }}" # BlockSTMWorkers is the number of workers for block-stm execution, 0 means using all available CPUs. block-stm-workers = {{ .EVM.BlockSTMWorkers }} +# BlockSTMPreEstimate is the flag to enable pre-estimation for block-stm execution. +block-stm-pre-estimate = {{ .EVM.BlockSTMPreEstimate }} ############################################################################### ### JSON RPC Configuration ### diff --git a/server/flags/flags.go b/server/flags/flags.go index 02dc161342..c795013c15 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -76,10 +76,11 @@ const ( // EVM flags const ( - EVMTracer = "evm.tracer" - EVMMaxTxGasWanted = "evm.max-tx-gas-wanted" - EVMBlockExecutor = "evm.block-executor" - EVMBlockSTMWorkers = "evm.block-stm-workers" + EVMTracer = "evm.tracer" + EVMMaxTxGasWanted = "evm.max-tx-gas-wanted" + EVMBlockExecutor = "evm.block-executor" + EVMBlockSTMWorkers = "evm.block-stm-workers" + EVMBlockSTMPreEstimate = "evm.block-stm-pre-estimate" ) // TLS flags