diff --git a/src/bin/run_with_importer.rs b/src/bin/run_with_importer.rs index 0670061c0..03960bc6c 100644 --- a/src/bin/run_with_importer.rs +++ b/src/bin/run_with_importer.rs @@ -52,7 +52,7 @@ async fn run(config: RunWithImporterConfig) -> anyhow::Result<()> { // config rpc_config.clone(), rpc_config.rpc_server, - rpc_config.executor.chain_id.into(), + rpc_config.executor.executor_chain_id.into(), ) .await; GlobalState::shutdown_from(TASK_NAME, "rpc server finished unexpectedly"); diff --git a/src/eth/executor/evm.rs b/src/eth/executor/evm.rs index daf0e4b17..42e8617cb 100644 --- a/src/eth/executor/evm.rs +++ b/src/eth/executor/evm.rs @@ -75,7 +75,7 @@ impl Evm { handler.set_instruction_table(instructions); // configure revm - let chain_id = config.chain_id; + let chain_id = config.executor_chain_id; let mut evm = RevmEvm::builder() .with_external_context(()) .with_db(RevmSession::new(storage, config)) @@ -238,7 +238,7 @@ impl Database for RevmSession { // warn if the loaded account is the `to` account and it does not have a bytecode if let Some(ref to_address) = self.input.to { if account.bytecode.is_none() && &address == to_address && self.input.is_contract_call() { - if self.config.reject_not_contract { + if self.config.executor_reject_not_contract { return Err(StratusError::TransactionAccountNotContract { address: *to_address }); } else { tracing::warn!(%address, "evm to_account is not a contract because does not have bytecode"); diff --git a/src/eth/executor/executor.rs b/src/eth/executor/executor.rs index 961b51cfd..8ba514f92 100644 --- a/src/eth/executor/executor.rs +++ b/src/eth/executor/executor.rs @@ -119,14 +119,14 @@ impl Evms { evm_tx }; - let tx_parallel = match config.strategy { + let tx_parallel = match config.executor_strategy { ExecutorStrategy::Serial => spawn_evms("evm-tx-unused", 1), // should not really be used if strategy is serial, but keep 1 for fallback - ExecutorStrategy::Paralell => spawn_evms("evm-tx-parallel", config.num_evms), + ExecutorStrategy::Paralell => spawn_evms("evm-tx-parallel", config.executor_evms), }; let tx_serial = spawn_evms("evm-tx-serial", 1); let tx_external = spawn_evms("evm-tx-external", 1); - let call_present = spawn_evms("evm-call-present", max(config.num_evms / 2, 1)); - let call_past = spawn_evms("evm-call-past", max(config.num_evms / 4, 1)); + let call_present = spawn_evms("evm-call-present", max(config.executor_evms / 2, 1)); + let call_past = spawn_evms("evm-call-past", max(config.executor_evms / 4, 1)); Evms { tx_parallel, @@ -370,7 +370,7 @@ impl Executor { // execute according to the strategy const INFINITE_ATTEMPTS: usize = usize::MAX; - let tx_execution = match self.config.strategy { + let tx_execution = match self.config.executor_strategy { // Executes transactions in serial mode: // * Uses a Mutex, so a new transactions starts executing only after the previous one is executed and persisted. // * Without a Mutex, conflict can happen because the next transactions starts executing before the previous one is saved. diff --git a/src/eth/executor/executor_config.rs b/src/eth/executor/executor_config.rs index ac0f3569c..772d25420 100644 --- a/src/eth/executor/executor_config.rs +++ b/src/eth/executor/executor_config.rs @@ -12,22 +12,27 @@ use crate::eth::storage::StratusStorage; #[derive(Parser, DebugAsJson, Clone, serde::Serialize)] pub struct ExecutorConfig { /// Chain ID of the network. - #[arg(long = "chain-id", env = "EXECUTOR_CHAIN_ID")] - pub chain_id: u64, + #[arg(long = "executor-chain-id", alias = "chain-id", env = "EXECUTOR_CHAIN_ID")] + pub executor_chain_id: u64, /// Number of EVM instances to run. /// /// TODO: should be configured for each kind of EvmRoute instead of being a single value. - #[arg(long = "evms", env = "EXECUTOR_EVMS")] - pub num_evms: usize, + #[arg(long = "executor-evms", alias = "evms", env = "EXECUTOR_EVMS")] + pub executor_evms: usize, /// EVM execution strategy. - #[arg(long = "strategy", env = "EXECUTOR_STRATEGY", default_value = "serial")] - pub strategy: ExecutorStrategy, + #[arg(long = "executor-strategy", alias = "strategy", env = "EXECUTOR_STRATEGY", default_value = "serial")] + pub executor_strategy: ExecutorStrategy, /// Should reject contract transactions and calls to accounts that are not contracts? - #[arg(long = "reject-not-contract", env = "EXECUTOR_REJECT_NOT_CONTRACT", default_value = "true")] - pub reject_not_contract: bool, + #[arg( + long = "executor-reject-not-contract", + alias = "reject-not-contract", + env = "EXECUTOR_REJECT_NOT_CONTRACT", + default_value = "true" + )] + pub executor_reject_not_contract: bool, } impl ExecutorConfig { @@ -36,7 +41,7 @@ impl ExecutorConfig { /// Note: Should be called only after async runtime is initialized. pub fn init(&self, storage: Arc, miner: Arc) -> Arc { let mut config = self.clone(); - config.num_evms = max(config.num_evms, 1); + config.executor_evms = max(config.executor_evms, 1); tracing::info!(?config, "creating executor"); let executor = Executor::new(storage, miner, config); diff --git a/src/globals.rs b/src/globals.rs index ce72f605a..6c0a85f67 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -43,6 +43,8 @@ where // apply env-var aliases env_alias("EXECUTOR_CHAIN_ID", "CHAIN_ID"); env_alias("EXECUTOR_EVMS", "EVMS"); + env_alias("EXECUTOR_EVMS", "NUM_EVMS"); + env_alias("EXECUTOR_REJECT_NOT_CONTRACT", "REJECT_NOT_CONTRACT"); env_alias("EXECUTOR_STRATEGY", "STRATEGY"); env_alias("TRACING_LOG_FORMAT", "LOG_FORMAT"); env_alias("TRACING_URL", "TRACING_COLLECTOR_URL"); diff --git a/src/main.rs b/src/main.rs index e3b398209..0085a719a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ async fn run(config: StratusConfig) -> anyhow::Result<()> { // config config.clone(), config.rpc_server, - config.executor.chain_id.into(), + config.executor.executor_chain_id.into(), ) .await?; diff --git a/tests/test_import_external_snapshot_common.rs b/tests/test_import_external_snapshot_common.rs index 8010bc301..98b17cebd 100644 --- a/tests/test_import_external_snapshot_common.rs +++ b/tests/test_import_external_snapshot_common.rs @@ -100,8 +100,8 @@ pub fn init_config_and_data( ) { // init config let mut global_services = GlobalServices::::init(); - global_services.config.executor.chain_id = 2009; - global_services.config.executor.num_evms = 8; + global_services.config.executor.executor_chain_id = 2009; + global_services.config.executor.executor_evms = 8; // init block data let block_json = fs::read_to_string(format!("tests/fixtures/snapshots/{}/block.json", block_number)).unwrap();