-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Switch GrandPa to new futures #3909
Conversation
|
I naively forgot to fix the tests, but fixing the tests is quite complicated because the network (used in tests) still uses futures 0.1. Still needs a bit of work. |
I suggest migrating network to new futures first, but that part would also be kind of painful |
We can't actually migrate the network, as it's waiting for libp2p. We could, however, use the compatibility layer to make it look like the network has migrated. However there's a chicken-and-egg problem. If we upgrade the network first, then the GrandPa tests will also fail to compile, as GrandPa would still use old futures. |
How about upgrading the network to 0.3 futures and compat it as 0.1? |
|
This code is surprisingly tricky to upgrade: https://github.com/paritytech/substrate/blob/master/core/finality-grandpa/src/communication/mod.rs#L352-L361 One way to do this could be to use We might wait until 7th of November (stabilization of async/await) to finish this PR. |
Demi-Marie
left a comment
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.
LGTM but I will wait on someone else to make the final call here.
| .compat() | ||
| ); | ||
| let inner_rx: Pin<Box<dyn Stream<Item = _> + Send>> = | ||
| Box::pin(gossip.messages_for(GRANDPA_ENGINE_ID, topic).map(Result::Ok)); |
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.
| Box::pin(gossip.messages_for(GRANDPA_ENGINE_ID, topic).map(Result::Ok)); | |
| Box::pin(gossip.messages_for(GRANDPA_ENGINE_ID, topic).map(Ok)); |
core/finality-grandpa/Cargo.toml
Outdated
| futures = "0.1.29" | ||
| futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] } | ||
| futures01 = { package = "futures", version = "0.1.29" } | ||
| futures-preview = { version = "0.3.0-alpha.19", features = ["compat"] } |
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.
Futures 0.3 has been released
| TestBlockSyncRequester::default(), | ||
| block_status, | ||
| global_rx.map_err(|_| panic!("should never error")), | ||
| global_rx.map_err(|()| panic!("should never error")), |
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.
This needs a better justification. If there is no possible error, we should use a void type here. It is possible to implement a void type without an ICE.
* Switch GrandPa to new futures * Work on making tests work * until_imported tests working again * Work on switching tests to stable futures * Modifications * Re-add test as #[ignore] * Don't ignore * Add manual unpins * Remove Header import * Return concrete Sink type * Switch to crates.io finality-grandpa version * Remove use statement that slipped in * Fix some nitpicks * Remove unpin from i * Fixed typo * Move futures01 to dev-deps * Fix nitpicks * Update client/finality-grandpa/src/communication/mod.rs Co-Authored-By: André Silva <[email protected]> * nitpicking Co-authored-by: Pierre Krieger <[email protected]> Co-authored-by: André Silva <[email protected]>
Transitions the code of
substrate-finality-grandpato Futures from the Rust standard library.cc #3099
A few notes:
telemetry_connection_sinksinsubstrate-serviceto futures 0.3, but couldn't do the same foron_exitbecause there's this weird against-the-design-of-futures cloning capability. This will need to be done separately later after some brainstorming.H256type for block hashes incommunication/mod.rs, otherwise the compiler wouldn't be able to infer it. This is probably related to the fact that the items of the newSinktrait are now a regular generic parameter, rather than an associated type. TheH256block hash type is already hardcoded in GrandPa, so this is not a huge deal.Service.Pre-requirement before merging: publish a new version of the
finality-grandpacrate, and update theCargo.tomlof this PR.