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

grandpa: pass the actual best block to voting rules #12477

Merged
merged 3 commits into from
Jan 4, 2023

Conversation

andresilva
Copy link
Member

GRANDPA allows plugging custom voting rules that will restrict the round votes according to some arbitrary logic. For these voting rules to make their decision we pass along the base block (i.e. the round base, we will finalize something that must be a descendant of this block), the best block and the target block (i.e. the block we will be aiming to finalize this round before potentially restricting it further with voting rules). As an example, one of the voting rules is that the block we target to finalize must always be N blocks behind the best block.

The block that we were passing along to the voting rule as the best block was actually the target block as returned by SelectChain::finality_target (without limiting it due to authority set changes). This made it so that, depending on the voting rules, we could unnecessarily restrict votes (as was the case with Polkadot). This PR changes this logic to pass the actual best block as computed by SelectChain::best_chain.

cc @ordian

@andresilva andresilva 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 Oct 11, 2022
@andresilva andresilva requested a review from a team October 12, 2022 07:51
Copy link
Member

@davxy davxy left a comment

Choose a reason for hiding this comment

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

LGTM

Just to elaborate (correct me if I misunderstood something)

  1. The SelectChain::finality_target implementation in Polkadot (SelectRelayChain) restricts the returned hash to only chains which are fully approved and which contains no disputes.
  2. If we already lowered the bar and we don't use the "real best", then the filters used later in voting_rule.restrict_vote() can unnecessarily lower the end target (e.g. because the "3/4" or the "before best by" rules which takes as the reference upper bound the best_header that is passed in)

@andresilva
Copy link
Member Author

@davxy Your understanding is accurate! 👍

@stale
Copy link

stale bot commented Dec 8, 2022

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 Dec 8, 2022
@davxy
Copy link
Member

davxy commented Dec 8, 2022

Not stale.

@andresilva can we merge this or you found something you like to fix?

@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 Dec 8, 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)

@andresilva
Copy link
Member Author

bot merge

@paritytech-processbot paritytech-processbot bot merged commit da3a34f into master Jan 4, 2023
@paritytech-processbot paritytech-processbot bot deleted the andre/grandpa-voting-rule-actual-best branch January 4, 2023 12:49
ltfschoen pushed a commit to ltfschoen/substrate that referenced this pull request Feb 22, 2023
* grandpa: pass the actual best block to voting rules

* grandpa: add test for checking best header is passed to voting rule
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* grandpa: pass the actual best block to voting rules

* grandpa: add test for checking best header is passed to voting rule
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.
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants