Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Implementer's guide: downward messages and HRMP, take 2 #1503

Merged
merged 54 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c90fdf4
First stab at downward messages.
pepyakin Jul 13, 2020
d1ab1fb
Add some structure to the router.
pepyakin Jul 13, 2020
69fe295
Update `ValidationOutputs`
pepyakin Jul 13, 2020
ceaa096
Add `processed_downward_messages` to `ValidationOutputs`.
pepyakin Jul 14, 2020
e952a01
s/AccountId/ParaId
pepyakin Jul 14, 2020
778cc2b
DownwardMessage::ParachainSpecfic
pepyakin Jul 14, 2020
bdb97af
s/ensure_horizontal_messages_fits/ensure_horizontal_messages_fit
pepyakin Jul 14, 2020
921ca3b
Clarify that Router called for each candidate
pepyakin Jul 14, 2020
3fff854
Update the preamble for Router.
pepyakin Jul 14, 2020
8072356
Rewrite the relay-chain extrinsic routines
pepyakin Jul 14, 2020
a622f77
Update gloassary
pepyakin Jul 14, 2020
0309bc5
Add DMP to the glossary
pepyakin Jul 14, 2020
1c75b51
If the queue is empty, `processed_downward_messages` can be 0
pepyakin Jul 14, 2020
c1f8482
Merge remote-tracking branch 'origin/master' into ser-ch-based-hrmp-v…
pepyakin Jul 28, 2020
d781330
WIP
pepyakin Jul 30, 2020
d62803e
Add condemned list
pepyakin Jul 30, 2020
5d09dd8
Pivot to message-storing channel based HRMP
pepyakin Jul 30, 2020
e5f642a
Finished draft
pepyakin Jul 30, 2020
b1e1b28
Tidy up
pepyakin Jul 30, 2020
02ae124
Remove a duplicate glossary entry
pepyakin Jul 30, 2020
5111966
Fix typo
pepyakin Jul 30, 2020
c94ba1d
Fix wording to emphasize that the channel is unidirectional
pepyakin Jul 30, 2020
bf7eb0a
Proper decrement `HrmpOpenChannelRequestCount`
pepyakin Jul 30, 2020
44f9338
Add a comment for `HrmpOpenChannelRequestCount`.
pepyakin Jul 30, 2020
ea1ad39
Remove old configuration values.
pepyakin Jul 30, 2020
012b839
Be more specific about the para{chain,thread} hrmp chan limits.
pepyakin Jul 30, 2020
2edf4c9
Fix indentation so the lists are rendendered properly
pepyakin Jul 30, 2020
50742fd
"to answer **the**" question instead of "a"
pepyakin Jul 30, 2020
09a0c4b
Add a missing call to `check_processed_downward_messages`
pepyakin Jul 30, 2020
7d8abd6
Clean more stuff during offboarding
pepyakin Jul 30, 2020
3f3f051
Fix typo
pepyakin Jul 30, 2020
defd96b
Fix typo for the config
pepyakin Jul 30, 2020
6faf068
Add a call to `prune_dmq`
pepyakin Jul 30, 2020
ca70234
Add explicit invariants for ingress/egress indexes
pepyakin Jul 30, 2020
017885e
Add comments for the sender/reciever deposit config fields
pepyakin Jul 31, 2020
439b02e
Document various fields and structs in Router module
pepyakin Jul 31, 2020
4285e51
More docs
pepyakin Jul 31, 2020
c1b3e0a
Missing docs in Candidate.md
pepyakin Jul 31, 2020
4ea0012
Tabs to spaces in router.md
pepyakin Aug 3, 2020
065f047
Apply Rob's suggestion
pepyakin Aug 3, 2020
0da3cfa
Add the hrmp_ prefix to the router messages
pepyakin Aug 3, 2020
0de4110
Those are entry points
pepyakin Aug 3, 2020
360c518
Use SessionIndex type for the `age` field
pepyakin Aug 3, 2020
3d6195d
Use a struct to represent `HrmpChannelId`
pepyakin Aug 3, 2020
7bd6316
Merge remote-tracking branch 'origin/master' into ser-ch-based-hrmp
pepyakin Aug 3, 2020
ce6e8de
Put only MQCs into the LocalValidationData
pepyakin Aug 4, 2020
eb97502
Close request can be initiated by the runtime directly
pepyakin Aug 4, 2020
5c1f312
Close request can be initiated by the runtime directly
pepyakin Aug 4, 2020
e18b84a
tabs/spaces
pepyakin Aug 4, 2020
1bcfe70
Maintain the list of the outgoing paras in Router
pepyakin Aug 4, 2020
6d42e9b
Update roadmap/implementers-guide/src/runtime/inclusion.md
pepyakin Aug 5, 2020
b1b0fd9
fix typo
pepyakin Aug 5, 2020
c22c5d2
Remove an unnecessary pair of code quotes
pepyakin Aug 5, 2020
ef9dc1e
Merge branch 'ser-ch-based-hrmp' of github.com:paritytech/polkadot in…
pepyakin Aug 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions roadmap/implementers-guide/src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ Here you can find definitions of a bunch of jargon, usually specific to the Polk
- Backed Candidate: A Backable Candidate noted in a relay-chain block
- Backing: A set of statements proving that a Parachain Candidate is backable.
- Collator: A node who generates Proofs-of-Validity (PoV) for blocks of a specific parachain.
- DMP: (Downward Message Passing). Message passing from the relay-chain to a parachain.
- Extrinsic: An element of a relay-chain block which triggers a specific entry-point of a runtime module with given arguments.
- GRANDPA: (Ghost-based Recursive ANcestor Deriving Prefix Agreement). The algorithm validators use to guarantee finality of the Relay Chain.
- HRMP: (Horizontally Relay-routed Message Passing). A mechanism for message passing between parachains (hence horizontal) that leverages the relay-chain storage. Predates XCMP.
- Inclusion Pipeline: The set of steps taken to carry a Parachain Candidate from authoring, to backing, to availability and full inclusion in an active fork of its parachain.
- Module: A component of the Runtime logic, encapsulating storage, routines, and entry-points.
- Module Entry Point: A recipient of new information presented to the Runtime. This may trigger routines.
- Module Routine: A piece of code executed within a module by block initialization, closing, or upon an entry point being triggered. This may execute computation, and read or write storage.
- MQC: (Message Queue Chain). A cryptographic data structure that resembles an append-only linked list which doesn't store original values but only their hashes. The whole structure is described by a single hash, referred as a "head". When a value is appended, it's contents hashed with the previous head creating a hash that becomes a new head.
- Node: A participant in the Polkadot network, who follows the protocols of communication and connection to other nodes. Nodes form a peer-to-peer network topology without a central authority.
- Parachain Candidate, or Candidate: A proposed block for inclusion into a parachain.
- Parablock: A block in a parachain.
Expand All @@ -26,8 +29,11 @@ Here you can find definitions of a bunch of jargon, usually specific to the Polk
- Runtime API: A means for the node-side behavior to access structured information based on the state of a fork of the blockchain.
- Secondary Checker: A validator who has been randomly selected to perform secondary approval checks on a parablock which is pending approval.
- Subsystem: A long-running task which is responsible for carrying out a particular category of work.
- UMP: (Upward Message Passing) A vertical message passing mechanism from a parachain to the relay chain.
- Validator: Specially-selected node in the network who is responsible for validating parachain blocks and issuing attestations about their validity.
- Validation Function: A piece of Wasm code that describes the state-transition function of a parachain.
- VMP: (Vertical Message Passing) A family of mechanisms that are responsible for message exchange between the relay chain and parachains.
- XCMP (Cross-Chain Message Passing) A type of horizontal message passing (i.e. between parachains) that allows secure message passing directly between parachains and has minimal resource requirements from the relay chain, thus highly scalable.

Also of use is the [Substrate Glossary](https://substrate.dev/docs/en/knowledgebase/getting-started/glossary).

Expand Down
7 changes: 7 additions & 0 deletions roadmap/implementers-guide/src/runtime/inclusion.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,20 @@ All failed checks should lead to an unrecoverable error making the block invalid
1. Check the collator's signature on the candidate data.
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::check_processed_downward_messages(para, commitments.processed_downward_messages)` to check that the DMQ is properly drained.
1. call `Router::check_hrmp_watermark(para, commitments.hrmp_watermark)` for each candidate to check rules of processing the HRMP watermark.
1. check that in the commitments of each candidate the horizontal messages are sorted by ascending recipient ParaId and there is no two horizontal messages have the same recipient.
1. using `Router::verify_outbound_hrmp(sender, commitments.horizontal_messages)` ensure that the each candidate's para correctly send horizontal messages.
pepyakin marked this conversation as resolved.
Show resolved Hide resolved
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::queue_outbound_hrmp` with the para id of the candidate and the list of horizontal messages taken from the commitment,
1. call `Router::prune_hrmp` with the para id of the candiate and the candidate's `hrmp_watermark`.
1. call `Router::prune_dmq` with the para id of the candidate and the candidate's `processed_downward_messages`.
1. Call `Paras::note_new_head` using the `HeadData` from the receipt and `relay_parent_number`.
* `collect_pending`:

Expand Down
3 changes: 2 additions & 1 deletion roadmap/implementers-guide/src/runtime/paras.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ OutgoingParas: Vec<ParaId>;

## Session Change

1. Clean up outgoing paras. This means removing the entries under `Heads`, `ValidationCode`, `FutureCodeUpgrades`, and `FutureCode`. An according entry should be added to `PastCode`, `PastCodeMeta`, and `PastCodePruning` using the outgoing `ParaId` and removed `ValidationCode` value. This is because any outdated validation code must remain available on-chain for a determined amount of blocks, and validation code outdated by de-registering the para is still subject to that invariant.
1. Clean up outgoing paras.
1. This means removing the entries under `Heads`, `ValidationCode`, `FutureCodeUpgrades`, and `FutureCode`. An according entry should be added to `PastCode`, `PastCodeMeta`, and `PastCodePruning` using the outgoing `ParaId` and removed `ValidationCode` value. This is because any outdated validation code must remain available on-chain for a determined amount of blocks, and validation code outdated by de-registering the para is still subject to that invariant.
1. Apply all incoming paras by initializing the `Heads` and `ValidationCode` using the genesis parameters.
1. Amend the `Parachains` list to reflect changes in registered parachains.
1. Amend the `Parathreads` set to reflect changes in registered parathreads.
Expand Down
Loading