mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 12:31:03 +00:00
Network bridge refactoring impl (#1537)
* update networking types * port over overseer-protocol message types * Add the collation protocol to network bridge * message sending * stub for ConnectToValidators * add some helper traits and methods to protocol types * add collator protocol message * leaves-updating * peer connection and disconnection * add utilities for dispatching multiple events * implement message handling * add an observedrole enum with equality and no sentry nodes * derive partial-eq on network bridge event * add PartialEq impls for network message types * add Into implementation for observedrole * port over existing network bridge tests * add some more tests * port bitfield distribution * port over bitfield distribution tests * add codec indices * port PoV distribution * port over PoV distribution tests * port over statement distribution * port over statement distribution tests * update overseer and service-new * address review comments * port availability distribution * port over availability distribution tests
This commit is contained in:
committed by
GitHub
parent
8e60a5197f
commit
a6b1d91d6e
@@ -78,7 +78,7 @@ use polkadot_subsystem::messages::{
|
||||
CandidateValidationMessage, CandidateBackingMessage,
|
||||
CandidateSelectionMessage, ChainApiMessage, StatementDistributionMessage,
|
||||
AvailabilityDistributionMessage, BitfieldSigningMessage, BitfieldDistributionMessage,
|
||||
ProvisionerMessage, PoVDistributionMessage, RuntimeApiMessage,
|
||||
ProvisionerMessage, PoVDistributionMessage, RuntimeApiMessage, CollatorProtocolMessage,
|
||||
AvailabilityStoreMessage, NetworkBridgeMessage, AllMessages,
|
||||
};
|
||||
pub use polkadot_subsystem::{
|
||||
@@ -333,6 +333,9 @@ pub struct Overseer<S: SpawnNamed> {
|
||||
/// A candidate selection subsystem.
|
||||
candidate_selection_subsystem: OverseenSubsystem<CandidateSelectionMessage>,
|
||||
|
||||
/// A collator protocol subsystem
|
||||
collator_protocol_subsystem: OverseenSubsystem<CollatorProtocolMessage>,
|
||||
|
||||
/// A statement distribution subsystem.
|
||||
statement_distribution_subsystem: OverseenSubsystem<StatementDistributionMessage>,
|
||||
|
||||
@@ -395,13 +398,15 @@ pub struct Overseer<S: SpawnNamed> {
|
||||
///
|
||||
/// [`Subsystem`]: trait.Subsystem.html
|
||||
/// [`DummySubsystem`]: struct.DummySubsystem.html
|
||||
pub struct AllSubsystems<CV, CB, CS, SD, AD, BS, BD, P, PoVD, RA, AS, NB, CA> {
|
||||
pub struct AllSubsystems<CV, CB, CS, CP, SD, AD, BS, BD, P, PoVD, RA, AS, NB, CA> {
|
||||
/// A candidate validation subsystem.
|
||||
pub candidate_validation: CV,
|
||||
/// A candidate backing subsystem.
|
||||
pub candidate_backing: CB,
|
||||
/// A candidate selection subsystem.
|
||||
pub candidate_selection: CS,
|
||||
/// A collator protocol subsystem.
|
||||
pub collator_protocol: CP,
|
||||
/// A statement distribution subsystem.
|
||||
pub statement_distribution: SD,
|
||||
/// An availability distribution subsystem.
|
||||
@@ -494,6 +499,7 @@ where
|
||||
/// candidate_validation: ValidationSubsystem,
|
||||
/// candidate_backing: DummySubsystem,
|
||||
/// candidate_selection: DummySubsystem,
|
||||
/// collator_protocol: DummySubsystem,
|
||||
/// statement_distribution: DummySubsystem,
|
||||
/// availability_distribution: DummySubsystem,
|
||||
/// bitfield_signing: DummySubsystem,
|
||||
@@ -524,15 +530,16 @@ where
|
||||
/// #
|
||||
/// # }); }
|
||||
/// ```
|
||||
pub fn new<CV, CB, CS, SD, AD, BS, BD, P, PoVD, RA, AS, NB, CA>(
|
||||
pub fn new<CV, CB, CS, CP, SD, AD, BS, BD, P, PoVD, RA, AS, NB, CA>(
|
||||
leaves: impl IntoIterator<Item = BlockInfo>,
|
||||
all_subsystems: AllSubsystems<CV, CB, CS, SD, AD, BS, BD, P, PoVD, RA, AS, NB, CA>,
|
||||
all_subsystems: AllSubsystems<CV, CB, CS, CP, SD, AD, BS, BD, P, PoVD, RA, AS, NB, CA>,
|
||||
mut s: S,
|
||||
) -> SubsystemResult<(Self, OverseerHandler)>
|
||||
where
|
||||
CV: Subsystem<OverseerSubsystemContext<CandidateValidationMessage>> + Send,
|
||||
CB: Subsystem<OverseerSubsystemContext<CandidateBackingMessage>> + Send,
|
||||
CS: Subsystem<OverseerSubsystemContext<CandidateSelectionMessage>> + Send,
|
||||
CP: Subsystem<OverseerSubsystemContext<CollatorProtocolMessage>> + Send,
|
||||
SD: Subsystem<OverseerSubsystemContext<StatementDistributionMessage>> + Send,
|
||||
AD: Subsystem<OverseerSubsystemContext<AvailabilityDistributionMessage>> + Send,
|
||||
BS: Subsystem<OverseerSubsystemContext<BitfieldSigningMessage>> + Send,
|
||||
@@ -574,6 +581,13 @@ where
|
||||
all_subsystems.candidate_selection,
|
||||
)?;
|
||||
|
||||
let collator_protocol_subsystem = spawn(
|
||||
&mut s,
|
||||
&mut running_subsystems,
|
||||
&mut running_subsystems_rx,
|
||||
all_subsystems.collator_protocol,
|
||||
)?;
|
||||
|
||||
let statement_distribution_subsystem = spawn(
|
||||
&mut s,
|
||||
&mut running_subsystems,
|
||||
@@ -655,6 +669,7 @@ where
|
||||
candidate_validation_subsystem,
|
||||
candidate_backing_subsystem,
|
||||
candidate_selection_subsystem,
|
||||
collator_protocol_subsystem,
|
||||
statement_distribution_subsystem,
|
||||
availability_distribution_subsystem,
|
||||
bitfield_signing_subsystem,
|
||||
@@ -690,6 +705,10 @@ where
|
||||
let _ = s.tx.send(FromOverseer::Signal(OverseerSignal::Conclude)).await;
|
||||
}
|
||||
|
||||
if let Some(ref mut s) = self.collator_protocol_subsystem.instance {
|
||||
let _ = s.tx.send(FromOverseer::Signal(OverseerSignal::Conclude)).await;
|
||||
}
|
||||
|
||||
if let Some(ref mut s) = self.statement_distribution_subsystem.instance {
|
||||
let _ = s.tx.send(FromOverseer::Signal(OverseerSignal::Conclude)).await;
|
||||
}
|
||||
@@ -844,6 +863,10 @@ where
|
||||
s.tx.send(FromOverseer::Signal(signal.clone())).await?;
|
||||
}
|
||||
|
||||
if let Some(ref mut s) = self.collator_protocol_subsystem.instance {
|
||||
s.tx.send(FromOverseer::Signal(signal.clone())).await?;
|
||||
}
|
||||
|
||||
if let Some(ref mut s) = self.statement_distribution_subsystem.instance {
|
||||
s.tx.send(FromOverseer::Signal(signal.clone())).await?;
|
||||
}
|
||||
@@ -900,6 +923,11 @@ where
|
||||
let _ = s.tx.send(FromOverseer::Communication { msg }).await;
|
||||
}
|
||||
}
|
||||
AllMessages::CollatorProtocol(msg) => {
|
||||
if let Some(ref mut s) = self.collator_protocol_subsystem.instance {
|
||||
let _ = s.tx.send(FromOverseer::Communication { msg }).await;
|
||||
}
|
||||
}
|
||||
AllMessages::StatementDistribution(msg) => {
|
||||
if let Some(ref mut s) = self.statement_distribution_subsystem.instance {
|
||||
let _ = s.tx.send(FromOverseer::Communication { msg }).await;
|
||||
@@ -1102,6 +1130,7 @@ mod tests {
|
||||
candidate_validation: TestSubsystem1(s1_tx),
|
||||
candidate_backing: TestSubsystem2(s2_tx),
|
||||
candidate_selection: DummySubsystem,
|
||||
collator_protocol: DummySubsystem,
|
||||
statement_distribution: DummySubsystem,
|
||||
availability_distribution: DummySubsystem,
|
||||
bitfield_signing: DummySubsystem,
|
||||
@@ -1166,6 +1195,7 @@ mod tests {
|
||||
candidate_validation: TestSubsystem1(s1_tx),
|
||||
candidate_backing: TestSubsystem4,
|
||||
candidate_selection: DummySubsystem,
|
||||
collator_protocol: DummySubsystem,
|
||||
statement_distribution: DummySubsystem,
|
||||
availability_distribution: DummySubsystem,
|
||||
bitfield_signing: DummySubsystem,
|
||||
@@ -1283,6 +1313,7 @@ mod tests {
|
||||
candidate_validation: TestSubsystem5(tx_5),
|
||||
candidate_backing: TestSubsystem6(tx_6),
|
||||
candidate_selection: DummySubsystem,
|
||||
collator_protocol: DummySubsystem,
|
||||
statement_distribution: DummySubsystem,
|
||||
availability_distribution: DummySubsystem,
|
||||
bitfield_signing: DummySubsystem,
|
||||
@@ -1385,6 +1416,7 @@ mod tests {
|
||||
candidate_validation: TestSubsystem5(tx_5),
|
||||
candidate_backing: TestSubsystem6(tx_6),
|
||||
candidate_selection: DummySubsystem,
|
||||
collator_protocol: DummySubsystem,
|
||||
statement_distribution: DummySubsystem,
|
||||
availability_distribution: DummySubsystem,
|
||||
bitfield_signing: DummySubsystem,
|
||||
|
||||
Reference in New Issue
Block a user