mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Request based PoV distribution (#2640)
* Indentation fix. * Prepare request-response for PoV fetching. * Drop old PoV distribution. * WIP: Fetch PoV directly from backing. * Backing compiles. * Runtime access and connection management for PoV distribution. * Get rid of seemingly dead code. * Implement PoV fetching. Backing does not yet use it. * Don't send `ConnectToValidators` for empty list. * Even better - no need to check over and over again. * PoV fetching implemented. + Typechecks + Should work Missing: - Guide - Tests - Do fallback fetching in case fetching from seconding validator fails. * Check PoV hash upon reception. * Implement retry of PoV fetching in backing. * Avoid pointless validation spawning. * Add jaeger span to pov requesting. * Add back tracing. * Review remarks. * Whitespace. * Whitespace again. * Cleanup + fix tests. * Log to log target in overseer. * Fix more tests. * Don't fail if group cannot be found. * Simple test for PoV fetcher. * Handle missing group membership better. * Add test for retry functionality. * Fix flaky test. * Spaces again. * Guide updates. * Spaces.
This commit is contained in:
@@ -264,10 +264,29 @@ impl NetworkBridgeMessage {
|
||||
}
|
||||
|
||||
/// Availability Distribution Message.
|
||||
#[derive(Debug, derive_more::From)]
|
||||
#[derive(Debug)]
|
||||
pub enum AvailabilityDistributionMessage {
|
||||
/// Incoming network request for an availability chunk.
|
||||
ChunkFetchingRequest(IncomingRequest<req_res_v1::ChunkFetchingRequest>)
|
||||
ChunkFetchingRequest(IncomingRequest<req_res_v1::ChunkFetchingRequest>),
|
||||
/// Incoming network request for a seconded PoV.
|
||||
PoVFetchingRequest(IncomingRequest<req_res_v1::PoVFetchingRequest>),
|
||||
/// Instruct availability distribution to fetch a remote PoV.
|
||||
///
|
||||
/// NOTE: The result of this fetch is not yet locally validated and could be bogus.
|
||||
FetchPoV {
|
||||
/// The relay parent giving the necessary context.
|
||||
relay_parent: Hash,
|
||||
/// Validator to fetch the PoV from.
|
||||
from_validator: ValidatorIndex,
|
||||
/// Candidate hash to fetch the PoV for.
|
||||
candidate_hash: CandidateHash,
|
||||
/// Expected hash of the PoV, a PoV not matching this hash will be rejected.
|
||||
pov_hash: Hash,
|
||||
/// Sender for getting back the result of this fetch.
|
||||
///
|
||||
/// The sender will be canceled if the fetching failed for some reason.
|
||||
tx: oneshot::Sender<PoV>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Availability Recovery Message.
|
||||
@@ -285,15 +304,6 @@ pub enum AvailabilityRecoveryMessage {
|
||||
AvailableDataFetchingRequest(IncomingRequest<req_res_v1::AvailableDataFetchingRequest>),
|
||||
}
|
||||
|
||||
impl AvailabilityDistributionMessage {
|
||||
/// If the current variant contains the relay parent hash, return it.
|
||||
pub fn relay_parent(&self) -> Option<Hash> {
|
||||
match self {
|
||||
Self::ChunkFetchingRequest(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Bitfield distribution message.
|
||||
#[derive(Debug, derive_more::From)]
|
||||
pub enum BitfieldDistributionMessage {
|
||||
@@ -568,33 +578,6 @@ impl BoundToRelayParent for ProvisionerMessage {
|
||||
}
|
||||
}
|
||||
|
||||
/// Message to the PoV Distribution subsystem.
|
||||
#[derive(Debug, derive_more::From)]
|
||||
pub enum PoVDistributionMessage {
|
||||
/// Fetch a PoV from the network.
|
||||
///
|
||||
/// This `CandidateDescriptor` should correspond to a candidate seconded under the provided
|
||||
/// relay-parent hash.
|
||||
FetchPoV(Hash, CandidateDescriptor, oneshot::Sender<Arc<PoV>>),
|
||||
/// Distribute a PoV for the given relay-parent and CandidateDescriptor.
|
||||
/// The PoV should correctly hash to the PoV hash mentioned in the CandidateDescriptor
|
||||
DistributePoV(Hash, CandidateDescriptor, Arc<PoV>),
|
||||
/// An update from the network bridge.
|
||||
#[from]
|
||||
NetworkBridgeUpdateV1(NetworkBridgeEvent<protocol_v1::PoVDistributionMessage>),
|
||||
}
|
||||
|
||||
impl PoVDistributionMessage {
|
||||
/// If the current variant contains the relay parent hash, return it.
|
||||
pub fn relay_parent(&self) -> Option<Hash> {
|
||||
match self {
|
||||
Self::FetchPoV(hash, _, _) => Some(*hash),
|
||||
Self::DistributePoV(hash, _, _) => Some(*hash),
|
||||
Self::NetworkBridgeUpdateV1(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Message to the Collation Generation subsystem.
|
||||
#[derive(Debug)]
|
||||
pub enum CollationGenerationMessage {
|
||||
@@ -717,8 +700,6 @@ pub enum AllMessages {
|
||||
/// Message for the Provisioner subsystem.
|
||||
#[skip]
|
||||
Provisioner(ProvisionerMessage),
|
||||
/// Message for the PoV Distribution subsystem.
|
||||
PoVDistribution(PoVDistributionMessage),
|
||||
/// Message for the Runtime API subsystem.
|
||||
#[skip]
|
||||
RuntimeApi(RuntimeApiMessage),
|
||||
@@ -741,6 +722,28 @@ pub enum AllMessages {
|
||||
GossipSupport(GossipSupportMessage),
|
||||
}
|
||||
|
||||
impl From<IncomingRequest<req_res_v1::PoVFetchingRequest>> for AvailabilityDistributionMessage {
|
||||
fn from(req: IncomingRequest<req_res_v1::PoVFetchingRequest>) -> Self {
|
||||
Self::PoVFetchingRequest(req)
|
||||
}
|
||||
}
|
||||
impl From<IncomingRequest<req_res_v1::ChunkFetchingRequest>> for AvailabilityDistributionMessage {
|
||||
fn from(req: IncomingRequest<req_res_v1::ChunkFetchingRequest>) -> Self {
|
||||
Self::ChunkFetchingRequest(req)
|
||||
}
|
||||
}
|
||||
impl From<IncomingRequest<req_res_v1::CollationFetchingRequest>> for CollatorProtocolMessage {
|
||||
fn from(req: IncomingRequest<req_res_v1::CollationFetchingRequest>) -> Self {
|
||||
Self::CollationFetchingRequest(req)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl From<IncomingRequest<req_res_v1::PoVFetchingRequest>> for AllMessages {
|
||||
fn from(req: IncomingRequest<req_res_v1::PoVFetchingRequest>) -> Self {
|
||||
From::<AvailabilityDistributionMessage>::from(From::from(req))
|
||||
}
|
||||
}
|
||||
impl From<IncomingRequest<req_res_v1::ChunkFetchingRequest>> for AllMessages {
|
||||
fn from(req: IncomingRequest<req_res_v1::ChunkFetchingRequest>) -> Self {
|
||||
From::<AvailabilityDistributionMessage>::from(From::from(req))
|
||||
@@ -751,11 +754,6 @@ impl From<IncomingRequest<req_res_v1::CollationFetchingRequest>> for AllMessages
|
||||
From::<CollatorProtocolMessage>::from(From::from(req))
|
||||
}
|
||||
}
|
||||
impl From<IncomingRequest<req_res_v1::CollationFetchingRequest>> for CollatorProtocolMessage {
|
||||
fn from(req: IncomingRequest<req_res_v1::CollationFetchingRequest>) -> Self {
|
||||
Self::CollationFetchingRequest(req)
|
||||
}
|
||||
}
|
||||
impl From<IncomingRequest<req_res_v1::AvailableDataFetchingRequest>> for AllMessages {
|
||||
fn from(req: IncomingRequest<req_res_v1::AvailableDataFetchingRequest>) -> Self {
|
||||
From::<AvailabilityRecoveryMessage>::from(From::from(req))
|
||||
|
||||
Reference in New Issue
Block a user