Ease parachain candidate code fetching (#2593)

* code stored in para + modify CandidateDescriptor.

* WIP: digest + some more impl

* validation_code_hash in payload + check in inclusion

* check in client + refator

* tests

* fix encoding indices

* remove old todos

* fix test

* fix test

* add test

* fetch validation code inside collation-generation from the relay-chain

* HashMismatch -> PoVHashMismatch + miscompilation

* refactor, store hash when needed

* storage rename: more specific but slightly too verbose

* do not hash on candidate validation, fetch hash instead

* better test

* fix test

* guide updates

* don't panic in runtime

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
Guillaume Thiolliere
2021-04-01 23:55:39 +02:00
committed by GitHub
parent 98082c5326
commit beca01f118
15 changed files with 494 additions and 102 deletions
+8 -1
View File
@@ -21,6 +21,7 @@ use sp_std::vec::Vec;
use parity_scale_codec::{Encode, Decode, CompactAs};
use sp_core::{RuntimeDebug, TypeId};
use sp_runtime::traits::Hash as _;
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize};
@@ -45,7 +46,6 @@ pub struct HeadData(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec<u8
impl HeadData {
/// Returns the hash of this head data.
pub fn hash(&self) -> Hash {
use sp_runtime::traits::Hash;
sp_runtime::traits::BlakeTwo256::hash(&self.0)
}
}
@@ -55,6 +55,13 @@ impl HeadData {
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, MallocSizeOf))]
pub struct ValidationCode(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec<u8>);
impl ValidationCode {
/// Get the blake2-256 hash of the validation code bytes.
pub fn hash(&self) -> Hash {
sp_runtime::traits::BlakeTwo256::hash(&self.0[..])
}
}
/// Parachain block data.
///
/// Contains everything required to validate para-block, may contain block and witness data.