Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Upgrade tokio to 1.22.0 and replace async-std with tokio #12646

Merged
merged 22 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7b8d8c5
Replace deprecated libp2p feature specs with correct ones
dmitry-markin Nov 8, 2022
ad2fd7e
Bump tokio to 1.21.2
dmitry-markin Nov 8, 2022
9e7398c
Replace async-std libp2p primitives with tokio ones
dmitry-markin Nov 8, 2022
20eaa28
minor: rustfmt
dmitry-markin Nov 8, 2022
6c2028f
Merge remote-tracking branch 'origin/master' into dm-upgrade-tokio-an…
dmitry-markin Nov 10, 2022
1a1539a
Fix TestNet to run initialization in the tokio context
dmitry-markin Nov 15, 2022
3140fa8
Convert telemetry test from async-std to tokio
dmitry-markin Nov 15, 2022
e73c6fe
Convert notifications tests from async-std to tokio
dmitry-markin Nov 15, 2022
064c7fa
Convert chain sync tests from async-std to tokio
dmitry-markin Nov 15, 2022
398d10c
Ditch async-std completely
dmitry-markin Nov 15, 2022
fe95866
Merge remote-tracking branch 'origin/master' into dm-upgrade-tokio-an…
dmitry-markin Nov 24, 2022
bee686d
Make executor mandatory
dmitry-markin Nov 24, 2022
449de4f
Bump tokio to 1.22.0
dmitry-markin Nov 24, 2022
0b2d272
minor: rustfmt
dmitry-markin Nov 25, 2022
4cdde07
Explicitly use tokio runtime in tests
dmitry-markin Nov 25, 2022
bbb75f6
Move more tests to explicit tokio runtime
dmitry-markin Nov 27, 2022
b6f4713
Explicitly set multithreaded runtime in tokio test
dmitry-markin Nov 27, 2022
a51414d
minor: rustfmt
dmitry-markin Nov 27, 2022
3f7e116
Merge remote-tracking branch 'origin/master' into dm-upgrade-tokio-an…
dmitry-markin Nov 27, 2022
8ce510c
minor: fix comment
dmitry-markin Nov 29, 2022
8184a9a
Merge remote-tracking branch 'origin/master' into dm-upgrade-tokio-an…
dmitry-markin Dec 3, 2022
3e53487
Replace async-std with tokio in MMR tests
dmitry-markin Dec 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 14 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ nix = "0.23"
serde_json = "1.0"
regex = "1.6.0"
platforms = "2.0"
async-std = { version = "1.11.0", features = ["attributes"] }
soketto = "0.7.1"
criterion = { version = "0.3.5", features = ["async_tokio"] }
tokio = { version = "1.17.0", features = ["macros", "time", "parking_lot"] }
tokio = { version = "1.21.2", features = ["macros", "time", "parking_lot"] }
tokio-util = { version = "0.7.4", features = ["compat"] }
wait-timeout = "0.2"
substrate-rpc-client = { path = "../../../utils/frame/rpc/client" }
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
Expand Down
6 changes: 3 additions & 3 deletions bin/node/cli/tests/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::process;
pub mod common;
pub mod websocket_server;

#[async_std::test]
#[tokio::test]
async fn telemetry_works() {
let config = websocket_server::Config {
capacity: 1,
Expand All @@ -38,7 +38,7 @@ async fn telemetry_works() {

let addr = server.local_addr().unwrap();

let server_task = async_std::task::spawn(async move {
let server_task = tokio::spawn(async move {
loop {
use websocket_server::Event;
match server.next_event().await {
Expand Down Expand Up @@ -78,7 +78,7 @@ async fn telemetry_works() {
.spawn()
.unwrap();

server_task.await;
server_task.await.expect("server task panicked");

assert!(substrate.try_wait().unwrap().is_none(), "the process should still be running");

Expand Down
7 changes: 4 additions & 3 deletions bin/node/cli/tests/websocket_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use async_std::net::{TcpListener, TcpStream};
use tokio::net::{TcpListener, TcpStream};
use tokio_util::compat::{Compat, TokioAsyncReadCompatExt};
dmitry-markin marked this conversation as resolved.
Show resolved Hide resolved
use core::pin::Pin;
use futures::prelude::*;
use soketto::handshake::{server::Response, Server};
Expand Down Expand Up @@ -71,7 +72,7 @@ pub struct WsServer {
negotiating: stream::FuturesUnordered<
Pin<
Box<
dyn Future<Output = Result<Server<'static, TcpStream>, Box<dyn std::error::Error>>>
dyn Future<Output = Result<Server<'static, Compat<TcpStream>>, Box<dyn std::error::Error>>>
+ Send,
>,
>,
Expand Down Expand Up @@ -120,7 +121,7 @@ impl WsServer {
let pending_incoming = self.pending_incoming.take().expect("no pending socket");

self.negotiating.push(Box::pin(async move {
let mut server = Server::new(pending_incoming);
let mut server = Server::new(pending_incoming.compat());

let websocket_key = match server.receive_request().await {
Ok(req) => req.key(),
Expand Down
2 changes: 1 addition & 1 deletion client/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" }
serde = "1.0.136"
strum = { version = "0.24.1", features = ["derive"] }
tempfile = "3.1.0"
tokio = "1.17.0"
tokio = "1.21.2"
sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" }
sc-network-test = { version = "0.8.0", path = "../network/test" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../primitives/finality-grandpa" }
Expand Down
2 changes: 1 addition & 1 deletion client/beefy/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ sc-rpc = { version = "4.0.0-dev", features = [
"test-helpers",
], path = "../../rpc" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
tokio = { version = "1.17.0", features = ["macros"] }
tokio = { version = "1.21.2", features = ["macros"] }
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ serde = "1.0.136"
serde_json = "1.0.85"
thiserror = "1.0.30"
tiny-bip39 = "0.8.2"
tokio = { version = "1.17.0", features = ["signal", "rt-multi-thread", "parking_lot"] }
tokio = { version = "1.21.2", features = ["signal", "rt-multi-thread", "parking_lot"] }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-client-db = { version = "0.10.0-dev", default-features = false, path = "../db" }
sc-keystore = { version = "4.0.0-dev", path = "../keystore" }
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/babe/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sp-runtime = { version = "6.0.0", path = "../../../../primitives/runtime" }
[dev-dependencies]
serde_json = "1.0.85"
tempfile = "3.1.0"
tokio = "1.17.0"
tokio = "1.21.2"
sc-consensus = { version = "0.10.0-dev", path = "../../../consensus/common" }
sc-keystore = { version = "4.0.0-dev", path = "../../../keystore" }
sp-keyring = { version = "6.0.0", path = "../../../../primitives/keyring" }
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/manual-seal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" }
sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" }

[dev-dependencies]
tokio = { version = "1.17.0", features = ["rt-multi-thread", "macros"] }
tokio = { version = "1.21.2", features = ["rt-multi-thread", "macros"] }
sc-basic-authorship = { version = "0.10.0-dev", path = "../../basic-authorship" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
substrate-test-runtime-transaction-pool = { version = "2.0.0", path = "../../../test-utils/runtime/transaction-pool" }
2 changes: 1 addition & 1 deletion client/finality-grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" }
assert_matches = "1.3.0"
finality-grandpa = { version = "0.16.0", features = ["derive-codec", "test-helpers"] }
serde = "1.0.136"
tokio = "1.17.0"
tokio = "1.21.2"
sc-network = { version = "0.10.0-dev", path = "../network" }
sc-network-test = { version = "0.8.0", path = "../network/test" }
sp-keyring = { version = "6.0.0", path = "../../primitives/keyring" }
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ sp-core = { version = "6.0.0", path = "../../../primitives/core" }
sp-finality-grandpa = { version = "4.0.0-dev", path = "../../../primitives/finality-grandpa" }
sp-keyring = { version = "6.0.0", path = "../../../primitives/keyring" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
tokio = { version = "1.17.0", features = ["macros"] }
tokio = { version = "1.21.2", features = ["macros"] }
4 changes: 3 additions & 1 deletion client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fnv = "1.0.6"
futures = "0.3.21"
futures-timer = "3.0.2"
ip_network = "0.4.1"
libp2p = { version = "0.49.0", features = ["async-std", "dns", "identify", "kad", "mdns-async-io", "mplex", "noise", "ping", "tcp", "yamux", "websocket"] }
libp2p = { version = "0.49.0", features = ["dns", "identify", "kad", "mdns", "mplex", "noise", "ping", "tcp", "tokio", "yamux", "websocket"] }
linked_hash_set = "0.1.3"
linked-hash-map = "0.5.4"
log = "0.4.17"
Expand Down Expand Up @@ -60,6 +60,8 @@ assert_matches = "1.3"
async-std = { version = "1.11.0", features = ["attributes"] }
rand = "0.7.2"
tempfile = "3.1.0"
tokio = { version = "1.21.2", features = ["macros"] }
tokio-util = { version = "0.7.4", features = ["compat"] }
sc-network-light = { version = "0.10.0-dev", path = "./light" }
sc-network-sync = { version = "0.10.0-dev", path = "./sync" }
sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" }
Expand Down
2 changes: 1 addition & 1 deletion client/network/bitswap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain"
sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" }

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
tokio = { version = "1.21.2", features = ["full"] }
sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" }
sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
sp-core = { version = "6.0.0", path = "../../../primitives/core" }
Expand Down
6 changes: 3 additions & 3 deletions client/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use libp2p::{
GetClosestPeersError, Kademlia, KademliaBucketInserts, KademliaConfig, KademliaEvent,
QueryId, QueryResult, Quorum, Record,
},
mdns::{Mdns, MdnsConfig, MdnsEvent},
mdns::{MdnsConfig, MdnsEvent, TokioMdns},
multiaddr::Protocol,
swarm::{
behaviour::toggle::{Toggle, ToggleIntoConnectionHandler},
Expand Down Expand Up @@ -235,7 +235,7 @@ impl DiscoveryConfig {
allow_private_ipv4,
discovery_only_if_under_num,
mdns: if enable_mdns {
match Mdns::new(MdnsConfig::default()) {
match TokioMdns::new(MdnsConfig::default()) {
Ok(mdns) => Some(mdns),
Err(err) => {
warn!(target: "sub-libp2p", "Failed to initialize mDNS: {:?}", err);
Expand Down Expand Up @@ -266,7 +266,7 @@ pub struct DiscoveryBehaviour {
/// it's always enabled in `NetworkWorker::new()`.
kademlia: Toggle<Kademlia<MemoryStore>>,
/// Discovers nodes on the local network.
mdns: Option<Mdns>,
mdns: Option<TokioMdns>,
/// Stream that fires when we need to perform the next random Kademlia query. `None` if
/// random walking is disabled.
next_kad_random_query: Option<Delay>,
Expand Down
Loading