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

Commit 419b58b

Browse files
rphmeierordian
authored andcommitted
yet another set of logging improvements (#2638)
1 parent 8debc0a commit 419b58b

File tree

2 files changed

+51
-17
lines changed
  • node/core

2 files changed

+51
-17
lines changed

node/core/approval-voting/src/lib.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,27 @@ async fn handle_approved_ancestor(
827827
);
828828
}
829829
Some(a_entry) => {
830-
let our_assignment = a_entry.our_assignment();
831-
tracing::debug!(
832-
target: LOG_TARGET,
833-
?our_assignment,
834-
);
830+
match a_entry.our_assignment() {
831+
None => tracing::debug!(
832+
target: LOG_TARGET,
833+
?candidate_hash,
834+
?block_hash,
835+
"no assignment."
836+
),
837+
Some(a) => {
838+
let tranche = a.tranche();
839+
let triggered = a.triggered();
840+
841+
tracing::debug!(
842+
target: LOG_TARGET,
843+
?candidate_hash,
844+
?block_hash,
845+
tranche,
846+
triggered,
847+
"assigned"
848+
);
849+
}
850+
}
835851
}
836852
}
837853
}

node/core/candidate-selection/src/lib.rs

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use polkadot_node_subsystem_util::{
3737
JobTrait, FromJobCommand, Validator, metrics::{self, prometheus},
3838
};
3939
use polkadot_primitives::v1::{
40-
CandidateReceipt, CollatorId, CoreState, CoreIndex, Hash, Id as ParaId, PoV,
40+
CandidateReceipt, CollatorId, CoreState, CoreIndex, Hash, Id as ParaId, PoV, BlockNumber,
4141
};
4242
use polkadot_node_primitives::SignedFullStatement;
4343
use std::{pin::Pin, sync::Arc};
@@ -139,30 +139,47 @@ impl JobTrait for CandidateSelectionJob {
139139
.with_stage(jaeger::Stage::CandidateSelection)
140140
.build();
141141

142-
let mut assignment = None;
142+
#[derive(Debug)]
143+
enum AssignmentState {
144+
Unassigned,
145+
Scheduled(ParaId),
146+
Occupied(BlockNumber),
147+
Free,
148+
}
149+
150+
let mut assignment = AssignmentState::Unassigned;
143151

144152
for (idx, core) in cores.into_iter().enumerate() {
145-
// Ignore prospective assignments on occupied cores for the time being.
146-
if let CoreState::Scheduled(scheduled) = core {
147-
let core_index = CoreIndex(idx as _);
148-
let group_index = group_rotation_info.group_for_core(core_index, n_cores);
149-
if let Some(g) = validator_groups.get(group_index.0 as usize) {
150-
if g.contains(&validator.index()) {
151-
assignment = Some(scheduled.para_id);
152-
break;
153+
let core_index = CoreIndex(idx as _);
154+
let group_index = group_rotation_info.group_for_core(core_index, n_cores);
155+
if let Some(g) = validator_groups.get(group_index.0 as usize) {
156+
if g.contains(&validator.index()) {
157+
match core {
158+
CoreState::Scheduled(scheduled) => {
159+
assignment = AssignmentState::Scheduled(scheduled.para_id);
160+
}
161+
CoreState::Occupied(occupied) => {
162+
// Ignore prospective assignments on occupied cores
163+
// for the time being.
164+
assignment = AssignmentState::Occupied(occupied.occupied_since);
165+
}
166+
CoreState::Free => {
167+
assignment = AssignmentState::Free;
168+
}
153169
}
170+
break;
154171
}
155172
}
156173
}
157174

158175
let assignment = match assignment {
159-
Some(assignment) => {
176+
AssignmentState::Scheduled(assignment) => {
160177
assignment_span.add_string_tag("assigned", "true");
161178
assignment_span.add_para_id(assignment);
162179

163180
assignment
164181
}
165-
None => {
182+
assignment => {
166183
assignment_span.add_string_tag("assigned", "false");
167184

168185
let validator_index = validator.index();
@@ -173,6 +190,7 @@ impl JobTrait for CandidateSelectionJob {
173190
?relay_parent,
174191
?validator_index,
175192
?validator_id,
193+
?assignment,
176194
"No assignment. Will not select candidate."
177195
);
178196

0 commit comments

Comments
 (0)