diff --git a/node/collation-generation/src/lib.rs b/node/collation-generation/src/lib.rs index 5c70f85eaeea..15173d1e0857 100644 --- a/node/collation-generation/src/lib.rs +++ b/node/collation-generation/src/lib.rs @@ -256,10 +256,12 @@ async fn handle_new_activations( }, }; - if config.collator.is_collating(relay_parent, &validation_data).await { + if let Some(forecast) = + config.collator.is_collating(relay_parent, &validation_data).await + { let _ = ctx .send_message(AllMessages::CollatorProtocol( - CollatorProtocolMessage::PreConnectAsCollator(relay_parent), + CollatorProtocolMessage::ForecastCollation(relay_parent, forecast), )) .await; gum::debug!( diff --git a/node/collation-generation/src/tests.rs b/node/collation-generation/src/tests.rs index 7703370c3762..9df8e292dc1a 100644 --- a/node/collation-generation/src/tests.rs +++ b/node/collation-generation/src/tests.rs @@ -19,7 +19,7 @@ mod handle_new_activations { use ::test_helpers::{dummy_hash, dummy_head_data, dummy_validator}; use futures::lock::Mutex; use polkadot_node_primitives::{ - BlockData, Collation, CollationResult, Collator, MaybeCompressedPoV, PoV, + BlockData, Collation, CollationForecast, CollationResult, Collator, MaybeCompressedPoV, PoV, }; use polkadot_node_subsystem::{ errors::RuntimeApiError, @@ -69,8 +69,12 @@ mod handle_new_activations { Some(CollationResult { collation: test_collation(), result_sender: None }) } - async fn is_collating(&self, _: Hash, _: &PersistedValidationData) -> bool { - false + async fn is_collating( + &self, + _: Hash, + _: &PersistedValidationData, + ) -> Option { + None } } diff --git a/node/network/collator-protocol/src/collator_side/advertising.rs b/node/network/collator-protocol/src/collator_side/advertising.rs new file mode 100644 index 000000000000..76bb400ac4e3 --- /dev/null +++ b/node/network/collator-protocol/src/collator_side/advertising.rs @@ -0,0 +1,197 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +use std::collections::{HashMap, HashSet}; + +use polkadot_node_network_protocol::v1::CollatorProtocolMessage; +use polkadot_node_network_protocol::{OurView, PeerId, View}; +use polkadot_primitives::v2::{CollatorPair, Id as ParaId, Hash, BlockNumber, SessionIndex, GroupRotationInfo, CoreIndex, GroupIndex, AuthorityDiscoveryId}; +use polkadot_subsystem::messages::CollatorProtocolMessage; +use polkadot_subsystem::{ActiveLeavesUpdate, SubsystemContext, SubsystemSender}; + +use crate::error::FatalResult; + +use crate::error::FatalResult; + +use super::Metrics; + +/// State for taking care of validator connections and advertisments. +struct Advertiser { + /// Our network peer id. + local_peer_id: PeerId, + + /// Our keys. + collator_pair: CollatorPair, + + /// The para this collator is collating on. + /// Starts as `None` and is updated with every `CollateOn` message. + collating_on: Option, + + /// Track all active peers and their views + /// to determine what is relevant to them. + peer_views: HashMap, + + /// Our own view. + view: OurView, + + /// Information about connections we want to have established. + /// + /// For connection management we basically need two blocks of information: + /// + /// 1. Time: When and for how long do we want the connection. + /// 2. To what validators/which backing group to connect to. + /// + /// ## Connection time management + /// + /// For simplicity we chose to make connection life management based on relay chain blocks, + /// which act as a natural pace maker. So the lifespan of a connection can be adjusted in + /// multiples of rougly 6 seconds (assuming normal operation). + /// + /// To ensure uninterrupted connectivity, for several blocks, all you have to do is to ensure + /// that this map contains an entry for those consecutive block numbers. We chose block numbers + /// as key for this map as opposed to `Hash`es, so you can ensure "guaranteed" uninterrupted + /// connectivity from a current block to a future block, e.g. for pre-connect. + /// + /// Concretely: For pre-connect (establishing a connection one block earlier than you need it), + /// you would make sure that this map contains two entries with the same value, one for the + /// current block height of the fork you are interested in and one with the block number + /// incremented. This way the connection will survive the next block in all cases. + /// + /// # Target/what validators to connect to + /// + /// The values of this map are the group/session combinations we want to be connected for the + /// given block height. + required_connections: HashMap>, + + /// Information about established connections to validators in a group. + connections: HashMap<(SessionIndex, GroupIndex), GroupConnection>, + + /// Lookup group index/session indexes for a peer that connected. + reverse_peers: HashMap>, + + /// Lookup groups in sessions for an Authority (in requested connections) + authority_group: HashMap>, + + // send task (given relay_parent, paraid): + // - send for paraid + // - resolves to coreid (on a per block basis) - can be found once we have block + // - resolves to groupid - can be found once we know the session (and block height) + // - resolves to `AuthorityDiscoveryIds` - can be found if we have session + // - which resolve to `PeerId`s - can be resolved once connected + requested_connections: HashMap, + /// `PeerId`s for already established connections for some group. + group_peers: HashMap>, + + established_connections: HashMap, + + /// Report metrics. + metrics: Metrics, +} + +/// Needed information for establishing connections. +struct ConnectionInfo { + /// The relay parent to use for determining the correct core. + relay_parent: Hash, + /// Block number to determine the desired backing group. + /// + /// Note: This seemingly redundant info, is not redundant in the case of `pre-connect`. In this + /// case the above relay_parent will be used for determining the core in advance, but the + /// responsbile backing group will be determined based on the given `block_number`. + block_number: BlockNumber, + /// What session we are operating in. + /// + /// For `pre-connect`, this will just be a guess, which might be wrong (we assume to stay in + /// the same session). + session_index: SessionIndex, +} + +/// Information about connections to a validator group. +/// +/// We keep track of connected peers in a validator group and the messages that should be sent to +/// them. +struct GroupConnection { + /// Connected peers. + peers: HashSet, + /// Messages that should be sent to connected peers in this group. + /// + /// When messages are sent, peers might not yet be connected, so we keep all messages that + /// should be sent to peers here, if a new peer connects all messages that are still relevant + /// to its view are sent. + messages: Vec, +} + +impl Advertiser { + pub fn new(local_peer_id: PeerId, collator_pair: CollatorPair, metrics: Metrics) -> Self { + Self { + local_peer_id, + collator_pair, + collating_on: None, + peer_views: HashMap::new(), + view: OurView::default(), + required_connections: HashMap::new(), + metrics, + } + } + + /// Ask for additional connections. + /// + /// They will automatically established once a block with block height `when` comes into view + /// and will be closed, once it goes out of view, assuming no other entry is present, which + /// preserves them. + /// + // - Lookup SessionIndex & Group + // - Add to required_connections + // - Update Connect message if necessary (connection affects already present block heights) + pub fn add_required_connections(&mut self, sender: &mut Sender, when: BlockNumber, info: ConnectionInfo) { + self.requried_connections.insert(when, info); + } + + /// Send a message to a validator group. + // + // - insert message + // - send to all already connected peers if in view. + // -> View still relevant with async backing? Likely only when it comes to height. + pub fn send_message(&mut self, session: SessionIndex, group: GroupIndex, msg: CollatorProtocolMessage) -> FatalResult<()> { + panic!("WIP"); + } + + // - Add to peers in groups. + // - Send any messages it has not received yet. + // - Cleanout any obsolete messages + pub fn on_peer_connected(&mut self, ...); + + + /// Process an active leaves update. + /// + /// - Make sure needed connections are established + /// - Make sure obsolete connections are dropped + pub fn process_active_leaves_update( + &mut self, + ctx: &mut Context, + update: &ActiveLeavesUpdate, + ) -> FatalResult<()> { + } + + /// Get all peers which have the given relay parent in their view. + fn peers_interested_in_leaf(&self, relay_parent: &Hash) -> Vec { + self.peer_views + .iter() + .filter(|(_, v)| v.contains(relay_parent)) + .map(|(peer, _)| *peer) + .collect() + } + +} diff --git a/node/network/collator-protocol/src/collator_side/metrics.rs b/node/network/collator-protocol/src/collator_side/metrics.rs new file mode 100644 index 000000000000..99da64f13278 --- /dev/null +++ b/node/network/collator-protocol/src/collator_side/metrics.rs @@ -0,0 +1,123 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +use polkadot_node_subsystem_util::metrics::{self, prometheus}; + +#[derive(Clone, Default)] +pub struct Metrics(Option); + +impl Metrics { + pub fn on_advertisment_made(&self) { + if let Some(metrics) = &self.0 { + metrics.advertisements_made.inc(); + } + } + + pub fn on_collation_sent_requested(&self) { + if let Some(metrics) = &self.0 { + metrics.collations_send_requested.inc(); + } + } + + pub fn on_collation_sent(&self) { + if let Some(metrics) = &self.0 { + metrics.collations_sent.inc(); + } + } + + /// Provide a timer for `process_msg` which observes on drop. + pub fn time_process_msg(&self) -> Option { + self.0.as_ref().map(|metrics| metrics.process_msg.start_timer()) + } + + /// Provide a timer for `distribute_collation` which observes on drop. + pub fn time_collation_distribution( + &self, + label: &'static str, + ) -> Option { + self.0.as_ref().map(|metrics| { + metrics.collation_distribution_time.with_label_values(&[label]).start_timer() + }) + } +} + +#[derive(Clone)] +struct MetricsInner { + advertisements_made: prometheus::Counter, + collations_sent: prometheus::Counter, + collations_send_requested: prometheus::Counter, + process_msg: prometheus::Histogram, + collation_distribution_time: prometheus::HistogramVec, +} + +impl metrics::Metrics for Metrics { + fn try_register( + registry: &prometheus::Registry, + ) -> std::result::Result { + let metrics = MetricsInner { + advertisements_made: prometheus::register( + prometheus::Counter::new( + "polkadot_parachain_collation_advertisements_made_total", + "A number of collation advertisements sent to validators.", + )?, + registry, + )?, + collations_send_requested: prometheus::register( + prometheus::Counter::new( + "polkadot_parachain_collations_sent_requested_total", + "A number of collations requested to be sent to validators.", + )?, + registry, + )?, + collations_sent: prometheus::register( + prometheus::Counter::new( + "polkadot_parachain_collations_sent_total", + "A number of collations sent to validators.", + )?, + registry, + )?, + process_msg: prometheus::register( + prometheus::Histogram::with_opts( + prometheus::HistogramOpts::new( + "polkadot_parachain_collator_protocol_collator_process_msg", + "Time spent within `collator_protocol_collator::process_msg`", + ) + .buckets(vec![ + 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, + 1.0, + ]), + )?, + registry, + )?, + collation_distribution_time: prometheus::register( + prometheus::HistogramVec::new( + prometheus::HistogramOpts::new( + "polkadot_parachain_collator_protocol_collator_distribution_time", + "Time spent within `collator_protocol_collator::distribute_collation`", + ) + .buckets(vec![ + 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, + 1.0, + ]), + &["state"], + )?, + registry, + )?, + }; + + Ok(Metrics(Some(metrics))) + } +} diff --git a/node/network/collator-protocol/src/collator_side/mod.rs b/node/network/collator-protocol/src/collator_side/mod.rs index e5c5f712a69e..a4a01f65f81d 100644 --- a/node/network/collator-protocol/src/collator_side/mod.rs +++ b/node/network/collator-protocol/src/collator_side/mod.rs @@ -14,6 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +//! The collator protocol implementation receives collations and forecasts for collations from the collation-generation and then makes sure to advertise those collations to the right validators, ensuring the necessary connections are open. This is taken care of by the `advertising` submodule. +//! +//! Afterwards requests for those collations must be handled, that is handled by the `responding` +//! module. +//! +//! The third functionality that is implemented is forwarding `Seconded` responses to the +//! collation-generation, is also taken care of by the responder, as it keeps track of available +//! collations and can issue the necessary cleanup of obsolete response senders. use std::{ collections::{HashMap, HashSet, VecDeque}, iter, @@ -37,7 +45,6 @@ use polkadot_node_network_protocol::{ }; use polkadot_node_primitives::{CollationSecondedSignal, PoV, Statement}; use polkadot_node_subsystem_util::{ - metrics::{self, prometheus}, runtime::{get_availability_cores, get_group_rotation_info, RuntimeInfo}, TimeoutExt, }; @@ -55,6 +62,31 @@ use super::{LOG_TARGET, NEXT_GROUP_PRECONNECT_WINDOW}; use crate::error::{log_error, Error, FatalError, Result}; use fatality::Split; +/// Advertising of collations to validators +/// +/// - Keep track of validator groups +/// - Keep track of views of connected validators +/// - Ensure needed connections are open and unneeded ones are closed +/// - Send out collation advertisments according to protocol (on correct views and to correct +/// validators) +mod advertising; + +/// Process incoming collation requests +/// +/// The whole request/response mechanism for actually getting collations to the validators is +/// handled here. +/// +/// In particular: +/// +/// - Queue/dequeue incoming requests with some processing policy +/// - Keep track of available collations & clean up unneeded onces. +/// - Gracefully handle requests for collations that are not yet ready. +mod responding; + +/// Metrics for the collator side of the collator protocol. +mod metrics; +pub use metrics::Metrics; + #[cfg(test)] mod tests; @@ -71,112 +103,6 @@ const COST_APPARENT_FLOOD: Rep = /// For considerations on this value, see: https://github.com/paritytech/polkadot/issues/4386 const MAX_UNSHARED_UPLOAD_TIME: Duration = Duration::from_millis(150); -#[derive(Clone, Default)] -pub struct Metrics(Option); - -impl Metrics { - fn on_advertisment_made(&self) { - if let Some(metrics) = &self.0 { - metrics.advertisements_made.inc(); - } - } - - fn on_collation_sent_requested(&self) { - if let Some(metrics) = &self.0 { - metrics.collations_send_requested.inc(); - } - } - - fn on_collation_sent(&self) { - if let Some(metrics) = &self.0 { - metrics.collations_sent.inc(); - } - } - - /// Provide a timer for `process_msg` which observes on drop. - fn time_process_msg(&self) -> Option { - self.0.as_ref().map(|metrics| metrics.process_msg.start_timer()) - } - - /// Provide a timer for `distribute_collation` which observes on drop. - fn time_collation_distribution( - &self, - label: &'static str, - ) -> Option { - self.0.as_ref().map(|metrics| { - metrics.collation_distribution_time.with_label_values(&[label]).start_timer() - }) - } -} - -#[derive(Clone)] -struct MetricsInner { - advertisements_made: prometheus::Counter, - collations_sent: prometheus::Counter, - collations_send_requested: prometheus::Counter, - process_msg: prometheus::Histogram, - collation_distribution_time: prometheus::HistogramVec, -} - -impl metrics::Metrics for Metrics { - fn try_register( - registry: &prometheus::Registry, - ) -> std::result::Result { - let metrics = MetricsInner { - advertisements_made: prometheus::register( - prometheus::Counter::new( - "polkadot_parachain_collation_advertisements_made_total", - "A number of collation advertisements sent to validators.", - )?, - registry, - )?, - collations_send_requested: prometheus::register( - prometheus::Counter::new( - "polkadot_parachain_collations_sent_requested_total", - "A number of collations requested to be sent to validators.", - )?, - registry, - )?, - collations_sent: prometheus::register( - prometheus::Counter::new( - "polkadot_parachain_collations_sent_total", - "A number of collations sent to validators.", - )?, - registry, - )?, - process_msg: prometheus::register( - prometheus::Histogram::with_opts( - prometheus::HistogramOpts::new( - "polkadot_parachain_collator_protocol_collator_process_msg", - "Time spent within `collator_protocol_collator::process_msg`", - ) - .buckets(vec![ - 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, - 1.0, - ]), - )?, - registry, - )?, - collation_distribution_time: prometheus::register( - prometheus::HistogramVec::new( - prometheus::HistogramOpts::new( - "polkadot_parachain_collator_protocol_collator_distribution_time", - "Time spent within `collator_protocol_collator::distribute_collation`", - ) - .buckets(vec![ - 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, - 1.0, - ]), - &["state"], - )?, - registry, - )?, - }; - - Ok(Metrics(Some(metrics))) - } -} - /// Info about validators we are currently connected to. /// /// It keeps track to which validators we advertised our collation. @@ -286,23 +212,6 @@ enum AssignmentType { } struct State { - /// Our network peer id. - local_peer_id: PeerId, - - /// Our collator pair. - collator_pair: CollatorPair, - - /// The para this collator is collating on. - /// Starts as `None` and is updated with every `CollateOn` message. - collating_on: Option, - - /// Track all active peers and their views - /// to determine what is relevant to them. - peer_views: HashMap, - - /// Our own view. - view: OurView, - /// Span per relay parent. span_per_relay_parent: HashMap, @@ -341,12 +250,7 @@ impl State { /// state fields to their default values (i.e. empty). fn new(local_peer_id: PeerId, collator_pair: CollatorPair, metrics: Metrics) -> State { State { - local_peer_id, - collator_pair, metrics, - collating_on: Default::default(), - peer_views: Default::default(), - view: Default::default(), span_per_relay_parent: Default::default(), collations: Default::default(), collation_result_senders: Default::default(), @@ -357,14 +261,6 @@ impl State { } } - /// Get all peers which have the given relay parent in their view. - fn peers_interested_in_leaf(&self, relay_parent: &Hash) -> Vec { - self.peer_views - .iter() - .filter(|(_, v)| v.contains(relay_parent)) - .map(|(peer, _)| *peer) - .collect() - } } /// Distribute a collation. @@ -792,7 +688,7 @@ where ); } }, - PreConnectAsCollator(relay_parent) => { + ForecastCollation(relay_parent, _forecast) => { if !state.view.contains(&relay_parent) { gum::warn!( target: LOG_TARGET, diff --git a/node/network/collator-protocol/src/collator_side/responding.rs b/node/network/collator-protocol/src/collator_side/responding.rs new file mode 100644 index 000000000000..3c9013eaf7b7 --- /dev/null +++ b/node/network/collator-protocol/src/collator_side/responding.rs @@ -0,0 +1,15 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . diff --git a/node/network/collator-protocol/src/error.rs b/node/network/collator-protocol/src/error.rs index 4f0b0921a05a..f228001e0032 100644 --- a/node/network/collator-protocol/src/error.rs +++ b/node/network/collator-protocol/src/error.rs @@ -26,6 +26,8 @@ use crate::LOG_TARGET; /// General result. pub type Result = std::result::Result; +pub type FatalResult = std::result::Result; +pub type JfyiResult = std::result::Result; use fatality::Nested; diff --git a/node/network/collator-protocol/src/lib.rs b/node/network/collator-protocol/src/lib.rs index 761c6e0d5807..bedd7264a047 100644 --- a/node/network/collator-protocol/src/lib.rs +++ b/node/network/collator-protocol/src/lib.rs @@ -41,6 +41,7 @@ use polkadot_subsystem::{ mod error; +/// Collator side of the protocol mod collator_side; mod validator_side; diff --git a/node/network/collator-protocol/src/validator_side/mod.rs b/node/network/collator-protocol/src/validator_side/mod.rs index 5c41e52fd64b..a84593a18bd1 100644 --- a/node/network/collator-protocol/src/validator_side/mod.rs +++ b/node/network/collator-protocol/src/validator_side/mod.rs @@ -1168,10 +1168,10 @@ async fn process_msg( "DistributeCollation message is not expected on the validator side of the protocol", ); }, - PreConnectAsCollator(_) => { + ForecastCollation(_, _) => { gum::warn!( target: LOG_TARGET, - "PreConnectAsCollator message is not expected on the validator side of the protocol", + "ForecastCollation message is not expected on the validator side of the protocol", ); }, ReportCollator(id) => { diff --git a/node/primitives/src/lib.rs b/node/primitives/src/lib.rs index 6c2964fd1b42..85d5a181cefe 100644 --- a/node/primitives/src/lib.rs +++ b/node/primitives/src/lib.rs @@ -347,6 +347,15 @@ impl CollationResult { } } +/// Let a collator share early information about an upcoming collation. +#[derive(Debug)] +pub enum CollationForecast { + /// We are already building a collation for this very relay parent. + Now, + /// We are going to provide a collation on the next relay parent. + NextBlock, +} + /// A wrapper over a parachain collator. #[cfg(not(target_os = "unknown"))] #[async_trait] @@ -363,18 +372,29 @@ pub trait Collator: Send + Sync { validation_data: &PersistedValidationData, ) -> Option; - /// If a parachain consensus allows it, figure out whether a collator is going to produce a - /// candidate based **on the child** of the given relay parent. + /// If a parachain consensus allows it, figure out whether we are going to be providing a + /// collation based on the given `relay_parent`. + /// + /// Implementation: /// - /// If the above is not possible, but a collator is aware it's going to produce a candidate - /// based **on relay parent**, should also return `true`. + /// 1. Collators who can't know in advance whether they are going to have a collation, shall + /// return `None` on every call. + /// 2. Collators who can know in advance whether they will provide a collation, shall behave in the + /// following way: + /// 1. They will have a collation for the passed relay_parent - return `Some(Now)`. + /// 2. They will have a collation at the child for the given relay parent - return + /// `Some(NextBlock)`. + /// 3. They will not have a collation now or at the next block - return `None`. /// - /// Otherwise, should always return `false`. + /// For collators of type 2, the node will use the forecast for establishing needed network + /// connections early and to announce collations, before they are ready - so the + /// advertising/request round trip can be done, while the collator is preparing the collation + /// already. async fn is_collating( &self, relay_parent: Hash, validation_data: &PersistedValidationData, - ) -> bool; + ) -> Option; } /// Configuration for the collation generator diff --git a/node/subsystem-types/src/messages.rs b/node/subsystem-types/src/messages.rs index 6fbad822dc10..d13111be12ee 100644 --- a/node/subsystem-types/src/messages.rs +++ b/node/subsystem-types/src/messages.rs @@ -34,9 +34,9 @@ use polkadot_node_network_protocol::{ }; use polkadot_node_primitives::{ approval::{BlockApprovalMeta, IndirectAssignmentCert, IndirectSignedApprovalVote}, - AvailableData, BabeEpoch, BlockWeight, CandidateVotes, CollationGenerationConfig, - CollationSecondedSignal, DisputeMessage, ErasureChunk, PoV, SignedDisputeStatement, - SignedFullStatement, ValidationResult, + AvailableData, BabeEpoch, BlockWeight, CandidateVotes, CollationForecast, + CollationGenerationConfig, CollationSecondedSignal, DisputeMessage, ErasureChunk, PoV, + SignedDisputeStatement, SignedFullStatement, ValidationResult, }; use polkadot_primitives::v2::{ AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash, @@ -184,17 +184,16 @@ impl CandidateValidationMessage { /// Messages received by the Collator Protocol subsystem. #[derive(Debug, derive_more::From)] pub enum CollatorProtocolMessage { - /// Signal to the collator protocol that it should connect to validators with the expectation - /// of collating on the given para. This is only expected to be called once, early on, if at all, - /// and only by the Collation Generation subsystem. As such, it will overwrite the value of - /// the previous signal. + /// Signal to the collator protocol on which parachain this collator is going to be collating. + /// This is only expected to be called once, early on, if at all. As such, it will overwrite + /// the value of the previous signal. /// /// This should be sent before any `DistributeCollation` message. CollateOn(ParaId), /// Provide a collation to distribute to validators with an optional result sender. /// - /// The result sender should be informed when at least one parachain validator seconded the collation. It is also - /// completely okay to just drop the sender. + /// The result sender should be informed when at least one parachain validator seconded the + /// collation. It is also completely okay to just drop the sender. DistributeCollation(CandidateReceipt, PoV, Option>), /// Report a collator as having provided an invalid collation. This should lead to disconnect /// and blacklist of the collator. @@ -210,9 +209,8 @@ pub enum CollatorProtocolMessage { /// /// The hash is the relay parent. Seconded(Hash, SignedFullStatement), - /// Issue a preconnect request for the given relay parent, i.e. get the peer set ready - /// for collating on it or its child. - PreConnectAsCollator(Hash), + /// Inform the collator protocol of an upcoming collation. + ForecastCollation(Hash, CollationForecast), } impl Default for CollatorProtocolMessage {