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

Accept PVF code hashes in validation host #3655

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2880898
Refactor runtime API requests
slumber Aug 17, 2021
2c6a031
Try to use cached compiled PVF
slumber Aug 17, 2021
da26bf0
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Aug 17, 2021
162be9b
fmt
slumber Aug 17, 2021
427bc1a
Refactor runtime API requests
slumber Aug 19, 2021
7311c27
Introduce PvfPreimage
slumber Aug 19, 2021
094d164
Reliable error handling
slumber Aug 19, 2021
50fcfca
Improve candidate validation readability
slumber Aug 22, 2021
2c39c37
Send correct hash to the PVF host
slumber Aug 22, 2021
8d40599
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Aug 22, 2021
c7cf9f5
Test validation by hash feature
slumber Aug 23, 2021
2d0d047
Remove extra comma
slumber Aug 30, 2021
828af04
Rename
slumber Oct 25, 2021
d2a2dbf
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Oct 25, 2021
8da537a
Rework candidate validation to use new runtime API endpoint
slumber Oct 25, 2021
bec11a3
fmt
slumber Oct 25, 2021
33560ca
Remove extra line
slumber Oct 26, 2021
0a93b6a
Get rid of unreachable
slumber Oct 27, 2021
e58b1ec
Remove mutable result
slumber Oct 27, 2021
0e9b0fe
Log the error
slumber Oct 27, 2021
a11d53a
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Dec 17, 2021
e4edd44
Resolve precheck todo
slumber Jan 18, 2022
9c91729
Host tests
slumber Jan 19, 2022
cb82bd4
Update implementers guide
slumber Jan 19, 2022
fb7e4e7
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Jan 19, 2022
c38eb81
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Jan 21, 2022
2a48e29
Remove unnecessary log message
slumber Feb 14, 2022
24c043c
Improve naming
slumber Feb 14, 2022
c3cf617
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Feb 14, 2022
249fc28
Revert error handling
slumber Feb 14, 2022
47e9e7e
Merge remote-tracking branch 'origin/master' into slumber-use-cached-pvf
slumber Mar 30, 2022
0a847ab
Replace tracing usage
slumber Mar 30, 2022
bccbbc3
Explain force enacting
slumber Apr 1, 2022
3668cfa
Merge branch 'master' into slumber-use-cached-pvf
mrcnski Oct 11, 2022
32680ca
Fix leftover errors from merge
mrcnski Oct 11, 2022
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
47 changes: 21 additions & 26 deletions node/core/candidate-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ where
) {
Ok(code) => code,
Err(e) => {
tracing::debug!(target: LOG_TARGET, err=?e, "Invalid validation code");
tracing::debug!(target: LOG_TARGET, err=?e, "Code decompression failed");

// If the validation code is invalid, the candidate certainly is.
return Ok(Ok(ValidationResult::Invalid(InvalidCandidate::CodeDecompressionFailure)))
Expand All @@ -396,7 +396,7 @@ where
} else {
// In case validation code is not provided, ask the backend to obtain
// it from the cache using the hash.
Pvf::Hash(ValidationCodeHash::from(descriptor.persisted_validation_data_hash))
Pvf::Hash(ValidationCodeHash::from(descriptor.validation_code_hash))
};

let raw_block_data =
Expand Down Expand Up @@ -443,23 +443,21 @@ where
Err(err) => return Ok(Err(ValidationFailed(err.to_string()))),
};

let validation_code = Pvf::from_code(
match sp_maybe_compressed_blob::decompress(
&validation_code.0,
VALIDATION_CODE_BOMB_LIMIT,
) {
Ok(code) => code,
Err(e) => {
tracing::debug!(target: LOG_TARGET, err=?e, "Invalid validation code");

// If the validation code is invalid, the candidate certainly is.
return Ok(Ok(ValidationResult::Invalid(
InvalidCandidate::CodeDecompressionFailure,
)))
},
}
.to_vec(),
);
let raw_code = match sp_maybe_compressed_blob::decompress(
&validation_code.0,
VALIDATION_CODE_BOMB_LIMIT,
) {
Ok(code) => code,
Err(e) => {
tracing::debug!(target: LOG_TARGET, err=?e, "Code decompression failed");

// If the validation code is invalid, the candidate certainly is.
return Ok(Ok(ValidationResult::Invalid(
InvalidCandidate::CodeDecompressionFailure,
)))
},
};
let validation_code = Pvf::from_code(raw_code.to_vec());
result = validation_backend.validate_candidate(validation_code, params).await;
}
}
Expand All @@ -478,13 +476,10 @@ where
Err(ValidationError::ArtifactNotFound) => {
// The code was supplied on the second attempt, this
// error should be unreachable.
tracing::error!(
target: LOG_TARGET,
"Unexpected error received from the validation host"
);
Err(ValidationFailed(
"Validation host failed to find artifact even though it was supplied".to_string(),
))
let error_message =
"Validation host failed to find artifact even though it was supplied";
tracing::error!(target: LOG_TARGET, error_message,);
slumber marked this conversation as resolved.
Show resolved Hide resolved
Err(ValidationFailed(error_message.to_string()))
},
Ok(res) =>
if res.head_data.hash() != descriptor.para_head {
Expand Down
2 changes: 1 addition & 1 deletion node/core/pvf/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ async fn handle_execute_pvf(
} else {
// Expect another request with PVF provided.
let _ = result_tx.send(Err(ValidationError::ArtifactNotFound));
};
}
}

return Ok(())
Expand Down