Downward Message Processing implementation (#1859)

* DMP: data structures and plumbing

* DMP: Implement DMP logic in the router module

DMP: Integrate DMP parts into the inclusion module

* DMP: Introduce the max size limit for the size of a downward message

* DMP: Runtime API for accessing inbound messages

* OCD

Small clean ups

* DMP: fix the naming of the error

* DMP: add caution about a non-existent recipient
This commit is contained in:
Sergei Shulepov
2020-10-28 11:41:42 +01:00
committed by GitHub
parent 1a25c41277
commit 9903bca259
26 changed files with 556 additions and 36 deletions
+17 -1
View File
@@ -31,7 +31,7 @@ pub use runtime_primitives::traits::{BlakeTwo256, Hash as HashT};
pub use polkadot_core_primitives::v1::{
BlockNumber, Moment, Signature, AccountPublic, AccountId, AccountIndex,
ChainId, Hash, Nonce, Balance, Header, Block, BlockId, UncheckedExtrinsic,
Remark, DownwardMessage,
Remark, DownwardMessage, InboundDownwardMessage,
};
// Export some polkadot-parachain primitives
@@ -266,6 +266,11 @@ pub struct PersistedValidationData<N = BlockNumber> {
/// vector is sorted ascending by the para id and doesn't contain multiple entries with the same
/// sender.
pub hrmp_mqc_heads: Vec<(Id, Hash)>,
/// The MQC head for the DMQ.
///
/// The DMQ MQC head will be used by the validation function to authorize the downward messages
/// passed by the collator.
pub dmq_mqc_head: Hash,
}
impl<N: Encode> PersistedValidationData<N> {
@@ -301,6 +306,8 @@ pub struct TransientValidationData<N = BlockNumber> {
/// which case the code upgrade should be applied at the end of the signaling
/// block.
pub code_upgrade_allowed: Option<N>,
/// The number of messages pending of the downward message queue.
pub dmq_length: u32,
}
/// Outputs of validating a candidate.
@@ -315,6 +322,8 @@ pub struct ValidationOutputs {
pub fees: Balance,
/// The new validation code submitted by the execution, if any.
pub new_validation_code: Option<ValidationCode>,
/// The number of messages processed from the DMQ.
pub processed_downward_messages: u32,
}
/// Commitments made in a `CandidateReceipt`. Many of these are outputs of validation.
@@ -331,6 +340,8 @@ pub struct CandidateCommitments {
pub new_validation_code: Option<ValidationCode>,
/// The head-data produced as a result of execution.
pub head_data: HeadData,
/// The number of messages processed from the DMQ.
pub processed_downward_messages: u32,
}
impl CandidateCommitments {
@@ -712,6 +723,11 @@ sp_api::decl_runtime_apis! {
/// We assume that every validator runs authority discovery,
/// which would allow us to establish point-to-point connection to given validators.
fn validator_discovery(validators: Vec<ValidatorId>) -> Vec<Option<AuthorityDiscoveryId>>;
/// Get all the pending inbound messages in the downward message queue for a para.
fn dmq_contents(
recipient: Id,
) -> Vec<InboundDownwardMessage<N>>;
}
}