Add candidate info to OccupiedCore (#2134)

* guide: add candidate information to OccupiedCore

* add descriptor and hash to occupied core type

* guide: add candidate hash to inclusion

* runtime: return candidate info in core state

* bitfield signing: stop querying runtime as much

* minimize going to runtime in availability distribution

* fix availability distribution tests

* guide: remove para ID from Occupied core

* get all crates compiling
This commit is contained in:
Robert Habermeier
2020-12-18 03:20:37 -05:00
committed by GitHub
parent eab86d6f4b
commit 38276b08a4
15 changed files with 129 additions and 208 deletions
@@ -24,6 +24,6 @@ If not running as a validator, do nothing.
- Begin by waiting a fixed period of time so availability distribution has the chance to make candidates available.
- Determine our validator index `i`, the set of backed candidates pending availability in `r`, and which bit of the bitfield each corresponds to.
- Start with an empty bitfield. For each bit in the bitfield, if there is a candidate pending availability, query the [Availability Store](../utility/availability-store.md) for whether we have the availability chunk for our validator index.
- Start with an empty bitfield. For each bit in the bitfield, if there is a candidate pending availability, query the [Availability Store](../utility/availability-store.md) for whether we have the availability chunk for our validator index. The `OccupiedCore` struct contains the candidate hash so the full candidate does not need to be fetched from runtime.
- For all chunks we have, set the corresponding bit in the bitfield.
- Sign the bitfield and dispatch a `BitfieldDistribution::DistributeBitfield` message.
@@ -12,8 +12,7 @@ This is all the information that a validator needs about scheduling for the curr
```rust
struct OccupiedCore {
/// The ID of the para occupying the core.
para_id: ParaId,
// NOTE: this has no ParaId as it can be deduced from the candidate descriptor.
/// If this core is freed by availability, this is the assignment that is next up on this
/// core, if any. None if there is nothing queued for this core.
next_up_on_available: Option<ScheduledCore>,
@@ -31,6 +30,10 @@ struct OccupiedCore {
availability: Bitfield,
/// The group assigned to distribute availability pieces of this candidate.
group_responsible: GroupIndex,
/// The hash of the candidate occupying the core.
candidate_hash: CandidateHash,
/// The descriptor of the candidate occupying the core.
candidate_descriptor: CandidateDescriptor,
}
struct ScheduledCore {
@@ -14,6 +14,7 @@ struct AvailabilityBitfield {
struct CandidatePendingAvailability {
core: CoreIndex, // availability core
hash: CandidateHash,
descriptor: CandidateDescriptor,
availability_votes: Bitfield, // one bit per validator.
relay_parent_number: BlockNumber, // number of the relay-parent.