mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 08:55:47 +00:00
8683bbeefb
Closes #2326. This PR both fixes a logic bug and replaces an incorrect name. ## Bug Fix: Respecting custom genesis builder Prior to this PR the standard logic for creating a genesis block was repeated inside of cumulus. This PR removes that duplicated logic, and calls into the proper `BuildGenesisBlock` implementation. One consequence is that if the genesis block has already been initialized, it will not be re-created, but rather read from the database like it is for other node invocations. So you need to watch out for old unpurged data during the development process. Offchain tools may need to be updated accordingly. I've already filed https://github.com/paritytech/zombienet/issues/1519 ## Rename: It doesn't export state. It exports head data. The name export-genesis-state was always wrong, nad it's never too late to right a wrong. I've changed the name of the struct to `ExportGenesisHeadCommand`. There is still the question of what to do with individual nodes' public CLIs. I have updated the parachain template to a reasonable default that preserves compatibility with tools that will expect `export-genesis-state` to still work. And I've chosen not to modify the public CLIs of any other nodes in the repo. I'll leave it up to their individual owners/maintains to decide whether that is appropriate. --------- Co-authored-by: Joshy Orndorff <git-user-email.h0ly5@simplelogin.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Bastian Köcher <info@kchr.de>
131 lines
4.3 KiB
Rust
131 lines
4.3 KiB
Rust
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// This file is part of Cumulus.
|
|
|
|
// Cumulus is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Cumulus is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
/// Sub-commands supported by the collator.
|
|
#[derive(Debug, clap::Subcommand)]
|
|
pub enum Subcommand {
|
|
/// Key management CLI utilities
|
|
#[command(subcommand)]
|
|
Key(sc_cli::KeySubcommand),
|
|
|
|
/// 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),
|
|
|
|
/// Revert the chain to a previous state.
|
|
Revert(sc_cli::RevertCmd),
|
|
|
|
/// Remove the whole chain.
|
|
PurgeChain(cumulus_client_cli::PurgeChainCmd),
|
|
|
|
/// Export the genesis state of the parachain.
|
|
#[command(alias = "export-genesis-state")]
|
|
ExportGenesisHead(cumulus_client_cli::ExportGenesisHeadCommand),
|
|
|
|
/// Export the genesis wasm of the parachain.
|
|
ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),
|
|
|
|
/// Sub-commands concerned with benchmarking.
|
|
/// The pallet benchmarking moved to the `pallet` sub-command.
|
|
#[command(subcommand)]
|
|
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
|
|
|
/// Try-runtime has migrated to a standalone
|
|
/// [CLI](<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
|
|
/// deprecation notice. It will be removed entirely some time after January 2024.
|
|
TryRuntime,
|
|
}
|
|
|
|
const AFTER_HELP_EXAMPLE: &str = color_print::cstr!(
|
|
r#"<bold><underline>Examples:</></>
|
|
<bold>polkadot-parachain --chain asset-hub-polkadot --sync warp -- --chain polkadot --sync warp</>
|
|
Launch a warp-syncing full node of the <italic>Asset Hub</> parachain on the <italic>Polkadot</> Relay Chain.
|
|
<bold>polkadot-parachain --chain asset-hub-polkadot --sync warp --relay-chain-rpc-url ws://rpc.example.com -- --chain polkadot</>
|
|
Launch a warp-syncing full node of the <italic>Asset Hub</> parachain on the <italic>Polkadot</> Relay Chain.
|
|
Uses <italic>ws://rpc.example.com</> as remote relay chain node.
|
|
"#
|
|
);
|
|
#[derive(Debug, clap::Parser)]
|
|
#[command(
|
|
propagate_version = true,
|
|
args_conflicts_with_subcommands = true,
|
|
subcommand_negates_reqs = true
|
|
)]
|
|
#[clap(after_help = AFTER_HELP_EXAMPLE)]
|
|
pub struct Cli {
|
|
#[command(subcommand)]
|
|
pub subcommand: Option<Subcommand>,
|
|
|
|
#[command(flatten)]
|
|
pub run: cumulus_client_cli::RunCmd,
|
|
|
|
/// Disable automatic hardware benchmarks.
|
|
///
|
|
/// By default these benchmarks are automatically ran at startup and measure
|
|
/// the CPU speed, the memory bandwidth and the disk speed.
|
|
///
|
|
/// The results are then printed out in the logs, and also sent as part of
|
|
/// telemetry, if telemetry is enabled.
|
|
#[arg(long)]
|
|
pub no_hardware_benchmarks: bool,
|
|
|
|
/// Relay chain arguments
|
|
#[arg(raw = true)]
|
|
pub relaychain_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 = crate::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.path().join("polkadot");
|
|
Self {
|
|
base_path: Some(base_path),
|
|
chain_id,
|
|
base: clap::Parser::parse_from(relay_chain_args),
|
|
}
|
|
}
|
|
}
|