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

client/network-gossip: Merge GossipEngine and GossipEngineInner #5042

Merged
merged 3 commits into from
Mar 9, 2020

Conversation

mxinden
Copy link
Contributor

@mxinden mxinden commented Feb 25, 2020

This pull request contains two commits, the latter supporting the former.

  1. client/network-gossip: Merge GossipEngine and GossipEngineInner

    Given that GossipEngine and GossipEngineInner are not shared between threads
    anyone (see client/network-gossip: Integrate GossipEngine tasks into Future impl #4767), neither depend
    on being Send or Sync. Thus one can merge the two as done in this patch. One
    only needs to wrap an Arc<Mutex<>> around the whole structure when the owner
    (e.g. finality-grandpa) needs to share the gossip engine between threads.

  2. client/finality-grandpa: Wrap GossipEngine in Arc Mutex & lock it on use

    GossipEngine in itself has no need to be Send and Sync, given that it
    does not rely on separately spawned background tasks anymore. Given that
    finality-grandpa shares the NetworkBridge potentially between threads
    its components need to be clonable, thus this patch wraps GossipEngine
    in an Arc<Mutex<>>.

This would require changes within Polkadot which I have not yet prepared, therefore please don't merge this pull request just yet.

Given that GossipEngine and GossipEngineInner are not shared between
threads anyone (public interface + background tasks), neither depends on
being Send or Sync. Thus one can merge the two as done in this patch.
One only needs to wrap an `Arc<Mutex<>>` around the whole structure when
the owner (e.g. finality-grandpa) needs to share the gossip engine
between threads.
GossipEngine in itself has no need to be Send and Sync, given that it
does not rely on separately spawned background tasks anymore. Given that
finality-grandpa shares the `NetworkBridge` potentially between threads
its components need to be clonable, thus this patch wraps `GossipEngine`
in an `Arc<Mutex<>>`.
@mxinden mxinden added the A0-please_review Pull request needs code review. label Feb 25, 2020
@mxinden mxinden requested a review from Demi-Marie as a code owner February 25, 2020 09:33
@@ -14,7 +14,6 @@ futures-timer = "3.0.1"
libp2p = { version = "0.16.1", default-features = false, features = ["libp2p-websocket"] }
log = "0.4.8"
lru = "0.1.2"
parking_lot = "0.10.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line probably summarizes the pull request the best.

@tomaka
Copy link
Contributor

tomaka commented Feb 25, 2020

Considering that each gossip protocol should have its own exclusive instance of GossipEngine, it looks good to me.

@tomaka
Copy link
Contributor

tomaka commented Feb 25, 2020

I didn't mark the PR as approved because of:

This would require changes within Polkadot which I have not yet prepared, therefore please don't merge this pull request just yet.

But consider it approval.

@tomaka
Copy link
Contributor

tomaka commented Feb 27, 2020

This is technically an API breaking change, no? So we can't do it during the stabilization period.

@mxinden
Copy link
Contributor Author

mxinden commented Feb 27, 2020

This is technically an API breaking change, no? So we can't do it during the stabilization period.

@tomaka yes, I am guessing so, given that GossipEngine is part of the public API and still Send but not Sync anymore after this patch.

@gnunicorn what is the right procedure here? Should I be adding the pull request to the 3.0 milestone?

@gnunicorn
Copy link
Contributor

if it can be raised during alpha-phase, we can consider still merging this before 2.0 – I consider not-too-involved API-clean-up PRs as "fixes". but it should have the corresponding polkadot PR pending. API changes will only be restricted once we reach beta-phase.

@mxinden
Copy link
Contributor Author

mxinden commented Mar 9, 2020

Corresponding Polkadot pull request: paritytech/polkadot#890

@gnunicorn as far as I can tell we have not yet reached the beta phase. Could you reconsider merging this?

@gnunicorn
Copy link
Contributor

sure, just follow the process lined out to get PRs merged during the freeze.

@gnunicorn gnunicorn added A8-looksgood and removed A0-please_review Pull request needs code review. labels Mar 9, 2020
@gnunicorn gnunicorn added this to the 2.0 milestone Mar 9, 2020
@andresilva
Copy link
Contributor

I thought we had not stabilized the consensus related parts, isn't it why this crate is at verison 0.8 rather than 2.0?

@mxinden
Copy link
Contributor Author

mxinden commented Mar 9, 2020

sure, just follow the process lined out to get PRs merged during the freeze.

@gnunicorn thanks a bunch for the help and writing all of this down. I also added B1-apinoteworthy given that it changes the public facing Substrate API.

@gnunicorn gnunicorn merged commit 78cdd3b into paritytech:master Mar 9, 2020
General-Beck pushed a commit to General-Beck/substrate that referenced this pull request Mar 12, 2020
…tytech#5042)

* client/network-gossip: Merge GossipEngine and GossipEngineInner

Given that GossipEngine and GossipEngineInner are not shared between
threads anyone (public interface + background tasks), neither depends on
being Send or Sync. Thus one can merge the two as done in this patch.
One only needs to wrap an `Arc<Mutex<>>` around the whole structure when
the owner (e.g. finality-grandpa) needs to share the gossip engine
between threads.

* client/finality-grandpa: Wrap GossipEngine in Arc Mutex & lock it on use

GossipEngine in itself has no need to be Send and Sync, given that it
does not rely on separately spawned background tasks anymore. Given that
finality-grandpa shares the `NetworkBridge` potentially between threads
its components need to be clonable, thus this patch wraps `GossipEngine`
in an `Arc<Mutex<>>`.
General-Beck pushed a commit to General-Beck/substrate that referenced this pull request Mar 17, 2020
…tytech#5042)

* client/network-gossip: Merge GossipEngine and GossipEngineInner

Given that GossipEngine and GossipEngineInner are not shared between
threads anyone (public interface + background tasks), neither depends on
being Send or Sync. Thus one can merge the two as done in this patch.
One only needs to wrap an `Arc<Mutex<>>` around the whole structure when
the owner (e.g. finality-grandpa) needs to share the gossip engine
between threads.

* client/finality-grandpa: Wrap GossipEngine in Arc Mutex & lock it on use

GossipEngine in itself has no need to be Send and Sync, given that it
does not rely on separately spawned background tasks anymore. Given that
finality-grandpa shares the `NetworkBridge` potentially between threads
its components need to be clonable, thus this patch wraps `GossipEngine`
in an `Arc<Mutex<>>`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants