Migrate polkadot-primitives to v6 (#1543)

- Async-backing related primitives are stable `primitives::v6`
- Async-backing API is now part of `api_version(7)`
- It's enabled on Rococo and Westend runtimes

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
Chris Sosnin
2023-09-27 13:32:02 +03:00
committed by GitHub
parent 5a2833cceb
commit 7cbe0c76ef
107 changed files with 2410 additions and 2792 deletions
@@ -55,7 +55,7 @@ pub use outgoing::{OutgoingRequest, OutgoingResult, Recipient, Requests, Respons
pub mod v1;
/// Actual versioned requests and responses that are sent over the wire.
pub mod vstaging;
pub mod v2;
/// A protocol per subsystem seems to make the most sense, this way we don't need any dispatching
/// within protocols.
@@ -66,7 +66,7 @@ pub enum Protocol {
/// Protocol for fetching collations from collators.
CollationFetchingV1,
/// Protocol for fetching collations from collators when async backing is enabled.
CollationFetchingVStaging,
CollationFetchingV2,
/// Protocol for fetching seconded PoVs from validators of the same group.
PoVFetchingV1,
/// Protocol for fetching available data.
@@ -78,7 +78,7 @@ pub enum Protocol {
/// Protocol for requesting candidates with attestations in statement distribution
/// when async backing is enabled.
AttestedCandidateVStaging,
AttestedCandidateV2,
}
/// Minimum bandwidth we expect for validators - 500Mbit/s is the recommendation, so approximately
@@ -147,7 +147,7 @@ const POV_RESPONSE_SIZE: u64 = MAX_POV_SIZE as u64 + 10_000;
/// This is `MAX_CODE_SIZE` plus some additional space for protocol overhead.
const STATEMENT_RESPONSE_SIZE: u64 = MAX_CODE_SIZE as u64 + 10_000;
/// Maximum response sizes for `AttestedCandidateVStaging`.
/// Maximum response sizes for `AttestedCandidateV2`.
///
/// This is `MAX_CODE_SIZE` plus some additional space for protocol overhead and
/// additional backing statements.
@@ -199,7 +199,7 @@ impl Protocol {
request_timeout: CHUNK_REQUEST_TIMEOUT,
inbound_queue: tx,
},
Protocol::CollationFetchingV1 | Protocol::CollationFetchingVStaging =>
Protocol::CollationFetchingV1 | Protocol::CollationFetchingV2 =>
RequestResponseConfig {
name,
fallback_names,
@@ -254,7 +254,7 @@ impl Protocol {
request_timeout: DISPUTE_REQUEST_TIMEOUT,
inbound_queue: tx,
},
Protocol::AttestedCandidateVStaging => RequestResponseConfig {
Protocol::AttestedCandidateV2 => RequestResponseConfig {
name,
fallback_names,
max_request_size: 1_000,
@@ -275,7 +275,7 @@ impl Protocol {
// as well.
Protocol::ChunkFetchingV1 => 100,
// 10 seems reasonable, considering group sizes of max 10 validators.
Protocol::CollationFetchingV1 | Protocol::CollationFetchingVStaging => 10,
Protocol::CollationFetchingV1 | Protocol::CollationFetchingV2 => 10,
// 10 seems reasonable, considering group sizes of max 10 validators.
Protocol::PoVFetchingV1 => 10,
// Validators are constantly self-selecting to request available data which may lead
@@ -307,7 +307,7 @@ impl Protocol {
// failure, so having a good value here is mostly about performance tuning.
Protocol::DisputeSendingV1 => 100,
Protocol::AttestedCandidateVStaging => {
Protocol::AttestedCandidateV2 => {
// We assume we can utilize up to 70% of the available bandwidth for statements.
// This is just a guess/estimate, with the following considerations: If we are
// faster than that, queue size will stay low anyway, even if not - requesters will
@@ -344,8 +344,8 @@ impl Protocol {
Protocol::DisputeSendingV1 => Some("/polkadot/send_dispute/1"),
// Introduced after legacy names became legacy.
Protocol::AttestedCandidateVStaging => None,
Protocol::CollationFetchingVStaging => None,
Protocol::AttestedCandidateV2 => None,
Protocol::CollationFetchingV2 => None,
}
}
}
@@ -402,8 +402,8 @@ impl ReqProtocolNames {
Protocol::StatementFetchingV1 => "/req_statement/1",
Protocol::DisputeSendingV1 => "/send_dispute/1",
Protocol::CollationFetchingVStaging => "/req_collation/2",
Protocol::AttestedCandidateVStaging => "/req_attested_candidate/2",
Protocol::CollationFetchingV2 => "/req_collation/2",
Protocol::AttestedCandidateV2 => "/req_attested_candidate/2",
};
format!("{}{}", prefix, short_name).into()
@@ -23,7 +23,7 @@ use sc_network::PeerId;
use polkadot_primitives::AuthorityDiscoveryId;
use super::{v1, vstaging, IsRequest, Protocol};
use super::{v1, v2, IsRequest, Protocol};
/// All requests that can be sent to the network bridge via `NetworkBridgeTxMessage::SendRequest`.
#[derive(Debug)]
@@ -42,10 +42,10 @@ pub enum Requests {
DisputeSendingV1(OutgoingRequest<v1::DisputeRequest>),
/// Request a candidate and attestations.
AttestedCandidateVStaging(OutgoingRequest<vstaging::AttestedCandidateRequest>),
AttestedCandidateV2(OutgoingRequest<v2::AttestedCandidateRequest>),
/// Fetch a collation from a collator which previously announced it.
/// Compared to V1 it requires specifying which candidate is requested by its hash.
CollationFetchingVStaging(OutgoingRequest<vstaging::CollationFetchingRequest>),
CollationFetchingV2(OutgoingRequest<v2::CollationFetchingRequest>),
}
impl Requests {
@@ -54,12 +54,12 @@ impl Requests {
match self {
Self::ChunkFetchingV1(_) => Protocol::ChunkFetchingV1,
Self::CollationFetchingV1(_) => Protocol::CollationFetchingV1,
Self::CollationFetchingVStaging(_) => Protocol::CollationFetchingVStaging,
Self::CollationFetchingV2(_) => Protocol::CollationFetchingV2,
Self::PoVFetchingV1(_) => Protocol::PoVFetchingV1,
Self::AvailableDataFetchingV1(_) => Protocol::AvailableDataFetchingV1,
Self::StatementFetchingV1(_) => Protocol::StatementFetchingV1,
Self::DisputeSendingV1(_) => Protocol::DisputeSendingV1,
Self::AttestedCandidateVStaging(_) => Protocol::AttestedCandidateVStaging,
Self::AttestedCandidateV2(_) => Protocol::AttestedCandidateV2,
}
}
@@ -74,12 +74,12 @@ impl Requests {
match self {
Self::ChunkFetchingV1(r) => r.encode_request(),
Self::CollationFetchingV1(r) => r.encode_request(),
Self::CollationFetchingVStaging(r) => r.encode_request(),
Self::CollationFetchingV2(r) => r.encode_request(),
Self::PoVFetchingV1(r) => r.encode_request(),
Self::AvailableDataFetchingV1(r) => r.encode_request(),
Self::StatementFetchingV1(r) => r.encode_request(),
Self::DisputeSendingV1(r) => r.encode_request(),
Self::AttestedCandidateVStaging(r) => r.encode_request(),
Self::AttestedCandidateV2(r) => r.encode_request(),
}
}
}
@@ -18,13 +18,13 @@
use parity_scale_codec::{Decode, Encode};
use polkadot_primitives::vstaging::{
use polkadot_primitives::{
CandidateHash, CommittedCandidateReceipt, Hash, Id as ParaId, PersistedValidationData,
UncheckedSignedStatement,
};
use super::{IsRequest, Protocol};
use crate::vstaging::StatementFilter;
use crate::v2::StatementFilter;
/// Request a candidate with statements.
#[derive(Debug, Clone, Encode, Decode)]
@@ -56,7 +56,7 @@ pub struct AttestedCandidateResponse {
impl IsRequest for AttestedCandidateRequest {
type Response = AttestedCandidateResponse;
const PROTOCOL: Protocol = Protocol::AttestedCandidateVStaging;
const PROTOCOL: Protocol = Protocol::AttestedCandidateV2;
}
/// Responses as sent by collators.
@@ -76,5 +76,5 @@ pub struct CollationFetchingRequest {
impl IsRequest for CollationFetchingRequest {
// The response is the same as for V1.
type Response = CollationFetchingResponse;
const PROTOCOL: Protocol = Protocol::CollationFetchingVStaging;
const PROTOCOL: Protocol = Protocol::CollationFetchingV2;
}