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

Implement Approval Voting Subsystem #2112

Merged
merged 210 commits into from
Feb 11, 2021
Merged

Implement Approval Voting Subsystem #2112

merged 210 commits into from
Feb 11, 2021

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Dec 11, 2020

Closes #1975

This implements all the logic of the approval voting system.

Approval votes are split into two parts: Assignments and Approvals. Validators first broadcast their assignment to indicate intent to check a candidate. Upon successfully checking, they broadcast an approval vote. If a validator doesn't broadcast their approval vote shortly after issuing an assignment, this is an indication that they are being prevented from recovering or validating the block data and that more validators should self-select to check the candidate. This is known as a "no-show".

The core of this subsystem is a Tick-based timer loop, where Ticks are 500ms. We also reason about time in terms of DelayTranches, which measure the number of ticks elapsed since a block was produced. We track metadata for all un-finalized but included candidates. We compute our local assignments to check each candidate, as well as which DelayTranche those assignments may be minimally triggered at. As the same candidate may appear in more than one block, we must produce our potential assignments for each (Block, Candidate) pair. The timing loop is based on waiting for assignments to become no-shows or waiting to broadcast and begin our own assignment to check.

Another main component of this subsystem is the logic for determining when a (Block, Candidate) pair has been approved and when to broadcast and trigger our own assignment. Once a (Block, Candidate) pair has been approved, we mark a corresponding bit in the BlockEntry that indicates the candidate has been approved under the block. When we trigger our own assignment, we broadcast it via Approval Distribution, begin fetching the data from Availability Recovery, and then pass it through to the Candidate Validation. Once these steps are successful, we issue our approval vote. If any of these steps fail, we don't issue any vote and will "no-show" from the perspective of other validators. In the future we will initiate disputes as well.

Where this all fits into Polkadot is via block finality. Our goal is to not finalize any block containing a candidate that is not approved. We provide a hook for a custom GRANDPA voting rule - GRANDPA makes requests of the form (target, minimum) consisting of a target block (i.e. longest chain) that it would like to finalize, and a minimum block which, due to the rules of GRANDPA, must be voted on. The minimum is typically the last finalized block, but may be beyond it, in the case of having a last-round-estimate beyond the last finalized. Thus, our goal is to inform GRANDPA of some block between target and minimum which we believe can be finalized safely. We do this by iterating backwards from the target to the minimum and finding the longest continuous chain from minimum where all candidates included by those blocks have been approved.

@rphmeier rphmeier added A3-in_progress Pull request is in progress. No review needed at this stage. 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 11, 2020
@rphmeier rphmeier added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Feb 9, 2021
@rphmeier rphmeier marked this pull request as ready for review February 9, 2021 05:19
Copy link
Contributor

@burdges burdges left a comment

Choose a reason for hiding this comment

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

LGTM 🎊

@rphmeier rphmeier merged commit 35ea1c4 into master Feb 11, 2021
@rphmeier rphmeier deleted the rh-approval-voting branch February 11, 2021 16:21
ordian added a commit that referenced this pull request Feb 11, 2021
* master:
  Implement Approval Voting Subsystem (#2112)
  Introduce PerPeerSet utility that allows to segrate based on PeerSet (#2420)
  [CI] Move check_labels to github actions (#2415)
  runtime: set equivocation report longevity (#2404)
  Companion for #7936: Migrate pallet-balances to pallet attribute macro (#2331)
  Corrected Physical (#2414)
  validator_discovery: cache by (Hash, ParaId) (#2402)
  Enable wasmtime caching for PVF (companion for #8057) (#2387)
  Use construct_runtime in tests, remove default PalletInfo impl (#2409)
  validator_discovery: pass PeerSet to the request (#2372)
  guide: more robust approval counting procedure (#2378)
  Publish rococo on every push to `rococo-v1` branch (#2388)
  Bump trie-db from 0.22.2 to 0.22.3 (#2344)
  Send view to new peers (#2392)
ordian added a commit that referenced this pull request Feb 11, 2021
* master:
  Implement Approval Voting Subsystem (#2112)
  Introduce PerPeerSet utility that allows to segrate based on PeerSet (#2420)
  [CI] Move check_labels to github actions (#2415)
  runtime: set equivocation report longevity (#2404)
  Companion for #7936: Migrate pallet-balances to pallet attribute macro (#2331)
  Corrected Physical (#2414)
  validator_discovery: cache by (Hash, ParaId) (#2402)
  Enable wasmtime caching for PVF (companion for #8057) (#2387)
  Use construct_runtime in tests, remove default PalletInfo impl (#2409)
  validator_discovery: pass PeerSet to the request (#2372)
  guide: more robust approval counting procedure (#2378)
  Publish rococo on every push to `rococo-v1` branch (#2388)
  Bump trie-db from 0.22.2 to 0.22.3 (#2344)
  Send view to new peers (#2392)
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
None yet
Development

Successfully merging this pull request may close these issues.

Implement Approval Voting Subsystem
3 participants