sc_cli/params/
import_params.rs1use crate::{
20 arg_enums::{
21 ExecutionStrategy, WasmExecutionMethod, WasmtimeInstantiationStrategy,
22 DEFAULT_WASMTIME_INSTANTIATION_STRATEGY, DEFAULT_WASM_EXECUTION_METHOD,
23 },
24 params::{DatabaseParams, PruningParams},
25};
26use clap::Args;
27use std::path::PathBuf;
28
29#[derive(Debug, Clone, Args)]
31pub struct ImportParams {
32 #[allow(missing_docs)]
33 #[clap(flatten)]
34 pub pruning_params: PruningParams,
35
36 #[allow(missing_docs)]
37 #[clap(flatten)]
38 pub database_params: DatabaseParams,
39
40 #[arg(
42 long = "wasm-execution",
43 value_name = "METHOD",
44 value_enum,
45 ignore_case = true,
46 default_value_t = DEFAULT_WASM_EXECUTION_METHOD,
47 )]
48 pub wasm_method: WasmExecutionMethod,
49
50 #[arg(
61 long,
62 value_name = "STRATEGY",
63 default_value_t = DEFAULT_WASMTIME_INSTANTIATION_STRATEGY,
64 value_enum,
65 )]
66 pub wasmtime_instantiation_strategy: WasmtimeInstantiationStrategy,
67
68 #[arg(long, value_name = "PATH")]
72 pub wasm_runtime_overrides: Option<PathBuf>,
73
74 #[allow(missing_docs)]
75 #[clap(flatten)]
76 pub execution_strategies: ExecutionStrategiesParams,
77
78 #[arg(long, value_name = "Bytes", default_value_t = 1024 * 1024 * 1024)]
82 pub trie_cache_size: usize,
83}
84
85impl ImportParams {
86 pub fn trie_cache_maximum_size(&self) -> Option<usize> {
88 if self.trie_cache_size == 0 {
89 None
90 } else {
91 Some(self.trie_cache_size)
92 }
93 }
94
95 pub fn wasm_method(&self) -> sc_service::config::WasmExecutionMethod {
97 self.execution_strategies.check_usage_and_print_deprecation_warning();
98
99 crate::execution_method_from_cli(self.wasm_method, self.wasmtime_instantiation_strategy)
100 }
101
102 pub fn wasm_runtime_overrides(&self) -> Option<PathBuf> {
105 self.wasm_runtime_overrides.clone()
106 }
107}
108
109#[derive(Debug, Clone, Args)]
111pub struct ExecutionStrategiesParams {
112 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
114 pub execution_syncing: Option<ExecutionStrategy>,
115
116 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
118 pub execution_import_block: Option<ExecutionStrategy>,
119
120 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
122 pub execution_block_construction: Option<ExecutionStrategy>,
123
124 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
126 pub execution_offchain_worker: Option<ExecutionStrategy>,
127
128 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
130 pub execution_other: Option<ExecutionStrategy>,
131
132 #[arg(
134 long,
135 value_name = "STRATEGY",
136 value_enum,
137 ignore_case = true,
138 conflicts_with_all = &[
139 "execution_other",
140 "execution_offchain_worker",
141 "execution_block_construction",
142 "execution_import_block",
143 "execution_syncing",
144 ]
145 )]
146 pub execution: Option<ExecutionStrategy>,
147}
148
149impl ExecutionStrategiesParams {
150 fn check_usage_and_print_deprecation_warning(&self) {
152 for (param, name) in [
153 (&self.execution_syncing, "execution-syncing"),
154 (&self.execution_import_block, "execution-import-block"),
155 (&self.execution_block_construction, "execution-block-construction"),
156 (&self.execution_offchain_worker, "execution-offchain-worker"),
157 (&self.execution_other, "execution-other"),
158 (&self.execution, "execution"),
159 ] {
160 if param.is_some() {
161 eprintln!(
162 "CLI parameter `--{name}` has no effect anymore and will be removed in the future!"
163 );
164 }
165 }
166 }
167}