yet another set of logging improvements (#2638)

This commit is contained in:
Robert Habermeier
2021-03-17 15:53:37 -04:00
committed by GitHub
parent 04f04ea6db
commit cd2b745b28
2 changed files with 51 additions and 17 deletions
+21 -5
View File
@@ -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"
);
}
}
}
}
}
@@ -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};
@@ -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();
@@ -173,6 +190,7 @@ impl JobTrait for CandidateSelectionJob {
?relay_parent,
?validator_index,
?validator_id,
?assignment,
"No assignment. Will not select candidate."
);