Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,11 +827,27 @@ async fn handle_approved_ancestor(
);
}
Some(a_entry) => {
let our_assignment = a_entry.our_assignment();
tracing::debug!(
target: LOG_TARGET,
?our_assignment,
);
match a_entry.our_assignment() {
None => tracing::debug!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
"no assignment."
),
Some(a) => {
let tranche = a.tranche();
let triggered = a.triggered();

tracing::debug!(
target: LOG_TARGET,
?candidate_hash,
?block_hash,
tranche,
triggered,
"assigned"
);
}
}
}
}
}
Expand Down
42 changes: 30 additions & 12 deletions node/core/candidate-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use polkadot_node_subsystem_util::{
JobTrait, FromJobCommand, Validator, metrics::{self, prometheus},
};
use polkadot_primitives::v1::{
CandidateReceipt, CollatorId, CoreState, CoreIndex, Hash, Id as ParaId, PoV,
CandidateReceipt, CollatorId, CoreState, CoreIndex, Hash, Id as ParaId, PoV, BlockNumber,
};
use polkadot_node_primitives::SignedFullStatement;
use std::{pin::Pin, sync::Arc};
Expand Down Expand Up @@ -139,30 +139,47 @@ impl JobTrait for CandidateSelectionJob {
.with_stage(jaeger::Stage::CandidateSelection)
.build();

let mut assignment = None;
#[derive(Debug)]
enum AssignmentState {
Unassigned,
Scheduled(ParaId),
Occupied(BlockNumber),
Free,
}

let mut assignment = AssignmentState::Unassigned;

for (idx, core) in cores.into_iter().enumerate() {
// Ignore prospective assignments on occupied cores for the time being.
if let CoreState::Scheduled(scheduled) = core {
let core_index = CoreIndex(idx as _);
let group_index = group_rotation_info.group_for_core(core_index, n_cores);
if let Some(g) = validator_groups.get(group_index.0 as usize) {
if g.contains(&validator.index()) {
assignment = Some(scheduled.para_id);
break;
let core_index = CoreIndex(idx as _);
let group_index = group_rotation_info.group_for_core(core_index, n_cores);
if let Some(g) = validator_groups.get(group_index.0 as usize) {
if g.contains(&validator.index()) {
match core {
CoreState::Scheduled(scheduled) => {
assignment = AssignmentState::Scheduled(scheduled.para_id);
}
CoreState::Occupied(occupied) => {
// Ignore prospective assignments on occupied cores
// for the time being.
assignment = AssignmentState::Occupied(occupied.occupied_since);
}
CoreState::Free => {
assignment = AssignmentState::Free;
}
}
break;
}
}
}

let assignment = match assignment {
Some(assignment) => {
AssignmentState::Scheduled(assignment) => {
assignment_span.add_string_tag("assigned", "true");
assignment_span.add_para_id(assignment);

assignment
}
None => {
assignment => {
assignment_span.add_string_tag("assigned", "false");

let validator_index = validator.index();
Expand All @@ -173,6 +190,7 @@ impl JobTrait for CandidateSelectionJob {
?relay_parent,
?validator_index,
?validator_id,
?assignment,
"No assignment. Will not select candidate."
);

Expand Down