mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Splitting relaychain and parachain command-line arguments (#42)
Fixes #34 Added .editorconfig
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
root = true
|
||||||
|
[*]
|
||||||
|
indent_style=tab
|
||||||
|
indent_size=tab
|
||||||
|
tab_width=4
|
||||||
|
end_of_line=lf
|
||||||
|
charset=utf-8
|
||||||
|
trim_trailing_whitespace=true
|
||||||
|
max_line_length=100
|
||||||
|
insert_final_newline=true
|
||||||
Generated
+491
-493
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ trie-root = '0.15.2'
|
|||||||
codec = { package = 'parity-scale-codec', version = '1.0.0' }
|
codec = { package = 'parity-scale-codec', version = '1.0.0' }
|
||||||
structopt = "0.3.3"
|
structopt = "0.3.3"
|
||||||
ctrlc = { version = "3.1.3", features = ["termination"] }
|
ctrlc = { version = "3.1.3", features = ["termination"] }
|
||||||
|
itertools = { version = "0.8.2" }
|
||||||
|
|
||||||
# Parachain dependencies
|
# Parachain dependencies
|
||||||
parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" }
|
parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" }
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ use sp_runtime::{
|
|||||||
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
|
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
|
||||||
BuildStorage,
|
BuildStorage,
|
||||||
};
|
};
|
||||||
|
use polkadot_service::ChainSpec as ChainSpecPolkadot;
|
||||||
|
use polkadot_service::CustomConfiguration as CustomConfigurationPolkadot;
|
||||||
|
|
||||||
use futures::{channel::oneshot, future::Map, FutureExt};
|
use futures::{channel::oneshot, future::Map, FutureExt};
|
||||||
|
|
||||||
@@ -64,17 +66,18 @@ struct ExportGenesisStateCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse command line arguments into service configuration.
|
/// Parse command line arguments into service configuration.
|
||||||
pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
|
pub fn run<I, T, E>(args_parachain: I, args_relaychain: I, exit: E, version: VersionInfo) -> error::Result<()>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = T>,
|
I: IntoIterator<Item = T>,
|
||||||
T: Into<std::ffi::OsString> + Clone,
|
T: Into<std::ffi::OsString> + Clone,
|
||||||
E: IntoExit + Send + 'static,
|
E: IntoExit + Send + 'static,
|
||||||
{
|
{
|
||||||
type Config<T> = Configuration<(), T>;
|
type Config<T> = Configuration<(), T>;
|
||||||
|
|
||||||
match parse_and_prepare::<SubCommands, NoCustom, _>(
|
match parse_and_prepare::<SubCommands, NoCustom, _>(
|
||||||
&version,
|
&version,
|
||||||
"cumulus-test-parachain-collator",
|
"cumulus-test-parachain-collator",
|
||||||
args,
|
args_parachain,
|
||||||
) {
|
) {
|
||||||
ParseAndPrepare::Run(cmd) => cmd.run(
|
ParseAndPrepare::Run(cmd) => cmd.run(
|
||||||
load_spec,
|
load_spec,
|
||||||
@@ -94,14 +97,19 @@ where
|
|||||||
// TODO
|
// TODO
|
||||||
config.network.listen_addresses = Vec::new();
|
config.network.listen_addresses = Vec::new();
|
||||||
|
|
||||||
// TODO
|
let mut polkadot_config = parse_and_prepare::<NoCustom, NoCustom, _>(
|
||||||
let mut polkadot_config =
|
&version,
|
||||||
polkadot_collator::Configuration::default_with_spec_and_base_path(
|
"cumulus-test-parachain-collator",
|
||||||
polkadot_service::ChainSpec::from_json_bytes(
|
args_relaychain,
|
||||||
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
).into_configuration::<CustomConfigurationPolkadot, _, _, _>(
|
||||||
)?,
|
load_spec_polkadot,
|
||||||
config.in_chain_config_dir("polkadot"),
|
config.in_chain_config_dir("polkadot"),
|
||||||
);
|
)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
.expect(
|
||||||
|
"can only fail when this is a CustomCommand. Running parse_and_prepare with \
|
||||||
|
NoCustom can never return a CustomCommand; therefore this will never fail; qed"
|
||||||
|
);
|
||||||
polkadot_config.network.boot_nodes = config.network.boot_nodes.clone();
|
polkadot_config.network.boot_nodes = config.network.boot_nodes.clone();
|
||||||
|
|
||||||
if let Some(ref config_dir) = polkadot_config.config_dir {
|
if let Some(ref config_dir) = polkadot_config.config_dir {
|
||||||
@@ -155,6 +163,12 @@ fn load_spec(_: &str) -> std::result::Result<Option<chain_spec::ChainSpec>, Stri
|
|||||||
Ok(Some(chain_spec::get_chain_spec()))
|
Ok(Some(chain_spec::get_chain_spec()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_spec_polkadot(_: &str) -> std::result::Result<Option<ChainSpecPolkadot>, String> {
|
||||||
|
Some(polkadot_service::ChainSpec::from_json_bytes(
|
||||||
|
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
||||||
|
)).transpose()
|
||||||
|
}
|
||||||
|
|
||||||
/// Export the genesis state of the parachain.
|
/// Export the genesis state of the parachain.
|
||||||
fn export_genesis_state(output: Option<PathBuf>) -> error::Result<()> {
|
fn export_genesis_state(output: Option<PathBuf>) -> error::Result<()> {
|
||||||
let storage = (&chain_spec::get_chain_spec()).build_storage()?;
|
let storage = (&chain_spec::get_chain_spec()).build_storage()?;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(unused_extern_crates)]
|
#![warn(unused_extern_crates)]
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
use polkadot_primitives::parachain::Id as ParaId;
|
use polkadot_primitives::parachain::Id as ParaId;
|
||||||
|
|
||||||
mod chain_spec;
|
mod chain_spec;
|
||||||
@@ -30,17 +31,28 @@ pub use sc_cli::{error, IntoExit, VersionInfo};
|
|||||||
|
|
||||||
/// The parachain id of this parachain.
|
/// The parachain id of this parachain.
|
||||||
pub const PARA_ID: ParaId = ParaId::new(100);
|
pub const PARA_ID: ParaId = ParaId::new(100);
|
||||||
|
const EXECUTABLE_NAME: &'static str = "cumulus-test-parachain-collator";
|
||||||
|
const DESCRIPTION: &'static str =
|
||||||
|
"Cumulus test parachain collator\n\nThe command-line arguments provided first will be \
|
||||||
|
passed to the parachain node, while the arguments provided after -- will be passed \
|
||||||
|
to the relaychain node.\n\n\
|
||||||
|
cumulus-test-parachain-collator [parachain-args] -- [relaychain-args]";
|
||||||
|
|
||||||
fn main() -> Result<(), cli::error::Error> {
|
fn main() -> Result<(), cli::error::Error> {
|
||||||
let version = VersionInfo {
|
let version = VersionInfo {
|
||||||
name: "Cumulus Test Parachain Collator",
|
name: "Cumulus Test Parachain Collator",
|
||||||
commit: env!("VERGEN_SHA_SHORT"),
|
commit: env!("VERGEN_SHA_SHORT"),
|
||||||
version: env!("CARGO_PKG_VERSION"),
|
version: env!("CARGO_PKG_VERSION"),
|
||||||
executable_name: "cumulus-test-parachain-collator",
|
|
||||||
author: "Parity Technologies <admin@parity.io>",
|
author: "Parity Technologies <admin@parity.io>",
|
||||||
description: "Cumulus test parachain collator",
|
description: DESCRIPTION,
|
||||||
|
executable_name: EXECUTABLE_NAME,
|
||||||
support_url: "https://github.com/paritytech/cumulus/issues/new",
|
support_url: "https://github.com/paritytech/cumulus/issues/new",
|
||||||
};
|
};
|
||||||
|
|
||||||
cli::run(std::env::args(), cli::Exit, version)
|
let args = std::env::args().collect::<Vec<String>>();
|
||||||
|
let mut iter = args.iter();
|
||||||
|
let parachain_args: Vec<_> = iter.take_while_ref(|&x| x != &"--").collect();
|
||||||
|
let relaychain_args: Vec<_> = iter.collect();
|
||||||
|
|
||||||
|
cli::run(parachain_args, relaychain_args, cli::Exit, version)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user