cargo +nightly fmt (#3540)

* cargo +nightly fmt

* add cargo-fmt check to ci

* update ci

* fmt

* fmt

* skip macro

* ignore bridges
This commit is contained in:
Shawn Tabrizi
2021-08-02 12:47:33 +02:00
committed by GitHub
parent 30e3012270
commit ff5d56fb76
350 changed files with 20617 additions and 21266 deletions
+126 -117
View File
@@ -59,46 +59,36 @@
// yielding false positives
#![warn(missing_docs)]
use std::fmt::{self, Debug};
use std::pin::Pin;
use std::sync::Arc;
use std::time::Duration;
use std::collections::{hash_map, HashMap};
use std::iter::FromIterator;
use futures::channel::oneshot;
use futures::{
select,
future::BoxFuture,
Future, FutureExt, StreamExt,
use std::{
collections::{hash_map, HashMap},
fmt::{self, Debug},
iter::FromIterator,
pin::Pin,
sync::Arc,
time::Duration,
};
use futures::{channel::oneshot, future::BoxFuture, select, Future, FutureExt, StreamExt};
use lru::LruCache;
use parking_lot::RwLock;
use polkadot_primitives::v1::{Block, BlockId,BlockNumber, Hash, ParachainHost};
use client::{BlockImportNotification, BlockchainEvents, FinalityNotification};
use polkadot_primitives::v1::{Block, BlockId, BlockNumber, Hash, ParachainHost};
use sp_api::{ApiExt, ProvideRuntimeApi};
use polkadot_node_network_protocol::{
v1 as protocol_v1,
};
use polkadot_node_network_protocol::v1 as protocol_v1;
use polkadot_node_subsystem_types::messages::{
CandidateValidationMessage, CandidateBackingMessage,
ChainApiMessage, StatementDistributionMessage,
AvailabilityDistributionMessage, BitfieldSigningMessage, BitfieldDistributionMessage,
ProvisionerMessage, RuntimeApiMessage,
AvailabilityStoreMessage, NetworkBridgeMessage, CollationGenerationMessage,
CollatorProtocolMessage, AvailabilityRecoveryMessage, ApprovalDistributionMessage,
ApprovalVotingMessage, GossipSupportMessage,
NetworkBridgeEvent,
DisputeParticipationMessage, DisputeCoordinatorMessage, ChainSelectionMessage,
DisputeDistributionMessage,
ApprovalDistributionMessage, ApprovalVotingMessage, AvailabilityDistributionMessage,
AvailabilityRecoveryMessage, AvailabilityStoreMessage, BitfieldDistributionMessage,
BitfieldSigningMessage, CandidateBackingMessage, CandidateValidationMessage, ChainApiMessage,
ChainSelectionMessage, CollationGenerationMessage, CollatorProtocolMessage,
DisputeCoordinatorMessage, DisputeDistributionMessage, DisputeParticipationMessage,
GossipSupportMessage, NetworkBridgeEvent, NetworkBridgeMessage, ProvisionerMessage,
RuntimeApiMessage, StatementDistributionMessage,
};
pub use polkadot_node_subsystem_types::{
OverseerSignal,
errors::{SubsystemResult, SubsystemError,},
ActiveLeavesUpdate, ActivatedLeaf, LeafStatus,
jaeger,
errors::{SubsystemError, SubsystemResult},
jaeger, ActivatedLeaf, ActiveLeavesUpdate, LeafStatus, OverseerSignal,
};
// TODO legacy, to be deleted, left for easier integration
@@ -110,30 +100,15 @@ mod metrics;
use self::metrics::Metrics;
use polkadot_node_metrics::{
metrics::{
prometheus,
Metrics as MetricsTrait
},
metrics::{prometheus, Metrics as MetricsTrait},
Metronome,
};
pub use polkadot_overseer_gen::{
TimeoutExt,
SpawnNamed,
Subsystem,
SubsystemMeterReadouts,
SubsystemMeters,
SubsystemIncomingMessages,
SubsystemInstance,
SubsystemSender,
SubsystemContext,
overlord,
MessagePacket,
SignalsReceived,
FromOverseer,
ToOverseer,
MapSubsystem,
};
pub use polkadot_overseer_gen as gen;
pub use polkadot_overseer_gen::{
overlord, FromOverseer, MapSubsystem, MessagePacket, SignalsReceived, SpawnNamed, Subsystem,
SubsystemContext, SubsystemIncomingMessages, SubsystemInstance, SubsystemMeterReadouts,
SubsystemMeters, SubsystemSender, TimeoutExt, ToOverseer,
};
/// Store 2 days worth of blocks, not accounting for forks,
/// in the LRU cache. Assumes a 6-second block time.
@@ -142,14 +117,14 @@ const KNOWN_LEAVES_CACHE_SIZE: usize = 2 * 24 * 3600 / 6;
#[cfg(test)]
mod tests;
/// Whether a header supports parachain consensus or not.
pub trait HeadSupportsParachains {
/// Return true if the given header supports parachain consensus. Otherwise, false.
fn head_supports_parachains(&self, head: &Hash) -> bool;
}
impl<Client> HeadSupportsParachains for Arc<Client> where
impl<Client> HeadSupportsParachains for Arc<Client>
where
Client: ProvideRuntimeApi<Block>,
Client::Api: ParachainHost<Block>,
{
@@ -159,7 +134,6 @@ impl<Client> HeadSupportsParachains for Arc<Client> where
}
}
/// A handle used to communicate with the [`Overseer`].
///
/// [`Overseer`]: struct.Overseer.html
@@ -205,11 +179,16 @@ impl Handle {
/// Note that due the fact the overseer doesn't store the whole active-leaves set, only deltas,
/// the response channel may never return if the hash was deactivated before this call.
/// In this case, it's the caller's responsibility to ensure a timeout is set.
pub async fn wait_for_activation(&mut self, hash: Hash, response_channel: oneshot::Sender<SubsystemResult<()>>) {
pub async fn wait_for_activation(
&mut self,
hash: Hash,
response_channel: oneshot::Sender<SubsystemResult<()>>,
) {
self.send_and_log_error(Event::ExternalRequest(ExternalRequest::WaitForActivation {
hash,
response_channel
})).await;
hash,
response_channel,
}))
.await;
}
/// Tell `Overseer` to shutdown.
@@ -293,21 +272,13 @@ pub struct BlockInfo {
impl From<BlockImportNotification<Block>> for BlockInfo {
fn from(n: BlockImportNotification<Block>) -> Self {
BlockInfo {
hash: n.hash,
parent_hash: n.header.parent_hash,
number: n.header.number,
}
BlockInfo { hash: n.hash, parent_hash: n.header.parent_hash, number: n.header.number }
}
}
impl From<FinalityNotification<Block>> for BlockInfo {
fn from(n: FinalityNotification<Block>) -> Self {
BlockInfo {
hash: n.hash,
parent_hash: n.header.parent_hash,
number: n.header.number,
}
BlockInfo { hash: n.hash, parent_hash: n.header.parent_hash, number: n.header.number }
}
}
@@ -345,10 +316,7 @@ pub enum ExternalRequest {
/// Glues together the [`Overseer`] and `BlockchainEvents` by forwarding
/// import and finality notifications into the [`OverseerHandle`].
pub async fn forward_events<P: BlockchainEvents<Block>>(
client: Arc<P>,
mut handle: Handle,
) {
pub async fn forward_events<P: BlockchainEvents<Block>>(client: Arc<P>, mut handle: Handle) {
let mut finality = client.finality_notification_stream();
let mut imports = client.import_notification_stream();
@@ -594,9 +562,53 @@ where
/// # });
/// # }
/// ```
pub fn new<CV, CB, SD, AD, AR, BS, BD, P, RA, AS, NB, CA, CG, CP, ApD, ApV, GS, DC, DP, DD, CS>(
pub fn new<
CV,
CB,
SD,
AD,
AR,
BS,
BD,
P,
RA,
AS,
NB,
CA,
CG,
CP,
ApD,
ApV,
GS,
DC,
DP,
DD,
CS,
>(
leaves: impl IntoIterator<Item = BlockInfo>,
all_subsystems: AllSubsystems<CV, CB, SD, AD, AR, BS, BD, P, RA, AS, NB, CA, CG, CP, ApD, ApV, GS, DC, DP, DD, CS>,
all_subsystems: AllSubsystems<
CV,
CB,
SD,
AD,
AR,
BS,
BD,
P,
RA,
AS,
NB,
CA,
CG,
CP,
ApD,
ApV,
GS,
DC,
DP,
DD,
CS,
>,
prometheus_registry: Option<&prometheus::Registry>,
supports_parachains: SupportsParachains,
s: S,
@@ -604,8 +616,10 @@ where
where
CV: Subsystem<OverseerSubsystemContext<CandidateValidationMessage>, SubsystemError> + Send,
CB: Subsystem<OverseerSubsystemContext<CandidateBackingMessage>, SubsystemError> + Send,
SD: Subsystem<OverseerSubsystemContext<StatementDistributionMessage>, SubsystemError> + Send,
AD: Subsystem<OverseerSubsystemContext<AvailabilityDistributionMessage>, SubsystemError> + Send,
SD: Subsystem<OverseerSubsystemContext<StatementDistributionMessage>, SubsystemError>
+ Send,
AD: Subsystem<OverseerSubsystemContext<AvailabilityDistributionMessage>, SubsystemError>
+ Send,
AR: Subsystem<OverseerSubsystemContext<AvailabilityRecoveryMessage>, SubsystemError> + Send,
BS: Subsystem<OverseerSubsystemContext<BitfieldSigningMessage>, SubsystemError> + Send,
BD: Subsystem<OverseerSubsystemContext<BitfieldDistributionMessage>, SubsystemError> + Send,
@@ -616,7 +630,8 @@ where
CA: Subsystem<OverseerSubsystemContext<ChainApiMessage>, SubsystemError> + Send,
CG: Subsystem<OverseerSubsystemContext<CollationGenerationMessage>, SubsystemError> + Send,
CP: Subsystem<OverseerSubsystemContext<CollatorProtocolMessage>, SubsystemError> + Send,
ApD: Subsystem<OverseerSubsystemContext<ApprovalDistributionMessage>, SubsystemError> + Send,
ApD:
Subsystem<OverseerSubsystemContext<ApprovalDistributionMessage>, SubsystemError> + Send,
ApV: Subsystem<OverseerSubsystemContext<ApprovalVotingMessage>, SubsystemError> + Send,
GS: Subsystem<OverseerSubsystemContext<GossipSupportMessage>, SubsystemError> + Send,
DC: Subsystem<OverseerSubsystemContext<DisputeCoordinatorMessage>, SubsystemError> + Send,
@@ -650,7 +665,9 @@ where
.dispute_distribution(all_subsystems.dispute_distribution)
.chain_selection(all_subsystems.chain_selection)
.leaves(Vec::from_iter(
leaves.into_iter().map(|BlockInfo { hash, parent_hash: _, number }| (hash, number))
leaves
.into_iter()
.map(|BlockInfo { hash, parent_hash: _, number }| (hash, number)),
))
.known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE))
.active_leaves(Default::default())
@@ -669,33 +686,29 @@ where
type Output = Option<(&'static str, SubsystemMeters)>;
fn map_subsystem(&self, subsystem: &'a OverseenSubsystem<T>) -> Self::Output {
subsystem.instance.as_ref().map(|instance| {
(
instance.name,
instance.meters.clone(),
)
})
subsystem
.instance
.as_ref()
.map(|instance| (instance.name, instance.meters.clone()))
}
}
let subsystem_meters = overseer.map_subsystems(ExtractNameAndMeters);
let metronome_metrics = metrics.clone();
let metronome = Metronome::new(std::time::Duration::from_millis(950))
.for_each(move |_| {
let metronome =
Metronome::new(std::time::Duration::from_millis(950)).for_each(move |_| {
// We combine the amount of messages from subsystems to the overseer
// as well as the amount of messages from external sources to the overseer
// into one `to_overseer` value.
metronome_metrics.channel_fill_level_snapshot(
subsystem_meters.iter()
subsystem_meters
.iter()
.cloned()
.filter_map(|x| x)
.map(|(name, ref meters)| (name, meters.read()))
.map(|(name, ref meters)| (name, meters.read())),
);
async move {
()
}
async move { () }
});
overseer.spawner().spawn("metrics_metronome", Box::pin(metronome));
}
@@ -705,10 +718,7 @@ where
/// Stop the overseer.
async fn stop(mut self) {
let _ = self.wait_terminate(
OverseerSignal::Conclude,
Duration::from_secs(1_u64)
).await;
let _ = self.wait_terminate(OverseerSignal::Conclude, Duration::from_secs(1_u64)).await;
}
/// Run the `Overseer`.
@@ -717,12 +727,8 @@ where
for (hash, number) in std::mem::take(&mut self.leaves) {
let _ = self.active_leaves.insert(hash, number);
if let Some((span, status)) = self.on_head_activated(&hash, None) {
let update = ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash,
number,
status,
span,
});
let update =
ActiveLeavesUpdate::start_work(ActivatedLeaf { hash, number, status, span });
self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await?;
}
}
@@ -778,8 +784,8 @@ where
hash_map::Entry::Vacant(entry) => entry.insert(block.number),
hash_map::Entry::Occupied(entry) => {
debug_assert_eq!(*entry.get(), block.number);
return Ok(());
}
return Ok(())
},
};
let mut update = match self.on_head_activated(&block.hash, Some(block.parent_hash)) {
@@ -787,7 +793,7 @@ where
hash: block.hash,
number: block.number,
status,
span
span,
}),
None => ActiveLeavesUpdate::default(),
};
@@ -822,7 +828,8 @@ where
self.on_head_deactivated(deactivated)
}
self.broadcast_signal(OverseerSignal::BlockFinalized(block.hash, block.number)).await?;
self.broadcast_signal(OverseerSignal::BlockFinalized(block.hash, block.number))
.await?;
// If there are no leaves being deactivated, we don't need to send an update.
//
@@ -836,11 +843,13 @@ where
/// Handles a header activation. If the header's state doesn't support the parachains API,
/// this returns `None`.
fn on_head_activated(&mut self, hash: &Hash, parent_hash: Option<Hash>)
-> Option<(Arc<jaeger::Span>, LeafStatus)>
{
fn on_head_activated(
&mut self,
hash: &Hash,
parent_hash: Option<Hash>,
) -> Option<(Arc<jaeger::Span>, LeafStatus)> {
if !self.supports_parachains.head_supports_parachains(hash) {
return None;
return None
}
self.metrics.on_head_activated();
@@ -894,9 +903,12 @@ where
// it's fine if the listener is no longer interested
let _ = response_channel.send(Ok(()));
} else {
self.activation_external_listeners.entry(hash).or_default().push(response_channel);
self.activation_external_listeners
.entry(hash)
.or_default()
.push(response_channel);
}
}
},
}
}
@@ -909,15 +921,12 @@ where
}
}
// Additional `From` implementations, in order to deal with incoming network messages.
// Kept out of the proc macro, for sake of simplicity reduce the need to make even
// more types to the proc macro logic.
use polkadot_node_network_protocol::{
request_response::{request::IncomingRequest, v1 as req_res_v1},
use polkadot_node_network_protocol::request_response::{
request::IncomingRequest, v1 as req_res_v1,
};
impl From<IncomingRequest<req_res_v1::PoVFetchingRequest>> for AllMessages {
+38 -39
View File
@@ -33,7 +33,6 @@ struct MetricsInner {
signals_received: prometheus::GaugeVec<prometheus::U64>,
}
/// A shareable metrics type for usage with the overseer.
#[derive(Default, Clone)]
pub struct Metrics(Option<MetricsInner>);
@@ -59,30 +58,42 @@ impl Metrics {
pub(crate) fn channel_fill_level_snapshot(
&self,
collection: impl IntoIterator<Item=(&'static str, SubsystemMeterReadouts)>,
collection: impl IntoIterator<Item = (&'static str, SubsystemMeterReadouts)>,
) {
if let Some(metrics) = &self.0 {
collection.into_iter().for_each(
|(name, readouts): (_, SubsystemMeterReadouts)| {
metrics.to_subsystem_bounded_sent.with_label_values(&[name])
.set(readouts.bounded.sent as u64);
collection
.into_iter()
.for_each(|(name, readouts): (_, SubsystemMeterReadouts)| {
metrics
.to_subsystem_bounded_sent
.with_label_values(&[name])
.set(readouts.bounded.sent as u64);
metrics.to_subsystem_bounded_received.with_label_values(&[name])
.set(readouts.bounded.received as u64);
metrics
.to_subsystem_bounded_received
.with_label_values(&[name])
.set(readouts.bounded.received as u64);
metrics.to_subsystem_unbounded_sent.with_label_values(&[name])
.set(readouts.unbounded.sent as u64);
metrics
.to_subsystem_unbounded_sent
.with_label_values(&[name])
.set(readouts.unbounded.sent as u64);
metrics.to_subsystem_unbounded_received.with_label_values(&[name])
.set(readouts.unbounded.received as u64);
metrics
.to_subsystem_unbounded_received
.with_label_values(&[name])
.set(readouts.unbounded.received as u64);
metrics.signals_sent.with_label_values(&[name])
.set(readouts.signals.sent as u64);
metrics
.signals_sent
.with_label_values(&[name])
.set(readouts.signals.sent as u64);
metrics.signals_received.with_label_values(&[name])
.set(readouts.signals.received as u64);
}
);
metrics
.signals_received
.with_label_values(&[name])
.set(readouts.signals.received as u64);
});
}
}
}
@@ -93,21 +104,21 @@ impl metrics::Metrics for Metrics {
activated_heads_total: prometheus::register(
prometheus::Counter::new(
"parachain_activated_heads_total",
"Number of activated heads."
"Number of activated heads.",
)?,
registry,
)?,
deactivated_heads_total: prometheus::register(
prometheus::Counter::new(
"parachain_deactivated_heads_total",
"Number of deactivated heads."
"Number of deactivated heads.",
)?,
registry,
)?,
messages_relayed_total: prometheus::register(
prometheus::Counter::new(
"parachain_messages_relayed_total",
"Number of messages relayed by Overseer."
"Number of messages relayed by Overseer.",
)?,
registry,
)?,
@@ -117,9 +128,7 @@ impl metrics::Metrics for Metrics {
"parachain_subsystem_bounded_sent",
"Number of elements sent to subsystems' bounded queues",
),
&[
"subsystem_name",
],
&["subsystem_name"],
)?,
registry,
)?,
@@ -129,9 +138,7 @@ impl metrics::Metrics for Metrics {
"parachain_subsystem_bounded_received",
"Number of elements received by subsystems' bounded queues",
),
&[
"subsystem_name",
],
&["subsystem_name"],
)?,
registry,
)?,
@@ -141,9 +148,7 @@ impl metrics::Metrics for Metrics {
"parachain_subsystem_unbounded_sent",
"Number of elements sent to subsystems' unbounded queues",
),
&[
"subsystem_name",
],
&["subsystem_name"],
)?,
registry,
)?,
@@ -153,9 +158,7 @@ impl metrics::Metrics for Metrics {
"parachain_subsystem_unbounded_received",
"Number of elements received by subsystems' unbounded queues",
),
&[
"subsystem_name",
],
&["subsystem_name"],
)?,
registry,
)?,
@@ -165,9 +168,7 @@ impl metrics::Metrics for Metrics {
"parachain_overseer_signals_sent",
"Number of signals sent by overseer to subsystems",
),
&[
"subsystem_name",
],
&["subsystem_name"],
)?,
registry,
)?,
@@ -177,9 +178,7 @@ impl metrics::Metrics for Metrics {
"parachain_overseer_signals_received",
"Number of signals received by subsystems from overseer",
),
&[
"subsystem_name",
],
&["subsystem_name"],
)?,
registry,
)?,
+156 -62
View File
@@ -19,16 +19,12 @@
//! In the future, everything should be set up using the generated
//! overseer builder pattern instead.
use crate::{AllMessages, OverseerSignal};
use polkadot_node_subsystem_types::errors::SubsystemError;
use polkadot_overseer_gen::{
MapSubsystem, SubsystemContext,
Subsystem,
SpawnedSubsystem,
FromOverseer,
};
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
use crate::OverseerSignal;
use crate::AllMessages;
use polkadot_overseer_gen::{
FromOverseer, MapSubsystem, SpawnedSubsystem, Subsystem, SubsystemContext,
};
/// A dummy subsystem that implements [`Subsystem`] for all
/// types of messages. Used for tests or as a placeholder.
@@ -37,7 +33,11 @@ pub struct DummySubsystem;
impl<Context> Subsystem<Context, SubsystemError> for DummySubsystem
where
Context: SubsystemContext<Signal=OverseerSignal, Error=SubsystemError, AllMessages=AllMessages>,
Context: SubsystemContext<
Signal = OverseerSignal,
Error = SubsystemError,
AllMessages = AllMessages,
>,
{
fn start(self, mut ctx: Context) -> SpawnedSubsystem<SubsystemError> {
let future = Box::pin(async move {
@@ -51,20 +51,16 @@ where
"Discarding a message sent from overseer {:?}",
overseer_msg
);
continue;
}
continue
},
}
}
});
SpawnedSubsystem {
name: "dummy-subsystem",
future,
}
SpawnedSubsystem { name: "dummy-subsystem", future }
}
}
/// This struct is passed as an argument to create a new instance of an [`Overseer`].
///
/// As any entity that satisfies the interface may act as a [`Subsystem`] this allows
@@ -75,9 +71,27 @@ where
/// subsystems are implemented and the rest can be mocked with the [`DummySubsystem`].
#[derive(Debug, Clone, AllSubsystemsGen)]
pub struct AllSubsystems<
CV = (), CB = (), SD = (), AD = (), AR = (), BS = (), BD = (), P = (),
RA = (), AS = (), NB = (), CA = (), CG = (), CP = (), ApD = (), ApV = (),
GS = (), DC = (), DP = (), DD = (), CS = (),
CV = (),
CB = (),
SD = (),
AD = (),
AR = (),
BS = (),
BD = (),
P = (),
RA = (),
AS = (),
NB = (),
CA = (),
CG = (),
CP = (),
ApD = (),
ApV = (),
GS = (),
DC = (),
DP = (),
DD = (),
CS = (),
> {
/// A candidate validation subsystem.
pub candidate_validation: CV,
@@ -187,7 +201,31 @@ impl<CV, CB, SD, AD, AR, BS, BD, P, RA, AS, NB, CA, CG, CP, ApD, ApV, GS, DC, DP
}
/// Reference every individual subsystem.
pub fn as_ref(&self) -> AllSubsystems<&'_ CV, &'_ CB, &'_ SD, &'_ AD, &'_ AR, &'_ BS, &'_ BD, &'_ P, &'_ RA, &'_ AS, &'_ NB, &'_ CA, &'_ CG, &'_ CP, &'_ ApD, &'_ ApV, &'_ GS, &'_ DC, &'_ DP, &'_ DD, &'_ CS> {
pub fn as_ref(
&self,
) -> AllSubsystems<
&'_ CV,
&'_ CB,
&'_ SD,
&'_ AD,
&'_ AR,
&'_ BS,
&'_ BD,
&'_ P,
&'_ RA,
&'_ AS,
&'_ NB,
&'_ CA,
&'_ CG,
&'_ CP,
&'_ ApD,
&'_ ApV,
&'_ GS,
&'_ DC,
&'_ DP,
&'_ DD,
&'_ CS,
> {
AllSubsystems {
candidate_validation: &self.candidate_validation,
candidate_backing: &self.candidate_backing,
@@ -214,30 +252,32 @@ impl<CV, CB, SD, AD, AR, BS, BD, P, RA, AS, NB, CA, CG, CP, ApD, ApV, GS, DC, DP
}
/// Map each subsystem.
pub fn map_subsystems<Mapper>(self, mapper: Mapper)
-> AllSubsystems<
<Mapper as MapSubsystem<CV>>::Output,
<Mapper as MapSubsystem<CB>>::Output,
<Mapper as MapSubsystem<SD>>::Output,
<Mapper as MapSubsystem<AD>>::Output,
<Mapper as MapSubsystem<AR>>::Output,
<Mapper as MapSubsystem<BS>>::Output,
<Mapper as MapSubsystem<BD>>::Output,
<Mapper as MapSubsystem<P>>::Output,
<Mapper as MapSubsystem<RA>>::Output,
<Mapper as MapSubsystem<AS>>::Output,
<Mapper as MapSubsystem<NB>>::Output,
<Mapper as MapSubsystem<CA>>::Output,
<Mapper as MapSubsystem<CG>>::Output,
<Mapper as MapSubsystem<CP>>::Output,
<Mapper as MapSubsystem<ApD>>::Output,
<Mapper as MapSubsystem<ApV>>::Output,
<Mapper as MapSubsystem<GS>>::Output,
<Mapper as MapSubsystem<DC>>::Output,
<Mapper as MapSubsystem<DP>>::Output,
<Mapper as MapSubsystem<DD>>::Output,
<Mapper as MapSubsystem<CS>>::Output,
>
pub fn map_subsystems<Mapper>(
self,
mapper: Mapper,
) -> AllSubsystems<
<Mapper as MapSubsystem<CV>>::Output,
<Mapper as MapSubsystem<CB>>::Output,
<Mapper as MapSubsystem<SD>>::Output,
<Mapper as MapSubsystem<AD>>::Output,
<Mapper as MapSubsystem<AR>>::Output,
<Mapper as MapSubsystem<BS>>::Output,
<Mapper as MapSubsystem<BD>>::Output,
<Mapper as MapSubsystem<P>>::Output,
<Mapper as MapSubsystem<RA>>::Output,
<Mapper as MapSubsystem<AS>>::Output,
<Mapper as MapSubsystem<NB>>::Output,
<Mapper as MapSubsystem<CA>>::Output,
<Mapper as MapSubsystem<CG>>::Output,
<Mapper as MapSubsystem<CP>>::Output,
<Mapper as MapSubsystem<ApD>>::Output,
<Mapper as MapSubsystem<ApV>>::Output,
<Mapper as MapSubsystem<GS>>::Output,
<Mapper as MapSubsystem<DC>>::Output,
<Mapper as MapSubsystem<DP>>::Output,
<Mapper as MapSubsystem<DD>>::Output,
<Mapper as MapSubsystem<CS>>::Output,
>
where
Mapper: MapSubsystem<CV>,
Mapper: MapSubsystem<CB>,
@@ -262,27 +302,81 @@ impl<CV, CB, SD, AD, AR, BS, BD, P, RA, AS, NB, CA, CG, CP, ApD, ApV, GS, DC, DP
Mapper: MapSubsystem<CS>,
{
AllSubsystems {
candidate_validation: <Mapper as MapSubsystem<CV>>::map_subsystem(&mapper, self.candidate_validation),
candidate_backing: <Mapper as MapSubsystem<CB>>::map_subsystem(&mapper, self.candidate_backing),
statement_distribution: <Mapper as MapSubsystem<SD>>::map_subsystem(&mapper, self.statement_distribution),
availability_distribution: <Mapper as MapSubsystem<AD>>::map_subsystem(&mapper, self.availability_distribution),
availability_recovery: <Mapper as MapSubsystem<AR>>::map_subsystem(&mapper, self.availability_recovery),
bitfield_signing: <Mapper as MapSubsystem<BS>>::map_subsystem(&mapper, self.bitfield_signing),
bitfield_distribution: <Mapper as MapSubsystem<BD>>::map_subsystem(&mapper, self.bitfield_distribution),
candidate_validation: <Mapper as MapSubsystem<CV>>::map_subsystem(
&mapper,
self.candidate_validation,
),
candidate_backing: <Mapper as MapSubsystem<CB>>::map_subsystem(
&mapper,
self.candidate_backing,
),
statement_distribution: <Mapper as MapSubsystem<SD>>::map_subsystem(
&mapper,
self.statement_distribution,
),
availability_distribution: <Mapper as MapSubsystem<AD>>::map_subsystem(
&mapper,
self.availability_distribution,
),
availability_recovery: <Mapper as MapSubsystem<AR>>::map_subsystem(
&mapper,
self.availability_recovery,
),
bitfield_signing: <Mapper as MapSubsystem<BS>>::map_subsystem(
&mapper,
self.bitfield_signing,
),
bitfield_distribution: <Mapper as MapSubsystem<BD>>::map_subsystem(
&mapper,
self.bitfield_distribution,
),
provisioner: <Mapper as MapSubsystem<P>>::map_subsystem(&mapper, self.provisioner),
runtime_api: <Mapper as MapSubsystem<RA>>::map_subsystem(&mapper, self.runtime_api),
availability_store: <Mapper as MapSubsystem<AS>>::map_subsystem(&mapper, self.availability_store),
network_bridge: <Mapper as MapSubsystem<NB>>::map_subsystem(&mapper, self.network_bridge),
availability_store: <Mapper as MapSubsystem<AS>>::map_subsystem(
&mapper,
self.availability_store,
),
network_bridge: <Mapper as MapSubsystem<NB>>::map_subsystem(
&mapper,
self.network_bridge,
),
chain_api: <Mapper as MapSubsystem<CA>>::map_subsystem(&mapper, self.chain_api),
collation_generation: <Mapper as MapSubsystem<CG>>::map_subsystem(&mapper, self.collation_generation),
collator_protocol: <Mapper as MapSubsystem<CP>>::map_subsystem(&mapper, self.collator_protocol),
approval_distribution: <Mapper as MapSubsystem<ApD>>::map_subsystem(&mapper, self.approval_distribution),
approval_voting: <Mapper as MapSubsystem<ApV>>::map_subsystem(&mapper, self.approval_voting),
gossip_support: <Mapper as MapSubsystem<GS>>::map_subsystem(&mapper, self.gossip_support),
dispute_coordinator: <Mapper as MapSubsystem<DC>>::map_subsystem(&mapper, self.dispute_coordinator),
dispute_participation: <Mapper as MapSubsystem<DP>>::map_subsystem(&mapper, self.dispute_participation),
dispute_distribution: <Mapper as MapSubsystem<DD>>::map_subsystem(&mapper, self.dispute_distribution),
chain_selection: <Mapper as MapSubsystem<CS>>::map_subsystem(&mapper, self.chain_selection),
collation_generation: <Mapper as MapSubsystem<CG>>::map_subsystem(
&mapper,
self.collation_generation,
),
collator_protocol: <Mapper as MapSubsystem<CP>>::map_subsystem(
&mapper,
self.collator_protocol,
),
approval_distribution: <Mapper as MapSubsystem<ApD>>::map_subsystem(
&mapper,
self.approval_distribution,
),
approval_voting: <Mapper as MapSubsystem<ApV>>::map_subsystem(
&mapper,
self.approval_voting,
),
gossip_support: <Mapper as MapSubsystem<GS>>::map_subsystem(
&mapper,
self.gossip_support,
),
dispute_coordinator: <Mapper as MapSubsystem<DC>>::map_subsystem(
&mapper,
self.dispute_coordinator,
),
dispute_participation: <Mapper as MapSubsystem<DP>>::map_subsystem(
&mapper,
self.dispute_participation,
),
dispute_distribution: <Mapper as MapSubsystem<DD>>::map_subsystem(
&mapper,
self.dispute_distribution,
),
chain_selection: <Mapper as MapSubsystem<CS>>::map_subsystem(
&mapper,
self.chain_selection,
),
}
}
}
+162 -186
View File
@@ -14,47 +14,37 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use std::sync::atomic;
use std::collections::HashMap;
use std::task::{Poll};
use futures::{executor, pin_mut, select, FutureExt, pending, poll, stream};
use futures::channel::mpsc;
use futures::{channel::mpsc, executor, pending, pin_mut, poll, select, stream, FutureExt};
use std::{collections::HashMap, sync::atomic, task::Poll};
use polkadot_primitives::v1::{CollatorPair, CandidateHash};
use polkadot_node_primitives::{CollationResult, CollationGenerationConfig, PoV, BlockData};
use polkadot_node_network_protocol::{PeerId, UnifiedReputationChange};
use polkadot_node_primitives::{BlockData, CollationGenerationConfig, CollationResult, PoV};
use polkadot_node_subsystem_types::{
ActivatedLeaf, LeafStatus,
messages::{
RuntimeApiRequest,
NetworkBridgeEvent,
},
jaeger,
messages::{NetworkBridgeEvent, RuntimeApiRequest},
ActivatedLeaf, LeafStatus,
};
use polkadot_primitives::v1::{CandidateHash, CollatorPair};
use crate::{
self as overseer,
Overseer,
HeadSupportsParachains,
gen::Delay,
};
use crate::{self as overseer, gen::Delay, HeadSupportsParachains, Overseer};
use metered_channel as metered;
use sp_core::crypto::Pair as _;
use assert_matches::assert_matches;
use sp_core::crypto::Pair as _;
use super::*;
type SpawnedSubsystem = crate::gen::SpawnedSubsystem<SubsystemError>;
struct TestSubsystem1(metered::MeteredSender<usize>);
impl<C> overseer::Subsystem<C, SubsystemError> for TestSubsystem1
where
C: overseer::SubsystemContext<Message=CandidateValidationMessage,Signal=OverseerSignal,AllMessages=AllMessages>,
C: overseer::SubsystemContext<
Message = CandidateValidationMessage,
Signal = OverseerSignal,
AllMessages = AllMessages,
>,
{
fn start(self, mut ctx: C) -> SpawnedSubsystem {
let mut sender = self.0;
@@ -67,8 +57,8 @@ where
Ok(FromOverseer::Communication { .. }) => {
let _ = sender.send(i).await;
i += 1;
continue;
}
continue
},
Ok(FromOverseer::Signal(OverseerSignal::Conclude)) => return Ok(()),
Err(_) => return Ok(()),
_ => (),
@@ -83,7 +73,11 @@ struct TestSubsystem2(metered::MeteredSender<usize>);
impl<C> overseer::Subsystem<C, SubsystemError> for TestSubsystem2
where
C: overseer::SubsystemContext<Message=CandidateBackingMessage,Signal=OverseerSignal,AllMessages=AllMessages>,
C: overseer::SubsystemContext<
Message = CandidateBackingMessage,
Signal = OverseerSignal,
AllMessages = AllMessages,
>,
{
fn start(self, mut ctx: C) -> SpawnedSubsystem {
let sender = self.0.clone();
@@ -95,25 +89,18 @@ where
loop {
if c < 10 {
let (tx, _) = oneshot::channel();
ctx.send_message(
CandidateValidationMessage::ValidateFromChainState(
Default::default(),
PoV {
block_data: BlockData(Vec::new()),
}.into(),
tx,
)
).await;
ctx.send_message(CandidateValidationMessage::ValidateFromChainState(
Default::default(),
PoV { block_data: BlockData(Vec::new()) }.into(),
tx,
))
.await;
c += 1;
continue;
continue
}
match ctx.try_recv().await {
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => {
break;
}
Ok(Some(_)) => {
continue;
}
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => break,
Ok(Some(_)) => continue,
Err(_) => return Ok(()),
_ => (),
}
@@ -130,7 +117,11 @@ struct ReturnOnStart;
impl<C> overseer::Subsystem<C, SubsystemError> for ReturnOnStart
where
C: overseer::SubsystemContext<Message=CandidateBackingMessage,Signal=OverseerSignal,AllMessages=AllMessages>,
C: overseer::SubsystemContext<
Message = CandidateBackingMessage,
Signal = OverseerSignal,
AllMessages = AllMessages,
>,
{
fn start(self, mut _ctx: C) -> SpawnedSubsystem {
SpawnedSubsystem {
@@ -167,13 +158,8 @@ fn overseer_works() {
.replace_candidate_validation(TestSubsystem1(s1_tx))
.replace_candidate_backing(TestSubsystem2(s2_tx));
let (overseer, handle) = Overseer::new(
vec![],
all_subsystems,
None,
MockSupportsParachains,
spawner,
).unwrap();
let (overseer, handle) =
Overseer::new(vec![], all_subsystems, None, MockSupportsParachains, spawner).unwrap();
let mut handle = Handle::Connected(handle);
let overseer_fut = overseer.run().fuse();
@@ -220,21 +206,12 @@ fn overseer_metrics_work() {
let second_block_hash = [2; 32].into();
let third_block_hash = [3; 32].into();
let first_block = BlockInfo {
hash: first_block_hash,
parent_hash: [0; 32].into(),
number: 1,
};
let second_block = BlockInfo {
hash: second_block_hash,
parent_hash: first_block_hash,
number: 2,
};
let third_block = BlockInfo {
hash: third_block_hash,
parent_hash: second_block_hash,
number: 3,
};
let first_block =
BlockInfo { hash: first_block_hash, parent_hash: [0; 32].into(), number: 1 };
let second_block =
BlockInfo { hash: second_block_hash, parent_hash: first_block_hash, number: 2 };
let third_block =
BlockInfo { hash: third_block_hash, parent_hash: second_block_hash, number: 3 };
let all_subsystems = AllSubsystems::<()>::dummy();
let registry = prometheus::Registry::new();
@@ -244,7 +221,8 @@ fn overseer_metrics_work() {
Some(&registry),
MockSupportsParachains,
spawner,
).unwrap();
)
.unwrap();
let mut handle = Handle::Connected(handle);
let overseer_fut = overseer.run().fuse();
@@ -252,7 +230,9 @@ fn overseer_metrics_work() {
handle.block_imported(second_block).await;
handle.block_imported(third_block).await;
handle.send_msg_anon(AllMessages::CandidateValidation(test_candidate_validation_msg())).await;
handle
.send_msg_anon(AllMessages::CandidateValidation(test_candidate_validation_msg()))
.await;
handle.stop().await;
select! {
@@ -291,15 +271,9 @@ fn overseer_ends_on_subsystem_exit() {
let spawner = sp_core::testing::TaskExecutor::new();
executor::block_on(async move {
let all_subsystems = AllSubsystems::<()>::dummy()
.replace_candidate_backing(ReturnOnStart);
let (overseer, _handle) = Overseer::new(
vec![],
all_subsystems,
None,
MockSupportsParachains,
spawner,
).unwrap();
let all_subsystems = AllSubsystems::<()>::dummy().replace_candidate_backing(ReturnOnStart);
let (overseer, _handle) =
Overseer::new(vec![], all_subsystems, None, MockSupportsParachains, spawner).unwrap();
overseer.run().await.unwrap();
})
@@ -309,7 +283,11 @@ struct TestSubsystem5(metered::MeteredSender<OverseerSignal>);
impl<C> overseer::Subsystem<C, SubsystemError> for TestSubsystem5
where
C: overseer::SubsystemContext<Message=CandidateValidationMessage,Signal=OverseerSignal,AllMessages=AllMessages>,
C: overseer::SubsystemContext<
Message = CandidateValidationMessage,
Signal = OverseerSignal,
AllMessages = AllMessages,
>,
{
fn start(self, mut ctx: C) -> SpawnedSubsystem {
let mut sender = self.0.clone();
@@ -322,7 +300,7 @@ where
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => break,
Ok(Some(FromOverseer::Signal(s))) => {
sender.send(s).await.unwrap();
continue;
continue
},
Ok(Some(_)) => continue,
Err(_) => break,
@@ -341,7 +319,11 @@ struct TestSubsystem6(metered::MeteredSender<OverseerSignal>);
impl<C> Subsystem<C, SubsystemError> for TestSubsystem6
where
C: overseer::SubsystemContext<Message=CandidateBackingMessage,Signal=OverseerSignal,AllMessages=AllMessages>,
C: overseer::SubsystemContext<
Message = CandidateBackingMessage,
Signal = OverseerSignal,
AllMessages = AllMessages,
>,
{
fn start(self, mut ctx: C) -> SpawnedSubsystem {
let mut sender = self.0.clone();
@@ -354,7 +336,7 @@ where
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => break,
Ok(Some(FromOverseer::Signal(s))) => {
sender.send(s).await.unwrap();
continue;
continue
},
Ok(Some(_)) => continue,
Err(_) => break,
@@ -380,34 +362,21 @@ fn overseer_start_stop_works() {
let second_block_hash = [2; 32].into();
let third_block_hash = [3; 32].into();
let first_block = BlockInfo {
hash: first_block_hash,
parent_hash: [0; 32].into(),
number: 1,
};
let second_block = BlockInfo {
hash: second_block_hash,
parent_hash: first_block_hash,
number: 2,
};
let third_block = BlockInfo {
hash: third_block_hash,
parent_hash: second_block_hash,
number: 3,
};
let first_block =
BlockInfo { hash: first_block_hash, parent_hash: [0; 32].into(), number: 1 };
let second_block =
BlockInfo { hash: second_block_hash, parent_hash: first_block_hash, number: 2 };
let third_block =
BlockInfo { hash: third_block_hash, parent_hash: second_block_hash, number: 3 };
let (tx_5, mut rx_5) = metered::channel(64);
let (tx_6, mut rx_6) = metered::channel(64);
let all_subsystems = AllSubsystems::<()>::dummy()
.replace_candidate_validation(TestSubsystem5(tx_5))
.replace_candidate_backing(TestSubsystem6(tx_6));
let (overseer, handle) = Overseer::new(
vec![first_block],
all_subsystems,
None,
MockSupportsParachains,
spawner,
).unwrap();
let (overseer, handle) =
Overseer::new(vec![first_block], all_subsystems, None, MockSupportsParachains, spawner)
.unwrap();
let mut handle = Handle::Connected(handle);
let overseer_fut = overseer.run().fuse();
@@ -466,8 +435,9 @@ fn overseer_start_stop_works() {
}
if ss5_results.len() == expected_heartbeats.len() &&
ss6_results.len() == expected_heartbeats.len() {
handle.stop().await;
ss6_results.len() == expected_heartbeats.len()
{
handle.stop().await;
}
}
@@ -487,21 +457,12 @@ fn overseer_finalize_works() {
let second_block_hash = [2; 32].into();
let third_block_hash = [3; 32].into();
let first_block = BlockInfo {
hash: first_block_hash,
parent_hash: [0; 32].into(),
number: 1,
};
let second_block = BlockInfo {
hash: second_block_hash,
parent_hash: [42; 32].into(),
number: 2,
};
let third_block = BlockInfo {
hash: third_block_hash,
parent_hash: second_block_hash,
number: 3,
};
let first_block =
BlockInfo { hash: first_block_hash, parent_hash: [0; 32].into(), number: 1 };
let second_block =
BlockInfo { hash: second_block_hash, parent_hash: [42; 32].into(), number: 2 };
let third_block =
BlockInfo { hash: third_block_hash, parent_hash: second_block_hash, number: 3 };
let (tx_5, mut rx_5) = metered::channel(64);
let (tx_6, mut rx_6) = metered::channel(64);
@@ -517,7 +478,8 @@ fn overseer_finalize_works() {
None,
MockSupportsParachains,
spawner,
).unwrap();
)
.unwrap();
let mut handle = Handle::Connected(handle);
let overseer_fut = overseer.run().fuse();
@@ -568,7 +530,9 @@ fn overseer_finalize_works() {
complete => break,
}
if ss5_results.len() == expected_heartbeats.len() && ss6_results.len() == expected_heartbeats.len() {
if ss5_results.len() == expected_heartbeats.len() &&
ss6_results.len() == expected_heartbeats.len()
{
handle.stop().await;
}
}
@@ -590,30 +554,20 @@ fn do_not_send_empty_leaves_update_on_block_finalization() {
let spawner = sp_core::testing::TaskExecutor::new();
executor::block_on(async move {
let imported_block = BlockInfo {
hash: Hash::random(),
parent_hash: Hash::random(),
number: 1,
};
let imported_block =
BlockInfo { hash: Hash::random(), parent_hash: Hash::random(), number: 1 };
let finalized_block = BlockInfo {
hash: Hash::random(),
parent_hash: Hash::random(),
number: 1,
};
let finalized_block =
BlockInfo { hash: Hash::random(), parent_hash: Hash::random(), number: 1 };
let (tx_5, mut rx_5) = metered::channel(64);
let all_subsystems = AllSubsystems::<()>::dummy()
.replace_candidate_backing(TestSubsystem6(tx_5));
let all_subsystems =
AllSubsystems::<()>::dummy().replace_candidate_backing(TestSubsystem6(tx_5));
let (overseer, handle) = Overseer::new(
Vec::new(),
all_subsystems,
None,
MockSupportsParachains,
spawner,
).unwrap();
let (overseer, handle) =
Overseer::new(Vec::new(), all_subsystems, None, MockSupportsParachains, spawner)
.unwrap();
let mut handle = Handle::Connected(handle);
let overseer_fut = overseer.run().fuse();
@@ -673,17 +627,13 @@ impl CounterSubsystem {
signals_received: Arc<atomic::AtomicUsize>,
msgs_received: Arc<atomic::AtomicUsize>,
) -> Self {
Self {
stop_signals_received,
signals_received,
msgs_received,
}
Self { stop_signals_received, signals_received, msgs_received }
}
}
impl<C, M> Subsystem<C, SubsystemError> for CounterSubsystem
where
C: overseer::SubsystemContext<Message=M,Signal=OverseerSignal,AllMessages=AllMessages>,
C: overseer::SubsystemContext<Message = M, Signal = OverseerSignal, AllMessages = AllMessages>,
M: Send,
{
fn start(self, mut ctx: C) -> SpawnedSubsystem {
@@ -694,15 +644,15 @@ where
match ctx.try_recv().await {
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => {
self.stop_signals_received.fetch_add(1, atomic::Ordering::SeqCst);
break;
break
},
Ok(Some(FromOverseer::Signal(_))) => {
self.signals_received.fetch_add(1, atomic::Ordering::SeqCst);
continue;
continue
},
Ok(Some(FromOverseer::Communication { .. })) => {
self.msgs_received.fetch_add(1, atomic::Ordering::SeqCst);
continue;
continue
},
Err(_) => (),
_ => (),
@@ -872,47 +822,74 @@ fn overseer_all_subsystems_receive_signals_and_messages() {
dispute_distribution: subsystem.clone(),
chain_selection: subsystem.clone(),
};
let (overseer, handle) = Overseer::new(
vec![],
all_subsystems,
None,
MockSupportsParachains,
spawner,
).unwrap();
let (overseer, handle) =
Overseer::new(vec![], all_subsystems, None, MockSupportsParachains, spawner).unwrap();
let mut handle = Handle::Connected(handle);
let overseer_fut = overseer.run().fuse();
pin_mut!(overseer_fut);
// send a signal to each subsystem
handle.block_imported(BlockInfo {
hash: Default::default(),
parent_hash: Default::default(),
number: Default::default(),
}).await;
handle
.block_imported(BlockInfo {
hash: Default::default(),
parent_hash: Default::default(),
number: Default::default(),
})
.await;
// send a msg to each subsystem
// except for BitfieldSigning and GossipSupport as the messages are not instantiable
handle.send_msg_anon(AllMessages::CandidateValidation(test_candidate_validation_msg())).await;
handle.send_msg_anon(AllMessages::CandidateBacking(test_candidate_backing_msg())).await;
handle.send_msg_anon(AllMessages::CollationGeneration(test_collator_generation_msg())).await;
handle.send_msg_anon(AllMessages::CollatorProtocol(test_collator_protocol_msg())).await;
handle.send_msg_anon(AllMessages::StatementDistribution(test_statement_distribution_msg())).await;
handle.send_msg_anon(AllMessages::AvailabilityRecovery(test_availability_recovery_msg())).await;
handle
.send_msg_anon(AllMessages::CandidateValidation(test_candidate_validation_msg()))
.await;
handle
.send_msg_anon(AllMessages::CandidateBacking(test_candidate_backing_msg()))
.await;
handle
.send_msg_anon(AllMessages::CollationGeneration(test_collator_generation_msg()))
.await;
handle
.send_msg_anon(AllMessages::CollatorProtocol(test_collator_protocol_msg()))
.await;
handle
.send_msg_anon(AllMessages::StatementDistribution(test_statement_distribution_msg()))
.await;
handle
.send_msg_anon(AllMessages::AvailabilityRecovery(test_availability_recovery_msg()))
.await;
// handle.send_msg_anon(AllMessages::BitfieldSigning(test_bitfield_signing_msg())).await;
// handle.send_msg_anon(AllMessages::GossipSupport(test_bitfield_signing_msg())).await;
handle.send_msg_anon(AllMessages::BitfieldDistribution(test_bitfield_distribution_msg())).await;
handle
.send_msg_anon(AllMessages::BitfieldDistribution(test_bitfield_distribution_msg()))
.await;
handle.send_msg_anon(AllMessages::Provisioner(test_provisioner_msg())).await;
handle.send_msg_anon(AllMessages::RuntimeApi(test_runtime_api_msg())).await;
handle.send_msg_anon(AllMessages::AvailabilityStore(test_availability_store_msg())).await;
handle.send_msg_anon(AllMessages::NetworkBridge(test_network_bridge_msg())).await;
handle
.send_msg_anon(AllMessages::AvailabilityStore(test_availability_store_msg()))
.await;
handle
.send_msg_anon(AllMessages::NetworkBridge(test_network_bridge_msg()))
.await;
handle.send_msg_anon(AllMessages::ChainApi(test_chain_api_msg())).await;
handle.send_msg_anon(AllMessages::ApprovalDistribution(test_approval_distribution_msg())).await;
handle.send_msg_anon(AllMessages::ApprovalVoting(test_approval_voting_msg())).await;
handle.send_msg_anon(AllMessages::DisputeCoordinator(test_dispute_coordinator_msg())).await;
handle.send_msg_anon(AllMessages::DisputeParticipation(test_dispute_participation_msg())).await;
handle.send_msg_anon(AllMessages::DisputeDistribution(test_dispute_distribution_msg())).await;
handle.send_msg_anon(AllMessages::ChainSelection(test_chain_selection_msg())).await;
handle
.send_msg_anon(AllMessages::ApprovalDistribution(test_approval_distribution_msg()))
.await;
handle
.send_msg_anon(AllMessages::ApprovalVoting(test_approval_voting_msg()))
.await;
handle
.send_msg_anon(AllMessages::DisputeCoordinator(test_dispute_coordinator_msg()))
.await;
handle
.send_msg_anon(AllMessages::DisputeParticipation(test_dispute_participation_msg()))
.await;
handle
.send_msg_anon(AllMessages::DisputeDistribution(test_dispute_distribution_msg()))
.await;
handle
.send_msg_anon(AllMessages::ChainSelection(test_chain_selection_msg()))
.await;
// Wait until all subsystems have received. Otherwise the messages might race against
// the conclude signal.
@@ -927,7 +904,7 @@ fn overseer_all_subsystems_receive_signals_and_messages() {
} else {
break
}
}
},
Some(_) => panic!("exited too early"),
}
}
@@ -1055,17 +1032,16 @@ fn context_holds_onto_message_until_enough_signals_received() {
assert_matches!(ctx.recv().await.unwrap(), FromOverseer::Signal(OverseerSignal::Conclude));
assert_eq!(ctx.signals_received.load(), 1);
bounded_tx.send(MessagePacket {
signals_received: 2,
message: (),
}).await.unwrap();
unbounded_tx.unbounded_send(MessagePacket {
signals_received: 2,
message: (),
}).unwrap();
bounded_tx
.send(MessagePacket { signals_received: 2, message: () })
.await
.unwrap();
unbounded_tx
.unbounded_send(MessagePacket { signals_received: 2, message: () })
.unwrap();
match poll!(ctx.recv()) {
Poll::Pending => {}
Poll::Pending => {},
Poll::Ready(_) => panic!("ready too early"),
};