Put parachain head hash into CandidateDescriptor (#2310)

* Put parachain head hash into `CandidateDescriptor`

* Update guide

* Add some checks
This commit is contained in:
Bastian Köcher
2021-01-25 13:56:17 +01:00
committed by GitHub
parent dba39c7515
commit 9563652bf2
6 changed files with 24 additions and 1 deletions
@@ -333,6 +333,7 @@ async fn handle_new_activations<Context: SubsystemContext>(
persisted_validation_data_hash,
pov_hash,
erasure_root,
para_head: commitments.head_data.hash(),
},
};
@@ -738,6 +739,7 @@ mod tests {
persisted_validation_data_hash: expect_validation_data_hash,
pov_hash: expect_pov_hash,
erasure_root: Default::default(), // this isn't something we're checking right now
para_head: test_collation().head_data.hash(),
};
assert_eq!(sent_messages.len(), 1);
@@ -459,6 +459,10 @@ fn validate_candidate_exhaustive<B: ValidationBackend, S: SpawnNamed + 'static>(
Ok(ValidationResult::Invalid(InvalidCandidate::ExecutionError(e.to_string()))),
Err(ValidationError::Internal(e)) => Err(ValidationFailed(e.to_string())),
Ok(res) => {
if res.head_data.hash() != descriptor.para_head {
return Ok(ValidationResult::Invalid(InvalidCandidate::ParaHeadHashMismatch));
}
let outputs = CandidateCommitments {
head_data: res.head_data,
upward_messages: res.upward_messages,
@@ -887,15 +891,17 @@ mod tests {
let validation_data = PersistedValidationData { max_pov_size: 1024, ..Default::default() };
let pov = PoV { block_data: BlockData(vec![1; 32]) };
let head_data = HeadData(vec![1, 1, 1]);
let mut descriptor = CandidateDescriptor::default();
descriptor.pov_hash = pov.hash();
descriptor.para_head = head_data.hash();
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
assert!(perform_basic_checks(&descriptor, validation_data.max_pov_size, &pov).is_ok());
let validation_result = WasmValidationResult {
head_data: HeadData(vec![1, 1, 1]),
head_data,
new_validation_code: Some(vec![2, 2, 2].into()),
upward_messages: Vec::new(),
horizontal_messages: Vec::new(),
+2
View File
@@ -150,6 +150,8 @@ pub enum InvalidCandidate {
HashMismatch,
/// Bad collator signature.
BadSignature,
/// Para head hash does not match.
ParaHeadHashMismatch,
}
/// Result of the validation of the candidate.