diff --git a/docs/polkadot/implementors-guide.rst b/docs/polkadot/implementors-guide.rst
deleted file mode 100644
index 1d17d9c8..00000000
--- a/docs/polkadot/implementors-guide.rst
+++ /dev/null
@@ -1,12 +0,0 @@
-===================
-Implementors' Guide
-===================
-
-.. raw:: html
-
-
-
-.. toctree::
- :glob:
-
- implementors-guide/*
diff --git a/docs/polkadot/implementors-guide/README.md b/docs/polkadot/implementors-guide/README.md
deleted file mode 100644
index 768715c7..00000000
--- a/docs/polkadot/implementors-guide/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# Parachains-core Implementers' Guide
-
-This is a software architecture and design document aimed to describe the purpose, functionality, and implementation of Polkadot's Parachains.
-
-The guide itself is contained within the [guide.md](guide.md) file.
\ No newline at end of file
diff --git a/docs/polkadot/implementors-guide/guide.md b/docs/polkadot/implementors-guide/guide.md
deleted file mode 100644
index 514dc2fc..00000000
--- a/docs/polkadot/implementors-guide/guide.md
+++ /dev/null
@@ -1,1208 +0,0 @@
-## The Polkadot Parachain Host Implementers' Guide
-
-## Ramble / Preamble
-
-This document aims to describe the purpose, functionality, and implementation of a host for Polkadot's _parachains_. It is not for the implementor of a specific parachain but rather for the implementor of the Parachain Host, which provides security and advancement for constituent parachains. In practice, this is for the implementors of Polkadot.
-
-There are a number of other documents describing the research in more detail. All referenced documents will be linked here and should be read alongside this document for the best understanding of the full picture. However, this is the only document which aims to describe key aspects of Polkadot's particular instantiation of much of that research down to low-level technical details and software architecture.
-
-## Table of Contents
-* [Origins](#Origins)
-* [Parachains: Basic Functionality](#Parachains-Basic-Functionality)
-* [Architecture](#Architecture)
- * [Node-side](#Architecture-Node-side)
- * [Runtime](#Architecture-Runtime)
-* [Subsystems](#Subsystems)
- * [Overseer](#Overseer)
- * [Candidate Backing](#Candidate-Backing-Subsystem)
-* [Data Structures and Types](#Data-Structures-and-Types)
-* [Glossary / Jargon](#Glossary)
-
-
-## Origins
-
-Parachains are the solution to a problem. As with any solution, it cannot be understood without first understanding the problem. So let's start by going over the issues faced by blockchain technology that led to us beginning to explore the design space for something like parachains.
-
-#### Issue 1: Scalability
-
-It became clear a few years ago that the transaction throughput of simple Proof-of-Work (PoW) blockchains such as Bitcoin, Ethereum, and myriad others was simply too low. [TODO: PoS, sharding, what if there were more blockchains, etc. etc.]
-
-Proof-of-Stake (PoS) systems can accomplish higher throughput than PoW blockchains. PoS systems are secured by bonded capital as opposed to spent effort - liquidity opportunity cost vs. burning electricity. The way they work is by selecting a set of validators with known economic identity who lock up tokens in exchange for earning the right to "validate" or participate in the consensus process. If they are found to carry out that process wrongly, they will be slashed, meaning some or all of the locked tokens will be burned. This provides a strong disincentive in the direction of misbehavior.
-
-Since the consensus protocol doesn't revolve around wasting effort, block times and agreement can occur much faster. Solutions to PoW challenges don't have to be found before a block can be authored, so the overhead of authoring a block is reduced to only the costs of creating and distributing the block.
-
-However, consensus on a PoS chain requires full agreement of 2/3+ of the validator set for everything that occurs at Layer 1: all logic which is carried out as part of the blockchain's state machine. This means that everybody still needs to check everything. Furthermore, validators may have different views of the system based on the information that they receive over an asynchronous network, making agreement on the latest state more difficult.
-
-Parachains are an example of a **sharded** protocol. Sharding is a concept borrowed from traditional database architecture. Rather than requiring every participant to check every transaction, we require each participant to check some subset of transactions, with enough redundancy baked in that byzantine (arbitrarily malicious) participants can't sneak in invalid transactions - at least not without being detected and getting slashed, with those transactions reverted.
-
-Sharding and Proof-of-Stake in coordination with each other allow a parachain host to provide full security on many parachains, even without all participants checking all state transitions.
-
-[TODO: note about network effects & bridging]
-
-#### Issue 2: Flexibility / Specialization
-
-"dumb" VMs don't give you the flexibility. Any engineer knows that being able to specialize on a problem gives them and their users more _leverage_. [TODO]
-
-
-Having recognized these issues, we set out to find a solution to these problems, which could allow developers to create and deploy purpose-built blockchains unified under a common source of security, with the capability of message-passing between them; a _heterogeneous sharding solution_, which we have come to know as **Parachains**.
-
-
-----
-
-## Parachains: Basic Functionality
-
-This section aims to describe, at a high level, the architecture, actors, and Subsystems involved in the implementation of parachains. It also illuminates certain subtleties and challenges faced in the design and implementation of those Subsystems. Our goal is to carry a parachain block from authoring to secure inclusion, and define a process which can be carried out repeatedly and in parallel for many different parachains to extend them over time. Understanding of the high-level approach taken here is important to provide context for the proposed architecture further on.
-
-The Parachain Host is a blockchain, known as the relay-chain, and the actors which provide security and inputs to the blockchain.
-
-First, it's important to go over the main actors we have involved in the parachain host.
-1. Validators. These nodes are responsible for validating proposed parachain blocks. They do so by checking a Proof-of-Validity (PoV) of the block and ensuring that the PoV remains available. They put financial capital down as "skin in the game" which can be slashed (destroyed) if they are proven to have misvalidated.
-2. Collators. These nodes are responsible for creating the Proofs-of-Validity that validators know how to check. Creating a PoV typically requires familiarity with the transaction format and block authoring rules of the parachain, as well as having access to the full state of the parachain.
-3. Fishermen. These are user-operated, permissionless nodes whose goal is to catch misbehaving validators in exchange for a bounty. Collators and validators can behave as Fishermen too. Fishermen aren't necessary for security, and aren't covered in-depth by this document.
-
-This alludes to a simple pipeline where collators send validators parachain blocks and their requisite PoV to check. Then, validators validate the block using the PoV, signing statements which describe either the positive or negative outcome, and with enough positive statements, the block can be included. Negative statements are not a veto but will lead to a dispute, with those on the wrong side being slashed. If another validator later detects that a validator or group of validators incorrectly signed a statement claiming a block was valid, then those validators will be _slashed_, with the checker receiving a bounty.
-
-However, there is a problem with this formulation. In order for another validator to check the previous group of validators' work after the fact, the PoV must remain _available_ so the other validator can fetch it in order to check the work. The PoVs are expected to be too large to include in the blockchain directly, so we require an alternate _data availability_ scheme which requires validators to prove that the inputs to their work will remain available, and so their work can be checked. Empirical tests tell us that many PoVs may be between 1 and 10MB during periods of heavy load.
-
-Here is a description of the Inclusion Pipeline: the path a parachain block (or parablock, for short) takes from creation to inclusion:
-1. Validators are selected and assigned to parachains by the Validator Assignment routine.
-1. A collator produces the parachain block, which is known as a parachain candidate or candidate, along with a PoV for the candidate.
-1. The collator forwards the candidate and PoV to validators assigned to the same parachain via the Collation Distribution Subsystem.
-1. The validators assigned to a parachain at a given point in time participate in the Candidate Backing Subsystem to validate candidates that were put forward for validation. Candidates which gather enough signed validity statements from validators are considered "backed" and are called backed candidates. Their backing is the set of signed validity statements.
-1. A relay-chain block author, selected by BABE, can include up to one (1) backed candidate for each parachain to include in the relay-chain block alongside its backing.
-1. Once included in the relay-chain, the parachain candidate is considered to be "pending availability". It is not considered to be part of the parachain until it is proven available.
-1. In the following relay-chain blocks, validators will participate in the Availability Distribution Subsystem to ensure availability of the candidate. Information regarding the availability of the candidate will be included in the subsequent relay-chain blocks.
-1. Once the relay-chain state machine has enough information to consider the candidate's PoV as being available, the candidate is considered to be part of the parachain and is graduated to being a full parachain block, or parablock for short.
-
-Note that the candidate can fail to be included in any of the following ways:
- - The collator is not able to propagate the candidate to any validators assigned to the parachain.
- - The candidate is not backed by validators participating in the Candidate Backing Subsystem.
- - The candidate is not selected by a relay-chain block author to be included in the relay chain
- - The candidate's PoV is not considered as available within a timeout and is discarded from the relay chain.
-
-This process can be divided further down. Steps 2 & 3 relate to the work of the collator in collating and distributing the candidate to validators via the Collation Distribution Subsystem. Steps 3 & 4 relate to the work of the validators in the Candidate Backing Subsystem and the block author (itself a validator) to include the block into the relay chain. Steps 6, 7, and 8 correspond to the logic of the relay-chain state-machine (otherwise known as the Runtime) used to fully incorporate the block into the chain. Step 7 requires further work on the validators' parts to participate in the Availability Distribution Subsystem and include that information into the relay chain for step 8 to be fully realized.
-
-This brings us to the second part of the process. Once a parablock is considered available and part of the parachain, it is still "pending approval". At this stage in the pipeline, the parablock has been backed by a majority of validators in the group assigned to that parachain, and its data has been guaranteed available by the set of validators as a whole. Once it's considered available, the host will even begin to accept children of that block. However, the validators in the parachain-group (known as the "Parachain Validators" for that parachain) are sampled from a validator set which contains some proportion of byzantine, or arbitrarily malicious members. This implies that the Parachain Validators for some parachain may be majority-dishonest, which means that secondary checks must be done on the block before it can be considered approved. This is necessary only because the Parachain Validators for a given parachain are sampled from an overall validator set which is assumed to be up to <1/3 dishonest - meaning that there is a chance to randomly sample Parachain Validators for a parachain that are majority or fully dishonest and can back a candidate wrongly. The Approval Process allows us to detect such misbehavior after-the-fact without allocating more Parachain Validators and reducing the throughput of the system. A parablock's failure to pass the approval process will invalidate the block as well as all of its descendents. However, only the validators who backed the block in question will be slashed, not the validators who backed the descendents.
-
-The Approval Process looks like this:
-1. Parablocks that have been included by the Inclusion Pipeline are pending approval for a time-window known as the secondary checking window.
-1. During the secondary-checking window, validators randomly self-select to perform secondary checks on the parablock.
-1. These validators, known in this context as secondary checkers, acquire the parablock and its PoV, and re-run the validation function.
-1. The secondary checkers submit the result of their checks to the relay chain. Contradictory results lead to escalation, where even more secondary checkers are selected and the secondary-checking window is extended.
-1. At the end of the Approval Process, the parablock is either Approved or it is rejected. More on the rejection process later.
-
-These two pipelines sum up the sequence of events necessary to extend and acquire full security on a Parablock. Note that the Inclusion Pipeline must conclude for a specific parachain before a new block can be accepted on that parachain. After inclusion, the Approval Process kicks off, and can be running for many parachain blocks at once.
-
-[TODO Diagram: Inclusion Pipeline & Approval Subsystems interaction]
-
-It is also important to take note of the fact that the relay-chain is extended by BABE, which is a forkful algorithm. That means that different block authors can be chosen at the same time, and may not be building on the same block parent. Furthermore, the set of validators is not fixed, nor is the set of parachains. And even with the same set of validators and parachains, the validators' assignments to parachains is flexible. This means that the architecture proposed in the next chapters must deal with the variability and multiplicity of the network state.
-
-```
-
- ....... Validator Group 1 ..........
- . .
- . (Validator 4) .
- . (Validator 1) (Validator 2) .
- . (Validator 5) .
- . .
- ..........Building on C ........... ........ Validator Group 2 ...........
- +----------------------+ . .
- | Relay Block C | . (Validator 7) .
- +----------------------+ . ( Validator 3) (Validator 6) .
- \ . .
- \ ......... Building on B .............
- \
- +----------------------+
- | Relay Block B |
- +----------------------+
- |
- +----------------------+
- | Relay Block A |
- +----------------------+
-
-```
-
-In this example, group 1 has received block C while the others have not due to network asynchrony. Now, a validator from group 2 may be able to build another block on top of B, called C'. Assume that afterwards, some validators become aware of both C and C', while others remain only aware of one.
-
-```
- ....... Validator Group 1 .......... ........ Validator Group 2 ...........
- . . . .
- . (Validator 4) (Validator 1) . . (Validator 7) (Validator 6) .
- . . . .
- .......... Building on C .......... ......... Building on C' .............
-
-
- ....... Validator Group 3 ..........
- . .
- . (Validator 2) (Validator 3) .
- . (Validator 5) .
- . .
- ....... Building on C and C' .......
-
- +----------------------+ +----------------------+
- | Relay Block C | | Relay Block C' |
- +----------------------+ +----------------------+
- \ /
- \ /
- \ /
- +----------------------+
- | Relay Block B |
- +----------------------+
- |
- +----------------------+
- | Relay Block A |
- +----------------------+
-```
-
-Those validators that are aware of many competing heads must be aware of the work happening on each one. They may contribute to some or a full extent on both. It is possible that due to network asynchrony two forks may grow in parallel for some time, although in the absence of an adversarial network this is unlikely in the case where there are validators who are aware of both chain heads.
-
-----
-
-## Architecture
-
-Our Parachain Host includes a blockchain known as the relay-chain. A blockchain is a Directed Acyclic Graph (DAG) of state transitions, where every block can be considered to be the head of a linked-list (known as a "chain" or "fork") with a cumulative state which is determined by applying the state transition of each block in turn. All paths through the DAG terminate at the Genesis Block. In fact, the blockchain is a tree, since each block can have only one parent.
-
-```
- +----------------+ +----------------+
- | Block 4 | | Block 5 |
- +----------------+ +----------------+
- \ /
- V V
- +---------------+
- | Block 3 |
- +---------------+
- |
- V
- +----------------+ +----------------+
- | Block 1 | | Block 2 |
- +----------------+ +----------------+
- \ /
- V V
- +----------------+
- | Genesis |
- +----------------+
-```
-
-
-A blockchain network is comprised of nodes. These nodes each have a view of many different forks of a blockchain and must decide which forks to follow and what actions to take based on the forks of the chain that they are aware of.
-
-So in specifying an architecture to carry out the functionality of a Parachain Host, we have to answer two categories of questions:
-1. What is the state-transition function of the blockchain? What is necessary for a transition to be considered valid, and what information is carried within the implicit state of a block?
-2. Being aware of various forks of the blockchain as well as global private state such as a view of the current time, what behaviors should a node undertake? What information should a node extract from the state of which forks, and how should that information be used?
-
-The first category of questions will be addressed by the Runtime, which defines the state-transition logic of the chain. Runtime logic only has to focus on the perspective of one chain, as each state has only a single parent state.
-
-The second category of questions addressed by Node-side behavior. Node-side behavior defines all activities that a node undertakes, given its view of the blockchain/block-DAG. Node-side behavior can take into account all or many of the forks of the blockchain, and only conditionally undertake certain activities based on which forks it is aware of, as well as the state of the head of those forks.
-
-```
-
- __________________________________
- / \
- | Runtime |
- | |
- \_________(Runtime API )___________/
- | ^
- V |
- +----------------------------------------------+
- | |
- | Node |
- | |
- | |
- +----------------------------------------------+
- + +
- | |
- --------------------+ +------------------------
- Transport
- ------------------------------------------------
-
-```
-
-
-It is also helpful to divide Node-side behavior into two further categories: Networking and Core. Networking behaviors relate to how information is distributed between nodes. Core behaviors relate to internal work that a specific node does. These two categories of behavior often interact, but can be heavily abstracted from each other. Core behaviors care that information is distributed and received, but not the internal details of how distribution and receipt function. Networking behaviors act on requests for distribution or fetching of information, but are not concerned with how the information is used afterwards. This allows us to create clean boundaries between Core and Networking activities, improving the modularity of the code.
-
-```
- ___________________ ____________________
- / Core \ / Networking \
- | | Send "Hello" | |
- | |- to "foo" --->| |
- | | | |
- | | | |
- | | | |
- | | Got "World" | |
- | |<-- from "bar" --| |
- | | | |
- \___________________/ \____________________/
- ______| |______
- ___Transport___
-
-```
-
-
-Node-side behavior is split up into various subsystems. Subsystems are long-lived workers that perform a particular category of work. Subsystems can communicate with each other, and do so via an Overseer that prevents race conditions.
-
-Runtime logic is divided up into Modules and APIs. Modules encapsulate particular behavior of the system. Modules consist of storage, routines, and entry-points. Routines are invoked by entry points, by other modules, upon block initialization or closing. Routines can read and alter the storage of the module. Entry-points are the means by which new information is introduced to a module and can limit the origins (user, root, parachain) that they accept being called by. Each block in the blockchain contains a set of Extrinsics. Each extrinsic targets a a specific entry point to trigger and which data should be passed to it. Runtime APIs provide a means for Node-side behavior to extract meaningful information from the state of a single fork.
-
-These two aspects of the implementation are heavily dependent on each other. The Runtime depends on Node-side behavior to author blocks, and to include Extrinsics which trigger the correct entry points. The Node-side behavior relies on Runtime APIs to extract information necessary to determine which actions to take.
-
----
-
-### Architecture: Node-side
-
-**Design Goals**
-
-* Modularity: Components of the system should be as self-contained as possible. Communication boundaries between components should be well-defined and mockable. This is key to creating testable, easily reviewable code.
-* Minimizing side effects: Components of the system should aim to minimize side effects and to communicate with other components via message-passing.
-* Operational Safety: The software will be managing signing keys where conflicting messages can lead to large amounts of value to be slashed. Care should be taken to ensure that no messages are signed incorrectly or in conflict with each other.
-
-The architecture of the node-side behavior aims to embody the Rust principles of ownership and message-passing to create clean, isolatable code. Each resource should have a single owner, with minimal sharing where unavoidable.
-
-Many operations that need to be carried out involve the network, which is asynchronous. This asynchrony affects all core subsystems that rely on the network as well. The approach of hierarchical state machines is well-suited to this kind of environment.
-
-We introduce a hierarchy of state machines consisting of an overseer supervising subsystems, where Subsystems can contain their own internal hierarchy of jobs. This is elaborated on in the [Subsystems](#Subsystems) section.
-
----
-
-### Architecture: Runtime
-
-(TODO: The best architecture at this time is unclear. This is a start by setting down the requirements of the runtime and then trying to come up with an architecture that encompasses all of them. Pretty messy right now and will be cleaned up as the architecture emerges).
-
-There are three key points during the execution of a block that we are generally interested in:
- * initialization: beginning the block and doing set up works. Runtime APIs draw information from the state directly after initialization.
- * during the block; most importantly inclusion of new parachain information
- * finalization: final checks and clean-up work before completing the block.
-
-In order to import parachains, handle misbehavior reports, and keep data accessible, we need to keep this data in the storage/state:
- * All currently registered parachains.
- * All currently registered parathreads.
- * The head of each registered parachain or parathread.
- * The validation code of each registered parachain or parathread.
- * Historical validation code for each registered parachain or parathread.
- * Historical, but not yet expired validation code for paras that were previously registered but are now not. (old code must remain available so secondary checkers can check after-the-fact yadda yadda in this case we do that by keeping it in the runtime state.)
- * Configuration: number of parathread cores, number of parachain slots. Length of scheduled parathread "lookahead". Length of parachain slashing period. How long to keep old validation code for. etc.
- * Historical data for validators sets at least [TODO: how many?] blocks into the past. Used when reporting equivocations to prove that the validator at question actually belonged to the validator set at the time the equivocation was commited.
-
-This information should not change at any point between block initialization and inclusion of new parachain information. The reason for that is that the inclusion of new parachain information will be checked against these values in the storage, but the new parachain information is produced by Node-side subsystems which draw information from Runtime APIs. Runtime APIs execute on top of the state directly after the initialization, so a divergence from that state would lead to validators producing unacceptable inputs.
-
-In the Substrate implementation, we may also have to worry about state changing due to other modules invoking `Call`s that change storage during initialization, but after the point at which parachain-specific modules run their initialization procedures. This could cause problems: parachain-specific modules could compute scheduling, parachain assignments, etc. during its initialization procedure, which would then become inconsistent afterwards. Other modules that might realistically cause such race conditions are Governance modules (which execute arbitrary `Call`s, or the `Scheduler` module). This implies that the runtime design should ensure that no racy entry points can affect storage that is used during parachain-specific module initialization. One way to accomplish this is to separate active storage items from pending storage updates. Other modules can add pending updates, but only the initialization or finalization logic can apply those to the active state. (of course, governance can reach in and break anything by mangling storage, but this is more about exposing a preventative API than a bulletproof one). One alternative is to ensure that all configuration is presented only as constants, which requires a full runtime upgrade to alter and as such does not suffer from these race conditions.
-
-Here is an attempted-exhaustive list of tasks the runtime is expected to carry out in each phase.
-
-initialization:
- * accept new registrations of parachains and parathreads. Probably best to do this only once a session to avoid bitfield schemas shifting often (see details on availability bitfields below)
- * determine scheduled parachains and parathreads for the upcoming block or blocks.
- * determine validator assignments to scheduled paras for the upcoming block or blocks.
- * remove blocks which have been pending availability for too long. this is tightly coupled with scheduling.
- * handle the start of a new session - discard all candidates pending availability and note the upcoming validator set.
- * apply calls from upward messages - messages from parachains to the relay chain.
-
-during the block:
- * Receive availability bitfields and move candidates from a pending availability to included state. See subsection below
- * Receive new backed candidates to target for availability. See subsection below.
- * Receive updates to configuration.
-
-process availability bitfields:
- * We will accept an optional signed bitfield from each validator in each block.
- * We need to check the signature and length of the bitfield for validity.
- * We will keep the most recent bitfield for each validator in the session. Each bit corresponds to a particular parachain candidate pending availability. Parachains are scheduled on every block, so we can assign a bit to each one of those. Parathreads are not scheduled on every block, and there may be a lot of them, so we probably don't want a dedicated bit in the bitfield for those. Since we want an upper bound on the number of parathreads we have scheduled or pending availability, a concept of "execution cores" used in scheduling (TODO) should be reusable here - have a dedicated bit in the bitfield for each core, and each core will be assigned to a different parathread over time.
- * Bits that are set to `true` denote candidate pending availability which are believed by this validator to be available.
- * Candidates that are pending availability and have the corresponding bit set in 2/3 of validators' bitfields (only counting those submitted after the candidate was included, since some validators may not have submitted bitfields in some time) are considered available and are then moved into the "pending approval" state.
- * Candidates that have just become available should apply any pending code upgrades based on the relay-parent they are targeting and should schedule any upcoming pending code upgrades.
-
-candidates entering the "pending approval" state:
- * Apply fees (TODO: not sure if fees are actually used, we don't seem to need 'em for XCMP)
- * Apply pending code upgrade, if any.
- * Schedule a new pending code upgrade if the candidate specifies any. (there is a race condition here: part of the configuration is "how long should it take before pending code changes are applied". This value is computed based on the relay-parent that was used at the point when the candidate was about to be included in the relay chain. This is potentially a few blocks later than that, as it can take some time for a candidate to become fully available. We need to ensure that the code upgrade is scheduled with the same delay as was expected when the code upgrade was signaled. The easiest thing to do is to make sure the `pending_code_delay` is passed through the entire availability pipeline).
- * Schedule Upwards messages - messages from the parachain to the relay chain.
-
-process new backed candidates:
- * ensure that only one candidate is backed for each parachain or parathread
- * ensure that the parachain or parathread of the candidate was scheduled and does not currently have a block pending availability.
- * check the backing of the candidate.
- * move to "pending approval" state. (pass along any configuration information that is liable to change)
-
-misbehavior reports and secondary checks:
- * Secondary checks will also be submitted within the block. This may lead to slashing as a secondary check period ends. We want to catch and punish for the cases of misbehavior that violate the protocol and put its security at risk. One of such cases is submitting conflicting votes on the same `CandidateReceipt`.Other examples include violations to AnV protocol or equivocations in finality. Misbehavior handling is implemented in
- * Runtime as an entry point.
- * Code in the Node that assists submitting misbehavior reports.
-
-finalization: (not finality)
- * ensure that required updates (bitfields and backed candidates) occurred within the block.
- * update scheduling metadata based on parachains that had blocks included or not. for instance, parathreads where the auction-winning collator didn't get a chance to include its block should be allowed to retry a couple of times.
-
-Availability bitfields must go in before parachain candidates, otherwise there would be a minimum of 1 relay chain block between blocks of the same parachain. As such, it's best for them to go into the same extrinsic.
-
-Parachains and Parathreads behave exactly the same except with respect to how they are scheduled. Parathreads are scheduled dynamically in a pay-as-you-go sense, with auctions. The winner of the auction (a collator) gets multiple opportunities to include its block. Parachains are scheduled on every block.
-
------
-
-## Runtime Architecture: A Proposal
-
-[TODO: Figure out what to do with the previous section - there's a lot of useful information. A lot of info might be beyond the scope of the document, but is still useful. Figure out which research resources we can link to and which points are new to this doc. some race condition concerns were never written down before]
-
-It's clear that we want to separate different aspects of the runtime logic into different modules.
-
-Reiterating from the [Architecture](#Architecture) section, Modules define their own storage, routines, and entry-points. They also define initialization and finalization logic.
-
-Due to the (lack of) guarantees provided by a particular blockchain-runtime framework, there is no defined or dependable order in which modules' initialization or finalization logic will run. Supporting this blockchain-runtime framework is important enough to include that same uncertainty in our model of runtime modules in this guide. Furthermore, initialization logic of modules can trigger the entry-points or routines of other modules. This is one architectural pressure against dividing the runtime logic into multiple modules. However, in this case the benefits of splitting things up outweigh the costs, provided that we take certain precautions against initialization and entry-point races.
-
-We also expect, although it's beyond the scope of this guide, that these runtime modules will exist alongside various other modules. This has two facets to consider. First, even if the modules that we describe here don't invoke each others' entry points or routines during initialization, we still have to protect against those other modules doing that. Second, some of those modules are expected to provide governance capabilities for the chain. Configuration exposed by parachain-host modules is mostly for the benefit of these governance modules, to allow the operators or community of the chain to tweak parameters.
-
-The runtime's primary roles to manage scheduling and updating of parachains and parathreads, as well as handling misbehavior reports and slashing. This guide doesn't focus on how parachains or parathreads are registered, only that they are. Also, this runtime description assumes that validator sets are selected somehow, but doesn't assume any other details than a periodic _session change_ event. Session changes give information about the incoming validator set and the validator set of the following session.
-
-The runtime also serves another role, which is to make data available to the Node-side logic via Runtime APIs. These Runtime APIs should be sufficient for the Node-side code to author blocks correctly.
-
-There is some functionality of the relay chain relating to parachains that we also consider beyond the scope of this document. In particular, all modules related to how parachains are registered aren't part of this guide, although we do provide routines that should be called by the registration process.
-
-We will split the logic of the runtime up into these modules:
- * Initializer: manage initialization order of the other modules.
- * Configuration: manage configuration and configuration updates in a non-racy manner.
- * Paras: manage chain-head and validation code for parachains and parathreads.
- * Scheduler: manages parachain and parathread scheduling as well as validator assignments.
- * Inclusion: handles the inclusion and availability of scheduled parachains and parathreads.
- * Validity: handles secondary checks and dispute resolution for included, available parablocks.
-
-The Initializer module is special - it's responsible for handling the initialization logic of the other modules to ensure that the correct initialization order and related invariants are maintained. The other modules won't specify a on-initialize logic, but will instead expose a special semi-private routine that the initialization module will call. The other modules are relatively straightforward and perform the roles described above.
-
-The Parachain Host operates under a changing set of validators. Time is split up into periodic sessions, where each session brings a potentially new set of validators. Sessions are buffered by one, meaning that the validators of the upcoming session are fixed and always known. Parachain Host runtime modules need to react to changes in the validator set, as it will affect the runtime logic for processing candidate backing, availability bitfields, and misbehavior reports. The Parachain Host modules can't determine ahead-of-time exactly when session change notifications are going to happen within the block (note: this depends on module initialization order again - better to put session before parachains modules). Ideally, session changes are always handled before initialization. It is clearly a problem if we compute validator assignments to parachains during initialization and then the set of validators changes. In the best case, we can recognize that re-initialization needs to be done. In the worst case, bugs would occur.
-
-There are 3 main ways that we can handle this issue:
- 1. Establish an invariant that session change notifications always happen after initialization. This means that when we receive a session change notification before initialization, we call the initialization routines before handling the session change.
- 2. Require that session change notifications always occur before initialization. Brick the chain if session change notifications ever happen after initialization.
- 3. Handle both the before and after cases.
-
-
-Although option 3 is the most comprehensive, it runs counter to our goal of simplicity. Option 1 means requiring the runtime to do redundant work at all sessions and will also mean, like option 3, that designing things in such a way that initialization can be rolled back and reapplied under the new environment. That leaves option 2, although it is a "nuclear" option in a way and requires us to constrain the parachain host to only run in full runtimes with a certain order of operations.
-
-So the other role of the initializer module is to forward session change notifications to modules in the initialization order, throwing an unrecoverable error if the notification is received after initialization.
-
-[REVIEW: other options? arguments in favor of going for options 1 or 3 instead of 2. we could do a "soft" version of 2 where we note that the chain is potentially broken due to bad initialization order]
-
-[TODO Diagram: order of runtime operations (initialization, session change)]
-
-### The Initializer Module
-
-#### Description
-
-This module is responsible for initializing the other modules in a deterministic order. It also has one other purpose as described above: accepting and forwarding session change notifications.
-
-#### Storage
-
-```rust
-HasInitialized: bool
-```
-
-#### Initialization
-
-The other modules are initialized in this order:
-1. Configuration
-1. Paras
-1. Scheduler
-1. Inclusion
-1. Validity.
-
-The configuration module is first, since all other modules need to operate under the same configuration as each other. It would lead to inconsistency if, for example, the scheduler ran first and then the configuration was updated before the Inclusion module.
-
-Set `HasInitialized` to true.
-
-#### Session Change
-
-If `HasInitialized` is true, throw an unrecoverable error (panic).
-Otherwise, forward the session change notification to other modules in initialization order.
-
-#### Finalization
-
-Finalization order is less important in this case than initialization order, so we finalize the modules in the reverse order from initialization.
-
-Set `HasInitialized` to false.
-
-### The Configuration Module
-
-#### Description
-
-This module is responsible for managing all configuration of the parachain host in-flight. It provides a central point for configuration updates to prevent races between configuration changes and parachain-processing logic. Configuration can only change during the session change routine, and as this module handles the session change notification first it provides an invariant that the configuration does not change throughout the entire session. Both the scheduler and inclusion modules rely on this invariant to ensure proper behavior of the scheduler.
-
-The configuration that we will be tracking is the [`HostConfiguration`](#Host-Configuration) struct.
-
-#### Storage
-
-The configuration module is responsible for two main pieces of storage.
-
-```rust
-/// The current configuration to be used.
-Configuration: HostConfiguration;
-/// A pending configuration to be applied on session change.
-PendingConfiguration: Option;
-```
-
-#### Session change
-
-The session change routine for the Configuration module is simple. If the `PendingConfiguration` is `Some`, take its value and set `Configuration` to be equal to it. Reset `PendingConfiguration` to `None`.
-
-#### Routines
-
-```rust
-/// Get the host configuration.
-pub fn configuration() -> HostConfiguration {
- Configuration::get()
-}
-
-/// Updating the pending configuration to be applied later.
-fn update_configuration(f: impl FnOnce(&mut HostConfiguration)) {
- PendingConfiguration::mutate(|pending| {
- let mut x = pending.unwrap_or_else(Self::configuration);
- f(&mut x);
- *pending = Some(x);
- })
-}
-```
-
-#### Entry-points
-
-The Configuration module exposes an entry point for each configuration member. These entry-points accept calls only from governance origins. These entry-points will use the `update_configuration` routine to update the specific configuration field.
-
-### The Paras Module
-
-#### Description
-
-The Paras module is responsible for storing information on parachains and parathreads. Registered parachains and parathreads cannot change except at session boundaries. This is primarily to ensure that the number of bits required for the availability bitfields does not change except at session boundaries.
-
-It's also responsible for managing parachain validation code upgrades as well as maintaining availability of old parachain code and its pruning.
-
-#### Storage
-
-Utility structs:
-```rust
-/// Metadata used to track previous parachain validation code that we keep in
-/// the state.
-pub struct ParaPastCodeMeta {
- // Block numbers where the code was replaced. These can be used as indices
- // into the `PastCode` map along with the `ParaId` to fetch the code itself.
- upgrade_times: Vec,
- // This tracks the highest pruned code-replacement, if any.
- last_pruned: Option,
-}
-
-enum UseCodeAt {
- // Use the current code.
- Current,
- // Use the code that was replaced at the given block number.
- ReplacedAt(BlockNumber),
-}
-
-struct ParaGenesisArgs {
- /// The initial head-data to use.
- genesis_head: HeadData,
- /// The validation code to start with.
- validation_code: ValidationCode,
- /// True if parachain, false if parathread.
- parachain: bool,
-}
-```
-
-Storage layout:
-```rust
-/// All parachains. Ordered ascending by ParaId. Parathreads are not included.
-Parachains: Vec,
-/// The head-data of every registered para.
-Heads: map ParaId => Option;
-/// The validation code of every live para.
-ValidationCode: map ParaId => Option;
-/// Actual past code, indicated by the para id as well as the block number at which it became outdated.
-PastCode: map (ParaId, BlockNumber) => Option;
-/// Past code of parachains. The parachains themselves may not be registered anymore,
-/// but we also keep their code on-chain for the same amount of time as outdated code
-/// to keep it available for secondary checkers.
-PastCodeMeta: map ParaId => ParaPastCodeMeta;
-/// Which paras have past code that needs pruning and the relay-chain block in which context the code was replaced.
-/// Multiple entries for a single para are permitted. Ordered ascending by block number.
-PastCodePruning: Vec<(ParaId, BlockNumber)>;
-/// The block number at which the planned code change is expected for a para.
-/// The change will be applied after the first parablock for this ID included which executes
-/// in the context of a relay chain block with a number >= `expected_at`.
-FutureCodeUpgrades: map ParaId => Option;
-/// The actual future code of a para.
-FutureCode: map ParaId => ValidationCode;
-
-/// Upcoming paras (chains and threads). These are only updated on session change. Corresponds to an
-/// entry in the upcoming-genesis map.
-UpcomingParas: Vec;
-/// Upcoming paras instantiation arguments.
-UpcomingParasGenesis: map ParaId => Option;
-/// Paras that are to be cleaned up at the end of the session.
-OutgoingParas: Vec;
-```
-#### 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. 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.
-
-#### Initialization
-
-1. Do pruning based on all entries in `PastCodePruning` with `BlockNumber <= now`. Update the corresponding `PastCodeMeta` and `PastCode` accordingly.
-
-#### Routines
-
-* `schedule_para_initialize(ParaId, ParaGenesisArgs)`: schedule a para to be initialized at the next session.
-* `schedule_para_cleanup(ParaId)`: schedule a para to be cleaned up at the next session.
-* `schedule_code_upgrade(ParaId, ValidationCode, expected_at: BlockNumber)`: Schedule a future code upgrade of the given parachain, to be applied after inclusion of a block of the same parachain executed in the context of a relay-chain block with number >= `expected_at`.
-* `note_new_head(ParaId, HeadData, BlockNumber)`: note that a para has progressed to a new head, where the new head was executed in the context of a relay-chain block with given number. This will apply pending code upgrades based on the block number provided.
-* `validation_code_at(ParaId, at: BlockNumber, assume_intermediate: Option)`: Fetches the validation code to be used when validating a block in the context of the given relay-chain height. A second block number parameter may be used to tell the lookup to proceed as if an intermediate parablock has been included at the given relay-chain height. This may return past, current, or (with certain choices of `assume_intermediate`) future code. `assume_intermediate`, if provided, must be before `at`. If `at` is too old or the `ParaId` does not reference any live para, this may return `None`.
-
-#### Finalization
-
-No finalization routine runs for this module.
-
-### The Scheduler Module
-
-#### Description
-
-[TODO: this section is still heavily under construction. key questions about execution cores and validator assignment are still open and the flow of the the section may be contradictory or inconsistent]
-
-The Scheduler module is responsible for two main tasks:
- - Partitioning validators into groups and assigning groups to parachains and parathreads.
- - Scheduling parachains and parathreads
-
-It aims to achieve these tasks with these goals in mind:
- - It should be possible to know at least a block ahead-of-time, ideally more, which validators are going to be assigned to which parachains.
- - Parachains that have a candidate pending availability in this fork of the chain should not be assigned.
- - Validator assignments should not be gameable. Malicious cartels should not be able to manipulate the scheduler to assign themselves as desired.
- - High or close to optimal throughput of parachains and parathreads. Work among validator groups should be balanced.
-
-The Scheduler manages resource allocation using the concept of "Execution Cores". There will be one execution core for each parachain, and a fixed number of cores used for multiplexing parathreads. Validators will be partitioned into groups, with the same number of groups as execution cores. Validator groups will be assigned to different execution cores over time.
-
-An execution core can exist in either one of two states at the beginning or end of a block: free or occupied. A free execution core can have a parachain or parathread assigned to it for the potential to have a backed candidate included. After inclusion, the core enters the occupied state as the backed candidate is pending availability. There is an important distinction: a core is not considered occupied until it is in charge of a block pending availability, although the implementation may treat scheduled cores the same as occupied ones for brevity. A core exits the occupied state when the candidate is no longer pending availability - either on timeout or on availability. A core starting in the occupied state can move to the free state and back to occupied all within a single block, as availability bitfields are processed before backed candidates. At the end of the block, there is a possible timeout on availability which can move the core back to the free state if occupied.
-
-```
-Execution Core State Machine
-
- Assignment &
- Backing
-+-----------+ +-----------+
-| +--------------> |
-| Free | | Occupied |
-| <--------------+ |
-+-----------+ Availability +-----------+
- or Timeout
-
-```
-
-```
-Execution Core Transitions within Block
-
- +-----------+ | +-----------+
- | | | | |
- | Free | | | Occupied |
- | | | | |
- +--/-----\--+ | +--/-----\--+
- /- -\ | /- -\
- No Backing /- \ Backing | Availability /- \ No availability
- /- \ | / \
- /- -\ | /- -\
- +-----v-----+ +----v------+ | +-----v-----+ +-----v-----+
- | | | | | | | | |
- | Free | | Occupied | | | Free | | Occupied |
- | | | | | | | | |
- +-----------+ +-----------+ | +-----|---\-+ +-----|-----+
- | | \ |
- | No backing | \ Backing | (no change)
- | | -\ |
- | +-----v-----+ \ +-----v-----+
- | | | \ | |
- | | Free -----+---> Occupied |
- | | | | |
- | +-----------+ +-----------+
- | Availability Timeout
-```
-
-Validator group assignments do not need to change very quickly. The security benefits of fast rotation is redundant with the challenge mechanism in the Validity module. Because of this, we only divide validators into groups at the beginning of the session and do not shuffle membership during the session. However, we do take steps to ensure that no particular validator group has dominance over a single parachain or parathread-multiplexer for an entire session to provide better guarantees of liveness.
-
-Validator groups rotate across execution cores in a round-robin fashion, with rotation occurring at fixed intervals. The i'th group will be assigned to the `(i+k)%n`'th core at any point in time, where `k` is the number of rotations that have occurred in the session, and `n` is the number of cores. This makes upcoming rotations within the same session predictable.
-
-When a rotation occurs, validator groups are still responsible for distributing availability pieces for any previous cores that are still occupied and pending availability. In practice, rotation and availability-timeout frequencies should be set so this will only be the core they have just been rotated from. It is possible that a validator group is rotated onto a core which is currently occupied. In this case, the validator group will have nothing to do until the previously-assigned group finishes their availability work and frees the core or the availability process times out. Depending on if the core is for a parachain or parathread, a different timeout `t` from the `HostConfiguration` will apply. Availability timeouts should only be triggered in the first `t-1` blocks after the beginning of a rotation.
-
-Parathreads operate on a system of claims. Collators participate in auctions to stake a claim on authoring the next block of a parathread, although the auction mechanism is beyond the scope of the scheduler. The scheduler guarantees that they'll be given at least a certain number of attempts to author a candidate that is backed and included. Attempts that fail during the availability phase are not counted, since ensuring availability at that stage is the responsibility of the backing validators, not of the collator. When a claim is accepted, it is placed into a queue of claims, and each claim is assigned to a particular parathread-multiplexing core in advance. Given that the current assignments of validator groups to cores are known, and the upcoming assignments are predictable, it is possible for parathread collators to know who they should be talking to now and how they should begin establishing connections with as a fallback.
-
-With this information, the Node-side can be aware of which parathreads have a good chance of being includable within the relay-chain block and can focus any additional resources on backing candidates from those parathreads. Furthermore, Node-side code is aware of which validator group will be responsible for that thread. If the necessary conditions are reached for core reassignment, those backed candidates can be included within the same block as the core being freed.
-
-Parathread claims, when scheduled onto a free core, may not result in a block pending availability. This may be due to collator error, networking timeout, or censorship by the validator group. In this case, the claims should be retried a certain number of times to give the collator a fair shot.
-
-Cores are treated as an ordered list of cores and are typically referred to by their index in that list.
-
-[
-
- TODO: Validator assignment. We want to assign validators to chains, not to cores. Assigning to cores means that for parathread cores, the parathread is unclear until late in the process so that would have bad implications for networking.
-
- We can prepare a set of chains by assigning all unassigned cores, optimistically assigning all previously assigned cores, and then taking the union of those sets. However, this means that validator assignment is not possible to know until the beginning of the block. Ideally, we'd always know about at least a couple of blocks in advance, which makes networking discovery easier. However, optimistic assignment seems incompatible with this goal.
-
-]
-
-#### Storage
-
-Utility structs:
-```rust
-struct ParathreadClaim(ParaId, CollatorId);
-struct ParathreadEntry {
- claim: ParathreadClaim,
- core: CoreIndex,
-}
-
-enum CoreOccupied {
- Parathread(ParathreadClaim, u32), // claim & retries
- Parachain,
-}
-
-struct CoreAssignment {
- core: CoreIndex,
- para_id: ParaId,
- collator: Option,
- group_idx: GroupIndex,
-}
-```
-
-Storage layout:
-```rust
-/// All the validator groups. One for each core.
-ValidatorGroups: Vec>;
-/// A queue of upcoming claims and which core they should be mapped onto.
-ParathreadQueue: Vec;
-/// One entry for each execution core. Entries are `None` if the core is not currently occupied. Can be
-/// temporarily `Some` if scheduled but not occupied.
-/// The i'th parachain belongs to the i'th core, with the remaining cores all being
-/// parathread-multiplexers.
-ExecutionCores: Vec