|
1 | 1 | use crate::{ |
2 | 2 | chain_spec, |
3 | | - cli::{Cli, RelayChainCli, Subcommand}, |
4 | | - service::{new_partial, DataHighwayRuntimeExecutor} |
| 3 | + cli::{ |
| 4 | + Cli, |
| 5 | + RelayChainCli, |
| 6 | + Subcommand, |
| 7 | + }, |
| 8 | + service::{ |
| 9 | + new_partial, |
| 10 | + DataHighwayRuntimeExecutor, |
| 11 | + }, |
5 | 12 | }; |
6 | | -use datahighway_runtime::RuntimeApi; |
7 | 13 | use codec::Encode; |
8 | 14 | use cumulus_client_service::genesis::generate_genesis_block; |
9 | 15 | use cumulus_primitives_core::ParaId; |
10 | | -use datahighway_runtime::Block; |
| 16 | +use datahighway_runtime::{ |
| 17 | + Block, |
| 18 | + RuntimeApi, |
| 19 | +}; |
11 | 20 | use log::info; |
12 | 21 | use polkadot_parachain::primitives::AccountIdConversion; |
13 | 22 | use sc_cli::{ |
@@ -160,48 +169,39 @@ pub fn run() -> Result<()> { |
160 | 169 | } |
161 | 170 | Some(Subcommand::CheckBlock(cmd)) => { |
162 | 171 | construct_async_run!(|components, cli, cmd, config| { |
163 | | - Ok(cmd.run(components.client, components.import_queue)) |
164 | | - }) |
| 172 | + Ok(cmd.run(components.client, components.import_queue)) |
| 173 | + }) |
165 | 174 | } |
166 | 175 | Some(Subcommand::ExportBlocks(cmd)) => { |
167 | | - construct_async_run!(|components, cli, cmd, config| { |
168 | | - Ok(cmd.run(components.client, config.database)) |
169 | | - }) |
| 176 | + construct_async_run!(|components, cli, cmd, config| { Ok(cmd.run(components.client, config.database)) }) |
170 | 177 | } |
171 | 178 | Some(Subcommand::ExportState(cmd)) => { |
172 | | - construct_async_run!(|components, cli, cmd, config| { |
173 | | - Ok(cmd.run(components.client, config.chain_spec)) |
174 | | - }) |
| 179 | + construct_async_run!(|components, cli, cmd, config| { Ok(cmd.run(components.client, config.chain_spec)) }) |
175 | 180 | } |
176 | 181 | Some(Subcommand::ImportBlocks(cmd)) => { |
177 | 182 | construct_async_run!(|components, cli, cmd, config| { |
178 | | - Ok(cmd.run(components.client, components.import_queue)) |
179 | | - }) |
| 183 | + Ok(cmd.run(components.client, components.import_queue)) |
| 184 | + }) |
180 | 185 | } |
181 | 186 | Some(Subcommand::PurgeChain(cmd)) => { |
182 | 187 | let runner = cli.create_runner(cmd)?; |
183 | 188 |
|
184 | 189 | runner.sync_run(|config| { |
185 | 190 | let polkadot_cli = RelayChainCli::new( |
186 | 191 | &config, |
187 | | - [RelayChainCli::executable_name().to_string()] |
188 | | - .iter() |
189 | | - .chain(cli.relaychain_args.iter()), |
| 192 | + [RelayChainCli::executable_name().to_string()].iter().chain(cli.relaychain_args.iter()), |
190 | 193 | ); |
191 | 194 |
|
192 | | - let polkadot_config = SubstrateCli::create_configuration( |
193 | | - &polkadot_cli, |
194 | | - &polkadot_cli, |
195 | | - config.task_executor.clone(), |
196 | | - ) |
197 | | - .map_err(|err| format!("Relay chain argument error: {}", err))?; |
| 195 | + let polkadot_config = |
| 196 | + SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, config.task_executor.clone()) |
| 197 | + .map_err(|err| format!("Relay chain argument error: {}", err))?; |
198 | 198 |
|
199 | 199 | cmd.run(config, polkadot_config) |
200 | 200 | }) |
201 | 201 | } |
202 | | - Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| { |
203 | | - Ok(cmd.run(components.client, components.backend)) |
204 | | - }), |
| 202 | + Some(Subcommand::Revert(cmd)) => { |
| 203 | + construct_async_run!(|components, cli, cmd, config| { Ok(cmd.run(components.client, components.backend)) }) |
| 204 | + } |
205 | 205 | Some(Subcommand::ExportGenesisState(params)) => { |
206 | 206 | let mut builder = sc_cli::LoggerBuilder::new(""); |
207 | 207 | builder.with_profiling(sc_tracing::TracingReceiver::Log, ""); |
@@ -249,50 +249,42 @@ pub fn run() -> Result<()> { |
249 | 249 | None => { |
250 | 250 | let runner = cli.create_runner(&cli.run.normalize())?; |
251 | 251 |
|
252 | | - runner.run_node_until_exit(|config| async move { |
253 | | - let para_id = |
254 | | - chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id); |
255 | | - |
256 | | - let polkadot_cli = RelayChainCli::new( |
257 | | - &config, |
258 | | - [RelayChainCli::executable_name().to_string()] |
259 | | - .iter() |
260 | | - .chain(cli.relaychain_args.iter()), |
261 | | - ); |
262 | | - |
263 | | - let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(2000)); |
264 | | - |
265 | | - let parachain_account = |
266 | | - AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id); |
267 | | - |
268 | | - let block: Block = |
269 | | - generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?; |
270 | | - let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); |
271 | | - |
272 | | - let task_executor = config.task_executor.clone(); |
273 | | - let polkadot_config = SubstrateCli::create_configuration( |
274 | | - &polkadot_cli, |
275 | | - &polkadot_cli, |
276 | | - task_executor, |
277 | | - ) |
278 | | - .map_err(|err| format!("Relay chain argument error: {}", err))?; |
279 | | - |
280 | | - info!("Parachain id: {:?}", id); |
281 | | - info!("Parachain Account: {}", parachain_account); |
282 | | - info!("Parachain genesis state: {}", genesis_state); |
283 | | - info!( |
284 | | - "Is collating: {}", |
285 | | - if config.role.is_authority() { |
286 | | - "yes" |
287 | | - } else { |
288 | | - "no" |
289 | | - } |
290 | | - ); |
291 | | - |
292 | | - crate::service::start_node(config, polkadot_config, id) |
293 | | - .await |
294 | | - .map(|r| r.0) |
295 | | - .map_err(Into::into) |
| 252 | + runner.run_node_until_exit(|config| { |
| 253 | + async move { |
| 254 | + let para_id = chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id); |
| 255 | + |
| 256 | + let polkadot_cli = RelayChainCli::new( |
| 257 | + &config, |
| 258 | + [RelayChainCli::executable_name().to_string()].iter().chain(cli.relaychain_args.iter()), |
| 259 | + ); |
| 260 | + |
| 261 | + let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(2000)); |
| 262 | + |
| 263 | + let parachain_account = |
| 264 | + AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id); |
| 265 | + |
| 266 | + let block: Block = generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?; |
| 267 | + let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); |
| 268 | + |
| 269 | + let task_executor = config.task_executor.clone(); |
| 270 | + let polkadot_config = |
| 271 | + SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor) |
| 272 | + .map_err(|err| format!("Relay chain argument error: {}", err))?; |
| 273 | + |
| 274 | + info!("Parachain id: {:?}", id); |
| 275 | + info!("Parachain Account: {}", parachain_account); |
| 276 | + info!("Parachain genesis state: {}", genesis_state); |
| 277 | + info!( |
| 278 | + "Is collating: {}", |
| 279 | + if config.role.is_authority() { |
| 280 | + "yes" |
| 281 | + } else { |
| 282 | + "no" |
| 283 | + } |
| 284 | + ); |
| 285 | + |
| 286 | + crate::service::start_node(config, polkadot_config, id).await.map(|r| r.0).map_err(Into::into) |
| 287 | + } |
296 | 288 | }) |
297 | 289 | } |
298 | 290 | } |
@@ -354,8 +346,8 @@ impl CliConfiguration<Self> for RelayChainCli { |
354 | 346 | } |
355 | 347 |
|
356 | 348 | fn init<C: SubstrateCli>(&self) -> Result<()> { |
357 | | - unreachable!("PolkadotCli is never initialized; qed"); |
358 | | - } |
| 349 | + unreachable!("PolkadotCli is never initialized; qed"); |
| 350 | + } |
359 | 351 |
|
360 | 352 | fn chain_id(&self, is_dev: bool) -> Result<String> { |
361 | 353 | let chain_id = self.base.base.chain_id(is_dev)?; |
|
0 commit comments