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

Removed assumptions about ancestry from fork tree prune method #12778

Closed
wants to merge 4 commits into from
Closed

Removed assumptions about ancestry from fork tree prune method #12778

wants to merge 4 commits into from

Conversation

davxy
Copy link
Member

@davxy davxy commented Nov 25, 2022

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

@davxy davxy self-assigned this Dec 17, 2022
@davxy davxy marked this pull request as ready for review December 17, 2022 16:30
@davxy davxy requested review from a team and andresilva December 17, 2022 16:30
@davxy davxy added A0-please_review Pull request needs code review. 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. labels Dec 17, 2022
/// node. Otherwise the tree remains unchanged. The given function
/// `is_descendent_of` should return `true` if the second hash (target) is a
/// descendent of the first hash (base).
/// Prune the tree, removing all non-canonical nodes.
Copy link
Member Author

Choose a reason for hiding this comment

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

The PR mostly involves the ForkTree::prune method.

The rest of the PR are mostly tests

@davxy davxy added the D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit label Dec 17, 2022
@davxy
Copy link
Member Author

davxy commented Dec 20, 2022

A burn-in has been performed. Both full sync and warp went good

@davxy davxy closed this by deleting the head repository Dec 20, 2022
@bkchr
Copy link
Member

bkchr commented Dec 21, 2022

A burn-in has been performed. Both full sync and warp went good

If it worked, why did you closed the pr? :D

@davxy
Copy link
Member Author

davxy commented Dec 21, 2022

Jeez that was not intentional :-D

@davxy davxy reopened this Dec 21, 2022
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.

👍 (code-wise; don't know enough to reason about business logic)

utils/fork-tree/src/lib.rs Show resolved Hide resolved
@davxy davxy requested a review from a team January 5, 2023 15:31
@stale
Copy link

stale bot commented Feb 4, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Feb 4, 2023
@davxy
Copy link
Member Author

davxy commented Feb 4, 2023

Not stale

@stale stale bot removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Feb 4, 2023
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.

Logic looks good! Only super nits.

utils/fork-tree/src/lib.rs Show resolved Hide resolved
utils/fork-tree/src/lib.rs Show resolved Hide resolved
@davxy davxy closed this Feb 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. 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
Status: done
Development

Successfully merging this pull request may close these issues.

4 participants