From ccdab42887b956b0f5ba9d1db82a9fa6fafc46d3 Mon Sep 17 00:00:00 2001 From: Ashley Date: Sat, 30 Nov 2019 17:34:45 +0100 Subject: [PATCH 1/7] updated exit-future (github repo) --- Cargo.lock | 10 +++++----- .../finality-grandpa/src/communication/mod.rs | 17 ++++++++++++++--- client/finality-grandpa/src/lib.rs | 8 +++++--- client/finality-grandpa/src/observer.rs | 6 ++++-- client/service/Cargo.toml | 2 +- client/service/src/builder.rs | 16 ++++++++-------- client/service/src/lib.rs | 11 +++++++---- 7 files changed, 44 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff709c1a3fa8e..85aae463cc0af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1097,10 +1097,10 @@ dependencies = [ [[package]] name = "exit-future" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.0" +source = "git+https://github.com/expenses/exit-future?branch=modernize#e56d51d0ea98d07bc0c8e724fbe164f5da2faeab" dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6418,7 +6418,7 @@ name = "substrate-service" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "grafana-data-source 2.0.0", @@ -8043,7 +8043,7 @@ dependencies = [ "checksum evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bcde5af3d542874ddeb53de0919302d57586ea04b3f76f54d865f8a6cdc70ae" "checksum evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b82bc9f275cb59d2bcc05d85c98736ddfaba003a7ef7b73893fa7c1c1fab29dc" "checksum evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbc89d29618c3722c17ba78ddf432d40ace8ee27e3f8b28b52a85921112e4b" -"checksum exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d8013f441e38e31c670e7f34ec8f1d5d3a2bd9d303c1ff83976ca886005e8f48" +"checksum exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)" = "" "checksum faerie 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f902f2af041f6c7177a2a04f805687cdc71e69c7cbef059a2755d8923f4cd7a8" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs index 247f9efd2df18..8130f888cacfc 100644 --- a/client/finality-grandpa/src/communication/mod.rs +++ b/client/finality-grandpa/src/communication/mod.rs @@ -287,7 +287,7 @@ impl> NetworkBridge { service: N, config: crate::Config, set_state: crate::environment::SharedVoterSetState, - on_exit: impl Future + Clone + Send + 'static, + on_exit: impl futures03::Future + Clone + Send + Unpin + 'static, ) -> ( Self, impl Future + Send + 'static, @@ -348,9 +348,20 @@ impl> NetworkBridge { // lazily spawn these jobs onto their own tasks. the lazy future has access // to tokio globals, which aren't available outside. let mut executor = tokio_executor::DefaultExecutor::current(); - executor.spawn(Box::new(rebroadcast_job.select(on_exit.clone()).then(|_| Ok(())))) + + use futures03::{FutureExt, TryFutureExt}; + + let rebroadcast_job = rebroadcast_job + .select(on_exit.clone().map(Ok).compat()) + .then(|_| Ok(())); + + let reporting_job = reporting_job + .select(on_exit.clone().map(Ok).compat()) + .then(|_| Ok(())); + + executor.spawn(Box::new(rebroadcast_job)) .expect("failed to spawn grandpa rebroadcast job task"); - executor.spawn(Box::new(reporting_job.select(on_exit.clone()).then(|_| Ok(())))) + executor.spawn(Box::new(reporting_job)) .expect("failed to spawn grandpa reporting job task"); Ok(()) }); diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 2b83488d5990b..c922dcc4504e3 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -555,7 +555,7 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( NumberFor: BlockNumberOps, DigestFor: Encode, RA: Send + Sync + 'static, - X: Future + Clone + Send + 'static, + X: futures03::Future + Clone + Send + Unpin + 'static, { let GrandpaParams { config, @@ -634,7 +634,9 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( let telemetry_task = telemetry_task .then(|_| futures::future::empty::<(), ()>()); - Ok(voter_work.select(on_exit).select2(telemetry_task).then(|_| Ok(()))) + use futures03::{FutureExt, TryFutureExt}; + + Ok(voter_work.select(on_exit.map(Ok).compat()).select2(telemetry_task).then(|_| Ok(()))) } /// Future that powers the voter. @@ -889,7 +891,7 @@ pub fn run_grandpa, N, RA, SC, VR, X>( DigestFor: Encode, RA: Send + Sync + 'static, VR: VotingRule> + Clone + 'static, - X: Future + Clone + Send + 'static, + X: futures03::Future + Clone + Send + Unpin + 'static, { run_grandpa_voter(grandpa_params) } diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index 83c2fac275ba6..44f514fe0bf7d 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -155,7 +155,7 @@ pub fn run_grandpa_observer, N, RA, SC>( config: Config, link: LinkHalf, network: N, - on_exit: impl Future + Clone + Send + 'static, + on_exit: impl futures03::Future + Clone + Send + Unpin + 'static, ) -> ::sp_blockchain::Result + Send + 'static> where B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, @@ -195,7 +195,9 @@ pub fn run_grandpa_observer, N, RA, SC>( let observer_work = network_startup.and_then(move |()| observer_work); - Ok(observer_work.select(on_exit).map(|_| ()).map_err(|_| ())) + use futures03::{FutureExt, TryFutureExt}; + + Ok(observer_work.select(on_exit.map(Ok).compat()).map(|_| ()).map_err(|_| ())) } /// Future that powers the observer. diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index bf9491add3949..325df631fc9c3 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.8" slog = { version = "2.5.2", features = ["nested-values"] } tokio-executor = "0.1.8" tokio-timer = "0.2.11" -exit-future = "0.1.4" +exit-future = { git = "https://github.com/expenses/exit-future", branch = "modernize" } serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 2f6774833744c..92069dcc40511 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -28,7 +28,7 @@ use chain_spec::{RuntimeGenesis, Extension}; use consensus_common::import_queue::ImportQueue; use futures::{prelude::*, sync::mpsc}; use futures03::{ - compat::{Compat, Future01CompatExt}, + compat::Compat, FutureExt as _, TryFutureExt as _, StreamExt as _, TryStreamExt as _, future::{select, Either} @@ -880,7 +880,7 @@ ServiceBuilder< Ok(()) }) - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(events)); } @@ -902,7 +902,7 @@ ServiceBuilder< ); Ok(()) }) - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(events)); @@ -967,7 +967,7 @@ ServiceBuilder< ); Ok(()) - }).select(exit.clone()).then(|_| Ok(())); + }).select(exit.clone().map(Ok).compat()).then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(tel_task)); // Periodically send the network state to the telemetry. @@ -980,7 +980,7 @@ ServiceBuilder< "state" => network_state, ); Ok(()) - }).select(exit.clone()).then(|_| Ok(())); + }).select(exit.clone().map(Ok).compat()).then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(tel_task_2)); // RPC @@ -1054,7 +1054,7 @@ ServiceBuilder< dht_event_tx, ) .map_err(|_| ()) - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())))); let telemetry_connection_sinks: Arc>>> = Default::default(); @@ -1099,7 +1099,7 @@ ServiceBuilder< Ok(()) }); let _ = to_spawn_tx.unbounded_send(Box::new(future - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())))); telemetry }); @@ -1108,7 +1108,7 @@ ServiceBuilder< if let Some(port) = config.grafana_port { let future = select( grafana_data_source::run_server(port).boxed(), - exit.clone().compat() + exit.clone() ).map(|either| match either { Either::Left((result, _)) => result.map_err(|_| ()), Either::Right(_) => Ok(()) diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 2115fd50a7167..35ed81b63144c 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -120,7 +120,8 @@ impl Executor + Send>> for SpawnTaskHandle &self, future: Box + Send>, ) -> Result<(), futures::future::ExecuteError + Send>>> { - let future = Box::new(future.select(self.on_exit.clone()).then(|_| Ok(()))); + let exit = self.on_exit.clone().map(Ok).compat(); + let future = Box::new(future.select(exit).then(|_| Ok(()))); if let Err(err) = self.sender.unbounded_send(future) { let kind = futures::future::ExecuteErrorKind::Shutdown; Err(futures::future::ExecuteError::new(kind, err.into_inner())) @@ -236,7 +237,8 @@ where } fn spawn_task(&self, task: impl Future + Send + 'static) { - let task = task.select(self.on_exit()).then(|_| Ok(())); + let exit = self.on_exit().map(Ok).compat(); + let task = task.select(exit).then(|_| Ok(())); let _ = self.to_spawn_tx.unbounded_send(Box::new(task)); } @@ -249,7 +251,8 @@ where let _ = essential_failed.send(()); Ok(()) }); - let task = essential_task.select(self.on_exit()).then(|_| Ok(())); + let exit = self.on_exit().map(Ok::<_, ()>).compat(); + let task = essential_task.select(exit).then(|_| Ok(())); let _ = self.to_spawn_tx.unbounded_send(Box::new(task)); } @@ -503,7 +506,7 @@ impl Drop for fn drop(&mut self) { debug!(target: "service", "Substrate service shutdown"); if let Some(signal) = self.signal.take() { - signal.fire(); + let _ = signal.fire(); } } } From dc9782865fd99ee0a6b24272d566f4dd4319a892 Mon Sep 17 00:00:00 2001 From: Ashley Date: Sat, 30 Nov 2019 20:42:53 +0100 Subject: [PATCH 2/7] Switch to broadcast crate --- Cargo.lock | 21 ++++++++++++++++++--- client/service/Cargo.toml | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85aae463cc0af..53bb7797d4979 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -359,6 +359,19 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "broadcaster" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bs58" version = "0.3.0" @@ -1098,8 +1111,9 @@ dependencies = [ [[package]] name = "exit-future" version = "0.2.0" -source = "git+https://github.com/expenses/exit-future?branch=modernize#e56d51d0ea98d07bc0c8e724fbe164f5da2faeab" +source = "git+https://github.com/expenses/exit-future?branch=broadcast#91714a1f03ef62362ac0aefd1df6f46e17a41463" dependencies = [ + "broadcaster 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6418,7 +6432,7 @@ name = "substrate-service" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)", + "exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=broadcast)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "grafana-data-source 2.0.0", @@ -7963,6 +7977,7 @@ dependencies = [ "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum broadcaster 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "07a1446420a56f1030271649ba0da46d23239b3a68c73591cea5247f15a788a0" +"checksum broadcaster 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dad5c90ca2c2414701f979c92a776c15341f8194d2881ca58274905638f8b873" "checksum bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" "checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" "checksum build-helper 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" @@ -8043,7 +8058,7 @@ dependencies = [ "checksum evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bcde5af3d542874ddeb53de0919302d57586ea04b3f76f54d865f8a6cdc70ae" "checksum evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b82bc9f275cb59d2bcc05d85c98736ddfaba003a7ef7b73893fa7c1c1fab29dc" "checksum evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbc89d29618c3722c17ba78ddf432d40ace8ee27e3f8b28b52a85921112e4b" -"checksum exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)" = "" +"checksum exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=broadcast)" = "" "checksum faerie 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f902f2af041f6c7177a2a04f805687cdc71e69c7cbef059a2755d8923f4cd7a8" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 325df631fc9c3..89691f0bdcefc 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.8" slog = { version = "2.5.2", features = ["nested-values"] } tokio-executor = "0.1.8" tokio-timer = "0.2.11" -exit-future = { git = "https://github.com/expenses/exit-future", branch = "modernize" } +exit-future = { git = "https://github.com/expenses/exit-future", branch = "broadcast" } serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" From c18f4321c29b021af053170b6ac3dd62bfe04d14 Mon Sep 17 00:00:00 2001 From: Ashley Date: Sun, 1 Dec 2019 14:59:17 +0100 Subject: [PATCH 3/7] Migrate client/cli --- Cargo.lock | 28 +++++++++++++--------- client/cli/Cargo.toml | 7 +++--- client/cli/src/lib.rs | 55 ++++++++++++++++++++++++------------------- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 53bb7797d4979..a73e5c02cada1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,6 +431,11 @@ dependencies = [ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bytes" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "c2-chacha" version = "0.2.3" @@ -1570,14 +1575,6 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "futures01" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "fxhash" version = "0.2.1" @@ -5623,7 +5620,6 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5644,7 +5640,7 @@ dependencies = [ "substrate-tracing 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6919,6 +6915,15 @@ dependencies = [ "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-buf" version = "0.1.1" @@ -7987,6 +7992,7 @@ dependencies = [ "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +"checksum bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c85319f157e4e26c703678e68e26ab71a46c0199286fa670b21cc9fec13d895" "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" "checksum cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d" @@ -8095,7 +8101,6 @@ dependencies = [ "checksum futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" -"checksum futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "7ef8cbbf52909170053540c6c05a62433ddb60662dabee714e2a882caa864f22" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" @@ -8399,6 +8404,7 @@ dependencies = [ "checksum tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2953ca5148619bc99695c1274cb54c5275bbb913c6adad87e72eaf8db9787f69" "checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20" "checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +"checksum tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e765bf9f550bd9b8a970633ca3b56b8120c4b6c5dcbe26a93744cb02fee4b17" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" "checksum tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9f5d22fd1e84bd4045d28813491cb7d7caae34d45c80517c2213f09a85e8787a" diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 976242d24dae6..e2d4fafcaa848 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -16,9 +16,8 @@ time = "0.1.42" ansi_term = "0.12.1" lazy_static = "1.4.0" app_dirs = "1.2.1" -tokio = "0.1.22" +tokio = "0.2.1" futures = { version = "0.3.1", features = ["compat"] } -futures01 = "0.1.29" fdlimit = "0.1.1" serde_json = "1.0.41" panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } @@ -33,9 +32,11 @@ substrate-telemetry = { path = "../telemetry" } keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } names = "0.11.0" structopt = "0.3.3" -rpassword = "4.0.1" substrate-tracing = { package = "substrate-tracing", path = "../tracing" } +[target.'cfg(not(target_os = "unknown"))'.dependencies] +rpassword = "4.0.1" + [dev-dependencies] tempfile = "3.1.0" diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 4d8b9830c89a6..26ee7a8862151 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -43,7 +43,7 @@ use primitives::H256; use std::{ io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fs::{self, File}, - net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr, + net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr, pin::Pin, task::Poll }; use names::{Generator, Name}; @@ -61,8 +61,7 @@ pub use traits::{GetLogFilter, AugmentClap}; use app_dirs::{AppInfo, AppDataType}; use log::info; use lazy_static::lazy_static; -use futures::{Future, FutureExt, TryFutureExt}; -use futures01::{Async, Future as _}; +use futures::{Future, compat::Future01CompatExt, executor::block_on}; use substrate_telemetry::TelemetryEndpoints; use sr_primitives::generic::BlockId; use sr_primitives::traits::Block as BlockT; @@ -396,23 +395,23 @@ impl<'a> ParseAndPrepareExport<'a> { // Note: while we would like the user to handle the exit themselves, we handle it here // for backwards compatibility reasons. let (exit_send, exit_recv) = std::sync::mpsc::channel(); - let exit = exit.into_exit() - .map(|_| Ok::<_, ()>(())) - .compat(); + let exit = exit.into_exit(); std::thread::spawn(move || { - let _ = exit.wait(); + block_on(exit); let _ = exit_send.send(()); }); - let mut export_fut = builder(config)?.export_blocks(file, from.into(), to.map(Into::into), json); - let fut = futures01::future::poll_fn(|| { + let mut export_fut = builder(config)? + .export_blocks(file, from.into(), to.map(Into::into), json) + .compat(); + let fut = futures::future::poll_fn(|cx| { if exit_recv.try_recv().is_ok() { - return Ok(Async::Ready(())); + return Poll::Ready(Ok(())); } - export_fut.poll() + Pin::new(&mut export_fut).poll(cx) }); - let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + let mut runtime = tokio::runtime::Runtime::new().unwrap(); runtime.block_on(fut)?; Ok(()) } @@ -455,23 +454,23 @@ impl<'a> ParseAndPrepareImport<'a> { // Note: while we would like the user to handle the exit themselves, we handle it here // for backwards compatibility reasons. let (exit_send, exit_recv) = std::sync::mpsc::channel(); - let exit = exit.into_exit() - .map(|_| Ok::<_, ()>(())) - .compat(); + let exit = exit.into_exit(); std::thread::spawn(move || { - let _ = exit.wait(); + block_on(exit); let _ = exit_send.send(()); }); - let mut import_fut = builder(config)?.import_blocks(file, false); - let fut = futures01::future::poll_fn(|| { + let mut import_fut = builder(config)? + .import_blocks(file, false) + .compat(); + let fut = futures::future::poll_fn(|cx| { if exit_recv.try_recv().is_ok() { - return Ok(Async::Ready(())); + return Poll::Ready(Ok(())); } - import_fut.poll() + Pin::new(&mut import_fut).poll(cx) }); - let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + let mut runtime = tokio::runtime::Runtime::new().unwrap(); runtime.block_on(fut)?; Ok(()) } @@ -513,8 +512,10 @@ impl<'a> CheckBlock<'a> { }; let start = std::time::Instant::now(); - let check = builder(config)?.check_block(block_id); - let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + let check = builder(config)? + .check_block(block_id) + .compat(); + let mut runtime = tokio::runtime::Runtime::new().unwrap(); runtime.block_on(check)?; println!("Completed in {} ms.", start.elapsed().as_millis()); Ok(()) @@ -717,6 +718,7 @@ fn fill_network_configuration( Ok(()) } +#[cfg(not(target_os = "unknown"))] fn input_keystore_password() -> Result { rpassword::read_password_from_tty(Some("Keystore password: ")) .map_err(|e| format!("{:?}", e)) @@ -728,7 +730,12 @@ fn fill_config_keystore_password( cli: &RunCmd, ) -> Result<(), String> { config.keystore_password = if cli.password_interactive { - Some(input_keystore_password()?.into()) + #[cfg(not(target_os = "unknown"))] + { + Some(input_keystore_password()?.into()) + } + #[cfg(target_os = "unknown")] + None } else if let Some(ref file) = cli.password_filename { Some(fs::read_to_string(file).map_err(|e| format!("{}", e))?.into()) } else if let Some(ref password) = cli.password { From 03237f43d54ae3e32b5e53c7fb99976dc13dd6fd Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 4 Dec 2019 12:27:10 +0100 Subject: [PATCH 4/7] Switch exit-future to modernize branch --- Cargo.lock | 23 +++-------------------- client/service/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28335485a1645..1ff7ead0e781b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -359,19 +359,6 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "broadcaster" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bs58" version = "0.3.0" @@ -1116,11 +1103,9 @@ dependencies = [ [[package]] name = "exit-future" version = "0.2.0" -source = "git+https://github.com/expenses/exit-future?branch=broadcast#91714a1f03ef62362ac0aefd1df6f46e17a41463" +source = "git+https://github.com/expenses/exit-future?branch=modernize#05b07ca0b9d3a0ee14dc146ccf4079ee1c1bee91" dependencies = [ - "broadcaster 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2720,7 +2705,6 @@ name = "lock_api" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5462,7 +5446,7 @@ name = "sc-service" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=broadcast)", + "exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "grafana-data-source 2.0.0", @@ -7987,7 +7971,6 @@ dependencies = [ "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum broadcaster 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "07a1446420a56f1030271649ba0da46d23239b3a68c73591cea5247f15a788a0" -"checksum broadcaster 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dad5c90ca2c2414701f979c92a776c15341f8194d2881ca58274905638f8b873" "checksum bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" "checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" "checksum build-helper 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" @@ -8069,7 +8052,7 @@ dependencies = [ "checksum evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bcde5af3d542874ddeb53de0919302d57586ea04b3f76f54d865f8a6cdc70ae" "checksum evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b82bc9f275cb59d2bcc05d85c98736ddfaba003a7ef7b73893fa7c1c1fab29dc" "checksum evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbc89d29618c3722c17ba78ddf432d40ace8ee27e3f8b28b52a85921112e4b" -"checksum exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=broadcast)" = "" +"checksum exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)" = "" "checksum faerie 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f902f2af041f6c7177a2a04f805687cdc71e69c7cbef059a2755d8923f4cd7a8" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 63ead31efb12e..518127d937258 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.8" slog = { version = "2.5.2", features = ["nested-values"] } tokio-executor = "0.1.8" tokio-timer = "0.2.11" -exit-future = { git = "https://github.com/expenses/exit-future", branch = "broadcast" } +exit-future = { git = "https://github.com/expenses/exit-future", branch = "modernize" } serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" From a488106805d220cb4aee9e46a71481424c6d87d5 Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 4 Dec 2019 13:54:07 +0100 Subject: [PATCH 5/7] Small changes --- client/cli/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 70beedc4273d4..74104beef470b 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -61,7 +61,7 @@ pub use traits::{GetLogFilter, AugmentClap}; use app_dirs::{AppInfo, AppDataType}; use log::info; use lazy_static::lazy_static; -use futures::{Future, compat::Future01CompatExt, executor::block_on}; +use futures::{Future, compat::Future01CompatExt}; use sc_telemetry::TelemetryEndpoints; use sp_runtime::generic::BlockId; use sp_runtime::traits::Block as BlockT; @@ -397,7 +397,7 @@ impl<'a> ParseAndPrepareExport<'a> { let (exit_send, exit_recv) = std::sync::mpsc::channel(); let exit = exit.into_exit(); std::thread::spawn(move || { - block_on(exit); + exit.wait(); let _ = exit_send.send(()); }); @@ -456,7 +456,7 @@ impl<'a> ParseAndPrepareImport<'a> { let (exit_send, exit_recv) = std::sync::mpsc::channel(); let exit = exit.into_exit(); std::thread::spawn(move || { - block_on(exit); + exit.wait(); let _ = exit_send.send(()); }); From 6579d12e4bc529ba1a4bc56d6bd828379932a42e Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 4 Dec 2019 14:04:53 +0100 Subject: [PATCH 6/7] Switch to cargo version and fix fg tests --- Cargo.lock | 6 +++--- client/finality-grandpa/src/communication/tests.rs | 11 +++++------ client/finality-grandpa/src/tests.rs | 10 +++++----- client/service/Cargo.toml | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ff7ead0e781b..ba45de4d2961f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1103,7 +1103,7 @@ dependencies = [ [[package]] name = "exit-future" version = "0.2.0" -source = "git+https://github.com/expenses/exit-future?branch=modernize#05b07ca0b9d3a0ee14dc146ccf4079ee1c1bee91" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5446,7 +5446,7 @@ name = "sc-service" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)", + "exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "grafana-data-source 2.0.0", @@ -8052,7 +8052,7 @@ dependencies = [ "checksum evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bcde5af3d542874ddeb53de0919302d57586ea04b3f76f54d865f8a6cdc70ae" "checksum evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b82bc9f275cb59d2bcc05d85c98736ddfaba003a7ef7b73893fa7c1c1fab29dc" "checksum evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbc89d29618c3722c17ba78ddf432d40ace8ee27e3f8b28b52a85921112e4b" -"checksum exit-future 0.2.0 (git+https://github.com/expenses/exit-future?branch=modernize)" = "" +"checksum exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" "checksum faerie 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f902f2af041f6c7177a2a04f805687cdc71e69c7cbef059a2755d8923f4cd7a8" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index b36f8ad3e635f..f2a2276a476cd 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -26,7 +26,7 @@ use std::sync::Arc; use keyring::Ed25519Keyring; use codec::Encode; use sp_runtime::traits::NumberFor; - +use std::{pin::Pin, task::{Context, Poll}}; use crate::environment::SharedVoterSetState; use fg_primitives::AuthorityList; use super::gossip::{self, GossipValidator}; @@ -175,12 +175,11 @@ fn make_test_network() -> ( #[derive(Clone)] struct Exit; - impl Future for Exit { - type Item = (); - type Error = (); + impl futures03::Future for Exit { + type Output = (); - fn poll(&mut self) -> Poll<(), ()> { - Ok(Async::NotReady) + fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<()> { + Poll::Pending } } diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index 256c211e8bcb5..d9010bd02b490 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -39,6 +39,7 @@ use sp_runtime::generic::{BlockId, DigestItem}; use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public}; use fg_primitives::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi}; use state_machine::{backend::InMemory, prove_read, read_proof_check}; +use std::{pin::Pin, task}; use authorities::AuthoritySet; use finality_proof::{FinalityProofProvider, AuthoritySetForFinalityProver, AuthoritySetForFinalityChecker}; @@ -175,12 +176,11 @@ impl TestNetFactory for GrandpaTestNet { #[derive(Clone)] struct Exit; -impl Future for Exit { - type Item = (); - type Error = (); +impl futures03::Future for Exit { + type Output = (); - fn poll(&mut self) -> Poll<(), ()> { - Ok(Async::NotReady) + fn poll(self: Pin<&mut Self>, _: &mut task::Context) -> task::Poll<()> { + task::Poll::Pending } } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 518127d937258..bbdc15f094a5a 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.8" slog = { version = "2.5.2", features = ["nested-values"] } tokio-executor = "0.1.8" tokio-timer = "0.2.11" -exit-future = { git = "https://github.com/expenses/exit-future", branch = "modernize" } +exit-future = "0.2.0" serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" From 9958c46e0aa223bfa1af1000b385772d94f6f1a0 Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 4 Dec 2019 14:13:35 +0100 Subject: [PATCH 7/7] Revert "Small changes" This reverts commit a488106805d220cb4aee9e46a71481424c6d87d5. --- client/cli/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 74104beef470b..70beedc4273d4 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -61,7 +61,7 @@ pub use traits::{GetLogFilter, AugmentClap}; use app_dirs::{AppInfo, AppDataType}; use log::info; use lazy_static::lazy_static; -use futures::{Future, compat::Future01CompatExt}; +use futures::{Future, compat::Future01CompatExt, executor::block_on}; use sc_telemetry::TelemetryEndpoints; use sp_runtime::generic::BlockId; use sp_runtime::traits::Block as BlockT; @@ -397,7 +397,7 @@ impl<'a> ParseAndPrepareExport<'a> { let (exit_send, exit_recv) = std::sync::mpsc::channel(); let exit = exit.into_exit(); std::thread::spawn(move || { - exit.wait(); + block_on(exit); let _ = exit_send.send(()); }); @@ -456,7 +456,7 @@ impl<'a> ParseAndPrepareImport<'a> { let (exit_send, exit_recv) = std::sync::mpsc::channel(); let exit = exit.into_exit(); std::thread::spawn(move || { - exit.wait(); + block_on(exit); let _ = exit_send.send(()); });