-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implementer's Guide: Flesh out more details for upward messages #1556
Changes from 8 commits
eab0270
06581bd
d1ef323
a34f5aa
0e419b9
32fa4e8
8ee8cb2
1a4713c
2402d47
a662912
77a0f46
7d87c60
032d8be
8d2fc1b
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 |
|---|---|---|
|
|
@@ -17,9 +17,7 @@ digraph { | |
| } | ||
| ``` | ||
|
|
||
| Downward Message Passing (DMP) is a mechanism for delivering messages to parachains from the relay chain. Downward | ||
| messages may originate not from the relay chain, but rather from another parachain via a mechanism | ||
| called HRMP (Will be described later). | ||
| Downward Message Passing (DMP) is a mechanism for delivering messages to parachains from the relay chain. | ||
|
|
||
| Each parachain has its own queue that stores all pending inbound downward messages. A parachain | ||
| doesn't have to process all messages at once, however, there are rules as to how the downward message queue | ||
|
|
@@ -28,16 +26,17 @@ The downward message queue doesn't have a cap on its size and it is up to the re | |
| that prevent spamming in place. | ||
|
|
||
| Upward Message Passing (UMP) is a mechanism responsible for delivering messages in the opposite direction: | ||
| from a parachain up to the relay chain. Upward messages are dispatched to Runtime entrypoints and | ||
| typically used for invoking some actions on the relay chain on behalf of the parachain. | ||
| from a parachain up to the relay chain. Upward messagess can serve different purposes and can be of different | ||
| kinds. | ||
|
|
||
| > NOTE: It is conceivable that upward messages will be divided to more fine-grained kinds with a dispatchable upward message | ||
| being only one kind of multiple. That would make upward messages inspectable and therefore would allow imposing additional | ||
| validity criteria for the candidates that contain these messages. | ||
| One kind of messages is `Dispatchable`. They could be thought of similar to extrinsics sent to a relay chain: they also | ||
pepyakin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| invoke exposed runtime entrypoints, they consume weight and require fees. The difference is that they originate from | ||
| a parachain. Each parachain has a queue of dispatchables to be executed. There can be only so many dispatchables at a time. | ||
| The weight that processing of the dispatchables can consume is limited by a preconfigured value. Therefore, it is possible | ||
| that some dispatchables will be left for later blocks. To make the dispatching more fair, the queues are processed turn-by-turn | ||
| in a round robin fashion. | ||
|
|
||
| Semantically, there is a queue of upward messages queue where messages from each parachain are stored. Each parachain | ||
| can have a limited number of messages and the total sum of pending messages is also limited. Each parachain can dispatch | ||
| multiple upward messages per candidate. | ||
| Other kinds of upward messages can be introduced in the future as well. Most likely the HRMP channel managem | ||
pepyakin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Horizontal Message Passing | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,11 +22,24 @@ enum ParachainDispatchOrigin { | |
| Root, | ||
| } | ||
|
|
||
| struct UpwardMessage { | ||
| /// The origin for the message to be sent from. | ||
| pub origin: ParachainDispatchOrigin, | ||
| /// The message data. | ||
| pub data: Vec<u8>, | ||
| /// An opaque byte buffer that encodes an entrypoint and the arguments that should be | ||
| /// provided to it upon the dispatch. | ||
| /// | ||
| /// NOTE In order to be executable the byte buffer should be decoded which potentially can fail if | ||
| /// the encoding was changed. | ||
| type RawDispatchable = Vec<u8>; | ||
|
|
||
| enum UpwardMessage { | ||
| /// This upward message is meant to schedule execution of a provided dispatchable. | ||
| Dispatchable { | ||
| /// The origin with which the dispatchable should be executed. | ||
| origin: ParachainDispatchOrigin, | ||
| /// The dispatchable to be executed in its raw form. | ||
| dispatchable: RawDispatchable, | ||
| }, | ||
| // Examples: | ||
| // HrmpOpenChannel { .. }, | ||
| // HrmpCloseChannel { .. }, | ||
|
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. What are these examples of?
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. Of other potential kinds of messages, I can remove that if you think that's unnecessary given that those will become real messages
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. I would be in favour of removing them, I find it unclear what usage they show. |
||
| } | ||
| ``` | ||
|
|
||
|
|
@@ -53,11 +66,25 @@ struct InboundHrmpMessage { | |
|
|
||
| ## 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. | ||
| `DownwardMessage`- is a message that go down from the relay chain to a parachain. Such a message | ||
pepyakin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| could be seen as a notification, however, it is concievable that they might be used by the relay | ||
pepyakin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| chain to send a request to the parachain (likely, through the `ParachainSpecific` variant). | ||
|
|
||
| ```rust,ignore | ||
| enum DispatchResult { | ||
| Executed { | ||
| success: bool, | ||
| }, | ||
| /// Decoding `RawDispatchable` into an executable runtime representation has failed. | ||
| DecodeFailed, | ||
| /// A dispatchable in question exceeded the maximum amount of weight allowed. | ||
| CriticalWeightExceeded, | ||
| } | ||
|
|
||
| enum DownwardMessage { | ||
| /// The parachain receives a dispatch result for each sent dispatchable upward message in order | ||
| /// they were sent. | ||
| DispatchResult(Vec<DispatchResult>), | ||
| /// Some funds were transferred into the parachain's account. The hash is the identifier that | ||
| /// was given with the transfer. | ||
| TransferInto(AccountId, Balance, Remark), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.