-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Removed assumptions about ancestry from fork tree prune method #12778
Removed assumptions about ancestry from fork tree prune method #12778
Conversation
/// 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. |
There was a problem hiding this comment.
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
A burn-in has been performed. Both full sync and warp went good |
If it worked, why did you closed the pr? :D |
Jeez that was not intentional :-D |
There was a problem hiding this 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)
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. |
Not stale |
There was a problem hiding this 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.
Fork tree prune method was assuming that the user's
predicate
closure makes thefind_node_index_where
to NOT return the tree node immediately preceding thehash
parameter (according tois_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.