Parachain validation moved to external process (#325)

* Improved execution & tests

* Style

* Made CLI arg const

* Moved Upwards message

* CLI subcommand for validation worker

* Build halting parachain

* Build halting parachain

* Made stuff private

* Reorganized parachain tests

* Comment

* Whitespace

* Apply suggestions from code review

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

* Fixed call data size check and introduced an enum

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Arkadiy Paronyan
2019-07-23 11:09:30 +02:00
committed by Bastian Köcher
parent 157cd9a217
commit f1fdb0cb83
19 changed files with 1076 additions and 417 deletions
+29 -14
View File
@@ -28,6 +28,7 @@ use tokio::runtime::Runtime;
use service::Service as BareService;
use std::sync::Arc;
use log::info;
use structopt::StructOpt;
pub use service::{
Components as ServiceComponents, PolkadotService, CustomConfiguration, ServiceFactory, Factory,
@@ -65,21 +66,28 @@ pub trait Worker: IntoExit {
fn work<S: PolkadotService>(self, service: &S, executor: TaskExecutor) -> Self::Work;
}
/// Parse command line arguments into service configuration.
///
/// IANA unassigned port ranges that we could use:
/// 6717-6766 Unassigned
/// 8504-8553 Unassigned
/// 9556-9591 Unassigned
/// 9803-9874 Unassigned
/// 9926-9949 Unassigned
pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Result<()> where
I: IntoIterator<Item = T>,
T: Into<std::ffi::OsString> + Clone,
#[derive(Debug, StructOpt, Clone)]
enum PolkadotSubCommands {
#[structopt(name = "validation-worker", raw(setting = "structopt::clap::AppSettings::Hidden"))]
ValidationWorker(ValidationWokerCommand),
}
impl cli::GetLogFilter for PolkadotSubCommands {
fn get_log_filter(&self) -> Option<String> { None }
}
#[derive(Debug, StructOpt, Clone)]
struct ValidationWokerCommand {
#[structopt()]
pub mem_id: String,
}
/// Parses polkadot specific CLI arguments and run the service.
pub fn run<W>(worker: W, version: cli::VersionInfo) -> error::Result<()> where
W: Worker,
{
cli::parse_and_execute::<service::Factory, NoCustom, NoCustom, _, _, _, _, _>(
load_spec, &version, "parity-polkadot", args, worker,
let command = cli::parse_and_execute::<service::Factory, PolkadotSubCommands, NoCustom, _, _, _, _, _>(
load_spec, &version, "parity-polkadot", std::env::args(), worker,
|worker, _cli_args, _custom_args, mut config| {
info!("{}", version.name);
info!(" version {}", config.full_version());
@@ -103,7 +111,14 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res
),
}.map_err(|e| format!("{:?}", e))
}
).map_err(Into::into).map(|_| ())
)?;
match command {
Some(PolkadotSubCommands::ValidationWorker(args)) => {
service::run_validation_worker(&args.mem_id).map_err(Into::into)
}
_ => Ok(())
}
}
fn run_until_exit<T, C, W>(