Port availability recovery to use req/res (#2694)

* add AvailableDataFetchingRequest

* rename AvailabilityFetchingRequest to ChunkFetchingRequest

* rename AvailabilityFetchingResponse to Chunk_

* add AvailableDataFetching request

* add available data fetching request to availability recovery message

* remove availability recovery message

* fix

* update network bridge

* port availability recovery to request/response

* use validators.len(), not shuffling

* fix availability recovery tests

* update guide

* Update node/network/availability-recovery/src/lib.rs

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>

* Update node/network/availability-recovery/src/lib.rs

Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com>

* remove println

Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com>
This commit is contained in:
Robert Habermeier
2021-03-25 15:34:24 +01:00
committed by GitHub
parent 349879df6b
commit 8a396c678f
19 changed files with 379 additions and 1067 deletions
+7 -32
View File
@@ -23,7 +23,7 @@ use polkadot_primitives::v1::{Hash, BlockNumber};
use parity_scale_codec::{Encode, Decode};
use std::{fmt, collections::HashMap};
pub use sc_network::PeerId;
pub use sc_network::{PeerId, IfDisconnected};
#[doc(hidden)]
pub use polkadot_node_jaeger as jaeger;
#[doc(hidden)]
@@ -38,9 +38,6 @@ pub mod peer_set;
/// Request/response protocols used in Polkadot.
pub mod request_response;
/// A unique identifier of a request.
pub type RequestId = u64;
/// A version of the protocol.
pub type ProtocolVersion = u32;
@@ -288,35 +285,17 @@ impl View {
/// v1 protocol types.
pub mod v1 {
use parity_scale_codec::{Encode, Decode};
use std::convert::TryFrom;
use parity_scale_codec::{Decode, Encode};
use super::RequestId;
use polkadot_primitives::v1::{
CandidateIndex, CollatorId, CompressedPoV, Hash, Id as ParaId, SignedAvailabilityBitfield,
CollatorSignature,
};
use polkadot_node_primitives::{
approval::{IndirectAssignmentCert, IndirectSignedApprovalVote},
SignedFullStatement,
};
use polkadot_primitives::v1::{
AvailableData, CandidateHash, CandidateIndex, CollatorId, CompressedPoV,
CollatorSignature, ErasureChunk, Hash, Id as ParaId, SignedAvailabilityBitfield,
ValidatorIndex,
};
/// Network messages used by the availability recovery subsystem.
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
pub enum AvailabilityRecoveryMessage {
/// Request a chunk for a given candidate hash and validator index.
RequestChunk(RequestId, CandidateHash, ValidatorIndex),
/// Respond with chunk for a given candidate hash and validator index.
/// The response may be `None` if the requestee does not have the chunk.
Chunk(RequestId, Option<ErasureChunk>),
/// Request full data for a given candidate hash.
RequestFullData(RequestId, CandidateHash),
/// Respond with full data for a given candidate hash.
/// The response may be `None` if the requestee does not have the data.
FullData(RequestId, Option<AvailableData>),
}
/// Network messages used by the bitfield distribution subsystem.
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
@@ -388,11 +367,8 @@ pub mod v1 {
/// Statement distribution messages
#[codec(index = 3)]
StatementDistribution(StatementDistributionMessage),
/// Availability recovery messages
#[codec(index = 4)]
AvailabilityRecovery(AvailabilityRecoveryMessage),
/// Approval distribution messages
#[codec(index = 5)]
#[codec(index = 4)]
ApprovalDistribution(ApprovalDistributionMessage),
}
@@ -400,7 +376,6 @@ pub mod v1 {
impl_try_from!(ValidationProtocol, PoVDistribution, PoVDistributionMessage);
impl_try_from!(ValidationProtocol, StatementDistribution, StatementDistributionMessage);
impl_try_from!(ValidationProtocol, ApprovalDistribution, ApprovalDistributionMessage);
impl_try_from!(ValidationProtocol, AvailabilityRecovery, AvailabilityRecoveryMessage);
/// All network messages on the collation peer-set.
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]