Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
substrate
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
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
Radu Popa
substrate
Commits
fb8769b6
Commit
fb8769b6
authored
5 years ago
by
Svyatoslav Nikolsky
Committed by
André Silva
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
finalize -> finalize_with_ancestors (#3576)
parent
9b08e7ff
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/network/src/protocol/sync/extra_requests.rs
+24
-1
24 additions, 1 deletion
core/network/src/protocol/sync/extra_requests.rs
with
24 additions
and
1 deletion
core/network/src/protocol/sync/extra_requests.rs
+
24
−
1
View file @
fb8769b6
...
...
@@ -138,7 +138,10 @@ impl<B: BlockT> ExtraRequests<B> {
}
if
best_finalized_number
>
self
.best_seen_finalized_number
{
match
self
.tree
.finalize
(
// normally we'll receive finality notifications for every block => finalize would be enough
// but if many blocks are finalized at once, some notifications may be omitted
// => let's use finalize_with_ancestors here
match
self
.tree
.finalize_with_ancestors
(
best_finalized_hash
,
best_finalized_number
,
&
is_descendent_of
,
...
...
@@ -437,6 +440,26 @@ mod tests {
assert_eq!
(
finality_proofs
.pending_requests
.iter
()
.collect
::
<
Vec
<
_
>>
(),
Vec
::
<&
(
Hash
,
u64
)
>
::
new
());
}
#[test]
fn
anecstor_roots_are_finalized_when_finality_notification_is_missed
()
{
let
mut
finality_proofs
=
ExtraRequests
::
<
Block
>
::
new
();
let
hash4
=
[
4
;
32
]
.into
();
let
hash5
=
[
5
;
32
]
.into
();
fn
is_descendent_of
(
base
:
&
Hash
,
target
:
&
Hash
)
->
Result
<
bool
,
ClientError
>
{
Ok
(
target
[
0
]
>=
base
[
0
])
}
// schedule request for #4
finality_proofs
.schedule
((
hash4
,
4
),
is_descendent_of
);
// receive finality notification for #5 (missing notification for #4!!!)
finality_proofs
.importing_requests
.insert
((
hash4
,
5
));
finality_proofs
.on_block_finalized
(
&
hash5
,
5
,
is_descendent_of
)
.unwrap
();
assert_eq!
(
finality_proofs
.tree
.roots
()
.count
(),
0
);
}
// Some Arbitrary instances to allow easy construction of random peer sets:
#[derive(Debug,
Clone)]
...
...
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