From 59c05dba3e9b74bb85f2a0233472430be2cf6947 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Mon, 16 Nov 2020 15:55:21 +0100 Subject: [PATCH] Upgrade Tokio to version 0.3 --- modules/Cargo.toml | 2 +- relayer-cli/Cargo.toml | 3 +-- relayer-cli/src/application.rs | 8 ++------ relayer-cli/src/commands/listen.rs | 9 +++++---- relayer-cli/src/commands/start.rs | 9 +++++---- relayer/Cargo.toml | 2 +- relayer/src/util/block_on.rs | 3 +-- 7 files changed, 16 insertions(+), 20 deletions(-) diff --git a/modules/Cargo.toml b/modules/Cargo.toml index e25f3a7b48..0012aa6ee6 100644 --- a/modules/Cargo.toml +++ b/modules/Cargo.toml @@ -46,5 +46,5 @@ version = "0.17.0-rc2" version = "0.17.0-rc2" [dev-dependencies] -tokio = { version = "0.2", features = ["macros"] } +tokio = { version = "0.3", features = ["macros"] } subtle-encoding = { version = "0.5" } diff --git a/relayer-cli/Cargo.toml b/relayer-cli/Cargo.toml index 546b8e981a..874299ffb3 100644 --- a/relayer-cli/Cargo.toml +++ b/relayer-cli/Cargo.toml @@ -9,12 +9,11 @@ authors = [ [dependencies] relayer = { path = "../relayer" } ibc = { path = "../modules" } -abscissa_tokio = "0.5.1" anomaly = "0.2.0" gumdrop = "0.7" serde = { version = "1", features = ["serde_derive"] } thiserror = "1" -tokio = { version = "0.2.13", features = ["rt-util", "sync"] } +tokio = { version = "0.3", features = ["rt", "rt-multi-thread", "time", "stream", "sync"] } tracing = "0.1.13" tracing-subscriber = "0.2.3" futures = "0.3.5" diff --git a/relayer-cli/src/application.rs b/relayer-cli/src/application.rs index 9d7ff6ac43..814434f270 100644 --- a/relayer-cli/src/application.rs +++ b/relayer-cli/src/application.rs @@ -82,11 +82,7 @@ impl Application for CliApp { /// beyond the default ones provided by the framework, this is the place /// to do so. fn register_components(&mut self, command: &Self::Cmd) -> Result<(), FrameworkError> { - use abscissa_tokio::TokioComponent; - - let mut components = self.framework_components(command)?; - components.push(Box::new(TokioComponent::new()?)); - + let components = self.framework_components(command)?; self.state.components.register(components) } @@ -110,4 +106,4 @@ impl Application for CliApp { trace::Config::default() } } -} +} \ No newline at end of file diff --git a/relayer-cli/src/commands/listen.rs b/relayer-cli/src/commands/listen.rs index e9b668e987..857daf630c 100644 --- a/relayer-cli/src/commands/listen.rs +++ b/relayer-cli/src/commands/listen.rs @@ -4,7 +4,7 @@ use abscissa_core::{ application::fatal_error, error::BoxError, tracing::debug, Command, Options, Runnable, }; -use crate::{application::APPLICATION, prelude::*, tasks::event_listener}; +use crate::{prelude::*, tasks::event_listener}; #[derive(Command, Debug, Options)] pub struct ListenCmd {} @@ -20,11 +20,12 @@ impl ListenCmd { impl Runnable for ListenCmd { fn run(&self) { - abscissa_tokio::run(&APPLICATION, async move { + let rt = tokio::runtime::Runtime::new().unwrap(); + + rt.block_on(async move { self.cmd() .await .unwrap_or_else(|e| fatal_error(app_reader().deref(), &*e)); - }) - .unwrap(); + }); } } diff --git a/relayer-cli/src/commands/start.rs b/relayer-cli/src/commands/start.rs index 2d65f50bc4..75f2417998 100644 --- a/relayer-cli/src/commands/start.rs +++ b/relayer-cli/src/commands/start.rs @@ -6,7 +6,7 @@ use abscissa_core::{ use relayer::{chain::CosmosSDKChain, config::Config}; -use crate::{application::APPLICATION, prelude::*, tasks}; +use crate::{prelude::*, tasks}; #[derive(Command, Debug, Options)] pub struct StartCmd { @@ -23,12 +23,13 @@ impl StartCmd { impl Runnable for StartCmd { fn run(&self) { - abscissa_tokio::run(&APPLICATION, async move { + let rt = tokio::runtime::Runtime::new().unwrap(); + + rt.block_on(async move { self.cmd() .await .unwrap_or_else(|e| fatal_error(app_reader().deref(), &*e)); - }) - .unwrap(); + }); } } diff --git a/relayer/Cargo.toml b/relayer/Cargo.toml index 71475cfa94..4ae954062d 100644 --- a/relayer/Cargo.toml +++ b/relayer/Cargo.toml @@ -19,7 +19,7 @@ sled = { version = "0.34.4", features = ["no_metrics", "no_logs"] } thiserror = "1.0.11" toml = "0.5" tracing = "0.1.13" -tokio = "0.2" +tokio = "0.3" serde_json = { version = "1" } bytes = "0.6.0" prost = "0.6.1" diff --git a/relayer/src/util/block_on.rs b/relayer/src/util/block_on.rs index aed8c9f98e..93459ece34 100644 --- a/relayer/src/util/block_on.rs +++ b/relayer/src/util/block_on.rs @@ -4,8 +4,7 @@ use futures::Future; /// Spawns a new tokio runtime and use it to block on the given future. pub fn block_on(future: F) -> F::Output { - tokio::runtime::Builder::new() - .basic_scheduler() + tokio::runtime::Builder::new_current_thread() .enable_all() .build() .unwrap()