mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-08-12 19:41:36 +00:00
Make --collator reusable and imply --validator (#380)
* Reusable RunCmd struct * wire new run command through service * Fill in the rest of the methods * attempt normalization * Settle on the borrowing approach * add the normalize call * bump substrate * Update client/cli/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update docs * Update client/cli/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -90,24 +90,6 @@ pub struct ExportGenesisWasmCommand {
|
||||
pub chain: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct RunCmd {
|
||||
#[structopt(flatten)]
|
||||
pub base: sc_cli::RunCmd,
|
||||
|
||||
/// Id of the parachain this collator collates for.
|
||||
#[structopt(long)]
|
||||
pub parachain_id: Option<u32>,
|
||||
}
|
||||
|
||||
impl std::ops::Deref for RunCmd {
|
||||
type Target = sc_cli::RunCmd;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.base
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(settings = &[
|
||||
structopt::clap::AppSettings::GlobalVersion,
|
||||
@@ -119,13 +101,7 @@ pub struct Cli {
|
||||
pub subcommand: Option<Subcommand>,
|
||||
|
||||
#[structopt(flatten)]
|
||||
pub run: RunCmd,
|
||||
|
||||
/// Run node as collator.
|
||||
///
|
||||
/// Note that this is the same as running with `--validator`.
|
||||
#[structopt(long, conflicts_with = "validator")]
|
||||
pub collator: bool,
|
||||
pub run: cumulus_client_cli::RunCmd,
|
||||
|
||||
/// Relaychain arguments
|
||||
#[structopt(raw = true)]
|
||||
|
||||
@@ -262,7 +262,7 @@ pub fn run() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
None => {
|
||||
let runner = cli.create_runner(&*cli.run)?;
|
||||
let runner = cli.create_runner(&cli.run.normalize())?;
|
||||
let use_shell = use_shell_runtime(&runner.config().chain_spec);
|
||||
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
@@ -295,20 +295,19 @@ pub fn run() -> Result<()> {
|
||||
task_executor,
|
||||
)
|
||||
.map_err(|err| format!("Relay chain argument error: {}", err))?;
|
||||
let collator = cli.run.base.validator || cli.collator;
|
||||
|
||||
info!("Parachain id: {:?}", id);
|
||||
info!("Parachain Account: {}", parachain_account);
|
||||
info!("Parachain genesis state: {}", genesis_state);
|
||||
info!("Is collating: {}", if collator { "yes" } else { "no" });
|
||||
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
||||
|
||||
if use_shell {
|
||||
crate::service::start_shell_node(config, key, polkadot_config, id, collator)
|
||||
crate::service::start_shell_node(config, key, polkadot_config, id)
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into)
|
||||
} else {
|
||||
crate::service::start_node(config, key, polkadot_config, id, collator)
|
||||
crate::service::start_node(config, key, polkadot_config, id)
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into)
|
||||
|
||||
@@ -146,7 +146,6 @@ async fn start_node_impl<RuntimeApi, Executor, RB>(
|
||||
collator_key: CollatorPair,
|
||||
polkadot_config: Configuration,
|
||||
id: ParaId,
|
||||
validator: bool,
|
||||
rpc_ext_builder: RB,
|
||||
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
|
||||
where
|
||||
@@ -198,6 +197,7 @@ where
|
||||
polkadot_full_node.backend.clone(),
|
||||
);
|
||||
|
||||
let validator = parachain_config.role.is_authority();
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
let transaction_pool = params.transaction_pool.clone();
|
||||
let mut task_manager = params.task_manager;
|
||||
@@ -295,17 +295,14 @@ pub async fn start_node(
|
||||
collator_key: CollatorPair,
|
||||
polkadot_config: Configuration,
|
||||
id: ParaId,
|
||||
validator: bool,
|
||||
) -> sc_service::error::Result<(
|
||||
TaskManager,
|
||||
Arc<TFullClient<Block, parachain_runtime::RuntimeApi, RuntimeExecutor>>,
|
||||
)> {
|
||||
) -> sc_service::error::Result<
|
||||
(TaskManager, Arc<TFullClient<Block, parachain_runtime::RuntimeApi, RuntimeExecutor>>)
|
||||
> {
|
||||
start_node_impl::<parachain_runtime::RuntimeApi, RuntimeExecutor, _>(
|
||||
parachain_config,
|
||||
collator_key,
|
||||
polkadot_config,
|
||||
id,
|
||||
validator,
|
||||
|_| Default::default(),
|
||||
)
|
||||
.await
|
||||
@@ -317,17 +314,14 @@ pub async fn start_shell_node(
|
||||
collator_key: CollatorPair,
|
||||
polkadot_config: Configuration,
|
||||
id: ParaId,
|
||||
validator: bool,
|
||||
) -> sc_service::error::Result<(
|
||||
TaskManager,
|
||||
Arc<TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>>,
|
||||
)> {
|
||||
) -> sc_service::error::Result<
|
||||
(TaskManager, Arc<TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>>)
|
||||
> {
|
||||
start_node_impl::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _>(
|
||||
parachain_config,
|
||||
collator_key,
|
||||
polkadot_config,
|
||||
id,
|
||||
validator,
|
||||
|_| Default::default(),
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user