Commit 67e1ba14 authored by Pierre Krieger's avatar Pierre Krieger Committed by Bastian Köcher
Browse files

Update to latest Substrate (#407)

* Update to latest Substrate

* Fix main.rs
parent 2eadec36
This diff is collapsed.
......@@ -13,6 +13,7 @@ edition = "2018"
cli = { package = "polkadot-cli", path = "cli" }
futures = "0.1"
ctrlc = { version = "3.0", features = ["termination"] }
service = { package = "polkadot-service", path = "service" }
[build-dependencies]
vergen = "3"
......
......@@ -21,17 +21,15 @@
mod chain_spec;
use std::ops::Deref;
use chain_spec::ChainSpec;
use futures::Future;
use tokio::runtime::Runtime;
use service::{Service as BareService, Error as ServiceError};
use std::sync::Arc;
use log::{info, error};
use structopt::StructOpt;
pub use service::{
Components as ServiceComponents, PolkadotService, CustomConfiguration, ServiceFactory, Factory,
AbstractService, CustomConfiguration,
ProvideRuntimeApi, CoreApi, ParachainHost,
};
......@@ -63,7 +61,13 @@ pub trait Worker: IntoExit {
fn configuration(&self) -> service::CustomConfiguration { Default::default() }
/// Do work and schedule exit.
fn work<S: PolkadotService>(self, service: &S, executor: TaskExecutor) -> Self::Work;
fn work<S, SC, B, CE>(self, service: &S, executor: TaskExecutor) -> Self::Work
where S: AbstractService<Block = service::Block, RuntimeApi = service::RuntimeApi,
Backend = B, SelectChain = SC,
NetworkSpecialization = service::PolkadotProtocol, CallExecutor = CE>,
SC: service::SelectChain<service::Block> + 'static,
B: service::Backend<service::Block, service::Blake2Hasher> + 'static,
CE: service::CallExecutor<service::Block, service::Blake2Hasher> + Clone + Send + Sync + 'static;
}
#[derive(Debug, StructOpt, Clone)]
......@@ -101,23 +105,24 @@ pub fn run<W>(worker: W, version: cli::VersionInfo) -> error::Result<()> where
service::Roles::LIGHT =>
run_until_exit(
runtime,
Factory::new_light(config).map_err(|e| format!("{:?}", e))?,
service::new_light(config).map_err(|e| format!("{:?}", e))?,
worker
),
_ => run_until_exit(
runtime,
Factory::new_full(config).map_err(|e| format!("{:?}", e))?,
service::new_full(config).map_err(|e| format!("{:?}", e))?,
worker
),
}.map_err(|e| format!("{:?}", e))
}),
cli::ParseAndPrepare::BuildSpec(cmd) => cmd.run(load_spec),
cli::ParseAndPrepare::ExportBlocks(cmd) =>
cmd.run::<service::Factory, _, _>(load_spec, worker),
cli::ParseAndPrepare::ImportBlocks(cmd) =>
cmd.run::<service::Factory, _, _>(load_spec, worker),
cli::ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder::<(), _, _, _, _, _>(|config|
Ok(service::new_chain_ops(config)?), load_spec, worker),
cli::ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder::<(), _, _, _, _, _>(|config|
Ok(service::new_chain_ops(config)?), load_spec, worker),
cli::ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec),
cli::ParseAndPrepare::RevertChain(cmd) => cmd.run::<service::Factory, _>(load_spec),
cli::ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder::<(), _, _, _, _>(|config|
Ok(service::new_chain_ops(config)?), load_spec),
cli::ParseAndPrepare::CustomCommand(PolkadotSubCommands::ValidationWorker(args)) => {
service::run_validation_worker(&args.mem_id)?;
Ok(())
......@@ -125,15 +130,17 @@ pub fn run<W>(worker: W, version: cli::VersionInfo) -> error::Result<()> where
}
}
fn run_until_exit<T, C, W>(
fn run_until_exit<T, SC, B, CE, W>(
mut runtime: Runtime,
service: T,
worker: W,
) -> error::Result<()>
where
T: Deref<Target=BareService<C>> + Future<Item = (), Error = ServiceError> + Send + 'static,
C: service::Components,
BareService<C>: PolkadotService,
T: AbstractService<Block = service::Block, RuntimeApi = service::RuntimeApi,
SelectChain = SC, Backend = B, NetworkSpecialization = service::PolkadotProtocol, CallExecutor = CE>,
SC: service::SelectChain<service::Block> + 'static,
B: service::Backend<service::Block, service::Blake2Hasher> + 'static,
CE: service::CallExecutor<service::Block, service::Blake2Hasher> + Clone + Send + Sync + 'static,
W: Worker,
{
let (exit_send, exit) = exit_future::signal();
......@@ -146,7 +153,7 @@ fn run_until_exit<T, C, W>(
// but we need to keep holding a reference to the global telemetry guard
let _telemetry = service.telemetry();
let work = worker.work(&*service, Arc::new(executor));
let work = worker.work(&service, Arc::new(executor));
let service = service.map_err(|err| error!("Error while running Service: {}", err));
let _ = runtime.block_on(service.select(work));
exit_send.fire();
......
......@@ -17,6 +17,7 @@ polkadot-primitives = { path = "../primitives" }
polkadot-cli = { path = "../cli" }
polkadot-network = { path = "../network" }
polkadot-validation = { path = "../validation" }
polkadot-service = { path = "../service" }
log = "0.4"
tokio = "0.1.7"
......
......@@ -62,13 +62,12 @@ use polkadot_primitives::{
}
};
use polkadot_cli::{
Worker, IntoExit, ProvideRuntimeApi, TaskExecutor, PolkadotService, CustomConfiguration,
ParachainHost,
Worker, IntoExit, ProvideRuntimeApi, TaskExecutor, AbstractService,
CustomConfiguration, ParachainHost,
};
use polkadot_network::validation::{SessionParams, ValidationNetwork};
use polkadot_network::NetworkService;
use polkadot_network::{NetworkService, PolkadotProtocol};
use tokio::timer::Timeout;
use consensus_common::SelectChain;
pub use polkadot_cli::VersionInfo;
pub use polkadot_network::validation::Incoming;
......@@ -287,8 +286,11 @@ impl<P, E> Worker for CollationNode<P, E> where
config
}
fn work<S>(self, service: &S, task_executor: TaskExecutor) -> Self::Work where
S: PolkadotService,
fn work<S, SC, B, CE>(self, service: &S, task_executor: TaskExecutor) -> Self::Work
where S: AbstractService<Block = polkadot_service::Block, RuntimeApi = polkadot_service::RuntimeApi, Backend = B, SelectChain = SC, NetworkSpecialization = PolkadotProtocol, CallExecutor = CE>,
SC: polkadot_service::SelectChain<polkadot_service::Block> + 'static,
B: polkadot_service::Backend<polkadot_service::Block, polkadot_service::Blake2Hasher> + 'static,
CE: polkadot_service::CallExecutor<polkadot_service::Block, polkadot_service::Blake2Hasher> + Clone + Send + Sync + 'static
{
let CollationNode { build_parachain_context, exit, para_id, key } = self;
let client = service.client();
......
......@@ -22,6 +22,9 @@ sr-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-ma
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client-db = { package = "substrate-client-db", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
......
This diff is collapsed.
......@@ -18,7 +18,7 @@
#![warn(missing_docs)]
use cli::{PolkadotService, VersionInfo, TaskExecutor};
use cli::{AbstractService, VersionInfo, TaskExecutor};
use futures::sync::oneshot;
use futures::{future, Future};
......@@ -45,7 +45,13 @@ impl cli::IntoExit for Worker {
impl cli::Worker for Worker {
type Work = <Self as cli::IntoExit>::Exit;
fn work<S: PolkadotService>(self, _service: &S, _: TaskExecutor) -> Self::Work {
fn work<S, SC, B, CE>(self, _: &S, _: TaskExecutor) -> Self::Work
where S: AbstractService<Block = service::Block, RuntimeApi = service::RuntimeApi,
Backend = B, SelectChain = SC,
NetworkSpecialization = service::PolkadotProtocol, CallExecutor = CE>,
SC: service::SelectChain<service::Block> + 'static,
B: service::Backend<service::Block, service::Blake2Hasher> + 'static,
CE: service::CallExecutor<service::Block, service::Blake2Hasher> + Clone + Send + Sync + 'static {
use cli::IntoExit;
self.into_exit()
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment