Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
0e0d051d
Unverified
Commit
0e0d051d
authored
Feb 18, 2021
by
asynchronous rob
Committed by
GitHub
Feb 18, 2021
Browse files
gate approval-checking logic (#2470)
parent
f778e527
Pipeline
#124580
passed with stages
in 33 minutes and 57 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Cargo.toml
View file @
0e0d051d
...
...
@@ -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]
...
...
node/service/Cargo.toml
View file @
0e0d051d
...
...
@@ -136,3 +136,7 @@ real-overseer = [
"polkadot-approval-distribution"
,
"polkadot-node-core-approval-voting"
,
]
approval-checking
=
[
"real-overseer"
]
node/service/src/grandpa_support.rs
View file @
0e0d051d
...
...
@@ -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
>
{
...
...
node/service/src/lib.rs
View file @
0e0d051d
...
...
@@ -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
(),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment