Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
05a5047e
Commit
05a5047e
authored
4 years ago
by
asynchronous rob
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
remove training wheels (#2800)
parent
57b56770
Branches
gh-readonly-queue/master/pr-3110-f07316f2723eae97f0d5cb1b82c03bf6efb146e3
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
polkadot/node/service/src/grandpa_support.rs
+16
-54
16 additions, 54 deletions
polkadot/node/service/src/grandpa_support.rs
polkadot/node/service/src/lib.rs
+1
-1
1 addition, 1 deletion
polkadot/node/service/src/lib.rs
with
17 additions
and
55 deletions
polkadot/node/service/src/grandpa_support.rs
+
16
−
54
View file @
05a5047e
...
...
@@ -26,7 +26,7 @@ use sp_runtime::traits::Header as _;
#[cfg(feature
=
"real-overseer"
)]
use
{
polkadot_primitives
::
v1
::{
Block
as
PolkadotBlock
,
Header
as
PolkadotHeader
,
BlockNumber
},
polkadot_primitives
::
v1
::{
Block
as
PolkadotBlock
,
Header
as
PolkadotHeader
},
polkadot_subsystem
::
messages
::
ApprovalVotingMessage
,
prometheus_endpoint
::{
self
,
Registry
},
polkadot_overseer
::
OverseerHandler
,
...
...
@@ -41,18 +41,18 @@ use {
/// approval checking would indicate.
#[cfg(feature
=
"real-overseer"
)]
#[derive(Clone)]
pub
(
crate
)
struct
ApprovalChecking
Diagnostic
{
pub
(
crate
)
struct
ApprovalChecking
VotingRule
{
checking_lag
:
Option
<
prometheus_endpoint
::
Gauge
<
prometheus_endpoint
::
U64
>>
,
overseer
:
OverseerHandler
,
}
#[cfg(feature
=
"real-overseer"
)]
impl
ApprovalChecking
Diagnostic
{
impl
ApprovalChecking
VotingRule
{
/// Create a new approval checking diagnostic voting rule.
pub
fn
new
(
overseer
:
OverseerHandler
,
registry
:
Option
<&
Registry
>
)
->
Result
<
Self
,
prometheus_endpoint
::
PrometheusError
>
{
Ok
(
ApprovalChecking
Diagnostic
{
Ok
(
ApprovalChecking
VotingRule
{
checking_lag
:
if
let
Some
(
registry
)
=
registry
{
Some
(
prometheus_endpoint
::
register
(
prometheus_endpoint
::
Gauge
::
with_opts
(
...
...
@@ -72,61 +72,16 @@ impl ApprovalCheckingDiagnostic {
}
#[cfg(feature
=
"real-overseer"
)]
impl
<
B
>
grandpa
::
VotingRule
<
PolkadotBlock
,
B
>
for
ApprovalChecking
Diagnostic
impl
<
B
>
grandpa
::
VotingRule
<
PolkadotBlock
,
B
>
for
ApprovalChecking
VotingRule
where
B
:
sp_blockchain
::
HeaderBackend
<
PolkadotBlock
>
{
fn
restrict_vote
(
&
self
,
backend
:
Arc
<
B
>
,
_
backend
:
Arc
<
B
>
,
base
:
&
PolkadotHeader
,
best_target
:
&
PolkadotHeader
,
current_target
:
&
PolkadotHeader
,
)
->
grandpa
::
VotingRuleResult
<
PolkadotBlock
>
{
// always wait 50 blocks behind the head to finalize.
const
DIAGNOSTIC_GRANDPA_DELAY
:
BlockNumber
=
50
;
let
aux
=
||
{
let
find_target
=
|
target_number
:
BlockNumber
,
current_header
:
&
PolkadotHeader
|
{
let
mut
target_hash
=
current_header
.hash
();
let
mut
target_header
=
current_header
.clone
();
loop
{
if
*
target_header
.number
()
<
target_number
{
unreachable!
(
"we are traversing backwards from a known block;
\
blocks are stored contiguously;
\
qed"
);
}
if
*
target_header
.number
()
==
target_number
{
return
Some
((
target_hash
,
target_number
));
}
target_hash
=
*
target_header
.parent_hash
();
target_header
=
backend
.header
(
BlockId
::
Hash
(
target_hash
))
.ok
()
?
.expect
(
"Header known to exist due to the existence of one of its descendents; qed"
);
}
};
// delay blocks behind the head, but make sure we're not ahead of the current
// target.
let
target_number
=
std
::
cmp
::
min
(
best_target
.number
()
.saturating_sub
(
DIAGNOSTIC_GRANDPA_DELAY
),
current_target
.number
()
.clone
(),
);
// don't go below base
let
target_number
=
std
::
cmp
::
max
(
target_number
,
base
.number
()
.clone
(),
);
find_target
(
target_number
,
current_target
)
};
let
actual_vote_target
=
aux
();
// Query approval checking and issue metrics.
let
mut
overseer
=
self
.overseer
.clone
();
let
checking_lag
=
self
.checking_lag
.clone
();
...
...
@@ -134,6 +89,9 @@ impl<B> grandpa::VotingRule<PolkadotBlock, B> for ApprovalCheckingDiagnostic
let
best_hash
=
best_target
.hash
();
let
best_number
=
best_target
.number
.clone
();
let
current_hash
=
current_target
.hash
();
let
current_number
=
current_target
.number
.clone
();
let
base_number
=
base
.number
;
Box
::
pin
(
async
move
{
...
...
@@ -157,14 +115,18 @@ impl<B> grandpa::VotingRule<PolkadotBlock, B> for ApprovalCheckingDiagnostic
checking_lag
.set
(
approval_checking_subsystem_lag
as
_
);
}
tracing
::
debug
!
(
tracing
::
trace
!
(
target
:
"parachain::approval-voting"
,
"GRANDPA: voting on {:?}. Approval-checking lag behind best is {}"
,
a
ctual_vote_target
,
a
pproval_checking_subsystem_vote
,
approval_checking_subsystem_lag
,
);
actual_vote_target
if
approval_checking_subsystem_vote
.map_or
(
false
,
|
v
|
current_number
<
v
.1
)
{
Some
((
current_hash
,
current_number
))
}
else
{
approval_checking_subsystem_vote
}
})
}
}
...
...
This diff is collapsed.
Click to expand it.
polkadot/node/service/src/lib.rs
+
1
−
1
View file @
05a5047e
...
...
@@ -1062,7 +1062,7 @@ pub fn new_full<RuntimeApi, Executor>(
#[cfg(feature
=
"real-overseer"
)]
let
builder
=
if
let
Some
(
ref
overseer
)
=
overseer_handler
{
builder
.add
(
grandpa_support
::
ApprovalChecking
Diagnostic
::
new
(
builder
.add
(
grandpa_support
::
ApprovalChecking
VotingRule
::
new
(
overseer
.clone
(),
prometheus_registry
.as_ref
(),
)
?
)
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment