-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Implementer's guide: downward messages and HRMP #1399
Changes from 3 commits
c90fdf4
d1ab1fb
69fe295
ceaa096
e952a01
778cc2b
bdb97af
921ca3b
3fff854
8072356
a622f77
0309bc5
1c75b51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,13 +68,18 @@ All failed checks should lead to an unrecoverable error making the block invalid | |
| 1. Transform each [`CommittedCandidateReceipt`](../types/candidate.md#committed-candidate-receipt) into the corresponding [`CandidateReceipt`](../types/candidate.md#candidate-receipt), setting the commitments aside. | ||
| 1. check the backing of the candidate using the signatures and the bitfields, comparing against the validators assigned to the groups, fetched with the `group_validators` lookup. | ||
| 1. check that the upward messages, when combined with the existing queue size, are not exceeding `config.max_upward_queue_count` and `config.watermark_upward_queue_size` parameters. | ||
| 1. call `Router::ensure_processed_downward_messages(para, processed_downward_messages)` to check rules of processing the downward message queue. | ||
| 1. check that the horizontal messages are sorted by ascending recipient ParaId and there is no two horizontal messages have the same recipient. | ||
| 1. using `Router::ensure_horizontal_messages_fit(sender, horizontal_messages)` ensure that the sender para doesn't overfill any downward queue. | ||
|
pepyakin marked this conversation as resolved.
Outdated
|
||
| 1. create an entry in the `PendingAvailability` map for each backed candidate with a blank `availability_votes` bitfield. | ||
| 1. create a corresponding entry in the `PendingAvailabilityCommitments` with the commitments. | ||
| 1. Return a `Vec<CoreIndex>` of all scheduled cores of the list of passed assignments that a candidate was successfully backed for, sorted ascending by CoreIndex. | ||
| * `enact_candidate(relay_parent_number: BlockNumber, CommittedCandidateReceipt)`: | ||
| 1. If the receipt contains a code upgrade, Call `Paras::schedule_code_upgrade(para_id, code, relay_parent_number + config.validationl_upgrade_delay)`. | ||
| > TODO: Note that this is safe as long as we never enact candidates where the relay parent is across a session boundary. In that case, which we should be careful to avoid with contextual execution, the configuration might have changed and the para may de-sync from the host's understanding of it. | ||
| 1. call `Router::queue_upward_messages` for each backed candidate, using the [`UpwardMessage`s](../types/messages.md#upward-message) from the [`CandidateCommitments`](../types/candidate.md#candidate-commitments). | ||
| 1. call `Router::drain_downward_messages` with the para id of the candidate and `processed_downward_messages` taken from the commitment, | ||
| 1. call `Router::queue_horizontal_messages` with the para id of the candidate and the list of horizontal messages taken from the commitment, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likewise: the name here doesn't match what is in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 1. Call `Paras::note_new_head` using the `HeadData` from the receipt and `relay_parent_number`. | ||
| * `collect_pending`: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,9 @@ | |
|
|
||
| Types of messages that are passed between parachains and the relay chain: UMP, DMP, XCMP. | ||
|
|
||
| There is also HRMP (Horizontally Relay-routed Message Passing) which provides the same functionality | ||
| although with smaller scalability potential. | ||
|
|
||
| ## Upward Message | ||
|
|
||
| A type of messages dispatched from a parachain to the relay chain. | ||
|
|
@@ -26,3 +29,34 @@ struct UpwardMessage { | |
| pub data: Vec<u8>, | ||
| } | ||
| ``` | ||
|
|
||
| ## Horizontal Message | ||
|
|
||
| This is a message sent from a parachain to another parachain that travels through the relay chain. | ||
| This message ends up in the recipient's mailbox. A size of a horizontal message is defined by its | ||
| `data` payload. | ||
|
|
||
| ```rust,ignore | ||
| struct HorizontalMessage { | ||
| /// The para that will get this message in its downward message queue. | ||
| pub recipient: ParaId, | ||
| /// The message payload. | ||
| pub data: Vec<u8>, | ||
| } | ||
| ``` | ||
|
|
||
| ## Downward Message | ||
|
|
||
| A message that go down from the relay chain to a parachain. Such a message could be initiated either | ||
| as a result of an operation took place on the relay chain or sent using a horizontal message. | ||
|
|
||
| ```rust,ignore | ||
| enum DownwardMessage { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, got it. Added it below, although I couldn't help myself to choose the name
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| /// Some funds were transferred into the parachain's account. The hash is the identifier that | ||
| /// was given with the transfer. | ||
| TransferInto(AccountId, Balance, Remark), | ||
| /// This downward message is a result of a horizontal message represented as opaque bytes sent | ||
| /// by the specified sender. | ||
| HorizontalMessage(AccountId, Vec<u8>), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yeah, I ofc meant Why do you think it might be not
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I thought we might embed the sender in the message but it seems better to keep the |
||
| } | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other points in this section refer to "each candidate" because the parameter is a set of candidates.
processed_downwards_messagesis part of theCandidateCommitments? it would be more clear to reference that directly because the name is not defined above.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah good point, fixed.
Ah I actually considered to do that but thought it was too verbose. I referred it as e.g.
commitments.processed_downward_messages. Is that what you meant?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is reasonable