Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

client: use appropriate ExecutionContext for initial sync / regular import #6180

Merged
merged 10 commits into from
Jun 12, 2020
Prev Previous commit
Next Next commit
cli: remove defaults from execution context flags
  • Loading branch information
andresilva committed Jun 4, 2020
commit 999bd84638f9fb3923ac586522f3f9ac5ef3920e
25 changes: 11 additions & 14 deletions client/cli/src/params/import_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ impl ImportParams {
/// Get execution strategies for the parameters
pub fn execution_strategies(&self, is_dev: bool, is_validator: bool) -> ExecutionStrategies {
let exec = &self.execution_strategies;
let exec_all_or = |strat: ExecutionStrategy, default: ExecutionStrategy| {
exec.execution.unwrap_or(if strat == default && is_dev {
let exec_all_or = |strat: Option<ExecutionStrategy>, default: ExecutionStrategy| {
let default = if is_dev {
ExecutionStrategy::Native
} else {
strat
}).into()
default
};

exec.execution.unwrap_or(strat.unwrap_or(default)).into()
};

let default_execution_import_block = if is_validator {
Expand Down Expand Up @@ -142,9 +144,8 @@ pub struct ExecutionStrategiesParams {
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
default_value = DEFAULT_EXECUTION_SYNCING.as_str(),
)]
pub execution_syncing: ExecutionStrategy,
pub execution_syncing: Option<ExecutionStrategy>,

/// The means of execution used when calling into the runtime for general block import
/// (including locally authored blocks).
Expand All @@ -153,39 +154,35 @@ pub struct ExecutionStrategiesParams {
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
default_value = DEFAULT_EXECUTION_IMPORT_BLOCK.as_str(),
)]
pub execution_import_block: ExecutionStrategy,
pub execution_import_block: Option<ExecutionStrategy>,

/// The means of execution used when calling into the runtime while constructing blocks.
#[structopt(
long = "execution-block-construction",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
default_value = DEFAULT_EXECUTION_BLOCK_CONSTRUCTION.as_str(),
)]
pub execution_block_construction: ExecutionStrategy,
pub execution_block_construction: Option<ExecutionStrategy>,

/// The means of execution used when calling into the runtime while using an off-chain worker.
#[structopt(
long = "execution-offchain-worker",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
default_value = DEFAULT_EXECUTION_OFFCHAIN_WORKER.as_str(),
)]
pub execution_offchain_worker: ExecutionStrategy,
pub execution_offchain_worker: Option<ExecutionStrategy>,

/// The means of execution used when calling into the runtime while not syncing, importing or constructing blocks.
#[structopt(
long = "execution-other",
value_name = "STRATEGY",
possible_values = &ExecutionStrategy::variants(),
case_insensitive = true,
default_value = DEFAULT_EXECUTION_OTHER.as_str(),
)]
pub execution_other: ExecutionStrategy,
pub execution_other: Option<ExecutionStrategy>,

/// The execution strategy that should be used by all execution contexts.
#[structopt(
Expand Down