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 = 67108864)]
82 pub trie_cache_size: usize,
83
84 #[arg(long)]
86 state_cache_size: Option<usize>,
87}
88
89impl ImportParams {
90 pub fn trie_cache_maximum_size(&self) -> Option<usize> {
92 if self.state_cache_size.is_some() {
93 eprintln!("`--state-cache-size` was deprecated. Please switch to `--trie-cache-size`.");
94 }
95
96 if self.trie_cache_size == 0 {
97 None
98 } else {
99 Some(self.trie_cache_size)
100 }
101 }
102
103 pub fn wasm_method(&self) -> sc_service::config::WasmExecutionMethod {
105 self.execution_strategies.check_usage_and_print_deprecation_warning();
106
107 crate::execution_method_from_cli(self.wasm_method, self.wasmtime_instantiation_strategy)
108 }
109
110 pub fn wasm_runtime_overrides(&self) -> Option<PathBuf> {
113 self.wasm_runtime_overrides.clone()
114 }
115}
116
117#[derive(Debug, Clone, Args)]
119pub struct ExecutionStrategiesParams {
120 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
122 pub execution_syncing: Option<ExecutionStrategy>,
123
124 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
126 pub execution_import_block: Option<ExecutionStrategy>,
127
128 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
130 pub execution_block_construction: Option<ExecutionStrategy>,
131
132 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
134 pub execution_offchain_worker: Option<ExecutionStrategy>,
135
136 #[arg(long, value_name = "STRATEGY", value_enum, ignore_case = true)]
138 pub execution_other: Option<ExecutionStrategy>,
139
140 #[arg(
142 long,
143 value_name = "STRATEGY",
144 value_enum,
145 ignore_case = true,
146 conflicts_with_all = &[
147 "execution_other",
148 "execution_offchain_worker",
149 "execution_block_construction",
150 "execution_import_block",
151 "execution_syncing",
152 ]
153 )]
154 pub execution: Option<ExecutionStrategy>,
155}
156
157impl ExecutionStrategiesParams {
158 fn check_usage_and_print_deprecation_warning(&self) {
160 for (param, name) in [
161 (&self.execution_syncing, "execution-syncing"),
162 (&self.execution_import_block, "execution-import-block"),
163 (&self.execution_block_construction, "execution-block-construction"),
164 (&self.execution_offchain_worker, "execution-offchain-worker"),
165 (&self.execution_other, "execution-other"),
166 (&self.execution, "execution"),
167 ] {
168 if param.is_some() {
169 eprintln!(
170 "CLI parameter `--{name}` has no effect anymore and will be removed in the future!"
171 );
172 }
173 }
174 }
175}