#subsystem

polkadot-node-core-backing

The Candidate Backing Subsystem. Tracks parachain candidates that can be backed, as well as the issuance of statements about candidates.

17 major breaking releases

18.0.0 Oct 1, 2024
17.0.0 Jul 19, 2024
15.0.0 Jul 13, 2024
14.0.0 Jun 24, 2024
0.0.0 Nov 21, 2022

#38 in #subsystem

Download history 345/week @ 2024-07-02 495/week @ 2024-07-09 484/week @ 2024-07-16 459/week @ 2024-07-23 373/week @ 2024-07-30 476/week @ 2024-08-06 594/week @ 2024-08-13 670/week @ 2024-08-20 435/week @ 2024-08-27 445/week @ 2024-09-03 751/week @ 2024-09-10 611/week @ 2024-09-17 911/week @ 2024-09-24 1005/week @ 2024-10-01 775/week @ 2024-10-08 645/week @ 2024-10-15

3,483 downloads per month
Used in 3 crates (2 directly)

GPL-3.0-only

220KB
5.5K SLoC

Release

Polkadot SDK stable2409


lib.rs:

Implements the CandidateBackingSubsystem.

This subsystem maintains the entire responsibility of tracking parachain candidates which can be backed, as well as the issuance of statements about candidates when run on a validator node.

There are two types of statements: Seconded and Valid. Seconded implies Valid, and nothing should be stated as Valid unless its already been Seconded.

Validators may only second candidates which fall under their own group assignment, and they may only second one candidate per depth per active leaf. Candidates which are stated as either Second or Valid by a majority of the assigned group of validators may be backed on-chain and proceed to the availability stage.

Depth is a concept relating to asynchronous backing, by which short sub-chains of candidates are backed and extended off-chain, and then placed asynchronously into blocks of the relay chain as those are authored and as the relay-chain state becomes ready for them. Asynchronous backing allows parachains to grow mostly independently from the state of the relay chain, which gives more time for parachains to be validated and thereby increases performance.

Most of the work of asynchronous backing is handled by the Prospective Parachains subsystem. The 'depth' of a parachain block with respect to a relay chain block is a measure of how many parachain blocks are between the most recent included parachain block in the post-state of the relay-chain block and the candidate. For instance, a candidate that descends directly from the most recent parachain block in the relay-chain state has depth 0. The child of that candidate would have depth 1. And so on.

The candidate backing subsystem keeps track of a set of 'active leaves' which are the most recent blocks in the relay-chain (which is in fact a tree) which could be built upon. Depth is always measured against active leaves, and the valid relay-parent that each candidate can have is determined by the active leaves. The Prospective Parachains subsystem enforces that the relay-parent increases monotonically, so that logic is not handled here. By communicating with the Prospective Parachains subsystem, this subsystem extrapolates an "implicit view" from the set of currently active leaves, which determines the set of all recent relay-chain block hashes which could be relay-parents for candidates backed in children of the active leaves.

In fact, this subsystem relies on the Statement Distribution subsystem to prevent spam by enforcing the rule that each validator may second at most one candidate per depth per active leaf. This bounds the number of candidates that the system needs to consider and is not handled within this subsystem, except for candidates seconded locally.

This subsystem also handles relay-chain heads which don't support asynchronous backing. For such active leaves, the only valid relay-parent is the leaf hash itself and the only allowed depth is 0.

Dependencies

~97–135MB
~2.5M SLoC