Availability store subsystem (#1404)

* Initial commit

* WIP

* Make atomic transactions

* Remove pruning code

* Fix build and add a Nop to bridge

* Fixes from review

* Move config struct around for clarity

* Rename constructor and warn on missing docs

* Fix a test and rename a message

* Fix some more reviews

* Obviously failed to rebase cleanly
This commit is contained in:
Fedor Sakharov
2020-07-27 14:13:02 +03:00
committed by GitHub
parent 65797c001c
commit 32a20a178c
15 changed files with 701 additions and 57 deletions
+2
View File
@@ -84,6 +84,8 @@ impl PartialEq for ActiveLeavesUpdate {
pub enum OverseerSignal {
/// Subsystems should adjust their jobs to start and stop work on appropriate block hashes.
ActiveLeaves(ActiveLeavesUpdate),
/// `Subsystem` is informed of a finalized block by its block hash.
BlockFinalized(Hash),
/// Conclude the work of the `Overseer` and all `Subsystem`s.
Conclude,
}
+21 -12
View File
@@ -25,11 +25,11 @@
use futures::channel::{mpsc, oneshot};
use polkadot_primitives::v1::{
BlockNumber, Hash,
CandidateReceipt, CommittedCandidateReceipt, PoV, ErasureChunk, BackedCandidate, Id as ParaId,
BlockNumber, Hash, CommittedCandidateReceipt,
CandidateReceipt, PoV, ErasureChunk, BackedCandidate, Id as ParaId,
SignedAvailabilityBitfield, SigningContext, ValidatorId, ValidationCode, ValidatorIndex,
CoreAssignment, CoreOccupied, HeadData, CandidateDescriptor,
ValidatorSignature, OmittedValidationData,
ValidatorSignature, OmittedValidationData, AvailableData,
};
use polkadot_node_primitives::{
MisbehaviorReport, SignedFullStatement, View, ProtocolId, ValidationResult,
@@ -235,31 +235,40 @@ impl BitfieldSigningMessage {
/// Availability store subsystem message.
#[derive(Debug)]
pub enum AvailabilityStoreMessage {
/// Query a `PoV` from the AV store.
QueryPoV(Hash, oneshot::Sender<Option<PoV>>),
/// Query a `AvailableData` from the AV store.
QueryAvailableData(Hash, oneshot::Sender<Option<AvailableData>>),
/// Query whether a `PoV` exists within the AV Store.
/// Query whether a `AvailableData` exists within the AV Store.
///
/// This is useful in cases like bitfield signing, when existence
/// matters, but we don't want to necessarily pass around multiple
/// megabytes of data to get a single bit of information.
QueryPoVAvailable(Hash, oneshot::Sender<bool>),
QueryDataAvailability(Hash, oneshot::Sender<bool>),
/// Query an `ErasureChunk` from the AV store.
QueryChunk(Hash, ValidatorIndex, oneshot::Sender<ErasureChunk>),
QueryChunk(Hash, ValidatorIndex, oneshot::Sender<Option<ErasureChunk>>),
/// Store an `ErasureChunk` in the AV store.
StoreChunk(Hash, ValidatorIndex, ErasureChunk),
///
/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
StoreChunk(Hash, ValidatorIndex, ErasureChunk, oneshot::Sender<Result<(), ()>>),
/// Store a `AvailableData` in the AV store.
/// If `ValidatorIndex` is present store corresponding chunk also.
///
/// Return `Ok(())` if the store operation succeeded, `Err(())` if it failed.
StoreAvailableData(Hash, Option<ValidatorIndex>, u32, AvailableData, oneshot::Sender<Result<(), ()>>),
}
impl AvailabilityStoreMessage {
/// If the current variant contains the relay parent hash, return it.
pub fn relay_parent(&self) -> Option<Hash> {
match self {
Self::QueryPoV(hash, _) => Some(*hash),
Self::QueryPoVAvailable(hash, _) => Some(*hash),
Self::QueryAvailableData(hash, _) => Some(*hash),
Self::QueryDataAvailability(hash, _) => Some(*hash),
Self::QueryChunk(hash, _, _) => Some(*hash),
Self::StoreChunk(hash, _, _) => Some(*hash),
Self::StoreChunk(hash, _, _, _) => Some(*hash),
Self::StoreAvailableData(hash, _, _, _, _) => Some(*hash),
}
}
}
+2 -1
View File
@@ -603,7 +603,7 @@ where
) -> bool {
use crate::FromOverseer::{Communication, Signal};
use crate::ActiveLeavesUpdate;
use crate::OverseerSignal::{Conclude, ActiveLeaves};
use crate::OverseerSignal::{BlockFinalized, Conclude, ActiveLeaves};
match incoming {
Ok(Signal(ActiveLeaves(ActiveLeavesUpdate { activated, deactivated }))) => {
@@ -667,6 +667,7 @@ where
}
}
}
Ok(Signal(BlockFinalized(_))) => {}
Err(err) => {
log::error!("error receiving message from subsystem context: {:?}", err);
Self::fwd_err(None, Error::from(err).into(), err_tx).await;