stratus/eth/executor/
executor_config.rs1use std::str::FromStr;
2use std::sync::Arc;
3
4use clap::Parser;
5use display_json::DebugAsJson;
6use revm::primitives::hardfork::SpecId;
7
8use crate::eth::executor::Executor;
9use crate::eth::miner::Miner;
10use crate::eth::storage::StratusStorage;
11
12#[derive(Parser, DebugAsJson, Clone, serde::Serialize)]
13pub struct ExecutorConfig {
14 #[arg(long = "executor-chain-id", alias = "chain-id", env = "EXECUTOR_CHAIN_ID")]
16 pub executor_chain_id: u64,
17
18 #[arg(long = "executor-call-present-evms", env = "EXECUTOR_CALL_PRESENT_EVMS", default_value_t = 50)]
19 pub call_present_evms: usize,
20
21 #[arg(long = "executor-call-past-evms", env = "EXECUTOR_CALL_PAST_EVMS", default_value_t = 50)]
22 pub call_past_evms: usize,
23
24 #[arg(long = "executor-inspector-evms", env = "EXECUTOR_INSPECTOR_EVMS", default_value_t = 50)]
25 pub inspector_evms: usize,
26
27 #[arg(
29 long = "executor-reject-not-contract",
30 alias = "reject-not-contract",
31 env = "EXECUTOR_REJECT_NOT_CONTRACT",
32 default_value = "true"
33 )]
34 pub executor_reject_not_contract: bool,
35
36 #[arg(long = "executor-evm-spec", env = "EXECUTOR_EVM_SPEC", default_value = "Prague", value_parser = parse_evm_spec)]
37 pub executor_evm_spec: SpecId,
38}
39
40fn parse_evm_spec(input: &str) -> anyhow::Result<SpecId> {
41 SpecId::from_str(input).map_err(|err| anyhow::anyhow!("unknown hard fork: {err:?}"))
42}
43
44impl ExecutorConfig {
45 pub fn init(&self, storage: Arc<StratusStorage>, miner: Arc<Miner>) -> Arc<Executor> {
49 let config = self.clone();
50 tracing::info!(?config, "creating executor");
51
52 let executor = Executor::new(storage, miner, config);
53 Arc::new(executor)
54 }
55}