diff --git a/polkadot/Cargo.toml b/polkadot/Cargo.toml index 082631cc62a63edb2744ac614dc0bcc84d6a9966..6fd9162ff1c5f34643a6f786d325253a904751be 100644 --- a/polkadot/Cargo.toml +++ b/polkadot/Cargo.toml @@ -91,6 +91,7 @@ panic = "unwind" [features] runtime-benchmarks=["cli/runtime-benchmarks"] real-overseer=["cli/real-overseer"] +approval-checking=["real-overseer", "service/approval-checking"] # Configuration for building a .deb package - for use with `cargo-deb` [package.metadata.deb] diff --git a/polkadot/node/service/Cargo.toml b/polkadot/node/service/Cargo.toml index 58f5c5c23512c5b60da058460539ef8f2e7f26fb..622ed317e585aee7e91f8146332eebb9e06b0e67 100644 --- a/polkadot/node/service/Cargo.toml +++ b/polkadot/node/service/Cargo.toml @@ -136,3 +136,7 @@ real-overseer = [ "polkadot-approval-distribution", "polkadot-node-core-approval-voting", ] + +approval-checking = [ + "real-overseer" +] diff --git a/polkadot/node/service/src/grandpa_support.rs b/polkadot/node/service/src/grandpa_support.rs index d411c8ed817e466e92436a29dd99c645da5dd68d..6468565a7b3e568664c77d577ef0f4f7b99c5fff 100644 --- a/polkadot/node/service/src/grandpa_support.rs +++ b/polkadot/node/service/src/grandpa_support.rs @@ -18,17 +18,20 @@ use std::sync::Arc; -use polkadot_primitives::v1::{Block as PolkadotBlock, Header as PolkadotHeader, BlockNumber, Hash}; -use polkadot_subsystem::messages::ApprovalVotingMessage; +use polkadot_primitives::v1::Hash; use sp_runtime::traits::{Block as BlockT, NumberFor}; use sp_runtime::generic::BlockId; use sp_runtime::traits::Header as _; -use prometheus_endpoint::{self, Registry}; -use polkadot_overseer::OverseerHandler; - -use futures::channel::oneshot; +#[cfg(feature = "approval-checking")] +use { + polkadot_primitives::v1::{Block as PolkadotBlock, Header as PolkadotHeader, BlockNumber}, + polkadot_subsystem::messages::ApprovalVotingMessage, + prometheus_endpoint::{self, Registry}, + polkadot_overseer::OverseerHandler, + futures::channel::oneshot, +}; /// A custom GRANDPA voting rule that acts as a diagnostic for the approval /// voting subsystem's desired votes. @@ -36,14 +39,14 @@ use futures::channel::oneshot; /// 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 /// approval checking would indicate. -#[cfg(feature = "full-node")] +#[cfg(feature = "approval-checking")] #[derive(Clone)] pub(crate) struct ApprovalCheckingDiagnostic { checking_lag: Option<prometheus_endpoint::Histogram>, overseer: OverseerHandler, } -#[cfg(feature = "full-node")] +#[cfg(feature = "approval-checking")] impl ApprovalCheckingDiagnostic { /// Create a new approval checking diagnostic voting rule. pub fn new(overseer: OverseerHandler, registry: Option<&Registry>) @@ -68,7 +71,7 @@ impl ApprovalCheckingDiagnostic { } } -#[cfg(feature = "full-node")] +#[cfg(feature = "approval-checking")] impl<B> grandpa::VotingRule<PolkadotBlock, B> for ApprovalCheckingDiagnostic where B: sp_blockchain::HeaderBackend<PolkadotBlock> { diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index 1cb4b1ce08720fbd6b89113e779fae378f7b7844..1d119014b8fe956a9db9f8b4d264f2e5920dbf5e 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -412,8 +412,13 @@ where use polkadot_statement_distribution::StatementDistribution as StatementDistributionSubsystem; use polkadot_availability_recovery::AvailabilityRecoverySubsystem; use polkadot_approval_distribution::ApprovalDistribution as ApprovalDistributionSubsystem; + + #[cfg(feature = "approval-checking")] use polkadot_node_core_approval_voting::ApprovalVotingSubsystem; + #[cfg(not(feature = "approval-checking"))] + let _ = slot_duration; // silence. + let all_subsystems = AllSubsystems { availability_distribution: AvailabilityDistributionSubsystem::new( keystore.clone(), @@ -488,11 +493,14 @@ where approval_distribution: ApprovalDistributionSubsystem::new( Metrics::register(registry)?, ), + #[cfg(feature = "approval-checking")] approval_voting: ApprovalVotingSubsystem::new( keystore.clone(), slot_duration, runtime_client.clone(), ), + #[cfg(not(feature = "approval-checking"))] + approval_voting: polkadot_subsystem::DummySubsystem, }; Overseer::new( @@ -828,6 +836,7 @@ pub fn new_full<RuntimeApi, Executor>( // given delay. let builder = grandpa::VotingRulesBuilder::default(); + #[cfg(feature = "approval-checking")] let builder = if let Some(ref overseer) = overseer_handler { builder.add(grandpa_support::ApprovalCheckingDiagnostic::new( overseer.clone(),