DMP Pallet
A module responsible for Downward Message Processing (DMP). See Messaging Overview for more details.
Storage
Storage layout required for implementation of DMP.
#![allow(unused)] fn main() { /// The downward messages addressed for a certain para. DownwardMessageQueues: map ParaId => Vec<InboundDownwardMessage>; /// A mapping that stores the downward message queue MQC head for each para. /// /// Each link in this chain has a form: /// `(prev_head, B, H(M))`, where /// - `prev_head`: is the previous head hash or zero if none. /// - `B`: is the relay-chain block number in which a message was appended. /// - `H(M)`: is the hash of the message being appended. DownwardMessageQueueHeads: map ParaId => Hash; }
Initialization
No initialization routine runs for this module.
Routines
Candidate Acceptance Function:
check_processed_downward_messages(P: ParaId, relay_parent_number: BlockNumber, processed_downward_messages: u32)
:- Checks that
processed_downward_messages
is at least 1 ifDownwardMessageQueues
forP
is not empty at the givenrelay_parent_number
. - Checks that
DownwardMessageQueues
forP
is at leastprocessed_downward_messages
long.
- Checks that
Candidate Enactment:
prune_dmq(P: ParaId, processed_downward_messages: u32)
:- Remove the first
processed_downward_messages
from theDownwardMessageQueues
ofP
.
- Remove the first
Utility routines.
queue_downward_message(P: ParaId, M: DownwardMessage)
:
- Check if the size of
M
exceeds theconfig.max_downward_message_size
. If so, return an error. - Wrap
M
intoInboundDownwardMessage
using the current block number forsent_at
. - Obtain a new MQC link for the resulting
InboundDownwardMessage
and replaceDownwardMessageQueueHeads
forP
with the resulting hash. - Add the resulting
InboundDownwardMessage
intoDownwardMessageQueues
forP
.
Session Change
- For each
P
inoutgoing_paras
(generated byParas::on_new_session
):- Remove all
DownwardMessageQueues
ofP
. - Remove
DownwardMessageQueueHeads
forP
.
- Remove all