From 82b60ce04574c6546fa81220e94359bc76f09317 Mon Sep 17 00:00:00 2001 From: Vedhavyas Singareddi Date: Mon, 16 Sep 2024 15:37:57 +0530 Subject: [PATCH] Fix revert command when running as parachain (#1363) --- bin/collator/src/command.rs | 39 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/bin/collator/src/command.rs b/bin/collator/src/command.rs index a2073426b..461738311 100644 --- a/bin/collator/src/command.rs +++ b/bin/collator/src/command.rs @@ -261,19 +261,32 @@ pub fn run() -> Result<()> { } Some(Subcommand::Revert(cmd)) => { let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { - client, - task_manager, - backend, - .. - } = parachain::new_partial(&config)?; - let aux_revert = Box::new(|client, _, blocks| { - sc_consensus_grandpa::revert(client, blocks)?; - Ok(()) - }); - Ok((cmd.run(client, backend, Some(aux_revert)), task_manager)) - }) + let chain_spec = &runner.config().chain_spec; + if chain_spec.is_dev() { + runner.async_run(|config| { + let PartialComponents { + client, + task_manager, + backend, + .. + } = local::new_partial(&config)?; + let aux_revert = Box::new(|client, _, blocks| { + sc_consensus_grandpa::revert(client, blocks)?; + Ok(()) + }); + Ok((cmd.run(client, backend, Some(aux_revert)), task_manager)) + }) + } else { + runner.async_run(|config| { + let PartialComponents { + client, + task_manager, + backend, + .. + } = parachain::new_partial(&config)?; + Ok((cmd.run(client, backend, None), task_manager)) + }) + } } Some(Subcommand::ExportGenesisState(cmd)) => { let runner = cli.create_runner(cmd)?;