mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 17:25:41 +00:00
Improve logging to make debugging parachains easier (#2279)
* Improve logging to make debugging parachains easier
This pr should make debugging parachains easier, by printing more
information about the validation process.
* 🤦
* moare
* Convert to debug
This commit is contained in:
@@ -386,7 +386,7 @@ struct BackgroundValidationParams<F> {
|
||||
}
|
||||
|
||||
async fn validate_and_make_available(
|
||||
params: BackgroundValidationParams<impl Fn(BackgroundValidationResult) -> ValidatedCandidateCommand>,
|
||||
params: BackgroundValidationParams<impl Fn(BackgroundValidationResult) -> ValidatedCandidateCommand + Sync>,
|
||||
) -> Result<(), Error> {
|
||||
let BackgroundValidationParams {
|
||||
mut tx_from,
|
||||
@@ -421,11 +421,17 @@ async fn validate_and_make_available(
|
||||
|
||||
let res = match v {
|
||||
ValidationResult::Valid(commitments, validation_data) => {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
candidate_hash = ?candidate.hash(),
|
||||
"Validation successful",
|
||||
);
|
||||
|
||||
// If validation produces a new set of commitments, we vote the candidate as invalid.
|
||||
if commitments.hash() != expected_commitments_hash {
|
||||
tracing::trace!(
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
candidate_receipt = ?candidate,
|
||||
candidate_hash = ?candidate.hash(),
|
||||
actual_commitments = ?commitments,
|
||||
"Commitments obtained with validation don't match the announced by the candidate receipt",
|
||||
);
|
||||
@@ -445,9 +451,9 @@ async fn validate_and_make_available(
|
||||
match erasure_valid {
|
||||
Ok(()) => Ok((candidate, commitments, pov.clone())),
|
||||
Err(InvalidErasureRoot) => {
|
||||
tracing::trace!(
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
candidate_receipt = ?candidate,
|
||||
candidate_hash = ?candidate.hash(),
|
||||
actual_commitments = ?commitments,
|
||||
"Erasure root doesn't match the announced by the candidate receipt",
|
||||
);
|
||||
@@ -457,9 +463,9 @@ async fn validate_and_make_available(
|
||||
}
|
||||
}
|
||||
ValidationResult::Invalid(reason) => {
|
||||
tracing::trace!(
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
candidate_receipt = ?candidate,
|
||||
candidate_hash = ?candidate.hash(),
|
||||
reason = ?reason,
|
||||
"Validation yielded an invalid candidate",
|
||||
);
|
||||
@@ -467,9 +473,7 @@ async fn validate_and_make_available(
|
||||
}
|
||||
};
|
||||
|
||||
let command = make_command(res);
|
||||
tx_command.send(command).await?;
|
||||
Ok(())
|
||||
tx_command.send(make_command(res)).await.map_err(Into::into)
|
||||
}
|
||||
|
||||
impl CandidateBackingJob {
|
||||
@@ -558,7 +562,7 @@ impl CandidateBackingJob {
|
||||
async fn background_validate_and_make_available(
|
||||
&mut self,
|
||||
params: BackgroundValidationParams<
|
||||
impl Fn(BackgroundValidationResult) -> ValidatedCandidateCommand + Send + 'static
|
||||
impl Fn(BackgroundValidationResult) -> ValidatedCandidateCommand + Send + 'static + Sync
|
||||
>,
|
||||
) -> Result<(), Error> {
|
||||
let candidate_hash = params.candidate.hash();
|
||||
@@ -604,6 +608,13 @@ impl CandidateBackingJob {
|
||||
let candidate_hash = candidate.hash();
|
||||
let span = self.get_unbacked_validation_child(parent_span, candidate_hash);
|
||||
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
candidate_hash = ?candidate_hash,
|
||||
candidate_receipt = ?candidate,
|
||||
"Validate and second candidate",
|
||||
);
|
||||
|
||||
self.background_validate_and_make_available(BackgroundValidationParams {
|
||||
tx_from: self.tx_from.clone(),
|
||||
tx_command: self.background_validation_tx.clone(),
|
||||
@@ -675,6 +686,12 @@ impl CandidateBackingJob {
|
||||
statement: &SignedFullStatement,
|
||||
parent_span: &JaegerSpan,
|
||||
) -> Result<Option<TableSummary>, Error> {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
statement = ?statement.payload().to_compact(),
|
||||
"Importing statement",
|
||||
);
|
||||
|
||||
let import_statement_span = {
|
||||
// create a span only for candidates we're already aware of.
|
||||
let candidate_hash = statement.payload().candidate_hash();
|
||||
@@ -696,6 +713,12 @@ impl CandidateBackingJob {
|
||||
if let Some(backed) =
|
||||
table_attested_to_backed(attested, &self.table_context)
|
||||
{
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
candidate_hash = ?candidate_hash,
|
||||
"Candidate backed",
|
||||
);
|
||||
|
||||
let message = ProvisionerMessage::ProvisionableData(
|
||||
self.parent,
|
||||
ProvisionableData::BackedCandidate(backed.receipt()),
|
||||
@@ -794,6 +817,13 @@ impl CandidateBackingJob {
|
||||
let candidate = self.table.get_candidate(&candidate_hash).ok_or(Error::CandidateNotFound)?.to_plain();
|
||||
let descriptor = candidate.descriptor().clone();
|
||||
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
candidate_hash = ?candidate_hash,
|
||||
candidate_receipt = ?candidate,
|
||||
"Kicking off validation",
|
||||
);
|
||||
|
||||
// Check that candidate is collated by the right collator.
|
||||
if self.required_collator.as_ref()
|
||||
.map_or(false, |c| c != &descriptor.collator)
|
||||
|
||||
@@ -368,6 +368,12 @@ where
|
||||
if let Some(per_request) = state.requests_info.remove(&id) {
|
||||
let _ = per_request.received.send(());
|
||||
if let Some(collator_id) = state.known_collators.get(&origin) {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
%request_id,
|
||||
"Received collation",
|
||||
);
|
||||
|
||||
let _ = per_request.result.send((receipt.clone(), pov.clone()));
|
||||
state.metrics.on_request(Ok(()));
|
||||
|
||||
@@ -420,8 +426,8 @@ where
|
||||
tracing::trace!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = %peer_id,
|
||||
para_id = %para_id,
|
||||
relay_parent = %relay_parent,
|
||||
%para_id,
|
||||
?relay_parent,
|
||||
"collation has already been requested",
|
||||
);
|
||||
return;
|
||||
@@ -449,6 +455,15 @@ where
|
||||
|
||||
state.requests_in_progress.push(request.wait().boxed());
|
||||
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = %peer_id,
|
||||
%para_id,
|
||||
%request_id,
|
||||
?relay_parent,
|
||||
"Requesting collation",
|
||||
);
|
||||
|
||||
let wire_message = protocol_v1::CollatorProtocolMessage::RequestCollation(
|
||||
request_id,
|
||||
relay_parent,
|
||||
@@ -737,7 +752,7 @@ where
|
||||
// if the chain has not moved on yet.
|
||||
match request {
|
||||
CollationRequestResult::Timeout(id) => {
|
||||
tracing::trace!(target: LOG_TARGET, id, "request timed out");
|
||||
tracing::debug!(target: LOG_TARGET, request_id=%id, "Collation timed out");
|
||||
request_timed_out(&mut ctx, &mut state, id).await;
|
||||
}
|
||||
CollationRequestResult::Received(id) => {
|
||||
|
||||
Reference in New Issue
Block a user