Implement PoV Distribution Subsystem (#1344)

* introduce candidatedescriptor type

* add PoVDistribution message type

* loosen bound on PoV Distribution to account for equivocations

* re-export some types from the messages module

* begin PoV Distribution subsystem

* remove redundant index from PoV distribution

* define state machine for pov distribution

* handle overseer signals

* set up control flow

* remove `ValidatorStatement` section

* implement PoV fetching

* implement distribution logic

* add missing `

* implement some network bridge event handlers

* stub for message processing, handle our view change

* control flow for handling messages

* handle `awaiting` message

* handle any incoming PoVs and redistribute

* actually provide a subsystem implementation

* remove set-builder notation

* begin testing PoV distribution

* test that we send awaiting messages only to peers with same view

* ensure we distribute awaited PoVs to peers on view changes

* test that peers can complete fetch and are rewarded

* test some reporting logic

* ensure peer is reported for flooding

* test punishing peers diverging from awaited protocol

* test that we eagerly complete peers' awaited PoVs based on what we receive

* test that we prune the awaited set after receiving

* expand pov-distribution in guide to match a change I made

* remove unneeded import
This commit is contained in:
Robert Habermeier
2020-07-08 18:15:39 -04:00
committed by GitHub
parent f83ba174f1
commit 151d73af5b
9 changed files with 1565 additions and 16 deletions
+31
View File
@@ -460,6 +460,17 @@ impl AbridgedCandidateReceipt {
pov_block_hash: *pov_block_hash,
}
}
/// Clone the relevant portions of the `AbridgedCandidateReceipt` to form a `CandidateDescriptor`.
pub fn to_descriptor(&self) -> CandidateDescriptor {
CandidateDescriptor {
para_id: self.parachain_index,
relay_parent: self.relay_parent,
collator: self.collator.clone(),
signature: self.signature.clone(),
pov_hash: self.pov_block_hash.clone(),
}
}
}
@@ -478,6 +489,26 @@ impl Ord for AbridgedCandidateReceipt {
}
}
/// A unique descriptor of the candidate receipt, in a lightweight format.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Default))]
pub struct CandidateDescriptor<H = Hash> {
/// The ID of the para this is a candidate for.
pub para_id: Id,
/// The hash of the relay-chain block this should be executed in
/// the context of.
// NOTE: the fact that the hash includes this value means that code depends
// on this for deduplication. Removing this field is likely to break things.
pub relay_parent: H,
/// The collator's relay-chain account ID
pub collator: CollatorId,
/// Signature on blake2-256 of components of this receipt:
/// The para ID, the relay parent, and the pov_hash.
pub signature: CollatorSignature,
/// The hash of the pov-block.
pub pov_hash: H,
}
/// A collation sent by a collator.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Default))]