mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-10 07:37:30 +00:00
Dispute distribution implementation (#3282)
* Dispute protocol. * Dispute distribution protocol. * Get network requests routed. * WIP: Basic dispute sender logic. * Basic validator determination logic. * WIP: Getting things to typecheck. * Slightly larger timeout. * More typechecking stuff. * Cleanup. * Finished most of the sending logic. * Handle active leaves updates - Cleanup dead disputes - Update sends for new sessions - Retry on errors * Pass sessions in already. * Startup dispute sending. * Provide incoming decoding facilities and use them in statement-distribution. * Relaxed runtime util requirements. We only need a `SubsystemSender` not a full `SubsystemContext`. * Better usability of incoming requests. Make it possible to consume stuff without clones. * Add basic receiver functionality. * Cleanup + fixes for sender. * One more sender fix. * Start receiver. * Make sure to send responses back. * WIP: Exposed authority discovery * Make tests pass. * Fully featured receiver. * Decrease cost of `NotAValidator`. * Make `RuntimeInfo` LRU cache size configurable. * Cache more sessions. * Fix collator protocol. * Disable metrics for now. * Make dispute-distribution a proper subsystem. * Fix naming. * Code style fixes. * Factored out 4x copied mock function. * WIP: Tests. * Whitespace cleanup. * Accessor functions. * More testing. * More Debug instances. * Fix busy loop. * Working tests. * More tests. * Cleanup. * Fix build. * Basic receiving test. * Non validator message gets dropped. * More receiving tests. * Test nested and subsequent imports. * Fix spaces. * Better formatted imports. * Import cleanup. * Metrics. * Message -> MuxedMessage * Message -> MuxedMessage * More review remarks. * Add missing metrics.rs. * Fix flaky test. * Dispute coordinator - deliver confirmations. * Send out `DisputeMessage` on issue local statement. * Unwire dispute distribution. * Review remarks. * Review remarks. * Better docs.
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
use futures::{SinkExt, StreamExt, channel::{mpsc, oneshot}, stream::FuturesUnordered};
|
||||
|
||||
use parity_scale_codec::Decode;
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
PeerId, UnifiedReputationChange as Rep,
|
||||
request_response::{
|
||||
@@ -85,35 +83,26 @@ pub async fn respond(
|
||||
Some(v) => v,
|
||||
};
|
||||
|
||||
let sc_network::config::IncomingRequest {
|
||||
payload,
|
||||
peer,
|
||||
pending_response,
|
||||
} = raw;
|
||||
|
||||
let payload = match StatementFetchingRequest::decode(&mut payload.as_ref()) {
|
||||
let req =
|
||||
match IncomingRequest::<StatementFetchingRequest>::try_from_raw(
|
||||
raw,
|
||||
vec![COST_INVALID_REQUEST],
|
||||
) {
|
||||
Err(err) => {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
?err,
|
||||
"Decoding request failed"
|
||||
);
|
||||
report_peer(pending_response, COST_INVALID_REQUEST);
|
||||
continue
|
||||
}
|
||||
Ok(payload) => payload,
|
||||
};
|
||||
|
||||
let req = IncomingRequest::new(
|
||||
peer,
|
||||
payload,
|
||||
pending_response
|
||||
);
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
if let Err(err) = sender.feed(
|
||||
ResponderMessage::GetData {
|
||||
requesting_peer: peer,
|
||||
requesting_peer: req.peer,
|
||||
relay_parent: req.payload.relay_parent,
|
||||
candidate_hash: req.payload.candidate_hash,
|
||||
tx,
|
||||
@@ -152,20 +141,3 @@ pub async fn respond(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Report peer who sent us a request.
|
||||
fn report_peer(
|
||||
tx: oneshot::Sender<sc_network::config::OutgoingResponse>,
|
||||
rep: Rep,
|
||||
) {
|
||||
if let Err(_) = tx.send(sc_network::config::OutgoingResponse {
|
||||
result: Err(()),
|
||||
reputation_changes: vec![rep.into_base_rep()],
|
||||
sent_feedback: None,
|
||||
}) {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
"Reporting peer failed."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user