Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fork tree prune assumptions removal v2 #13327

Merged
merged 11 commits into from
Feb 15, 2023

Conversation

davxy
Copy link
Member

@davxy davxy commented Feb 7, 2023

Superseeds #12778


Fork tree prune method was assuming that the user's predicate closure makes the find_node_index_where to NOT return the tree node immediately preceding the hash parameter (according to is_descendent_of closure).

Up to date the only users of this structure are GRANDPA and BABE to keep a tree of epoch changes announcements AND according to their predicate, the assumption is satisfied.

But this is a time-bomb

If at some point the struct is used in a context where the predicate doesn't satisfy the assumption, the tree would break and we loose part of the tree due to how prune logic is implemented.
(indeed this assumption was the cause of #12758 bug)

This PR removes the assumption and makes the tree more resilient and independent for any use case.


  • Burn-in test
  • Test in live network

@davxy davxy added B0-silent Changes should not be mentioned in any release notes A1-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix C1-low and removed C3-medium labels Feb 7, 2023
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, good catch

@@ -32,7 +32,7 @@ pub enum Error<E> {
UnfinalizedAncestor,
/// Imported or finalized node that is an ancestor of previously finalized node.
Revert,
/// Error throw by client when checking for node ancestry.
/// Error thrown by user when checking for node ancestry.
Client(E),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename this to Ancestry(E)? Or something else if someone has a better suggestion.

utils/fork-tree/src/lib.rs Outdated Show resolved Hide resolved
utils/fork-tree/src/lib.rs Show resolved Hide resolved
client/consensus/epochs/src/lib.rs Show resolved Hide resolved
utils/fork-tree/src/lib.rs Outdated Show resolved Hide resolved
@davxy davxy requested a review from a team February 7, 2023 16:26
Copy link
Contributor

@skunert skunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice readability improvements over the last PR

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@davxy davxy added C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit and removed C1-low PR touches the given topic and has a low impact on builders. C1-low labels Feb 8, 2023
@davxy davxy merged commit a10ccb5 into paritytech:master Feb 15, 2023
@davxy davxy deleted the fork-tree-prune-assumptions-removal-v2 branch February 15, 2023 10:49
rossbulat pushed a commit that referenced this pull request Feb 19, 2023
* Removed assumptions about ancestry from fork tree prune method

* Tests improvement

* Fork tree prune refactory

* Code refactory

* Correctly handle borderline, but legit, case

* Apply suggestions from code review

Co-authored-by: André Silva <[email protected]>

* Removed duplicated test

---------

Co-authored-by: André Silva <[email protected]>
rossbulat pushed a commit that referenced this pull request Feb 19, 2023
ltfschoen pushed a commit to ltfschoen/substrate that referenced this pull request Feb 22, 2023
* Removed assumptions about ancestry from fork tree prune method

* Tests improvement

* Fork tree prune refactory

* Code refactory

* Correctly handle borderline, but legit, case

* Apply suggestions from code review

Co-authored-by: André Silva <[email protected]>

* Removed duplicated test

---------

Co-authored-by: André Silva <[email protected]>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* Removed assumptions about ancestry from fork tree prune method

* Tests improvement

* Fork tree prune refactory

* Code refactory

* Correctly handle borderline, but legit, case

* Apply suggestions from code review

Co-authored-by: André Silva <[email protected]>

* Removed duplicated test

---------

Co-authored-by: André Silva <[email protected]>
Ank4n pushed a commit that referenced this pull request Feb 28, 2023
* Removed assumptions about ancestry from fork tree prune method

* Tests improvement

* Fork tree prune refactory

* Code refactory

* Correctly handle borderline, but legit, case

* Apply suggestions from code review

Co-authored-by: André Silva <[email protected]>

* Removed duplicated test

---------

Co-authored-by: André Silva <[email protected]>
ukint-vs pushed a commit to gear-tech/substrate that referenced this pull request Apr 10, 2023
* Removed assumptions about ancestry from fork tree prune method

* Tests improvement

* Fork tree prune refactory

* Code refactory

* Correctly handle borderline, but legit, case

* Apply suggestions from code review

Co-authored-by: André Silva <[email protected]>

* Removed duplicated test

---------

Co-authored-by: André Silva <[email protected]>
nathanwhit pushed a commit to nathanwhit/substrate that referenced this pull request Jul 19, 2023
* Removed assumptions about ancestry from fork tree prune method

* Tests improvement

* Fork tree prune refactory

* Code refactory

* Correctly handle borderline, but legit, case

* Apply suggestions from code review

Co-authored-by: André Silva <[email protected]>

* Removed duplicated test

---------

Co-authored-by: André Silva <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A1-needs_burnin Pull request needs to be tested on a live validator node before merge. DevOps is notified via matrix B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants