diff --git a/Cargo.lock b/Cargo.lock index 5f039f2d12f7..8419bd1c0942 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3308,6 +3308,8 @@ dependencies = [ "futures-timer 3.0.2", "kv-log-macro", "log 0.4.8", + "polkadot-primitives", + "polkadot-statement-table", "streamunordered", ] diff --git a/overseer/Cargo.toml b/overseer/Cargo.toml index bcd0a8e9e529..d04fbe4ad81b 100644 --- a/overseer/Cargo.toml +++ b/overseer/Cargo.toml @@ -9,6 +9,8 @@ futures = "0.3.5" log = "0.4.8" futures-timer = "3.0.2" streamunordered = "0.5.1" +polkadot-primitives = { path = "../primitives" } +polkadot-statement-table = { path = "../statement-table" } [dev-dependencies] futures = { version = "0.3.5", features = ["thread-pool"] } diff --git a/overseer/src/lib.rs b/overseer/src/lib.rs index f7ac6cac5079..6ecab6d5c31a 100644 --- a/overseer/src/lib.rs +++ b/overseer/src/lib.rs @@ -69,6 +69,8 @@ use futures::{ }; use futures_timer::Delay; use streamunordered::{StreamYield, StreamUnordered}; +use polkadot_primitives::Hash; +use polkadot_statement_table::SignedStatement; /// An error type that describes faults that may happen /// @@ -225,9 +227,9 @@ pub struct SubsystemContext{ #[derive(Debug)] pub enum OverseerSignal { /// `Subsystem` should start working. - StartWork, + StartWork(Hash), /// `Subsystem` should stop working. - StopWork, + StopWork(Hash), /// Conclude the work of the `Overseer` and all `Subsystem`s. Conclude, } @@ -249,6 +251,16 @@ pub enum CandidateBackingSubsystemMessage { Second, } + +#[derive(Debug)] +/// A message type used by the StatementGossip [`Subsystem`]. +/// +/// [`Subsystem`]: trait.Subsystem.html +pub enum StatementGossipSubsystemMessage { + ToGossip { relay_parent: Hash, statement: SignedStatement }, + Received { relay_parent: Hash, statement: SignedStatement } +} + /// A message type tying together all message types that are used across [`Subsystem`]s. /// /// [`Subsystem`]: trait.Subsystem.html @@ -256,6 +268,7 @@ pub enum CandidateBackingSubsystemMessage { pub enum AllMessages { Validation(ValidationSubsystemMessage), CandidateBacking(CandidateBackingSubsystemMessage), + StatementGossip(StatementGossipSubsystemMessage) } /// A message type that a [`Subsystem`] receives from the [`Overseer`]. @@ -355,6 +368,9 @@ pub struct Overseer { /// A candidate backing subsystem candidate_backing_subsystem: OverseenSubsystem, + /// A statement gossip subsystem + statement_gossip_subsystem: OverseenSubsystem, + /// Spawner to spawn tasks to. s: S, @@ -473,6 +489,7 @@ where pub fn new( validation: Box + Send>, candidate_backing: Box + Send>, + statement_gossip: Box + Send>, mut s: S, ) -> SubsystemResult<(Self, OverseerHandler)> { let (events_tx, events_rx) = mpsc::channel(CHANNEL_CAPACITY); @@ -498,9 +515,17 @@ where candidate_backing, )?; + let statement_gossip_subsystem = spawn( + &mut s, + &mut running_subsystems, + &mut running_subsystems_rx, + statement_gossip, + )?; + let this = Self { validation_subsystem, candidate_backing_subsystem, + statement_gossip_subsystem, s, running_subsystems, running_subsystems_rx, @@ -588,6 +613,11 @@ where let _ = s.tx.send(FromOverseer::Communication { msg }).await; } } + AllMessages::StatementGossip(msg) => { + if let Some(ref mut s) = self.statement_gossip_subsystem.instance { + let _ = s.tx.send(FromOverseer::Communication { msg }).await; + } + } } }