mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
Add logging to PVF and other related parts (#3596)
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -41,7 +41,7 @@ use polkadot_node_subsystem_util::metrics::{self, prometheus};
|
||||
use polkadot_parachain::primitives::{ValidationParams, ValidationResult as WasmValidationResult};
|
||||
use polkadot_primitives::v1::{
|
||||
CandidateCommitments, CandidateDescriptor, Hash, OccupiedCoreAssumption,
|
||||
PersistedValidationData, ValidationCode,
|
||||
PersistedValidationData, ValidationCode, ValidationCodeHash,
|
||||
};
|
||||
|
||||
use parity_scale_codec::Encode;
|
||||
@@ -164,6 +164,7 @@ where
|
||||
match res {
|
||||
Ok(x) => {
|
||||
metrics.on_validation_event(&x);
|
||||
|
||||
if let Err(_e) = response_sender.send(x) {
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
@@ -349,11 +350,19 @@ async fn validate_candidate_exhaustive(
|
||||
) -> SubsystemResult<Result<ValidationResult, ValidationFailed>> {
|
||||
let _timer = metrics.time_validate_candidate_exhaustive();
|
||||
|
||||
let validation_code_hash = validation_code.hash();
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
?validation_code_hash,
|
||||
para_id = ?descriptor.para_id,
|
||||
"About to validate a candidate.",
|
||||
);
|
||||
|
||||
if let Err(e) = perform_basic_checks(
|
||||
&descriptor,
|
||||
persisted_validation_data.max_pov_size,
|
||||
&*pov,
|
||||
&validation_code,
|
||||
&validation_code_hash,
|
||||
) {
|
||||
return Ok(Ok(ValidationResult::Invalid(e)))
|
||||
}
|
||||
@@ -478,10 +487,9 @@ fn perform_basic_checks(
|
||||
candidate: &CandidateDescriptor,
|
||||
max_pov_size: u32,
|
||||
pov: &PoV,
|
||||
validation_code: &ValidationCode,
|
||||
validation_code_hash: &ValidationCodeHash,
|
||||
) -> Result<(), InvalidCandidate> {
|
||||
let pov_hash = pov.hash();
|
||||
let validation_code_hash = validation_code.hash();
|
||||
|
||||
let encoded_pov_size = pov.encoded_size();
|
||||
if encoded_pov_size > max_pov_size as usize {
|
||||
@@ -492,7 +500,7 @@ fn perform_basic_checks(
|
||||
return Err(InvalidCandidate::PoVHashMismatch)
|
||||
}
|
||||
|
||||
if validation_code_hash != candidate.validation_code_hash {
|
||||
if *validation_code_hash != candidate.validation_code_hash {
|
||||
return Err(InvalidCandidate::CodeHashMismatch)
|
||||
}
|
||||
|
||||
|
||||
@@ -340,8 +340,12 @@ fn candidate_validation_ok_is_ok() {
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
|
||||
let check =
|
||||
perform_basic_checks(&descriptor, validation_data.max_pov_size, &pov, &validation_code);
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
validation_data.max_pov_size,
|
||||
&pov,
|
||||
&validation_code.hash(),
|
||||
);
|
||||
assert!(check.is_ok());
|
||||
|
||||
let validation_result = WasmValidationResult {
|
||||
@@ -386,8 +390,12 @@ fn candidate_validation_bad_return_is_invalid() {
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
|
||||
let check =
|
||||
perform_basic_checks(&descriptor, validation_data.max_pov_size, &pov, &validation_code);
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
validation_data.max_pov_size,
|
||||
&pov,
|
||||
&validation_code.hash(),
|
||||
);
|
||||
assert!(check.is_ok());
|
||||
|
||||
let v = executor::block_on(validate_candidate_exhaustive(
|
||||
@@ -418,8 +426,12 @@ fn candidate_validation_timeout_is_internal_error() {
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
|
||||
let check =
|
||||
perform_basic_checks(&descriptor, validation_data.max_pov_size, &pov, &validation_code);
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
validation_data.max_pov_size,
|
||||
&pov,
|
||||
&validation_code.hash(),
|
||||
);
|
||||
assert!(check.is_ok());
|
||||
|
||||
let v = executor::block_on(validate_candidate_exhaustive(
|
||||
@@ -449,8 +461,12 @@ fn candidate_validation_code_mismatch_is_invalid() {
|
||||
descriptor.validation_code_hash = ValidationCode(vec![1; 16]).hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
|
||||
let check =
|
||||
perform_basic_checks(&descriptor, validation_data.max_pov_size, &pov, &validation_code);
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
validation_data.max_pov_size,
|
||||
&pov,
|
||||
&validation_code.hash(),
|
||||
);
|
||||
assert_matches!(check, Err(InvalidCandidate::CodeHashMismatch));
|
||||
|
||||
let v = executor::block_on(validate_candidate_exhaustive(
|
||||
|
||||
Reference in New Issue
Block a user