diff --git a/substrate/.gitlab-ci.yml b/substrate/.gitlab-ci.yml index 99b354a60b..d3c9951df4 100644 --- a/substrate/.gitlab-ci.yml +++ b/substrate/.gitlab-ci.yml @@ -137,10 +137,14 @@ check-web-wasm: - time cargo web build -p sr-io - time cargo web build -p sr-primitives - time cargo web build -p sr-std + - time cargo web build -p substrate-client + - time cargo web build -p substrate-consensus-aura + - time cargo web build -p substrate-consensus-babe - time cargo web build -p substrate-consensus-common - time cargo web build -p substrate-keyring - time cargo web build -p substrate-keystore - time cargo web build -p substrate-executor + - time cargo web build -p substrate-network - time cargo web build -p substrate-network-libp2p - time cargo web build -p substrate-panic-handler - time cargo web build -p substrate-peerset diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 7e92564208..738ccb6694 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -4068,6 +4068,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4125,6 +4126,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-client 2.0.0", "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4196,7 +4198,7 @@ dependencies = [ "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", "substrate-test-client 2.0.0", - "tokio 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/substrate/core/consensus/aura/Cargo.toml b/substrate/core/consensus/aura/Cargo.toml index 446dcbff3a..9c46b942a4 100644 --- a/substrate/core/consensus/aura/Cargo.toml +++ b/substrate/core/consensus/aura/Cargo.toml @@ -22,7 +22,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../common" authorities = { package = "substrate-consensus-authorities", path = "../authorities" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.17" -tokio = "0.1.7" +tokio-timer = "0.2.11" parking_lot = "0.8.0" log = "0.4" @@ -32,4 +32,5 @@ substrate-executor = { path = "../../executor" } network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} service = { package = "substrate-service", path = "../../service" } test_client = { package = "substrate-test-client", path = "../../test-client" } +tokio = "0.1.7" env_logger = "0.6" diff --git a/substrate/core/consensus/aura/src/lib.rs b/substrate/core/consensus/aura/src/lib.rs index e3fffad33f..ad618c2188 100644 --- a/substrate/core/consensus/aura/src/lib.rs +++ b/substrate/core/consensus/aura/src/lib.rs @@ -56,7 +56,7 @@ use inherents::{InherentDataProviders, InherentData}; use authorities::AuthoritiesApi; use futures::{Future, IntoFuture, future}; -use tokio::timer::Timeout; +use tokio_timer::Timeout; use log::{error, warn, debug, info, trace}; use srml_aura::{ @@ -914,7 +914,7 @@ mod tests { .map(|_| ()) .map_err(|_| ()); - let drive_to_completion = ::tokio::timer::Interval::new_interval(TEST_ROUTING_INTERVAL) + let drive_to_completion = ::tokio_timer::Interval::new_interval(TEST_ROUTING_INTERVAL) .for_each(move |_| { net.lock().send_import_notifications(); net.lock().sync_without_disconnects(); diff --git a/substrate/core/consensus/babe/Cargo.toml b/substrate/core/consensus/babe/Cargo.toml index 04cd42c680..020497a104 100644 --- a/substrate/core/consensus/babe/Cargo.toml +++ b/substrate/core/consensus/babe/Cargo.toml @@ -23,7 +23,7 @@ authorities = { package = "substrate-consensus-authorities", path = "../authorit slots = { package = "substrate-consensus-slots", path = "../slots" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } futures = "0.1.26" -tokio = "0.1.18" +tokio-timer = "0.2.11" parking_lot = "0.8.0" log = "0.4.6" schnorrkel = "0.1.1" @@ -36,4 +36,5 @@ substrate-executor = { path = "../../executor" } network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} service = { package = "substrate-service", path = "../../service" } test_client = { package = "substrate-test-client", path = "../../test-client" } +tokio = "0.1.18" env_logger = "0.6.1" diff --git a/substrate/core/consensus/babe/src/lib.rs b/substrate/core/consensus/babe/src/lib.rs index c66eb68137..f28c23de54 100644 --- a/substrate/core/consensus/babe/src/lib.rs +++ b/substrate/core/consensus/babe/src/lib.rs @@ -79,7 +79,7 @@ use client::{ }; use slots::{CheckedHeader, check_equivocation}; use futures::{Future, IntoFuture, future}; -use tokio::timer::Timeout; +use tokio_timer::Timeout; use log::{error, warn, debug, info, trace}; use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, slot_now}; @@ -984,7 +984,7 @@ mod tests { .map(drop) .map_err(drop); - let drive_to_completion = ::tokio::timer::Interval::new_interval(TEST_ROUTING_INTERVAL) + let drive_to_completion = ::tokio_timer::Interval::new_interval(TEST_ROUTING_INTERVAL) .for_each(move |_| { net.lock().send_import_notifications(); net.lock().sync_without_disconnects(); diff --git a/substrate/core/consensus/slots/Cargo.toml b/substrate/core/consensus/slots/Cargo.toml index 7a3b487dc6..b82c2fc9d7 100644 --- a/substrate/core/consensus/slots/Cargo.toml +++ b/substrate/core/consensus/slots/Cargo.toml @@ -13,7 +13,7 @@ runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } consensus_common = { package = "substrate-consensus-common", path = "../common" } inherents = { package = "substrate-inherents", path = "../../inherents" } futures = "0.1.17" -tokio = "0.1.7" +tokio-timer = "0.2.11" parking_lot = "0.8.0" log = "0.4" diff --git a/substrate/core/consensus/slots/src/lib.rs b/substrate/core/consensus/slots/src/lib.rs index aee398a9ce..18ec2451be 100644 --- a/substrate/core/consensus/slots/src/lib.rs +++ b/substrate/core/consensus/slots/src/lib.rs @@ -41,8 +41,6 @@ use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{ApiRef, Block, ProvideRuntimeApi}; use std::fmt::Debug; use std::ops::Deref; -use std::sync::mpsc; -use std::thread; /// A worker that should be invoked at every new slot. pub trait SlotWorker { @@ -66,58 +64,6 @@ pub trait SlotCompatible { ) -> Result<(u64, u64), consensus_common::Error>; } -/// Start a new slot worker in a separate thread. -#[deprecated(since = "1.1", note = "Please spawn a thread manually")] -pub fn start_slot_worker_thread( - slot_duration: SlotDuration, - select_chain: C, - worker: W, - sync_oracle: SO, - on_exit: OnExit, - inherent_data_providers: InherentDataProviders, -) -> Result<(), consensus_common::Error> -where - B: Block + 'static, - C: SelectChain + Clone + 'static, - W: SlotWorker + Send + Sync + 'static, - SO: SyncOracle + Send + Clone + 'static, - SC: SlotCompatible + 'static, - OnExit: Future + Send + 'static, - T: SlotData + Send + Clone + 'static, -{ - use tokio::runtime::current_thread::Runtime; - - let (result_sender, result_recv) = mpsc::channel(); - - thread::spawn(move || { - let mut runtime = match Runtime::new() { - Ok(r) => r, - Err(e) => { - warn!(target: "slots", "Unable to start authorship: {:?}", e); - return; - } - }; - - let slot_worker_future = start_slot_worker::<_, _, _, T, _, SC>( - slot_duration.clone(), - select_chain, - worker, - sync_oracle, - inherent_data_providers, - ); - - result_sender - .send(Ok(())) - .expect("Receive is not dropped before receiving a result; qed"); - - let _ = runtime.block_on(slot_worker_future.select(on_exit).map(|_| ())); - }); - - result_recv - .recv() - .expect("Slots start thread result sender dropped") -} - /// Start a new slot worker. /// /// Every time a new slot is triggered, `worker.on_slot` is called and the future it returns is diff --git a/substrate/core/consensus/slots/src/slots.rs b/substrate/core/consensus/slots/src/slots.rs index 964eeaff29..a848a96762 100644 --- a/substrate/core/consensus/slots/src/slots.rs +++ b/substrate/core/consensus/slots/src/slots.rs @@ -26,7 +26,7 @@ use inherents::{InherentData, InherentDataProviders}; use log::warn; use std::marker::PhantomData; use std::time::{Duration, Instant}; -use tokio::timer::Delay; +use tokio_timer::Delay; /// Returns current duration since unix epoch. pub fn duration_now() -> Option { diff --git a/substrate/core/test-runtime/wasm/Cargo.lock b/substrate/core/test-runtime/wasm/Cargo.lock index be1e3ab84f..19c6b36ebc 100644 --- a/substrate/core/test-runtime/wasm/Cargo.lock +++ b/substrate/core/test-runtime/wasm/Cargo.lock @@ -2561,7 +2561,7 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "tokio 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]]