Add a command to purge the relay chain only (#306)

* Add a command to purge the relay chain only

* WIP

* Update rococo-parachains/src/cli.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Move cli stuff to its own crate

* Copyright dates

* Test not working for some reason...

* WIP

* Revert "WIP"

This reverts commit f97cd63742c7df822e4a6e52a29db5e0f56b7bfa.

* Fix test to use provided relay chain

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Add hint about which database could not be purged

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Cecile Tonglet
2021-03-03 13:40:22 +01:00
committed by GitHub
parent fb649f19c2
commit e53a932fe4
42 changed files with 257 additions and 83 deletions
+23 -7
View File
@@ -1,4 +1,4 @@
// Copyright 2019 Parity Technologies (UK) Ltd.
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
@@ -203,7 +203,25 @@ pub fn run() -> Result<()> {
}
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.database))
runner.sync_run(|config| {
let polkadot_cli = RelayChainCli::new(
&config,
[RelayChainCli::executable_name().to_string()]
.iter()
.chain(cli.relaychain_args.iter()),
);
let polkadot_config = SubstrateCli::create_configuration(
&polkadot_cli,
&polkadot_cli,
config.task_executor.clone(),
None,
)
.map_err(|err| format!("Relay chain argument error: {}", err))?;
cmd.run(config, polkadot_config)
})
}
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
@@ -269,13 +287,11 @@ pub fn run() -> Result<()> {
// TODO
let key = sp_core::Pair::generate().0;
let extension = chain_spec::Extensions::try_get(&*config.chain_spec);
let relay_chain_id = extension.map(|e| e.relay_chain.clone());
let para_id = extension.map(|e| e.para_id);
let para_id =
chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id);
let polkadot_cli = RelayChainCli::new(
config.base_path.as_ref().map(|x| x.path().join("polkadot")),
relay_chain_id,
&config,
[RelayChainCli::executable_name().to_string()]
.iter()
.chain(cli.relaychain_args.iter()),