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

Commit

Permalink
Final cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyOlson64 committed Mar 10, 2023
1 parent 20ceda9 commit 02e5608
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions node/core/dispute-coordinator/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ impl metrics::Metrics for Metrics {
registry,
)?,
participation_priority_queue_size: prometheus::register(
prometheus::Gauge::new("polkadot_parachain_dispute_priority_queue_size",
prometheus::Gauge::new("polkadot_parachain_dispute_participation_priority_queue_size",
"Number of disputes waiting for local participation in the priority queue.")?,
registry,
)?,
participation_best_effort_queue_size: prometheus::register(
prometheus::Gauge::new("polkadot_parachain_dispute_best_effort_queue_size",
prometheus::Gauge::new("polkadot_parachain_dispute_participation_best_effort_queue_size",
"Number of disputes waiting for local participation in the best effort queue.")?,
registry,
)?,
Expand Down
3 changes: 1 addition & 2 deletions node/core/dispute-coordinator/src/participation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ impl Participation {
recent_head: Hash,
) -> FatalResult<()> {
while self.running_participations.len() < MAX_PARALLEL_PARTICIPATIONS {
let maybe_req = self.queue.dequeue();
if let Some(req) = maybe_req {
if let Some(req) = self.queue.dequeue() {
self.fork_participation(ctx, req, recent_head)?;
} else {
break
Expand Down
25 changes: 13 additions & 12 deletions node/core/dispute-coordinator/src/participation/queues/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,22 @@ impl ParticipationRequest {
let Self { candidate_hash, candidate_receipt, .. } = self;
(candidate_hash, candidate_receipt)
}
// For tests we want to check whether requests are equal, but the
// request_timer field of ParticipationRequest doesn't implement
// eq. This helper checks whether all other fields are equal,
// which is sufficient.
#[cfg(test)]
pub fn functionally_equal(&self, other: ParticipationRequest) -> bool {
if &self.candidate_receipt == other.candidate_receipt() &&
&self.candidate_hash == other.candidate_hash() &&
}

impl PartialEq for ParticipationRequest {
fn eq(&self, other: &Self) -> bool {
let ParticipationRequest {
candidate_receipt,
candidate_hash,
session: _session,
_request_timer,
} = self;
candidate_receipt == other.candidate_receipt() &&
candidate_hash == other.candidate_hash() &&
self.session == other.session()
{
return true
}
false
}
}
impl Eq for ParticipationRequest {}

impl Queues {
/// Create new `Queues`.
Expand Down
18 changes: 9 additions & 9 deletions node/core/dispute-coordinator/src/participation/queues/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ fn ordering_works_as_expected() {
);

// Prioritized queue is ordered correctly
assert!(queue.dequeue().unwrap().functionally_equal(req_prio));
assert!(queue.dequeue().unwrap().functionally_equal(req_prio_2));
assert_eq!(queue.dequeue(), Some(req_prio));
assert_eq!(queue.dequeue(), Some(req_prio_2));
// So is the best-effort
assert!(queue.dequeue().unwrap().functionally_equal(req1));
assert!(queue.dequeue().unwrap().functionally_equal(req3));
assert!(queue.dequeue().unwrap().functionally_equal(req5_unknown_parent));
assert_eq!(queue.dequeue(), Some(req1));
assert_eq!(queue.dequeue(), Some(req3));
assert_eq!(queue.dequeue(), Some(req5_unknown_parent));

assert_matches!(queue.dequeue(), None);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ fn candidate_is_only_dequeued_once() {
.unwrap();

// Make space in prio:
assert!(queue.dequeue().unwrap().functionally_equal(req_prio));
assert_eq!(queue.dequeue(), Some(req_prio));

// Insert first as prio:
queue
Expand All @@ -196,8 +196,8 @@ fn candidate_is_only_dequeued_once() {
)
.unwrap();

assert!(queue.dequeue().unwrap().functionally_equal(req_best_effort_then_prio));
assert!(queue.dequeue().unwrap().functionally_equal(req_prio_then_best_effort));
assert!(queue.dequeue().unwrap().functionally_equal(req1));
assert_eq!(queue.dequeue(), Some(req_best_effort_then_prio));
assert_eq!(queue.dequeue(), Some(req_prio_then_best_effort));
assert_eq!(queue.dequeue(), Some(req1));
assert_matches!(queue.dequeue(), None);
}

0 comments on commit 02e5608

Please sign in to comment.