Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
break provisioner/candidate-backing cycle (#5432)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
  • Loading branch information
eskimor and rphmeier authored May 2, 2022
1 parent 3f8f7d1 commit 568169b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,16 +739,19 @@ impl CandidateBackingJob {
}

/// Check if there have happened any new misbehaviors and issue necessary messages.
async fn issue_new_misbehaviors(&mut self, sender: &mut JobSender<impl SubsystemSender>) {
fn issue_new_misbehaviors(&mut self, sender: &mut JobSender<impl SubsystemSender>) {
// collect the misbehaviors to avoid double mutable self borrow issues
let misbehaviors: Vec<_> = self.table.drain_misbehaviors().collect();
for (validator_id, report) in misbehaviors {
sender
.send_message(ProvisionerMessage::ProvisionableData(
self.parent,
ProvisionableData::MisbehaviorReport(self.parent, validator_id, report),
))
.await;
// The provisioner waits on candidate-backing, which means
// that we need to send unbounded messages to avoid cycles.
//
// Misbehaviors are bounded by the number of validators and
// the block production protocol.
sender.send_unbounded_message(ProvisionerMessage::ProvisionableData(
self.parent,
ProvisionableData::MisbehaviorReport(self.parent, validator_id, report),
));
}
}

Expand Down Expand Up @@ -813,11 +816,16 @@ impl CandidateBackingJob {
"Candidate backed",
);

// The provisioner waits on candidate-backing, which means
// that we need to send unbounded messages to avoid cycles.
//
// Backed candidates are bounded by the number of validators,
// parachains, and the block production rate of the relay chain.
let message = ProvisionerMessage::ProvisionableData(
self.parent,
ProvisionableData::BackedCandidate(backed.receipt()),
);
sender.send_message(message).await;
sender.send_unbounded_message(message);

span.as_ref().map(|s| s.child("backed"));
span
Expand All @@ -831,7 +839,7 @@ impl CandidateBackingJob {
None
};

self.issue_new_misbehaviors(sender).await;
self.issue_new_misbehaviors(sender);

// It is important that the child span is dropped before its parent span (`unbacked_span`)
drop(import_statement_span);
Expand Down

0 comments on commit 568169b

Please sign in to comment.