Skip to content

Commit cebe6ec

Browse files
authored
Separate the EVM and Ethereum RPC params (#404)
1 parent d13e2c9 commit cebe6ec

File tree

5 files changed

+55
-28
lines changed

5 files changed

+55
-28
lines changed

crates/humanode-peer/src/cli/config.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,26 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider {
4444
}
4545
});
4646

47-
let evm = self.evm_params().map(|params| configuration::Evm {
48-
max_past_logs: params.max_past_logs,
49-
max_stored_filters: params.max_stored_filters,
50-
target_gas_price: params.target_gas_price,
51-
fee_history_limit: params.fee_history_limit,
52-
});
47+
let evm = {
48+
let params = self.evm_params();
49+
configuration::Evm {
50+
target_gas_price: params.map(|p| p.target_gas_price).unwrap_or(1),
51+
}
52+
};
53+
54+
let ethereum_rpc = self
55+
.ethereum_rpc_params()
56+
.map(|params| configuration::EthereumRpc {
57+
max_past_logs: params.max_past_logs,
58+
max_stored_filters: params.max_stored_filters,
59+
fee_history_limit: params.fee_history_limit,
60+
});
5361

5462
Ok(Configuration {
5563
substrate,
5664
bioauth_flow,
5765
evm,
66+
ethereum_rpc,
5867
})
5968
}
6069

@@ -67,6 +76,11 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider {
6776
fn evm_params(&self) -> Option<&params::EvmParams> {
6877
None
6978
}
79+
80+
/// Provide the Ethereum RPC params.
81+
fn ethereum_rpc_params(&self) -> Option<&params::EthereumRpcParams> {
82+
None
83+
}
7084
}
7185

7286
/// Indirect relation to the [`sc_cli::CliConfiguration`] for any type.

crates/humanode-peer/src/cli/params.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,17 @@ pub struct BioauthFlowParams {
5151
pub robonode_url: Option<String>,
5252
}
5353

54-
/// Shared CLI parameters used to configure evm.
54+
/// Shared CLI parameters used to configure EVM.
5555
#[derive(Debug, clap::Parser, Clone)]
5656
pub struct EvmParams {
57+
/// The dynamic-fee pallet target gas price set by block author.
58+
#[clap(long, default_value = "1")]
59+
pub target_gas_price: u64,
60+
}
61+
62+
/// Shared CLI parameters used to configure Ethereum RPC.
63+
#[derive(Debug, clap::Parser, Clone)]
64+
pub struct EthereumRpcParams {
5765
/// Maximum number of logs to keep from the latest block;
5866
/// it is not possible to query logs older than this amount from the latest block in the past.
5967
#[clap(long, default_value = "10000")]
@@ -63,10 +71,6 @@ pub struct EvmParams {
6371
#[clap(long, default_value = "500")]
6472
pub max_stored_filters: usize,
6573

66-
/// The dynamic-fee pallet target gas price set by block author.
67-
#[clap(long, default_value = "1")]
68-
pub target_gas_price: u64,
69-
7074
/// Maximum fee history cache size.
7175
#[clap(long, default_value = "2048")]
7276
pub fee_history_limit: u64,

crates/humanode-peer/src/cli/run_cmd.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ pub struct RunCmd {
1717
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
1818
#[clap(flatten)]
1919
pub evm_params: params::EvmParams,
20+
21+
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
22+
#[clap(flatten)]
23+
pub ethereum_rpc_params: params::EthereumRpcParams,
2024
}
2125

2226
impl SubstrateCliConfigurationProvider for RunCmd {
@@ -35,4 +39,8 @@ impl CliConfigurationExt for RunCmd {
3539
fn evm_params(&self) -> Option<&params::EvmParams> {
3640
Some(&self.evm_params)
3741
}
42+
43+
fn ethereum_rpc_params(&self) -> Option<&params::EthereumRpcParams> {
44+
Some(&self.ethereum_rpc_params)
45+
}
3846
}

crates/humanode-peer/src/configuration.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ pub struct Configuration {
1515
/// always required.
1616
pub bioauth_flow: Option<BioauthFlow>,
1717

18-
/// EVM configuration,
19-
pub evm: Option<Evm>,
18+
/// EVM configuration.
19+
pub evm: Evm,
20+
21+
/// Ethereum RPC configuration.
22+
pub ethereum_rpc: Option<EthereumRpc>,
2023
}
2124

2225
/// Bioauth flow configuration parameters.
@@ -50,16 +53,19 @@ impl BioauthFlow {
5053

5154
/// EVM configuration parameters.
5255
pub struct Evm {
56+
/// The dynamic-fee pallet target gas price set by block author.
57+
pub target_gas_price: u64,
58+
}
59+
60+
/// Ethereum RPC configuration parameters.
61+
pub struct EthereumRpc {
5362
/// Maximum number of blocks to keep the log information available
5463
/// for querying via the RPC (from the latest block).
5564
pub max_past_logs: u32,
5665

5766
/// Maximum number of stored filters.
5867
pub max_stored_filters: usize,
5968

60-
/// The dynamic-fee pallet target gas price set by block author.
61-
pub target_gas_price: u64,
62-
6369
/// Maximum fee history cache size.
6470
pub fee_history_limit: u64,
6571
}

crates/humanode-peer/src/service/mod.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ pub fn new_partial(
112112
..
113113
} = config;
114114

115-
let evm_config = evm_config
116-
.as_ref()
117-
.ok_or_else(|| ServiceError::Other("evm config is not set".into()))?;
118-
119115
let telemetry = config
120116
.telemetry_endpoints
121117
.clone()
@@ -241,7 +237,8 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
241237
let Configuration {
242238
substrate: mut config,
243239
bioauth_flow: bioauth_flow_config,
244-
evm: evm_config,
240+
evm: _evm_config,
241+
ethereum_rpc: ethereum_rpc_config,
245242
} = config;
246243

247244
let grandpa_protocol_name = sc_finality_grandpa::protocol_standard_name(
@@ -269,8 +266,8 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
269266
let bioauth_flow_config = bioauth_flow_config
270267
.ok_or_else(|| ServiceError::Other("bioauth flow config is not set".into()))?;
271268

272-
let evm_config =
273-
evm_config.expect("already used during substrate partial components exctraction");
269+
let ethereum_rpc_config = ethereum_rpc_config
270+
.ok_or_else(|| ServiceError::Other("Ethereum RPC config is not set".into()))?;
274271

275272
let role = config.role.clone();
276273
let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
@@ -282,7 +279,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
282279
let prometheus_registry = config.prometheus_registry().cloned();
283280
let eth_filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));
284281
let eth_fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));
285-
let eth_fee_history_limit = evm_config.fee_history_limit;
282+
let eth_fee_history_limit = ethereum_rpc_config.fee_history_limit;
286283
let eth_overrides = humanode_rpc::overrides_handle(Arc::clone(&client));
287284

288285
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
@@ -356,7 +353,6 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
356353
let select_chain = select_chain.clone();
357354

358355
let eth_filter_pool = eth_filter_pool.clone();
359-
let eth_max_stored_filters = evm_config.max_stored_filters;
360356
let frontier_backend = Arc::clone(&frontier_backend);
361357
let eth_overrides = Arc::clone(&eth_overrides);
362358
let eth_block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(
@@ -366,7 +362,6 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
366362
50,
367363
config.prometheus_registry().cloned(),
368364
));
369-
let eth_max_past_logs = evm_config.max_past_logs;
370365
let eth_fee_history_cache = Arc::clone(&eth_fee_history_cache);
371366

372367
Box::new(move |deny_unsafe, subscription_task_executor| {
@@ -398,9 +393,9 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
398393
select_chain: select_chain.clone(),
399394
evm: humanode_rpc::EvmDeps {
400395
eth_filter_pool: eth_filter_pool.clone(),
401-
eth_max_stored_filters,
396+
eth_max_stored_filters: ethereum_rpc_config.max_stored_filters,
402397
eth_backend: Arc::clone(&frontier_backend),
403-
eth_max_past_logs,
398+
eth_max_past_logs: ethereum_rpc_config.max_past_logs,
404399
eth_fee_history_limit,
405400
eth_fee_history_cache: Arc::clone(&eth_fee_history_cache),
406401
eth_overrides: Arc::clone(&eth_overrides),

0 commit comments

Comments
 (0)