mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-08-06 09:35:57 +00:00
Fix cycle dispute-coordinator <-> dispute-distribution (#6489)
* First iteration of message sender. * dyn Fn variant (no cloning) * Full implementation + Clone, without allocs on `Send` * Further clarifications/cleanup. * MessageSender -> NestingSender * Doc update/clarification. * dispute-coordinator: Send disputes on startup. + Some fixes, cleanup. * Fix whitespace. * Dispute distribution fixes, cleanup. * Cargo.lock * Fix spaces. * More format fixes. What is cargo fmt doing actually? * More fmt fixes. * Fix nesting sender. * Fixes. * Whitespace * Enable logging. * Guide update. * Fmt fixes, typos. * Remove unused function. * Simplifications, doc fixes. * Update roadmap/implementers-guide/src/node/disputes/dispute-coordinator.md Co-authored-by: Marcin S. <marcin@bytedude.com> * Fmt + doc example fix. Co-authored-by: eskimor <eskimor@no-such-url.com> Co-authored-by: Marcin S. <marcin@bytedude.com>
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use futures::{channel::mpsc, future::RemoteHandle, Future, FutureExt, SinkExt};
|
||||
use futures::{future::RemoteHandle, Future, FutureExt};
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
request_response::{
|
||||
@@ -27,7 +27,7 @@ use polkadot_node_network_protocol::{
|
||||
IfDisconnected,
|
||||
};
|
||||
use polkadot_node_subsystem::{messages::NetworkBridgeTxMessage, overseer};
|
||||
use polkadot_node_subsystem_util::{metrics, runtime::RuntimeInfo};
|
||||
use polkadot_node_subsystem_util::{metrics, nesting_sender::NestingSender, runtime::RuntimeInfo};
|
||||
use polkadot_primitives::v2::{
|
||||
AuthorityDiscoveryId, CandidateHash, Hash, SessionIndex, ValidatorIndex,
|
||||
};
|
||||
@@ -44,7 +44,7 @@ use crate::{
|
||||
/// Keeps track of all the validators that have to be reached for a dispute.
|
||||
///
|
||||
/// The unit of work for a `SendTask` is an authority/validator.
|
||||
pub struct SendTask {
|
||||
pub struct SendTask<M> {
|
||||
/// The request we are supposed to get out to all `parachain` validators of the dispute's session
|
||||
/// and to all current authorities.
|
||||
request: DisputeRequest,
|
||||
@@ -58,7 +58,7 @@ pub struct SendTask {
|
||||
has_failed_sends: bool,
|
||||
|
||||
/// Sender to be cloned for tasks.
|
||||
tx: mpsc::Sender<TaskFinish>,
|
||||
tx: NestingSender<M, TaskFinish>,
|
||||
}
|
||||
|
||||
/// Status of a particular vote/statement delivery to a particular validator.
|
||||
@@ -100,7 +100,7 @@ impl TaskResult {
|
||||
}
|
||||
|
||||
#[overseer::contextbounds(DisputeDistribution, prefix = self::overseer)]
|
||||
impl SendTask {
|
||||
impl<M: 'static + Send + Sync> SendTask<M> {
|
||||
/// Initiates sending a dispute message to peers.
|
||||
///
|
||||
/// Creation of new `SendTask`s is subject to rate limiting. As each `SendTask` will trigger
|
||||
@@ -110,7 +110,7 @@ impl SendTask {
|
||||
ctx: &mut Context,
|
||||
runtime: &mut RuntimeInfo,
|
||||
active_sessions: &HashMap<SessionIndex, Hash>,
|
||||
tx: mpsc::Sender<TaskFinish>,
|
||||
tx: NestingSender<M, TaskFinish>,
|
||||
request: DisputeRequest,
|
||||
metrics: &Metrics,
|
||||
) -> Result<Self> {
|
||||
@@ -272,9 +272,9 @@ impl SendTask {
|
||||
///
|
||||
/// And spawn tasks for handling the response.
|
||||
#[overseer::contextbounds(DisputeDistribution, prefix = self::overseer)]
|
||||
async fn send_requests<Context>(
|
||||
async fn send_requests<Context, M: 'static + Send + Sync>(
|
||||
ctx: &mut Context,
|
||||
tx: mpsc::Sender<TaskFinish>,
|
||||
tx: NestingSender<M, TaskFinish>,
|
||||
receivers: Vec<AuthorityDiscoveryId>,
|
||||
req: DisputeRequest,
|
||||
metrics: &Metrics,
|
||||
@@ -307,11 +307,11 @@ async fn send_requests<Context>(
|
||||
}
|
||||
|
||||
/// Future to be spawned in a task for awaiting a response.
|
||||
async fn wait_response_task(
|
||||
async fn wait_response_task<M: 'static + Send + Sync>(
|
||||
pending_response: impl Future<Output = OutgoingResult<DisputeResponse>>,
|
||||
candidate_hash: CandidateHash,
|
||||
receiver: AuthorityDiscoveryId,
|
||||
mut tx: mpsc::Sender<TaskFinish>,
|
||||
mut tx: NestingSender<M, TaskFinish>,
|
||||
_timer: Option<metrics::prometheus::prometheus::HistogramTimer>,
|
||||
) {
|
||||
let result = pending_response.await;
|
||||
@@ -320,7 +320,7 @@ async fn wait_response_task(
|
||||
Ok(DisputeResponse::Confirmed) =>
|
||||
TaskFinish { candidate_hash, receiver, result: TaskResult::Succeeded },
|
||||
};
|
||||
if let Err(err) = tx.feed(msg).await {
|
||||
if let Err(err) = tx.send_message(msg).await {
|
||||
gum::debug!(
|
||||
target: LOG_TARGET,
|
||||
%err,
|
||||
|
||||
Reference in New Issue
Block a user