Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the EVM and Ethereum RPC params #404

Merged
merged 3 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions crates/humanode-peer/src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand All @@ -67,6 +76,11 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider {
fn evm_params(&self) -> Option<&params::EvmParams> {
None
}

/// Provide the Ethereum RPC params.
fn ethereum_rpc_params(&self) -> Option<&params::EthereumRpcParams> {
None
}
}

/// Indirect relation to the [`sc_cli::CliConfiguration`] for any type.
Expand Down
14 changes: 9 additions & 5 deletions crates/humanode-peer/src/cli/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ pub struct BioauthFlowParams {
pub robonode_url: Option<String>,
}

/// 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")]
Expand All @@ -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,
Expand Down
16 changes: 11 additions & 5 deletions crates/humanode-peer/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ pub struct Configuration {
/// always required.
pub bioauth_flow: Option<BioauthFlow>,

/// EVM configuration,
pub evm: Option<Evm>,
/// EVM configuration.
pub evm: Evm,

/// Ethereum RPC configuration.
pub ethereum_rpc: Option<EthereumRpc>,
}

/// Bioauth flow configuration parameters.
Expand Down Expand Up @@ -50,16 +53,19 @@ 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,

/// 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,
}
17 changes: 7 additions & 10 deletions crates/humanode-peer/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -241,7 +237,8 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
let Configuration {
substrate: mut config,
bioauth_flow: bioauth_flow_config,
evm: evm_config,
evm: _evm_config,
ethereum_rpc: ethereum_rpc_config,
} = config;

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

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

let role = config.role.clone();
let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
Expand All @@ -282,7 +279,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
let prometheus_registry = config.prometheus_registry().cloned();
let eth_filter_pool: Option<FilterPool> = 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(
Expand Down Expand Up @@ -356,7 +353,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
let select_chain = select_chain.clone();

let eth_filter_pool = eth_filter_pool.clone();
let eth_max_stored_filters = evm_config.max_stored_filters;
let eth_max_stored_filters = ethereum_rpc_config.max_stored_filters;
let frontier_backend = Arc::clone(&frontier_backend);
let eth_overrides = Arc::clone(&eth_overrides);
let eth_block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(
Expand All @@ -366,7 +363,7 @@ pub async fn new_full(config: Configuration) -> Result<TaskManager, ServiceError
50,
config.prometheus_registry().cloned(),
));
let eth_max_past_logs = evm_config.max_past_logs;
let eth_max_past_logs = ethereum_rpc_config.max_past_logs;
let eth_fee_history_cache = Arc::clone(&eth_fee_history_cache);

Box::new(move |deny_unsafe, subscription_task_executor| {
Expand Down