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

candidate-validation: info logs on failure #5957

Merged
merged 1 commit into from
Sep 2, 2022
Merged
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
23 changes: 14 additions & 9 deletions node/core/candidate-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,11 @@ async fn validate_candidate_exhaustive(
let _timer = metrics.time_validate_candidate_exhaustive();

let validation_code_hash = validation_code.hash();
let para_id = candidate_receipt.descriptor.para_id.clone();
gum::debug!(
target: LOG_TARGET,
?validation_code_hash,
para_id = ?candidate_receipt.descriptor.para_id,
?para_id,
"About to validate a candidate.",
);

Expand All @@ -514,6 +515,7 @@ async fn validate_candidate_exhaustive(
&*pov,
&validation_code_hash,
) {
gum::info!(target: LOG_TARGET, ?para_id, "Invalid candidate (basic checks)");
return Ok(ValidationResult::Invalid(e))
}

Expand All @@ -523,7 +525,7 @@ async fn validate_candidate_exhaustive(
) {
Ok(code) => code,
Err(e) => {
gum::debug!(target: LOG_TARGET, err=?e, "Invalid validation code");
gum::info!(target: LOG_TARGET, ?para_id, err=?e, "Invalid candidate (validation code)");

// If the validation code is invalid, the candidate certainly is.
return Ok(ValidationResult::Invalid(InvalidCandidate::CodeDecompressionFailure))
Expand All @@ -534,7 +536,7 @@ async fn validate_candidate_exhaustive(
match sp_maybe_compressed_blob::decompress(&pov.block_data.0, POV_BOMB_LIMIT) {
Ok(block_data) => BlockData(block_data.to_vec()),
Err(e) => {
gum::debug!(target: LOG_TARGET, err=?e, "Invalid PoV code");
gum::info!(target: LOG_TARGET, ?para_id, err=?e, "Invalid candidate (PoV code)");

// If the PoV is invalid, the candidate certainly is.
return Ok(ValidationResult::Invalid(InvalidCandidate::PoVDecompressionFailure))
Expand All @@ -552,12 +554,8 @@ async fn validate_candidate_exhaustive(
.validate_candidate(raw_validation_code.to_vec(), timeout, params)
.await;

if let Err(ref e) = result {
gum::debug!(
target: LOG_TARGET,
error = ?e,
"Failed to validate candidate",
);
if let Err(ref error) = result {
gum::info!(target: LOG_TARGET, ?para_id, ?error, "Failed to validate candidate",);
}

match result {
Expand All @@ -576,6 +574,7 @@ async fn validate_candidate_exhaustive(

Ok(res) =>
if res.head_data.hash() != candidate_receipt.descriptor.para_head {
gum::info!(target: LOG_TARGET, ?para_id, "Invalid candidate (para_head)");
Ok(ValidationResult::Invalid(InvalidCandidate::ParaHeadHashMismatch))
} else {
let outputs = CandidateCommitments {
Expand All @@ -587,6 +586,12 @@ async fn validate_candidate_exhaustive(
hrmp_watermark: res.hrmp_watermark,
};
if candidate_receipt.commitments_hash != outputs.hash() {
gum::info!(
target: LOG_TARGET,
?para_id,
"Invalid candidate (commitments hash)"
);

// If validation produced a new set of commitments, we treat the candidate as invalid.
Ok(ValidationResult::Invalid(InvalidCandidate::CommitmentsHashMismatch))
} else {
Expand Down