Remove real-overseer 🎉 (#2834)

* remove real-overseer

* overseer: only activate leaves which support parachains

* integrate HeadSupportsParachains into service

* remove unneeded line
This commit is contained in:
Robert Habermeier
2021-04-08 20:24:06 +02:00
committed by GitHub
parent a345e2a83e
commit 57038b2e46
19 changed files with 135 additions and 165 deletions
-2
View File
@@ -176,11 +176,9 @@ build-linux-release:
# extra features when building on `rococo-v1` branch and manual build on PRs # extra features when building on `rococo-v1` branch and manual build on PRs
- if: $CI_COMMIT_REF_NAME == "rococo-v1" - if: $CI_COMMIT_REF_NAME == "rococo-v1"
variables: variables:
EXTRA_FLAGS: "--features=real-overseer"
RUSTFLAGS: "-Cdebug-assertions=y" RUSTFLAGS: "-Cdebug-assertions=y"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
variables: variables:
EXTRA_FLAGS: "--features=real-overseer"
RUSTFLAGS: "-Cdebug-assertions=y" RUSTFLAGS: "-Cdebug-assertions=y"
- when: always - when: always
script: script:
+1
View File
@@ -6059,6 +6059,7 @@ dependencies = [
"polkadot-node-subsystem-util", "polkadot-node-subsystem-util",
"polkadot-primitives", "polkadot-primitives",
"sc-client-api", "sc-client-api",
"sp-api",
"sp-core", "sp-core",
"tracing", "tracing",
] ]
-1
View File
@@ -95,7 +95,6 @@ panic = "unwind"
[features] [features]
runtime-benchmarks=["cli/runtime-benchmarks"] runtime-benchmarks=["cli/runtime-benchmarks"]
real-overseer=["cli/real-overseer"]
try-runtime = ["cli/try-runtime"] try-runtime = ["cli/try-runtime"]
# Configuration for building a .deb package - for use with `cargo-deb` # Configuration for building a .deb package - for use with `cargo-deb`
-1
View File
@@ -58,5 +58,4 @@ browser = [
runtime-benchmarks = [ "service/runtime-benchmarks" ] runtime-benchmarks = [ "service/runtime-benchmarks" ]
trie-memory-tracker = [ "sp-trie/memory-tracker" ] trie-memory-tracker = [ "sp-trie/memory-tracker" ]
full-node = [ "service/full-node" ] full-node = [ "service/full-node" ]
real-overseer = [ "service/real-overseer" ]
try-runtime = [ "service/try-runtime" ] try-runtime = [ "service/try-runtime" ]
+1
View File
@@ -7,6 +7,7 @@ edition = "2018"
[dependencies] [dependencies]
async-trait = "0.1.42" async-trait = "0.1.42"
client = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "master" } client = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
futures = "0.3.12" futures = "0.3.12"
futures-timer = "3.0.2" futures-timer = "3.0.2"
polkadot-node-primitives = { package = "polkadot-node-primitives", path = "../primitives" } polkadot-node-primitives = { package = "polkadot-node-primitives", path = "../primitives" }
@@ -27,13 +27,19 @@ use futures::{
use futures_timer::Delay; use futures_timer::Delay;
use polkadot_node_primitives::{PoV, BlockData}; use polkadot_node_primitives::{PoV, BlockData};
use polkadot_overseer::{Overseer, AllSubsystems}; use polkadot_primitives::v1::Hash;
use polkadot_overseer::{Overseer, HeadSupportsParachains, AllSubsystems};
use polkadot_subsystem::{Subsystem, SubsystemContext, SpawnedSubsystem, FromOverseer}; use polkadot_subsystem::{Subsystem, SubsystemContext, SpawnedSubsystem, FromOverseer};
use polkadot_subsystem::messages::{ use polkadot_subsystem::messages::{
CandidateValidationMessage, CandidateBackingMessage, AllMessages, CandidateValidationMessage, CandidateBackingMessage, AllMessages,
}; };
struct AlwaysSupportsParachains;
impl HeadSupportsParachains for AlwaysSupportsParachains {
fn head_supports_parachains(&self, _head: &Hash) -> bool { true }
}
struct Subsystem1; struct Subsystem1;
impl Subsystem1 { impl Subsystem1 {
@@ -146,6 +152,7 @@ fn main() {
vec![], vec![],
all_subsystems, all_subsystems,
None, None,
AlwaysSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
let overseer_fut = overseer.run().fuse(); let overseer_fut = overseer.run().fuse();
+78 -19
View File
@@ -75,8 +75,9 @@ use futures::{
}; };
use futures_timer::Delay; use futures_timer::Delay;
use polkadot_primitives::v1::{Block, BlockNumber, Hash}; use polkadot_primitives::v1::{Block, BlockId,BlockNumber, Hash, ParachainHost};
use client::{BlockImportNotification, BlockchainEvents, FinalityNotification}; use client::{BlockImportNotification, BlockchainEvents, FinalityNotification};
use sp_api::{ApiExt, ProvideRuntimeApi};
use polkadot_subsystem::messages::{ use polkadot_subsystem::messages::{
CandidateValidationMessage, CandidateBackingMessage, CandidateValidationMessage, CandidateBackingMessage,
@@ -118,6 +119,22 @@ impl<F, T, U> MapSubsystem<T> for F where F: Fn(T) -> U {
} }
} }
/// 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
Client: ProvideRuntimeApi<Block>,
Client::Api: ParachainHost<Block>,
{
fn head_supports_parachains(&self, head: &Hash) -> bool {
let id = BlockId::Hash(*head);
self.runtime_api().has_api::<dyn ParachainHost<Block>>(&id).unwrap_or(false)
}
}
/// This struct is passed as an argument to create a new instance of an [`Overseer`]. /// 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 /// As any entity that satisfies the interface may act as a [`Subsystem`] this allows
@@ -1515,7 +1532,7 @@ struct SubsystemMeterReadouts {
} }
/// The `Overseer` itself. /// The `Overseer` itself.
pub struct Overseer<S> { pub struct Overseer<S, SupportsParachains> {
/// Handles to all subsystems. /// Handles to all subsystems.
subsystems: AllSubsystems< subsystems: AllSubsystems<
OverseenSubsystem<CandidateValidationMessage>, OverseenSubsystem<CandidateValidationMessage>,
@@ -1564,6 +1581,9 @@ pub struct Overseer<S> {
/// The set of the "active leaves". /// The set of the "active leaves".
active_leaves: HashMap<Hash, BlockNumber>, active_leaves: HashMap<Hash, BlockNumber>,
/// An implementation for checking whether a header supports parachain consensus.
supports_parachains: SupportsParachains,
/// Various Prometheus metrics. /// Various Prometheus metrics.
metrics: Metrics, metrics: Metrics,
} }
@@ -1740,9 +1760,10 @@ impl fmt::Debug for Metrics {
} }
} }
impl<S> Overseer<S> impl<S, SupportsParachains> Overseer<S, SupportsParachains>
where where
S: SpawnNamed, S: SpawnNamed,
SupportsParachains: HeadSupportsParachains,
{ {
/// Create a new instance of the `Overseer` with a fixed set of [`Subsystem`]s. /// Create a new instance of the `Overseer` with a fixed set of [`Subsystem`]s.
/// ///
@@ -1778,7 +1799,8 @@ where
/// # use std::time::Duration; /// # use std::time::Duration;
/// # use futures::{executor, pin_mut, select, FutureExt}; /// # use futures::{executor, pin_mut, select, FutureExt};
/// # use futures_timer::Delay; /// # use futures_timer::Delay;
/// # use polkadot_overseer::{Overseer, AllSubsystems}; /// # use polkadot_overseer::{Overseer, HeadSupportsParachains, AllSubsystems};
/// # use polkadot_primitives::v1::Hash;
/// # use polkadot_subsystem::{ /// # use polkadot_subsystem::{
/// # Subsystem, DummySubsystem, SpawnedSubsystem, SubsystemContext, /// # Subsystem, DummySubsystem, SpawnedSubsystem, SubsystemContext,
/// # messages::CandidateValidationMessage, /// # messages::CandidateValidationMessage,
@@ -1805,12 +1827,18 @@ where
/// } /// }
/// ///
/// # fn main() { executor::block_on(async move { /// # fn main() { executor::block_on(async move {
///
/// struct AlwaysSupportsParachains;
/// impl HeadSupportsParachains for AlwaysSupportsParachains {
/// fn head_supports_parachains(&self, _head: &Hash) -> bool { true }
/// }
/// let spawner = sp_core::testing::TaskExecutor::new(); /// let spawner = sp_core::testing::TaskExecutor::new();
/// let all_subsystems = AllSubsystems::<()>::dummy().replace_candidate_validation(ValidationSubsystem); /// let all_subsystems = AllSubsystems::<()>::dummy().replace_candidate_validation(ValidationSubsystem);
/// let (overseer, _handler) = Overseer::new( /// let (overseer, _handler) = Overseer::new(
/// vec![], /// vec![],
/// all_subsystems, /// all_subsystems,
/// None, /// None,
/// AlwaysSupportsParachains,
/// spawner, /// spawner,
/// ).unwrap(); /// ).unwrap();
/// ///
@@ -1831,6 +1859,7 @@ where
leaves: impl IntoIterator<Item = BlockInfo>, leaves: impl IntoIterator<Item = BlockInfo>,
all_subsystems: AllSubsystems<CV, CB, CS, SD, AD, AR, BS, BD, P, RA, AS, NB, CA, CG, CP, ApD, ApV, GS>, all_subsystems: AllSubsystems<CV, CB, CS, SD, AD, AR, BS, BD, P, RA, AS, NB, CA, CG, CP, ApD, ApV, GS>,
prometheus_registry: Option<&prometheus::Registry>, prometheus_registry: Option<&prometheus::Registry>,
supports_parachains: SupportsParachains,
mut s: S, mut s: S,
) -> SubsystemResult<(Self, OverseerHandler)> ) -> SubsystemResult<(Self, OverseerHandler)>
where where
@@ -2289,6 +2318,7 @@ where
active_leaves, active_leaves,
metrics, metrics,
span_per_active_leaf: Default::default(), span_per_active_leaf: Default::default(),
supports_parachains,
}; };
Ok((this, handler)) Ok((this, handler))
@@ -2337,12 +2367,13 @@ where
for (hash, number) in std::mem::take(&mut self.leaves) { for (hash, number) in std::mem::take(&mut self.leaves) {
let _ = self.active_leaves.insert(hash, number); let _ = self.active_leaves.insert(hash, number);
let span = self.on_head_activated(&hash, None); if let Some(span) = self.on_head_activated(&hash, None) {
update.activated.push(ActivatedLeaf { update.activated.push(ActivatedLeaf {
hash, hash,
number, number,
span, span,
}); });
}
} }
if !update.is_empty() { if !update.is_empty() {
@@ -2421,12 +2452,14 @@ where
} }
}; };
let span = self.on_head_activated(&block.hash, Some(block.parent_hash)); let mut update = match self.on_head_activated(&block.hash, Some(block.parent_hash)) {
let mut update = ActiveLeavesUpdate::start_work(ActivatedLeaf { Some(span) => ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: block.hash, hash: block.hash,
number: block.number, number: block.number,
span span
}); }),
None => ActiveLeavesUpdate::default(),
};
if let Some(number) = self.active_leaves.remove(&block.parent_hash) { if let Some(number) = self.active_leaves.remove(&block.parent_hash) {
debug_assert_eq!(block.number.saturating_sub(1), number); debug_assert_eq!(block.number.saturating_sub(1), number);
@@ -2436,7 +2469,11 @@ where
self.clean_up_external_listeners(); self.clean_up_external_listeners();
self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await if !update.is_empty() {
self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await
} else {
Ok(())
}
} }
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))] #[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
@@ -2555,8 +2592,16 @@ where
Ok(()) Ok(())
} }
/// Handles a header activation. If the header's state doesn't support the parachains API,
/// this returns `None`.
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))] #[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
fn on_head_activated(&mut self, hash: &Hash, parent_hash: Option<Hash>) -> Arc<jaeger::Span> { fn on_head_activated(&mut self, hash: &Hash, parent_hash: Option<Hash>)
-> Option<Arc<jaeger::Span>>
{
if !self.supports_parachains.head_supports_parachains(hash) {
return None;
}
self.metrics.on_head_activated(); self.metrics.on_head_activated();
if let Some(listeners) = self.activation_external_listeners.remove(hash) { if let Some(listeners) = self.activation_external_listeners.remove(hash) {
for listener in listeners { for listener in listeners {
@@ -2573,7 +2618,7 @@ where
let span = Arc::new(span); let span = Arc::new(span);
self.span_per_active_leaf.insert(*hash, span.clone()); self.span_per_active_leaf.insert(*hash, span.clone());
span Some(span)
} }
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))] #[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
@@ -2786,6 +2831,13 @@ mod tests {
} }
} }
struct MockSupportsParachains;
impl HeadSupportsParachains for MockSupportsParachains {
fn head_supports_parachains(&self, _head: &Hash) -> bool {
true
}
}
// Checks that a minimal configuration of two jobs can run and exchange messages. // Checks that a minimal configuration of two jobs can run and exchange messages.
#[test] #[test]
@@ -2807,6 +2859,7 @@ mod tests {
vec![], vec![],
all_subsystems, all_subsystems,
None, None,
MockSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
let overseer_fut = overseer.run().fuse(); let overseer_fut = overseer.run().fuse();
@@ -2876,6 +2929,7 @@ mod tests {
vec![first_block], vec![first_block],
all_subsystems, all_subsystems,
Some(&registry), Some(&registry),
MockSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
let overseer_fut = overseer.run().fuse(); let overseer_fut = overseer.run().fuse();
@@ -2929,6 +2983,7 @@ mod tests {
vec![], vec![],
all_subsystems, all_subsystems,
None, None,
MockSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
@@ -3034,6 +3089,7 @@ mod tests {
vec![first_block], vec![first_block],
all_subsystems, all_subsystems,
None, None,
MockSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
@@ -3139,6 +3195,7 @@ mod tests {
vec![first_block, second_block], vec![first_block, second_block],
all_subsystems, all_subsystems,
None, None,
MockSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
@@ -3236,6 +3293,7 @@ mod tests {
Vec::new(), Vec::new(),
all_subsystems, all_subsystems,
None, None,
MockSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
@@ -3479,6 +3537,7 @@ mod tests {
vec![], vec![],
all_subsystems, all_subsystems,
None, None,
MockSupportsParachains,
spawner, spawner,
).unwrap(); ).unwrap();
let overseer_fut = overseer.run().fuse(); let overseer_fut = overseer.run().fuse();
+15 -19
View File
@@ -113,25 +113,6 @@ db = ["service/db"]
full-node = [ full-node = [
"polkadot-node-core-av-store", "polkadot-node-core-av-store",
"polkadot-node-core-approval-voting", "polkadot-node-core-approval-voting",
"sc-finality-grandpa-warp-sync",
"kvdb-rocksdb"
]
runtime-benchmarks = [
"polkadot-runtime/runtime-benchmarks",
"kusama-runtime/runtime-benchmarks",
"westend-runtime/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks"
]
try-runtime = [
"polkadot-runtime/try-runtime",
"kusama-runtime/try-runtime",
"westend-runtime/try-runtime",
"rococo-runtime/try-runtime",
]
real-overseer = [
"full-node",
"polkadot-availability-bitfield-distribution", "polkadot-availability-bitfield-distribution",
"polkadot-availability-distribution", "polkadot-availability-distribution",
"polkadot-availability-recovery", "polkadot-availability-recovery",
@@ -148,4 +129,19 @@ real-overseer = [
"polkadot-node-core-runtime-api", "polkadot-node-core-runtime-api",
"polkadot-statement-distribution", "polkadot-statement-distribution",
"polkadot-approval-distribution", "polkadot-approval-distribution",
"sc-finality-grandpa-warp-sync",
"kvdb-rocksdb"
]
runtime-benchmarks = [
"polkadot-runtime/runtime-benchmarks",
"kusama-runtime/runtime-benchmarks",
"westend-runtime/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks"
]
try-runtime = [
"polkadot-runtime/try-runtime",
"kusama-runtime/try-runtime",
"westend-runtime/try-runtime",
"rococo-runtime/try-runtime",
] ]
+4 -4
View File
@@ -24,7 +24,7 @@ use sp_runtime::traits::{Block as BlockT, NumberFor};
use sp_runtime::generic::BlockId; use sp_runtime::generic::BlockId;
use sp_runtime::traits::Header as _; use sp_runtime::traits::Header as _;
#[cfg(feature = "real-overseer")] #[cfg(feature = "full-node")]
use { use {
polkadot_primitives::v1::{Block as PolkadotBlock, Header as PolkadotHeader}, polkadot_primitives::v1::{Block as PolkadotBlock, Header as PolkadotHeader},
polkadot_subsystem::messages::ApprovalVotingMessage, polkadot_subsystem::messages::ApprovalVotingMessage,
@@ -39,14 +39,14 @@ use {
/// The practical effect of this voting rule is to implement a fixed delay of /// The practical effect of this voting rule is to implement a fixed delay of
/// blocks and to issue a prometheus metric on the lag behind the head that /// blocks and to issue a prometheus metric on the lag behind the head that
/// approval checking would indicate. /// approval checking would indicate.
#[cfg(feature = "real-overseer")] #[cfg(feature = "full-node")]
#[derive(Clone)] #[derive(Clone)]
pub(crate) struct ApprovalCheckingVotingRule { pub(crate) struct ApprovalCheckingVotingRule {
checking_lag: Option<prometheus_endpoint::Gauge<prometheus_endpoint::U64>>, checking_lag: Option<prometheus_endpoint::Gauge<prometheus_endpoint::U64>>,
overseer: OverseerHandler, overseer: OverseerHandler,
} }
#[cfg(feature = "real-overseer")] #[cfg(feature = "full-node")]
impl ApprovalCheckingVotingRule { impl ApprovalCheckingVotingRule {
/// Create a new approval checking diagnostic voting rule. /// Create a new approval checking diagnostic voting rule.
pub fn new(overseer: OverseerHandler, registry: Option<&Registry>) pub fn new(overseer: OverseerHandler, registry: Option<&Registry>)
@@ -71,7 +71,7 @@ impl ApprovalCheckingVotingRule {
} }
} }
#[cfg(feature = "real-overseer")] #[cfg(feature = "full-node")]
impl<B> grandpa::VotingRule<PolkadotBlock, B> for ApprovalCheckingVotingRule impl<B> grandpa::VotingRule<PolkadotBlock, B> for ApprovalCheckingVotingRule
where B: sp_blockchain::HeaderBackend<PolkadotBlock> where B: sp_blockchain::HeaderBackend<PolkadotBlock>
{ {
+9 -97
View File
@@ -27,6 +27,7 @@ mod parachains_db;
use { use {
std::time::Duration, std::time::Duration,
tracing::info, tracing::info,
polkadot_network_bridge::RequestMultiplexer,
polkadot_node_core_av_store::Config as AvailabilityConfig, polkadot_node_core_av_store::Config as AvailabilityConfig,
polkadot_node_core_av_store::Error as AvailabilityError, polkadot_node_core_av_store::Error as AvailabilityError,
polkadot_node_core_approval_voting::Config as ApprovalVotingConfig, polkadot_node_core_approval_voting::Config as ApprovalVotingConfig,
@@ -44,8 +45,6 @@ use {
beefy_primitives::ecdsa::AuthoritySignature as BeefySignature, beefy_primitives::ecdsa::AuthoritySignature as BeefySignature,
sp_runtime::traits::Header as HeaderT, sp_runtime::traits::Header as HeaderT,
}; };
#[cfg(feature = "real-overseer")]
use polkadot_network_bridge::RequestMultiplexer;
use sp_core::traits::SpawnNamed; use sp_core::traits::SpawnNamed;
@@ -413,36 +412,7 @@ fn new_partial<RuntimeApi, Executor>(
}) })
} }
#[cfg(all(feature="full-node", not(feature = "real-overseer")))] #[cfg(feature = "full-node")]
fn real_overseer<Spawner, RuntimeClient>(
leaves: impl IntoIterator<Item = BlockInfo>,
_: Arc<LocalKeystore>,
_: Arc<RuntimeClient>,
_parachains_db: (),
_: AvailabilityConfig,
_: ApprovalVotingConfig,
_: Arc<sc_network::NetworkService<Block, Hash>>,
_: AuthorityDiscoveryService,
_request_multiplexer: (),
registry: Option<&Registry>,
spawner: Spawner,
_: IsCollator,
_: IsolationStrategy,
) -> Result<(Overseer<Spawner>, OverseerHandler), Error>
where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
Spawner: 'static + SpawnNamed + Clone + Unpin,
{
Overseer::new(
leaves,
AllSubsystems::<()>::dummy(),
registry,
spawner,
).map_err(|e| e.into())
}
#[cfg(all(feature = "full-node", feature = "real-overseer"))]
fn real_overseer<Spawner, RuntimeClient>( fn real_overseer<Spawner, RuntimeClient>(
leaves: impl IntoIterator<Item = BlockInfo>, leaves: impl IntoIterator<Item = BlockInfo>,
keystore: Arc<LocalKeystore>, keystore: Arc<LocalKeystore>,
@@ -457,7 +427,7 @@ fn real_overseer<Spawner, RuntimeClient>(
spawner: Spawner, spawner: Spawner,
is_collator: IsCollator, is_collator: IsCollator,
isolation_strategy: IsolationStrategy, isolation_strategy: IsolationStrategy,
) -> Result<(Overseer<Spawner>, OverseerHandler), Error> ) -> Result<(Overseer<Spawner, Arc<RuntimeClient>>, OverseerHandler), Error>
where where
RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore, RuntimeClient: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block> + AuxStore,
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>, RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
@@ -582,6 +552,7 @@ where
leaves, leaves,
all_subsystems, all_subsystems,
registry, registry,
runtime_client.clone(),
spawner, spawner,
).map_err(|e| e.into()) ).map_err(|e| e.into())
} }
@@ -711,17 +682,10 @@ pub fn new_full<RuntimeApi, Executor>(
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>, RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static, Executor: NativeExecutionDispatch + 'static,
{ {
#[cfg(feature = "real-overseer")]
info!("real-overseer feature is ENABLED");
let role = config.role.clone(); let role = config.role.clone();
let force_authoring = config.force_authoring; let force_authoring = config.force_authoring;
let backoff_authoring_blocks = { let backoff_authoring_blocks = {
let mut backoff = sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging { let mut backoff = sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default();
#[cfg(feature = "real-overseer")]
unfinalized_slack: 100,
..Default::default()
};
if config.chain_spec.is_rococo() { if config.chain_spec.is_rococo() {
// it's a testnet that's in flux, finality has stalled sometimes due // it's a testnet that's in flux, finality has stalled sometimes due
@@ -761,7 +725,6 @@ pub fn new_full<RuntimeApi, Executor>(
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config()); config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
} }
#[cfg(feature = "real-overseer")]
{ {
use polkadot_network_bridge::{peer_sets_info, IsAuthority}; use polkadot_network_bridge::{peer_sets_info, IsAuthority};
let is_authority = if role.is_authority() { let is_authority = if role.is_authority() {
@@ -772,20 +735,6 @@ pub fn new_full<RuntimeApi, Executor>(
config.network.extra_sets.extend(peer_sets_info(is_authority)); config.network.extra_sets.extend(peer_sets_info(is_authority));
} }
// Add a dummy collation set with the intent of printing an error if one tries to connect a
// collator to a node that isn't compiled with `--features real-overseer`.
#[cfg(not(feature = "real-overseer"))]
config.network.extra_sets.push(sc_network::config::NonDefaultSetConfig {
notifications_protocol: "/polkadot/collation/1".into(),
max_notification_size: 16,
set_config: sc_network::config::SetConfig {
in_peers: 25,
out_peers: 0,
reserved_nodes: Vec::new(),
non_reserved_mode: sc_network::config::NonReservedPeerMode::Accept,
},
});
// TODO: At the moment, the collator protocol uses notifications protocols to download // TODO: At the moment, the collator protocol uses notifications protocols to download
// collations. Because of DoS-protection measures, notifications protocols have a very limited // collations. Because of DoS-protection measures, notifications protocols have a very limited
// bandwidth capacity, resulting in the collation download taking a long time. // bandwidth capacity, resulting in the collation download taking a long time.
@@ -793,26 +742,16 @@ pub fn new_full<RuntimeApi, Executor>(
// this problem. This configuraiton change should preferably not reach any live network, and // this problem. This configuraiton change should preferably not reach any live network, and
// should be removed once the collation protocol is finished. // should be removed once the collation protocol is finished.
// Tracking issue: https://github.com/paritytech/polkadot/issues/2283 // Tracking issue: https://github.com/paritytech/polkadot/issues/2283
#[cfg(feature = "real-overseer")] config.network.yamux_window_size = Some(5 * 1024 * 1024);
fn adjust_yamux(cfg: &mut sc_network::config::NetworkConfiguration) {
cfg.yamux_window_size = Some(5 * 1024 * 1024);
}
#[cfg(not(feature = "real-overseer"))]
fn adjust_yamux(_: &mut sc_network::config::NetworkConfiguration) {}
adjust_yamux(&mut config.network);
config.network.request_response_protocols.push(sc_finality_grandpa_warp_sync::request_response_config_for_chain( config.network.request_response_protocols.push(sc_finality_grandpa_warp_sync::request_response_config_for_chain(
&config, task_manager.spawn_handle(), backend.clone(), import_setup.1.shared_authority_set().clone(), &config, task_manager.spawn_handle(), backend.clone(), import_setup.1.shared_authority_set().clone(),
)); ));
#[cfg(feature = "real-overseer")] let request_multiplexer = {
fn register_request_response(config: &mut sc_network::config::NetworkConfiguration) -> RequestMultiplexer {
let (multiplexer, configs) = RequestMultiplexer::new(); let (multiplexer, configs) = RequestMultiplexer::new();
config.request_response_protocols.extend(configs); config.network.request_response_protocols.extend(configs);
multiplexer multiplexer
} };
#[cfg(not(feature = "real-overseer"))]
fn register_request_response(_: &mut sc_network::config::NetworkConfiguration) {}
let request_multiplexer = register_request_response(&mut config.network);
let (network, network_status_sinks, system_rpc_tx, network_starter) = let (network, network_status_sinks, system_rpc_tx, network_starter) =
service::build_network(service::BuildNetworkParams { service::build_network(service::BuildNetworkParams {
@@ -825,43 +764,17 @@ pub fn new_full<RuntimeApi, Executor>(
block_announce_validator_builder: None, block_announce_validator_builder: None,
})?; })?;
// See above. We have added a dummy collation set with the intent of printing an error if one
// tries to connect a collator to a node that isn't compiled with `--features real-overseer`.
#[cfg(not(feature = "real-overseer"))]
task_manager.spawn_handle().spawn("dummy-collation-handler", {
let mut network_events = network.event_stream("dummy-collation-handler");
async move {
use futures::prelude::*;
while let Some(ev) = network_events.next().await {
if let sc_network::Event::NotificationStreamOpened { protocol, .. } = ev {
if protocol == "/polkadot/collation/1" {
tracing::warn!(
"Incoming collator on a node with parachains disabled. This warning \
is harmless and is here to warn developers that they might have \
accidentally compiled their node without the `real-overseer` feature \
enabled."
);
}
}
}
}
});
if config.offchain_worker.enabled { if config.offchain_worker.enabled {
let _ = service::build_offchain_workers( let _ = service::build_offchain_workers(
&config, task_manager.spawn_handle(), client.clone(), network.clone(), &config, task_manager.spawn_handle(), client.clone(), network.clone(),
); );
} }
#[cfg(feature = "real-overseer")]
let parachains_db = crate::parachains_db::open_creating( let parachains_db = crate::parachains_db::open_creating(
config.database.path().ok_or(Error::DatabasePathRequired)?.into(), config.database.path().ok_or(Error::DatabasePathRequired)?.into(),
crate::parachains_db::CacheSizes::default(), crate::parachains_db::CacheSizes::default(),
)?; )?;
#[cfg(not(feature = "real-overseer"))]
let parachains_db = ();
let availability_config = AvailabilityConfig { let availability_config = AvailabilityConfig {
col_data: crate::parachains_db::REAL_COLUMNS.col_availability_data, col_data: crate::parachains_db::REAL_COLUMNS.col_availability_data,
col_meta: crate::parachains_db::REAL_COLUMNS.col_availability_meta, col_meta: crate::parachains_db::REAL_COLUMNS.col_availability_meta,
@@ -1064,7 +977,6 @@ pub fn new_full<RuntimeApi, Executor>(
// given delay. // given delay.
let builder = grandpa::VotingRulesBuilder::default(); let builder = grandpa::VotingRulesBuilder::default();
#[cfg(feature = "real-overseer")]
let builder = if let Some(ref overseer) = overseer_handler { let builder = if let Some(ref overseer) = overseer_handler {
builder.add(grandpa_support::ApprovalCheckingVotingRule::new( builder.add(grandpa_support::ApprovalCheckingVotingRule::new(
overseer.clone(), overseer.clone(),
@@ -13,7 +13,7 @@
//! A RocksDB instance for storing parachain data; availability data, and approvals. //! A RocksDB instance for storing parachain data; availability data, and approvals.
#[cfg(feature = "real-overseer")] #[cfg(feature = "full-node")]
use { use {
std::io, std::io,
std::path::PathBuf, std::path::PathBuf,
@@ -25,7 +25,6 @@ use {
mod upgrade; mod upgrade;
mod columns { mod columns {
#[cfg(feature = "real-overseer")]
pub const NUM_COLUMNS: u32 = 3; pub const NUM_COLUMNS: u32 = 3;
@@ -73,13 +72,13 @@ impl Default for CacheSizes {
} }
} }
#[cfg(feature = "real-overseer")] #[cfg(feature = "full-node")]
fn other_io_error(err: String) -> io::Error { fn other_io_error(err: String) -> io::Error {
io::Error::new(io::ErrorKind::Other, err) io::Error::new(io::ErrorKind::Other, err)
} }
/// Open the database on disk, creating it if it doesn't exist. /// Open the database on disk, creating it if it doesn't exist.
#[cfg(feature = "real-overseer")] #[cfg(feature = "full-node")]
pub fn open_creating( pub fn open_creating(
root: PathBuf, root: PathBuf,
cache_sizes: CacheSizes, cache_sizes: CacheSizes,
@@ -14,7 +14,7 @@
//! Migration code for the parachain's DB. //! Migration code for the parachain's DB.
#![cfg(feature = "real-overseer")] #![cfg(feature = "full-node")]
use std::fs; use std::fs;
use std::io; use std::io;
@@ -360,9 +360,15 @@ impl<C: SubsystemContext<Message = Msg>, Msg: Send + 'static> Subsystem<C> for F
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use polkadot_overseer::{Overseer, AllSubsystems}; use polkadot_overseer::{Overseer, HeadSupportsParachains, AllSubsystems};
use futures::executor::block_on; use futures::executor::block_on;
use polkadot_node_subsystem::messages::CandidateSelectionMessage; use polkadot_node_subsystem::messages::CandidateSelectionMessage;
use polkadot_primitives::v1::Hash;
struct AlwaysSupportsParachains;
impl HeadSupportsParachains for AlwaysSupportsParachains {
fn head_supports_parachains(&self, _head: &Hash) -> bool { true }
}
#[test] #[test]
fn forward_subsystem_works() { fn forward_subsystem_works() {
@@ -373,6 +379,7 @@ mod tests {
Vec::new(), Vec::new(),
all_subsystems, all_subsystems,
None, None,
AlwaysSupportsParachains,
spawner.clone(), spawner.clone(),
).unwrap(); ).unwrap();
@@ -37,6 +37,3 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "master
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
tokio = { version = "0.2", features = ["macros"] } tokio = { version = "0.2", features = ["macros"] }
[features]
real-overseer = [ "polkadot-service/real-overseer" ]
@@ -2,13 +2,13 @@
First start two validators that will run for the relay chain: First start two validators that will run for the relay chain:
```sh ```sh
cargo run --features=real-overseer --release -- -d alice --chain rococo-local --validator --alice --port 50551 cargo run --release -- -d alice --chain rococo-local --validator --alice --port 50551
cargo run --features=real-overseer --release -- -d bob --chain rococo-local --validator --bob --port 50552 cargo run --release -- -d bob --chain rococo-local --validator --bob --port 50552
``` ```
Next start the collator that will collate for the adder parachain: Next start the collator that will collate for the adder parachain:
```sh ```sh
cargo run --features=real-overseer --release -p test-parachain-adder-collator -- --tmp --chain rococo-local --port 50553 cargo run --release -p test-parachain-adder-collator -- --tmp --chain rococo-local --port 50553
``` ```
The last step is to register the parachain using polkadot-js. The parachain id is The last step is to register the parachain using polkadot-js. The parachain id is
@@ -17,9 +17,7 @@
//! Integration test that ensures that we can build and include parachain //! Integration test that ensures that we can build and include parachain
//! blocks of the adder parachain. //! blocks of the adder parachain.
// If this test is failing, make sure to run all tests with the `real-overseer` feature being enabled.
#[substrate_test_utils::test] #[substrate_test_utils::test]
#[cfg(feature = "real-overseer")]
async fn collating_using_adder_collator(task_executor: sc_service::TaskExecutor) { async fn collating_using_adder_collator(task_executor: sc_service::TaskExecutor) {
use sp_keyring::AccountKeyring::*; use sp_keyring::AccountKeyring::*;
use futures::join; use futures::join;
+2 -2
View File
@@ -31,11 +31,11 @@ adder_collator="target/release/adder-collator"
# ensure the polkadot binary exists and is up to date # ensure the polkadot binary exists and is up to date
if [ ! -x "$polkadot" ] || [ "$polkadot" -ot "$last_modified_rust_file" ]; then if [ ! -x "$polkadot" ] || [ "$polkadot" -ot "$last_modified_rust_file" ]; then
cargo build --release --features real-overseer cargo build --release
fi fi
# likewise for the adder collator # likewise for the adder collator
if [ ! -x "$adder_collator" ] || [ "$adder_collator" -ot "$last_modified_rust_file" ]; then if [ ! -x "$adder_collator" ] || [ "$adder_collator" -ot "$last_modified_rust_file" ]; then
cargo build --release --features real-overseer -p test-parachain-adder-collator cargo build --release -p test-parachain-adder-collator
fi fi
genesis="$(mktemp --directory)" genesis="$(mktemp --directory)"
+1 -4
View File
@@ -4,7 +4,4 @@ set -e
#shellcheck source=../common/lib.sh #shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh" source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"
time cargo test --all --release --verbose --locked --features=runtime-benchmarks --features=real-overseer time cargo test --all --release --verbose --locked --features=runtime-benchmarks
cd parachain/test-parachains/adder/collator/
time cargo test --release --verbose --locked --features=real-overseer
+1 -1
View File
@@ -27,7 +27,7 @@ polkadot="target/release/polkadot"
# ensure the polkadot binary exists and is up to date # ensure the polkadot binary exists and is up to date
if [ ! -x "$polkadot" ] || [ "$polkadot" -ot "$last_modified_rust_file" ]; then if [ ! -x "$polkadot" ] || [ "$polkadot" -ot "$last_modified_rust_file" ]; then
cargo build --release --features real-overseer cargo build --release
fi fi
# setup variables # setup variables