split NetworkBridge into two subsystems (#5616)

* foo

* rolling session window

* fixup

* remove use statemetn

* fmt

* split NetworkBridge into two subsystems

Pending cleanup

* split

* chore: reexport OrchestraError as OverseerError

* chore: silence warnings

* fixup tests

* chore: add default timenout of 30s to subsystem test helper ctx handle

* single item channel

* fixins

* fmt

* cleanup

* remove dead code

* remove sync bounds again

* wire up shared state

* deal with some FIXMEs

* use distinct tags

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>

* use tag

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>

* address naming

tx and rx are common in networking and also have an implicit meaning regarding networking
compared to incoming and outgoing which are already used with subsystems themselvesq

* remove unused sync oracle

* remove unneeded state

* fix tests

* chore: fmt

* do not try to register twice

* leak Metrics type

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
Bernhard Schuster
2022-07-12 18:22:36 +02:00
committed by GitHub
parent c11c1f38f4
commit 3240cb5e4d
40 changed files with 1880 additions and 1429 deletions
+30 -22
View File
@@ -318,9 +318,36 @@ pub enum DisputeDistributionMessage {
SendDispute(DisputeMessage),
}
/// Messages received by the network bridge subsystem.
/// Messages received from other subsystems.
#[derive(Debug)]
pub enum NetworkBridgeMessage {
pub enum NetworkBridgeRxMessage {
/// Inform the distribution subsystems about the new
/// gossip network topology formed.
///
/// The only reason to have this here, is the availability of the
/// authority discovery service, otherwise, the `GossipSupport`
/// subsystem would make more sense.
NewGossipTopology {
/// The session info this gossip topology is concerned with.
session: SessionIndex,
/// Ids of our neighbors in the X dimensions of the new gossip topology,
/// along with their validator indices within the session.
///
/// We're not necessarily connected to all of them, but we should
/// try to be.
our_neighbors_x: HashMap<AuthorityDiscoveryId, ValidatorIndex>,
/// Ids of our neighbors in the X dimensions of the new gossip topology,
/// along with their validator indices within the session.
///
/// We're not necessarily connected to all of them, but we should
/// try to be.
our_neighbors_y: HashMap<AuthorityDiscoveryId, ValidatorIndex>,
},
}
/// Messages received from other subsystems by the network bridge subsystem.
#[derive(Debug)]
pub enum NetworkBridgeTxMessage {
/// Report a peer for their actions.
ReportPeer(PeerId, UnifiedReputationChange),
@@ -375,27 +402,9 @@ pub enum NetworkBridgeMessage {
/// The peer set we want the connection on.
peer_set: PeerSet,
},
/// Inform the distribution subsystems about the new
/// gossip network topology formed.
NewGossipTopology {
/// The session info this gossip topology is concerned with.
session: SessionIndex,
/// Ids of our neighbors in the X dimensions of the new gossip topology,
/// along with their validator indices within the session.
///
/// We're not necessarily connected to all of them, but we should
/// try to be.
our_neighbors_x: HashMap<AuthorityDiscoveryId, ValidatorIndex>,
/// Ids of our neighbors in the X dimensions of the new gossip topology,
/// along with their validator indices within the session.
///
/// We're not necessarily connected to all of them, but we should
/// try to be.
our_neighbors_y: HashMap<AuthorityDiscoveryId, ValidatorIndex>,
},
}
impl NetworkBridgeMessage {
impl NetworkBridgeTxMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
match self {
@@ -408,7 +417,6 @@ impl NetworkBridgeMessage {
Self::ConnectToValidators { .. } => None,
Self::ConnectToResolvedValidators { .. } => None,
Self::SendRequests { .. } => None,
Self::NewGossipTopology { .. } => None,
}
}
}