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
@@ -25,7 +25,7 @@ use primitives::v1::{
Id as ParaId, OccupiedCoreAssumption, SessionIndex, ValidationCode,
CommittedCandidateReceipt, ScheduledCore, OccupiedCore, CoreOccupied, CoreIndex,
GroupIndex, CandidateEvent, PersistedValidationData, SessionInfo,
InboundDownwardMessage, InboundHrmpMessage, AuthorityDiscoveryId
InboundDownwardMessage, InboundHrmpMessage, AuthorityDiscoveryId, Hash
};
use crate::{initializer, inclusion, scheduler, configuration, paras, session_info, dmp, hrmp, shared};
@@ -330,3 +330,10 @@ pub fn inbound_hrmp_channels_contents<T: hrmp::Config>(
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<T::BlockNumber>>> {
<hrmp::Module<T>>::inbound_hrmp_channels_contents(recipient)
}
/// Implementation for the `validation_code_by_hash` function of the runtime API.
pub fn validation_code_by_hash<T: paras::Config>(
hash: Hash,
) -> Option<ValidationCode> {
<paras::Module<T>>::code_by_hash(hash)
}