diff --git a/crates/humanode-peer/src/cli/config.rs b/crates/humanode-peer/src/cli/config.rs index 54f7deb55..ef27a371b 100644 --- a/crates/humanode-peer/src/cli/config.rs +++ b/crates/humanode-peer/src/cli/config.rs @@ -44,17 +44,26 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider { } }); - let evm = self.evm_params().map(|params| configuration::Evm { - max_past_logs: params.max_past_logs, - max_stored_filters: params.max_stored_filters, - target_gas_price: params.target_gas_price, - fee_history_limit: params.fee_history_limit, - }); + let evm = { + let params = self.evm_params(); + configuration::Evm { + target_gas_price: params.map(|p| p.target_gas_price).unwrap_or(1), + } + }; + + let ethereum_rpc = self + .ethereum_rpc_params() + .map(|params| configuration::EthereumRpc { + max_past_logs: params.max_past_logs, + max_stored_filters: params.max_stored_filters, + fee_history_limit: params.fee_history_limit, + }); Ok(Configuration { substrate, bioauth_flow, evm, + ethereum_rpc, }) } @@ -67,6 +76,11 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider { fn evm_params(&self) -> Option<¶ms::EvmParams> { None } + + /// Provide the Ethereum RPC params. + fn ethereum_rpc_params(&self) -> Option<¶ms::EthereumRpcParams> { + None + } } /// Indirect relation to the [`sc_cli::CliConfiguration`] for any type. diff --git a/crates/humanode-peer/src/cli/params.rs b/crates/humanode-peer/src/cli/params.rs index ec095ca11..25b41bae5 100644 --- a/crates/humanode-peer/src/cli/params.rs +++ b/crates/humanode-peer/src/cli/params.rs @@ -51,9 +51,17 @@ pub struct BioauthFlowParams { pub robonode_url: Option, } -/// Shared CLI parameters used to configure evm. +/// Shared CLI parameters used to configure EVM. #[derive(Debug, clap::Parser, Clone)] pub struct EvmParams { + /// The dynamic-fee pallet target gas price set by block author. + #[clap(long, default_value = "1")] + pub target_gas_price: u64, +} + +/// Shared CLI parameters used to configure Ethereum RPC. +#[derive(Debug, clap::Parser, Clone)] +pub struct EthereumRpcParams { /// Maximum number of logs to keep from the latest block; /// it is not possible to query logs older than this amount from the latest block in the past. #[clap(long, default_value = "10000")] @@ -63,10 +71,6 @@ pub struct EvmParams { #[clap(long, default_value = "500")] pub max_stored_filters: usize, - /// The dynamic-fee pallet target gas price set by block author. - #[clap(long, default_value = "1")] - pub target_gas_price: u64, - /// Maximum fee history cache size. #[clap(long, default_value = "2048")] pub fee_history_limit: u64, diff --git a/crates/humanode-peer/src/cli/run_cmd.rs b/crates/humanode-peer/src/cli/run_cmd.rs index 35e19f2bc..6fc75911f 100644 --- a/crates/humanode-peer/src/cli/run_cmd.rs +++ b/crates/humanode-peer/src/cli/run_cmd.rs @@ -17,6 +17,10 @@ pub struct RunCmd { #[allow(missing_docs, clippy::missing_docs_in_private_items)] #[clap(flatten)] pub evm_params: params::EvmParams, + + #[allow(missing_docs, clippy::missing_docs_in_private_items)] + #[clap(flatten)] + pub ethereum_rpc_params: params::EthereumRpcParams, } impl SubstrateCliConfigurationProvider for RunCmd { @@ -35,4 +39,8 @@ impl CliConfigurationExt for RunCmd { fn evm_params(&self) -> Option<¶ms::EvmParams> { Some(&self.evm_params) } + + fn ethereum_rpc_params(&self) -> Option<¶ms::EthereumRpcParams> { + Some(&self.ethereum_rpc_params) + } } diff --git a/crates/humanode-peer/src/configuration.rs b/crates/humanode-peer/src/configuration.rs index c7fc34bbd..6a3bd6246 100644 --- a/crates/humanode-peer/src/configuration.rs +++ b/crates/humanode-peer/src/configuration.rs @@ -15,8 +15,11 @@ pub struct Configuration { /// always required. pub bioauth_flow: Option, - /// EVM configuration, - pub evm: Option, + /// EVM configuration. + pub evm: Evm, + + /// Ethereum RPC configuration. + pub ethereum_rpc: Option, } /// Bioauth flow configuration parameters. @@ -50,6 +53,12 @@ impl BioauthFlow { /// EVM configuration parameters. pub struct Evm { + /// The dynamic-fee pallet target gas price set by block author. + pub target_gas_price: u64, +} + +/// Ethereum RPC configuration parameters. +pub struct EthereumRpc { /// Maximum number of blocks to keep the log information available /// for querying via the RPC (from the latest block). pub max_past_logs: u32, @@ -57,9 +66,6 @@ pub struct Evm { /// Maximum number of stored filters. pub max_stored_filters: usize, - /// The dynamic-fee pallet target gas price set by block author. - pub target_gas_price: u64, - /// Maximum fee history cache size. pub fee_history_limit: u64, } diff --git a/crates/humanode-peer/src/service/mod.rs b/crates/humanode-peer/src/service/mod.rs index 6ae1bdb91..f9743dcb2 100644 --- a/crates/humanode-peer/src/service/mod.rs +++ b/crates/humanode-peer/src/service/mod.rs @@ -112,10 +112,6 @@ pub fn new_partial( .. } = config; - let evm_config = evm_config - .as_ref() - .ok_or_else(|| ServiceError::Other("evm config is not set".into()))?; - let telemetry = config .telemetry_endpoints .clone() @@ -241,7 +237,8 @@ pub async fn new_full(config: Configuration) -> Result Result Result = Some(Arc::new(Mutex::new(BTreeMap::new()))); let eth_fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new())); - let eth_fee_history_limit = evm_config.fee_history_limit; + let eth_fee_history_limit = ethereum_rpc_config.fee_history_limit; let eth_overrides = humanode_rpc::overrides_handle(Arc::clone(&client)); let proposer_factory = sc_basic_authorship::ProposerFactory::new( @@ -356,7 +353,6 @@ pub async fn new_full(config: Configuration) -> Result Result Result