Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,27 @@ impl CollationTracker {
receipt: CandidateReceipt,
) {
let head = receipt.descriptor.para_head();
let para_id = receipt.descriptor.para_id();
let Some(entry) = self.entries.get_mut(&head) else {
gum::debug!(
target: crate::LOG_TARGET_STATS,
?para_id,
?head,
"Included collation not found in tracker",
);
return;
};

let pov_hash = entry.pov_hash();
let candidate_hash = entry.candidate_hash();

if entry.included().is_some() {
gum::debug!(
target: crate::LOG_TARGET_STATS,
?para_id,
?head,
?candidate_hash,
?pov_hash,
"Collation already included in a fork, skipping",
);
return
Expand All @@ -320,8 +328,10 @@ impl CollationTracker {
?latency,
relay_block = ?leaf,
relay_parent = ?entry.relay_parent,
para_id = ?receipt.descriptor.para_id(),
head = ?receipt.descriptor.para_head(),
?para_id,
?head,
?candidate_hash,
?pov_hash,
"Collation included on relay chain",
);
}
Expand Down Expand Up @@ -412,6 +422,10 @@ pub(crate) struct CollationStats {
/// The collation backing latency (seconds). Duration since collation fetched
/// until the import of a relay chain block where collation is backed.
backed_latency_metric: Option<HistogramTimer>,
/// The Collation candidate hash
candidate_hash: Hash,
/// The Collation PoV hash
pov_hash: Hash,
}

impl CollationStats {
Expand All @@ -421,6 +435,8 @@ impl CollationStats {
relay_parent_number: BlockNumber,
relay_parent: Hash,
metrics: &Metrics,
candidate_hash: Hash,
pov_hash: Hash,
) -> Self {
Self {
pre_backing_status: CollationStatus::Created,
Expand All @@ -434,6 +450,8 @@ impl CollationStats {
included_at: None,
fetch_latency_metric: metrics.time_collation_fetch_latency(),
backed_latency_metric: None,
candidate_hash,
pov_hash,
}
}

Expand Down Expand Up @@ -472,6 +490,16 @@ impl CollationStats {
self.head
}

/// Get candidate hash.
pub fn candidate_hash(&self) -> H256 {
self.candidate_hash
}

/// Get candidate PoV hash.
pub fn pov_hash(&self) -> H256 {
self.pov_hash
}

/// Set the timestamp at which collation is fetched.
pub fn set_fetched_at(&mut self, fetched_at: Instant) {
self.fetched_at = Some(fetched_at);
Expand Down
18 changes: 15 additions & 3 deletions polkadot/node/network/collator-protocol/src/collator_side/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ async fn distribute_collation<Context>(
}

let para_head = receipt.descriptor.para_head();
let pov_hash = pov.hash();
per_relay_parent.collations.insert(
candidate_hash,
CollationData {
Expand All @@ -527,9 +528,16 @@ async fn distribute_collation<Context>(
},
core_index,
session_index,
stats: per_relay_parent
.block_number
.map(|n| CollationStats::new(para_head, n, candidate_relay_parent, &state.metrics)),
stats: per_relay_parent.block_number.map(|n| {
CollationStats::new(
para_head,
n,
candidate_relay_parent,
&state.metrics,
*candidate_hash,
pov_hash,
)
}),
},
);

Expand Down Expand Up @@ -1533,13 +1541,17 @@ fn process_expired_collations(
for expired_collation in expired_collations {
let collation_state = expired_collation.expiry_state();
let age = expired_collation.expired().unwrap_or_default();
let candidate_hash = expired_collation.candidate_hash();
let pov_hash = expired_collation.pov_hash();
gum::debug!(
target: crate::LOG_TARGET_STATS,
?age,
?collation_state,
relay_parent = ?removed,
?para_id,
head = ?expired_collation.head(),
?candidate_hash,
?pov_hash,
"Collation expired",
);

Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_9927.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: 'Log: log `candidate_hash` nor the `pov_hash` when collations expire'
doc:
- audience: Node Dev
description: |-
When collations expire we do not log the `candidate_hash` nor the `pov_hash`, making it hard to map the
logged entries about Candidate generated and Candidate expired together.

This PR adds `pov_hash` and `candidate_hash` to the CollationStats struct and use these fields when we
log "Collation expired".

crates:
- name: polkadot-collator-protocol
bump: patch
Loading