mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 00:28:01 +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:
@@ -23,7 +23,7 @@ use futures::{FutureExt, SinkExt};
|
||||
|
||||
use polkadot_erasure_coding::branch_hash;
|
||||
use polkadot_node_network_protocol::request_response::{
|
||||
request::{OutgoingRequest, RequestError, Requests},
|
||||
request::{OutgoingRequest, RequestError, Requests, Recipient},
|
||||
v1::{AvailabilityFetchingRequest, AvailabilityFetchingResponse},
|
||||
};
|
||||
use polkadot_primitives::v1::{
|
||||
@@ -31,7 +31,7 @@ use polkadot_primitives::v1::{
|
||||
SessionIndex,
|
||||
};
|
||||
use polkadot_subsystem::messages::{
|
||||
AllMessages, AvailabilityStoreMessage, NetworkBridgeMessage,
|
||||
AllMessages, AvailabilityStoreMessage, NetworkBridgeMessage, IfDisconnected,
|
||||
};
|
||||
use polkadot_subsystem::{SubsystemContext, jaeger};
|
||||
|
||||
@@ -330,12 +330,12 @@ impl RunningTask {
|
||||
validator: &AuthorityDiscoveryId,
|
||||
) -> std::result::Result<AvailabilityFetchingResponse, TaskError> {
|
||||
let (full_request, response_recv) =
|
||||
OutgoingRequest::new(validator.clone(), self.request);
|
||||
OutgoingRequest::new(Recipient::Authority(validator.clone()), self.request);
|
||||
let requests = Requests::AvailabilityFetching(full_request);
|
||||
|
||||
self.sender
|
||||
.send(FromFetchTask::Message(AllMessages::NetworkBridge(
|
||||
NetworkBridgeMessage::SendRequests(vec![requests]),
|
||||
NetworkBridgeMessage::SendRequests(vec![requests], IfDisconnected::TryConnect)
|
||||
)))
|
||||
.await
|
||||
.map_err(|_| TaskError::ShuttingDown)?;
|
||||
|
||||
@@ -28,6 +28,7 @@ use sp_keyring::Sr25519Keyring;
|
||||
|
||||
use polkadot_primitives::v1::{BlockData, CandidateHash, PoV, ValidatorIndex};
|
||||
use polkadot_node_network_protocol::request_response::v1;
|
||||
use polkadot_node_network_protocol::request_response::Recipient;
|
||||
use polkadot_subsystem::messages::AllMessages;
|
||||
|
||||
use crate::metrics::Metrics;
|
||||
@@ -56,7 +57,7 @@ fn task_does_not_accept_invalid_chunk() {
|
||||
chunk_responses: {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(
|
||||
Sr25519Keyring::Alice.public().into(),
|
||||
Recipient::Authority(Sr25519Keyring::Alice.public().into()),
|
||||
AvailabilityFetchingResponse::Chunk(
|
||||
v1::ChunkResponse {
|
||||
chunk: vec![1,2,3],
|
||||
@@ -88,7 +89,7 @@ fn task_stores_valid_chunk() {
|
||||
chunk_responses: {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(
|
||||
Sr25519Keyring::Alice.public().into(),
|
||||
Recipient::Authority(Sr25519Keyring::Alice.public().into()),
|
||||
AvailabilityFetchingResponse::Chunk(
|
||||
v1::ChunkResponse {
|
||||
chunk: chunk.chunk.clone(),
|
||||
@@ -124,7 +125,7 @@ fn task_does_not_accept_wrongly_indexed_chunk() {
|
||||
chunk_responses: {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(
|
||||
Sr25519Keyring::Alice.public().into(),
|
||||
Recipient::Authority(Sr25519Keyring::Alice.public().into()),
|
||||
AvailabilityFetchingResponse::Chunk(
|
||||
v1::ChunkResponse {
|
||||
chunk: chunk.chunk.clone(),
|
||||
@@ -163,7 +164,7 @@ fn task_stores_valid_chunk_if_there_is_one() {
|
||||
chunk_responses: {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(
|
||||
Sr25519Keyring::Alice.public().into(),
|
||||
Recipient::Authority(Sr25519Keyring::Alice.public().into()),
|
||||
AvailabilityFetchingResponse::Chunk(
|
||||
v1::ChunkResponse {
|
||||
chunk: chunk.chunk.clone(),
|
||||
@@ -172,11 +173,11 @@ fn task_stores_valid_chunk_if_there_is_one() {
|
||||
)
|
||||
);
|
||||
m.insert(
|
||||
Sr25519Keyring::Bob.public().into(),
|
||||
Recipient::Authority(Sr25519Keyring::Bob.public().into()),
|
||||
AvailabilityFetchingResponse::NoSuchChunk
|
||||
);
|
||||
m.insert(
|
||||
Sr25519Keyring::Charlie.public().into(),
|
||||
Recipient::Authority(Sr25519Keyring::Charlie.public().into()),
|
||||
AvailabilityFetchingResponse::Chunk(
|
||||
v1::ChunkResponse {
|
||||
chunk: vec![1,2,3],
|
||||
@@ -199,7 +200,7 @@ fn task_stores_valid_chunk_if_there_is_one() {
|
||||
struct TestRun {
|
||||
/// Response to deliver for a given validator index.
|
||||
/// None means, answer with NetworkError.
|
||||
chunk_responses: HashMap<AuthorityDiscoveryId, AvailabilityFetchingResponse>,
|
||||
chunk_responses: HashMap<Recipient, AvailabilityFetchingResponse>,
|
||||
/// Set of chunks that should be considered valid:
|
||||
valid_chunks: HashSet<Vec<u8>>,
|
||||
}
|
||||
@@ -240,11 +241,12 @@ impl TestRun {
|
||||
/// end.
|
||||
async fn handle_message(&self, msg: AllMessages) -> bool {
|
||||
match msg {
|
||||
AllMessages::NetworkBridge(NetworkBridgeMessage::SendRequests(reqs)) => {
|
||||
AllMessages::NetworkBridge(NetworkBridgeMessage::SendRequests(reqs, IfDisconnected::TryConnect)) => {
|
||||
let mut valid_responses = 0;
|
||||
for req in reqs {
|
||||
let req = match req {
|
||||
Requests::AvailabilityFetching(req) => req,
|
||||
_ => panic!("Unexpected request"),
|
||||
};
|
||||
let response = self.chunk_responses.get(&req.peer)
|
||||
.ok_or(network::RequestFailure::Refused);
|
||||
|
||||
@@ -29,6 +29,7 @@ use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
use sp_core::{traits::SpawnNamed, testing::TaskExecutor};
|
||||
use sc_network as network;
|
||||
use sc_network::IfDisconnected;
|
||||
use sc_network::config as netconfig;
|
||||
|
||||
use polkadot_subsystem::{ActiveLeavesUpdate, FromOverseer, OverseerSignal, messages::{AllMessages,
|
||||
@@ -201,7 +202,7 @@ impl TestState {
|
||||
tracing::trace!(target: LOG_TARGET, remaining_stores, "Stores left to go");
|
||||
let msg = overseer_recv(&mut rx).await;
|
||||
match msg {
|
||||
AllMessages::NetworkBridge(NetworkBridgeMessage::SendRequests(reqs)) => {
|
||||
AllMessages::NetworkBridge(NetworkBridgeMessage::SendRequests(reqs, IfDisconnected::TryConnect)) => {
|
||||
for req in reqs {
|
||||
// Forward requests:
|
||||
let in_req = to_incoming_req(&executor, req);
|
||||
@@ -313,5 +314,6 @@ fn to_incoming_req(
|
||||
tx
|
||||
)
|
||||
}
|
||||
_ => panic!("Unexpected request!"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user