mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +00:00
overseer becomes orchestra (#5542)
* rename overseer-gen to orchestra Also drop `gum` and use `tracing`. * make orchestra compile as standalone * introduce Spawner trait to split from sp_core Finalizes the independence of orchestra from polkadot-overseer * slip of the pen * other fixins * remove unused import * Update node/overseer/orchestra/proc-macro/src/impl_builder.rs Co-authored-by: Vsevolod Stakhov <vsevolod.stakhov@parity.io> * Update node/overseer/orchestra/proc-macro/src/impl_builder.rs Co-authored-by: Vsevolod Stakhov <vsevolod.stakhov@parity.io> * orchestra everywhere * leaky data * Bump scale-info from 2.1.1 to 2.1.2 (#5552) Bumps [scale-info](https://github.com/paritytech/scale-info) from 2.1.1 to 2.1.2. - [Release notes](https://github.com/paritytech/scale-info/releases) - [Changelog](https://github.com/paritytech/scale-info/blob/master/CHANGELOG.md) - [Commits](https://github.com/paritytech/scale-info/compare/v2.1.1...v2.1.2) --- updated-dependencies: - dependency-name: scale-info dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add missing markdown code block delimiter (#5555) * bitfield-signing: remove util::jobs usage (#5523) * Switch to pooling copy-on-write instantiation strategy for WASM (companion for Substrate#11232) (#5337) * Switch to pooling copy-on-write instantiation strategy for WASM * Fix compilation of `polkadot-test-service` * Update comments * Move `max_memory_size` to `Semantics` * Rename `WasmInstantiationStrategy` to `WasmtimeInstantiationStrategy` * Update a safety comment * update lockfile for {"substrate"} Co-authored-by: parity-processbot <> * Fix build Co-authored-by: Vsevolod Stakhov <vsevolod.stakhov@parity.io> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Malte Kliemann <mail@maltekliemann.com> Co-authored-by: Chris Sosnin <48099298+slumber@users.noreply.github.com> Co-authored-by: Koute <koute@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d9eff4ecd4
commit
450ca2baca
@@ -16,13 +16,12 @@
|
||||
|
||||
use crate::{
|
||||
prometheus::Registry, HeadSupportsParachains, InitializedOverseerBuilder, MetricsTrait,
|
||||
Overseer, OverseerMetrics, OverseerSignal, OverseerSubsystemContext, SpawnNamed,
|
||||
Overseer, OverseerMetrics, OverseerSignal, OverseerSubsystemContext, SpawnGlue,
|
||||
KNOWN_LEAVES_CACHE_SIZE,
|
||||
};
|
||||
use lru::LruCache;
|
||||
use orchestra::{FromOrchestra, SpawnedSubsystem, Subsystem, SubsystemContext};
|
||||
use polkadot_node_subsystem_types::{errors::SubsystemError, messages::*};
|
||||
use polkadot_overseer_gen::{FromOverseer, SpawnedSubsystem, Subsystem, SubsystemContext};
|
||||
|
||||
/// A dummy subsystem that implements [`Subsystem`] for all
|
||||
/// types of messages. Used for tests or as a placeholder.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
@@ -37,7 +36,7 @@ where
|
||||
loop {
|
||||
match ctx.recv().await {
|
||||
Err(_) => return Ok(()),
|
||||
Ok(FromOverseer::Signal(OverseerSignal::Conclude)) => return Ok(()),
|
||||
Ok(FromOrchestra::Signal(OverseerSignal::Conclude)) => return Ok(()),
|
||||
Ok(overseer_msg) => {
|
||||
gum::debug!(
|
||||
target: "dummy-subsystem",
|
||||
@@ -63,7 +62,7 @@ pub fn dummy_overseer_builder<'a, Spawner, SupportsParachains>(
|
||||
registry: Option<&'a Registry>,
|
||||
) -> Result<
|
||||
InitializedOverseerBuilder<
|
||||
Spawner,
|
||||
SpawnGlue<Spawner>,
|
||||
SupportsParachains,
|
||||
DummySubsystem,
|
||||
DummySubsystem,
|
||||
@@ -90,7 +89,7 @@ pub fn dummy_overseer_builder<'a, Spawner, SupportsParachains>(
|
||||
SubsystemError,
|
||||
>
|
||||
where
|
||||
Spawner: SpawnNamed + Send + Sync + 'static,
|
||||
SpawnGlue<Spawner>: orchestra::Spawner + 'static,
|
||||
SupportsParachains: HeadSupportsParachains,
|
||||
{
|
||||
one_for_all_overseer_builder(spawner, supports_parachains, DummySubsystem, registry)
|
||||
@@ -104,7 +103,7 @@ pub fn one_for_all_overseer_builder<'a, Spawner, SupportsParachains, Sub>(
|
||||
registry: Option<&'a Registry>,
|
||||
) -> Result<
|
||||
InitializedOverseerBuilder<
|
||||
Spawner,
|
||||
SpawnGlue<Spawner>,
|
||||
SupportsParachains,
|
||||
Sub,
|
||||
Sub,
|
||||
@@ -131,7 +130,7 @@ pub fn one_for_all_overseer_builder<'a, Spawner, SupportsParachains, Sub>(
|
||||
SubsystemError,
|
||||
>
|
||||
where
|
||||
Spawner: SpawnNamed + Send + Sync + 'static,
|
||||
SpawnGlue<Spawner>: orchestra::Spawner + 'static,
|
||||
SupportsParachains: HeadSupportsParachains,
|
||||
Sub: Clone
|
||||
+ Subsystem<OverseerSubsystemContext<AvailabilityDistributionMessage>, SubsystemError>
|
||||
@@ -185,7 +184,7 @@ where
|
||||
.active_leaves(Default::default())
|
||||
.known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE))
|
||||
.leaves(Default::default())
|
||||
.spawner(spawner)
|
||||
.spawner(SpawnGlue(spawner))
|
||||
.metrics(metrics)
|
||||
.supports_parachains(supports_parachains);
|
||||
Ok(builder)
|
||||
|
||||
@@ -105,11 +105,12 @@ pub use polkadot_node_metrics::{
|
||||
|
||||
use parity_util_mem::MemoryAllocationTracker;
|
||||
|
||||
pub use polkadot_overseer_gen as gen;
|
||||
pub use polkadot_overseer_gen::{
|
||||
contextbounds, overlord, subsystem, FromOverseer, MapSubsystem, MessagePacket, SignalsReceived,
|
||||
SpawnNamed, Subsystem, SubsystemContext, SubsystemIncomingMessages, SubsystemInstance,
|
||||
SubsystemMeterReadouts, SubsystemMeters, SubsystemSender, TimeoutExt, ToOverseer,
|
||||
pub use orchestra as gen;
|
||||
pub use orchestra::{
|
||||
contextbounds, orchestra, subsystem, FromOrchestra, MapSubsystem, MessagePacket,
|
||||
SignalsReceived, Spawner, Subsystem, SubsystemContext, SubsystemIncomingMessages,
|
||||
SubsystemInstance, SubsystemMeterReadouts, SubsystemMeters, SubsystemSender, TimeoutExt,
|
||||
ToOrchestra,
|
||||
};
|
||||
|
||||
/// Store 2 days worth of blocks, not accounting for forks,
|
||||
@@ -119,6 +120,42 @@ pub const KNOWN_LEAVES_CACHE_SIZE: usize = 2 * 24 * 3600 / 6;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use sp_core::traits::SpawnNamed;
|
||||
|
||||
/// Glue to connect `trait orchestra::Spawner` and `SpawnNamed` from `substrate`.
|
||||
pub struct SpawnGlue<S>(pub S);
|
||||
|
||||
impl<S> AsRef<S> for SpawnGlue<S> {
|
||||
fn as_ref(&self) -> &S {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Clone> Clone for SpawnGlue<S> {
|
||||
fn clone(&self) -> Self {
|
||||
Self(self.0.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: SpawnNamed + Clone + Send + Sync> crate::gen::Spawner for SpawnGlue<S> {
|
||||
fn spawn_blocking(
|
||||
&self,
|
||||
name: &'static str,
|
||||
group: Option<&'static str>,
|
||||
future: futures::future::BoxFuture<'static, ()>,
|
||||
) {
|
||||
SpawnNamed::spawn_blocking(&self.0, name, group, future)
|
||||
}
|
||||
fn spawn(
|
||||
&self,
|
||||
name: &'static str,
|
||||
group: Option<&'static str>,
|
||||
future: futures::future::BoxFuture<'static, ()>,
|
||||
) {
|
||||
SpawnNamed::spawn(&self.0, name, group, future)
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a header supports parachain consensus or not.
|
||||
pub trait HeadSupportsParachains {
|
||||
/// Return true if the given header supports parachain consensus. Otherwise, false.
|
||||
@@ -346,7 +383,7 @@ pub async fn forward_events<P: BlockchainEvents<Block>>(client: Arc<P>, mut hand
|
||||
/// # SubsystemError,
|
||||
/// # gen::{
|
||||
/// # SubsystemContext,
|
||||
/// # FromOverseer,
|
||||
/// # FromOrchestra,
|
||||
/// # SpawnedSubsystem,
|
||||
/// # },
|
||||
/// # };
|
||||
@@ -408,7 +445,7 @@ pub async fn forward_events<P: BlockchainEvents<Block>>(client: Arc<P>, mut hand
|
||||
/// # });
|
||||
/// # }
|
||||
/// ```
|
||||
#[overlord(
|
||||
#[orchestra(
|
||||
gen=AllMessages,
|
||||
event=Event,
|
||||
signal=OverseerSignal,
|
||||
@@ -594,15 +631,15 @@ pub fn spawn_metronome_metrics<S, SupportsParachains>(
|
||||
metronome_metrics: OverseerMetrics,
|
||||
) -> Result<(), SubsystemError>
|
||||
where
|
||||
S: SpawnNamed,
|
||||
S: Spawner,
|
||||
SupportsParachains: HeadSupportsParachains,
|
||||
{
|
||||
struct ExtractNameAndMeters;
|
||||
|
||||
impl<'a, T: 'a> MapSubsystem<&'a OverseenSubsystem<T>> for ExtractNameAndMeters {
|
||||
impl<'a, T: 'a> MapSubsystem<&'a OrchestratedSubsystem<T>> for ExtractNameAndMeters {
|
||||
type Output = Option<(&'static str, SubsystemMeters)>;
|
||||
|
||||
fn map_subsystem(&self, subsystem: &'a OverseenSubsystem<T>) -> Self::Output {
|
||||
fn map_subsystem(&self, subsystem: &'a OrchestratedSubsystem<T>) -> Self::Output {
|
||||
subsystem
|
||||
.instance
|
||||
.as_ref()
|
||||
@@ -662,7 +699,7 @@ where
|
||||
impl<S, SupportsParachains> Overseer<S, SupportsParachains>
|
||||
where
|
||||
SupportsParachains: HeadSupportsParachains,
|
||||
S: SpawnNamed,
|
||||
S: Spawner,
|
||||
{
|
||||
/// Stop the `Overseer`.
|
||||
async fn stop(mut self) {
|
||||
@@ -707,12 +744,12 @@ where
|
||||
}
|
||||
}
|
||||
},
|
||||
msg = self.to_overseer_rx.select_next_some() => {
|
||||
msg = self.to_orchestra_rx.select_next_some() => {
|
||||
match msg {
|
||||
ToOverseer::SpawnJob { name, subsystem, s } => {
|
||||
ToOrchestra::SpawnJob { name, subsystem, s } => {
|
||||
self.spawn_job(name, subsystem, s);
|
||||
}
|
||||
ToOverseer::SpawnBlockingJob { name, subsystem, s } => {
|
||||
ToOrchestra::SpawnBlockingJob { name, subsystem, s } => {
|
||||
self.spawn_blocking_job(name, subsystem, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ where
|
||||
let mut i = 0;
|
||||
loop {
|
||||
match ctx.recv().await {
|
||||
Ok(FromOverseer::Communication { .. }) => {
|
||||
Ok(FromOrchestra::Communication { .. }) => {
|
||||
let _ = sender.send(i).await;
|
||||
i += 1;
|
||||
continue
|
||||
},
|
||||
Ok(FromOverseer::Signal(OverseerSignal::Conclude)) => return Ok(()),
|
||||
Ok(FromOrchestra::Signal(OverseerSignal::Conclude)) => return Ok(()),
|
||||
Err(_) => return Ok(()),
|
||||
_ => (),
|
||||
}
|
||||
@@ -121,7 +121,7 @@ where
|
||||
continue
|
||||
}
|
||||
match ctx.try_recv().await {
|
||||
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => break,
|
||||
Ok(Some(FromOrchestra::Signal(OverseerSignal::Conclude))) => break,
|
||||
Ok(Some(_)) => continue,
|
||||
Err(_) => return Ok(()),
|
||||
_ => (),
|
||||
@@ -318,8 +318,8 @@ where
|
||||
future: Box::pin(async move {
|
||||
loop {
|
||||
match ctx.try_recv().await {
|
||||
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => break,
|
||||
Ok(Some(FromOverseer::Signal(s))) => {
|
||||
Ok(Some(FromOrchestra::Signal(OverseerSignal::Conclude))) => break,
|
||||
Ok(Some(FromOrchestra::Signal(s))) => {
|
||||
sender.send(s).await.unwrap();
|
||||
continue
|
||||
},
|
||||
@@ -350,8 +350,8 @@ where
|
||||
future: Box::pin(async move {
|
||||
loop {
|
||||
match ctx.try_recv().await {
|
||||
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => break,
|
||||
Ok(Some(FromOverseer::Signal(s))) => {
|
||||
Ok(Some(FromOrchestra::Signal(OverseerSignal::Conclude))) => break,
|
||||
Ok(Some(FromOrchestra::Signal(s))) => {
|
||||
sender.send(s).await.unwrap();
|
||||
continue
|
||||
},
|
||||
@@ -754,15 +754,15 @@ where
|
||||
future: Box::pin(async move {
|
||||
loop {
|
||||
match ctx.try_recv().await {
|
||||
Ok(Some(FromOverseer::Signal(OverseerSignal::Conclude))) => {
|
||||
Ok(Some(FromOrchestra::Signal(OverseerSignal::Conclude))) => {
|
||||
self.stop_signals_received.fetch_add(1, atomic::Ordering::SeqCst);
|
||||
break
|
||||
},
|
||||
Ok(Some(FromOverseer::Signal(_))) => {
|
||||
Ok(Some(FromOrchestra::Signal(_))) => {
|
||||
self.signals_received.fetch_add(1, atomic::Ordering::SeqCst);
|
||||
continue
|
||||
},
|
||||
Ok(Some(FromOverseer::Communication { .. })) => {
|
||||
Ok(Some(FromOrchestra::Communication { .. })) => {
|
||||
self.msgs_received.fetch_add(1, atomic::Ordering::SeqCst);
|
||||
continue
|
||||
},
|
||||
@@ -1139,7 +1139,7 @@ fn context_holds_onto_message_until_enough_signals_received() {
|
||||
|
||||
let test_fut = async move {
|
||||
signal_tx.send(OverseerSignal::Conclude).await.unwrap();
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOverseer::Signal(OverseerSignal::Conclude));
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOrchestra::Signal(OverseerSignal::Conclude));
|
||||
|
||||
assert_eq!(ctx.signals_received.load(), 1);
|
||||
bounded_tx
|
||||
@@ -1158,9 +1158,9 @@ fn context_holds_onto_message_until_enough_signals_received() {
|
||||
assert!(ctx.pending_incoming.is_some());
|
||||
|
||||
signal_tx.send(OverseerSignal::Conclude).await.unwrap();
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOverseer::Signal(OverseerSignal::Conclude));
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOverseer::Communication { msg: () });
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOverseer::Communication { msg: () });
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOrchestra::Signal(OverseerSignal::Conclude));
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOrchestra::Communication { msg: () });
|
||||
assert_matches!(ctx.recv().await.unwrap(), FromOrchestra::Communication { msg: () });
|
||||
assert!(ctx.pending_incoming.is_none());
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user