mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-06 09:07:30 +00:00
7ec0963e3b
* para-template: Add bench commands Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * collator: Add bench commands Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test benchmark commands Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove comments Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * update lockfile for {"polkadot"} * Remove benchmark block test as the collator cannot produce blocks on its own Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <>
120 lines
3.3 KiB
Rust
120 lines
3.3 KiB
Rust
use crate::chain_spec;
|
|
use clap::Parser;
|
|
use std::path::PathBuf;
|
|
|
|
/// Sub-commands supported by the collator.
|
|
#[derive(Debug, clap::Subcommand)]
|
|
pub enum Subcommand {
|
|
/// Export the genesis state of the parachain.
|
|
#[clap(name = "export-genesis-state")]
|
|
ExportGenesisState(ExportGenesisStateCommand),
|
|
|
|
/// Export the genesis wasm of the parachain.
|
|
#[clap(name = "export-genesis-wasm")]
|
|
ExportGenesisWasm(ExportGenesisWasmCommand),
|
|
|
|
/// Build a chain specification.
|
|
BuildSpec(sc_cli::BuildSpecCmd),
|
|
|
|
/// Validate blocks.
|
|
CheckBlock(sc_cli::CheckBlockCmd),
|
|
|
|
/// Export blocks.
|
|
ExportBlocks(sc_cli::ExportBlocksCmd),
|
|
|
|
/// Export the state of a given block into a chain spec.
|
|
ExportState(sc_cli::ExportStateCmd),
|
|
|
|
/// Import blocks.
|
|
ImportBlocks(sc_cli::ImportBlocksCmd),
|
|
|
|
/// Remove the whole chain.
|
|
PurgeChain(cumulus_client_cli::PurgeChainCmd),
|
|
|
|
/// Revert the chain to a previous state.
|
|
Revert(sc_cli::RevertCmd),
|
|
|
|
/// Sub-commands concerned with benchmarking.
|
|
/// The pallet benchmarking moved to the `pallet` sub-command.
|
|
#[clap(subcommand)]
|
|
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
|
|
|
/// Try some testing command against a specified runtime state.
|
|
TryRuntime(try_runtime_cli::TryRuntimeCmd),
|
|
}
|
|
|
|
/// Command for exporting the genesis state of the parachain
|
|
#[derive(Debug, Parser)]
|
|
pub struct ExportGenesisStateCommand {
|
|
/// Output file name or stdout if unspecified.
|
|
#[clap(parse(from_os_str))]
|
|
pub output: Option<PathBuf>,
|
|
|
|
/// Write output in binary. Default is to write in hex.
|
|
#[clap(short, long)]
|
|
pub raw: bool,
|
|
|
|
/// The name of the chain for that the genesis state should be exported.
|
|
#[clap(long)]
|
|
pub chain: Option<String>,
|
|
}
|
|
|
|
/// Command for exporting the genesis wasm file.
|
|
#[derive(Debug, Parser)]
|
|
pub struct ExportGenesisWasmCommand {
|
|
/// Output file name or stdout if unspecified.
|
|
#[clap(parse(from_os_str))]
|
|
pub output: Option<PathBuf>,
|
|
|
|
/// Write output in binary. Default is to write in hex.
|
|
#[clap(short, long)]
|
|
pub raw: bool,
|
|
|
|
/// The name of the chain for that the genesis wasm file should be exported.
|
|
#[clap(long)]
|
|
pub chain: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Parser)]
|
|
#[clap(
|
|
propagate_version = true,
|
|
args_conflicts_with_subcommands = true,
|
|
subcommand_negates_reqs = true
|
|
)]
|
|
pub struct Cli {
|
|
#[clap(subcommand)]
|
|
pub subcommand: Option<Subcommand>,
|
|
|
|
#[clap(flatten)]
|
|
pub run: cumulus_client_cli::RunCmd,
|
|
|
|
/// Relay chain arguments
|
|
#[clap(raw = true)]
|
|
pub relay_chain_args: Vec<String>,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct RelayChainCli {
|
|
/// The actual relay chain cli object.
|
|
pub base: polkadot_cli::RunCmd,
|
|
|
|
/// Optional chain id that should be passed to the relay chain.
|
|
pub chain_id: Option<String>,
|
|
|
|
/// The base path that should be used by the relay chain.
|
|
pub base_path: Option<PathBuf>,
|
|
}
|
|
|
|
impl RelayChainCli {
|
|
/// Parse the relay chain CLI parameters using the para chain `Configuration`.
|
|
pub fn new<'a>(
|
|
para_config: &sc_service::Configuration,
|
|
relay_chain_args: impl Iterator<Item = &'a String>,
|
|
) -> Self {
|
|
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
|
|
let chain_id = extension.map(|e| e.relay_chain.clone());
|
|
let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
|
|
Self { base_path, chain_id, base: polkadot_cli::RunCmd::parse_from(relay_chain_args) }
|
|
}
|
|
}
|