-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Upgrade tokio to 1.22.0 and replace async-std with tokio #12646
Upgrade tokio to 1.22.0 and replace async-std with tokio #12646
Conversation
Doesn't work yet, because the tests rely on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM but I have two questions:
- is there a reason why
async_std::spawn
in tests is not converted totokio::spawn
? - the example code in
rust-libp2p
repository instructs to configure executor for the swarm in tokio chat example. Should we configure the default executor similarly in caseparams.executor
isNone
inservice.rs
?
I'm paranoid about the second bullet because I burned two weeks debugging bizarre async execution issues after having configured libp2p incorrectly.
Nice! 👍 We should completely nuke |
…d-libp2p-primitives
Interestingly, the PR libp2p/rust-libp2p#3097 has just landed in libp2p that makes the specification of executor explicit during the construction of I'm going to change the API of CC @altonen |
I suspect that I have converted some |
libp2p 0.50 was released last week. here is the PR that updates substrate: #12734 let me know if you want me to change executors to tokio. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
use sc_block_builder::BlockBuilderProvider; | ||
use sc_client_api::BlockBackend; | ||
|
||
sp_tracing::try_init_simple(); | ||
|
||
let mut net = BeefyTestNet::new(2); | ||
let runtime = Runtime::new().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dummy question: can't we just use #[tokio::test]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can. I think, historically some tests were synchronous and later converted to async ones with manual runtime instantiation, and I just repeated the mistake and did the same in other places. Probably this doesn't make sense, so I'm going to convert all these tests to #[tokio::test]
in a follow-up PR.
@@ -87,7 +93,7 @@ fn notifications_state_consistent() { | |||
); | |||
} | |||
|
|||
async_std::task::block_on(async move { | |||
runtime.block_on(async move { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope we can get rid of all these block_on
calls in the future in some follow-up PR
bot merge |
…12646) * Replace deprecated libp2p feature specs with correct ones * Bump tokio to 1.21.2 * Replace async-std libp2p primitives with tokio ones * minor: rustfmt * Fix TestNet to run initialization in the tokio context * Convert telemetry test from async-std to tokio * Convert notifications tests from async-std to tokio * Convert chain sync tests from async-std to tokio * Ditch async-std completely * Make executor mandatory * Bump tokio to 1.22.0 * minor: rustfmt * Explicitly use tokio runtime in tests * Move more tests to explicit tokio runtime * Explicitly set multithreaded runtime in tokio test * minor: rustfmt * minor: fix comment * Replace async-std with tokio in MMR tests
…12646) * Replace deprecated libp2p feature specs with correct ones * Bump tokio to 1.21.2 * Replace async-std libp2p primitives with tokio ones * minor: rustfmt * Fix TestNet to run initialization in the tokio context * Convert telemetry test from async-std to tokio * Convert notifications tests from async-std to tokio * Convert chain sync tests from async-std to tokio * Ditch async-std completely * Make executor mandatory * Bump tokio to 1.22.0 * minor: rustfmt * Explicitly use tokio runtime in tests * Move more tests to explicit tokio runtime * Explicitly set multithreaded runtime in tokio test * minor: rustfmt * minor: fix comment * Replace async-std with tokio in MMR tests
Resolves #12499.
polkadot companion: paritytech/polkadot#6262
cumulus companion: paritytech/cumulus#1917