mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 07:58:00 +00:00
Request based collation fetching (#2621)
* Introduce collation fetching protocol also move to mod.rs * Allow `PeerId`s in requests to network bridge. * Fix availability distribution tests. * Move CompressedPoV to primitives. * Request based collator protocol: validator side - Missing: tests - Collator side - don't connect, if not connected * Fixes. * Basic request based collator side. * Minor fix on collator side. * Don't connect in requests in collation protocol. Also some cleanup. * Fix PoV distribution * Bump substrate * Add back metrics + whitespace fixes. * Add back missing spans. * More cleanup. * Guide update. * Fix tests * Handle results in tests. * Fix weird compilation issue. * Add missing ) * Get rid of dead code. * Get rid of redundant import. * Fix runtime build. * Cleanup. * Fix wasm build. * Format fixes. Thanks @andronik !
This commit is contained in:
@@ -24,6 +24,9 @@
|
||||
|
||||
use futures::channel::{mpsc, oneshot};
|
||||
use thiserror::Error;
|
||||
|
||||
pub use sc_network::IfDisconnected;
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
peer_set::PeerSet, v1 as protocol_v1, UnifiedReputationChange, PeerId,
|
||||
request_response::{Requests, request::IncomingRequest, v1 as req_res_v1},
|
||||
@@ -198,21 +201,8 @@ pub enum CollatorProtocolMessage {
|
||||
/// Get a network bridge update.
|
||||
#[from]
|
||||
NetworkBridgeUpdateV1(NetworkBridgeEvent<protocol_v1::CollatorProtocolMessage>),
|
||||
}
|
||||
|
||||
impl CollatorProtocolMessage {
|
||||
/// If the current variant contains the relay parent hash, return it.
|
||||
pub fn relay_parent(&self) -> Option<Hash> {
|
||||
match self {
|
||||
Self::CollateOn(_) => None,
|
||||
Self::DistributeCollation(receipt, _, _) => Some(receipt.descriptor().relay_parent),
|
||||
Self::FetchCollation(relay_parent, _, _, _) => Some(*relay_parent),
|
||||
Self::ReportCollator(_) => None,
|
||||
Self::NoteGoodCollation(_) => None,
|
||||
Self::NetworkBridgeUpdateV1(_) => None,
|
||||
Self::NotifyCollationSeconded(_, _) => None,
|
||||
}
|
||||
}
|
||||
/// Incoming network request for a collation.
|
||||
CollationFetchingRequest(IncomingRequest<req_res_v1::CollationFetchingRequest>)
|
||||
}
|
||||
|
||||
/// Messages received by the network bridge subsystem.
|
||||
@@ -234,7 +224,8 @@ pub enum NetworkBridgeMessage {
|
||||
SendCollationMessages(Vec<(Vec<PeerId>, protocol_v1::CollationProtocol)>),
|
||||
|
||||
/// Send requests via substrate request/response.
|
||||
SendRequests(Vec<Requests>),
|
||||
/// Second parameter, tells what to do if we are not yet connected to the peer.
|
||||
SendRequests(Vec<Requests>, IfDisconnected),
|
||||
|
||||
/// Connect to peers who represent the given `validator_ids`.
|
||||
///
|
||||
@@ -750,3 +741,13 @@ impl From<IncomingRequest<req_res_v1::AvailabilityFetchingRequest>> for AllMessa
|
||||
From::<AvailabilityDistributionMessage>::from(From::from(req))
|
||||
}
|
||||
}
|
||||
impl From<IncomingRequest<req_res_v1::CollationFetchingRequest>> for AllMessages {
|
||||
fn from(req: IncomingRequest<req_res_v1::CollationFetchingRequest>) -> Self {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user