Unverified Commit 0e0d051d authored by asynchronous rob's avatar asynchronous rob Committed by GitHub
Browse files

gate approval-checking logic (#2470)

parent f778e527
Pipeline #124580 passed with stages
in 33 minutes and 57 seconds
......@@ -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]
......
......@@ -136,3 +136,7 @@ real-overseer = [
"polkadot-approval-distribution",
"polkadot-node-core-approval-voting",
]
approval-checking = [
"real-overseer"
]
......@@ -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>
{
......
......@@ -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(),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment