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

rewrite network code to use notifications_protocol APIs from Substrate #788

Merged
merged 25 commits into from
Feb 10, 2020

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Jan 22, 2020

This API is much better for interfacing with the rest of the validation pipeline, which is futures-based.

I skipped implementing PoVBlock requests, because the idea is to do that by gossip after #742 is in.

Old network code has been placed in the legacy submodule. It will be removed in a follow-up that plugs in the new network code in place of the old.

@rphmeier rphmeier added the A3-in_progress Pull request is in progress. No review needed at this stage. label Jan 22, 2020
@gavofyork gavofyork added the B0-silent Changes should not be mentioned in any release notes label Feb 4, 2020
@rphmeier rphmeier added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Feb 5, 2020
@rphmeier rphmeier marked this pull request as ready for review February 5, 2020 16:00
Comment on lines +703 to +705
.filter_map(|msg| match msg.0 {
crate::legacy::gossip::GossipMessage::Statement(s) => future::ready(Some(s.signed_statement)),
_ => future::ready(None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably making this async and removing future::ready would be a bit more tidier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue I ran into when trying this suggestion is that the async move {} block isn't Unpin, which select requires. So we have to pin_mut!(checked_messages).


// import all statements pending on this candidate
let (mut statements, _traces) = if let GenericStatement::Candidate(_) = statement.statement {
deferred_statements.take_deferred(&c_hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe .take_deferred(&c_hash).0 and remove the unused _traces variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I find this (pattern matching rather than field access) to be more idiomatic Rust.

}

impl ParachainNetwork for Service {
type Error = future::Either<mpsc::SendError, oneshot::Canceled>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: probably instead of Either RouterError could be used? It seems to include the variants of this Either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so, although the Either formulation is more minimal.

Copy link
Contributor

@montekki montekki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rphmeier rphmeier merged commit 0742653 into master Feb 10, 2020
@rphmeier rphmeier deleted the rh-notifications-protocol branch February 10, 2020 14:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants