This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Ensure BeforeBestBlockBy voting rule accounts for base #9920
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The changeset here is just to modify
BeforeBestBlockBy
to check whether voting N blocks behind is even possible, and if not, it votes on the base.This is fixing a bug that manifested on the Rococo network after activating Polkadot's custom fork-choice rule, which can prioritize shorter chains over longer ones.
A diagram for illustration:
In this scenario, finality for B is racing with the production of B1'. If B is finalized before B1' is produced, nodes with B1' as their best chain will attempt to vote before block B and this is ignored by the voting rule machinery and leads to voting to finalize B1'. Then, if B1' is finalized before a block B2' is built on top of it, the cycle repeats, and can repeat indefinitely. This undermines the intention of the voting rule, hence the fix.