Browse Source

Finalized rest of spec

Bedeho Mender 5 years ago
parent
commit
c7408b918d

+ 203 - 136
testnets/acropolis/specification/README.md

@@ -1,211 +1,278 @@
-# WIP: Rome Testnet Specification
+# Acropolis Testnet Specification
 
-## Table Of Content
+## Table Of Contents
 
-- [Purpose](#purpose)
-- [Decisions](#decisions)
-- [Work In Progress](#work-in-progress)
+- [Document](#document)
+- [Caveat](#caveat)
 - [Glossary](#glossary)
-- [Notation](#notation)
-- [Rome](#rome)
- - [Overview](#overview)
- - [Roles](#roles)
- - [Substrate Runtime](#substrate-runtime)
+- [Format](#format)
+- [Overview](#overview)
+- [Substrate Runtime](#substrate-runtime)
+  - [Runtime Version](#runtime-version)
+  - [Native Version](#native-version)
+  - [Substrate Version](#substrate-version)
+  - [Modules](#modules)
+    - [Forum](#forum)
+    - [Proposals](#proposals)
+    - [CouncilElection](#councilelection)
+    - [Council](#council)
+    - [Memo](#memo)
+    - [Members](#members)
+    - [Migration](#migration)
+    - [Actors](#actors)
+    - [DataObjectTypeRegistry](#dataobjecttyperegistry)
+    - [DataDirectory](#datadirectory)
+    - [DataObjectStorageRegistry](#dataobjectstorageregistry)
+    - [DownloadSessions](#downloadsessions)
+  - [SRML Modules](#srml-modules)
+  - [Runtime API](#runtime-api)
+<!-- - [Communication Protocols](#communication-protocols) -->
+
+## Document
+
+The purpose of this document is to serve as a starting point for the implementation phase of the given testnet. It is only a starting point in the sense that the implementation effort will always depart from the up front specification to some, possibly substantial, extent, but no effort is made to synchronise the specification at any time. Instead, the any such synchronisation would be done in the specification of a future network. The value of such a specification is primarily to establish a relatively precise shared understanding among all contributors to a testnet release.
+
+## Caveat
+
+Parts of the specification are not well harmonised with the rest, in particular the storage system, due to time constraints. Read graciously, this will be resolved later. Also, a substantial number of modules are not yet specced, as already implemented modules from prior testnets are being reused. Full specs will eventually be available as future networks are released where changes are made to these modules. Lastly, a number off communication protocols are not captured in this spec due to time constraints, they will be introduced for later networks.
 
-## Document Purpose
-
-The life time and purpose of this docuemnt is separated into two distinct phases,
-
-- Enable greater
-- xxx
-- audience
-- use case
-- scope
-- frist ry, tierative arrive at standard, extract generalised template for joystrema and other Susbtrate teams.
-
-## How to read this specification
-
-Given the descrbied purpose of this document, the style of specification admits to the following constraints
-
-- S
-
-Take Substrate for granted, and SRML momdules, dont explicitly described.
-
-
-<explain how you wille xplain different parts, what each part of the explanation does>
-
-### Substrate
-
-We are speicfying what:
+## Glossary
 
--  explain how to intereprt speciciation, so we understand `map`, build et.
-- xxxx
+- **Substrate:** A blockchain SDK, used for this testnet, that abstracts away concerns about consensus and p2p communication.
 
-what bout built in stuff, like types `origin`, and functions, like `ensure_signed`.
+- **Runtime:** Application specific consensus code written for the Substrate SDK. Includes state and transaction rules specific to the application, but excludes consensus algorithm and p2p networking.
 
-what about block level callback?
+- **Substrate Module:** A substrate runtime is partitioned into functionality integrated units, called modules, which have their own local state, transaction types and events.
 
-variables
- - **origin** : instance variable for signed
- - **who**: instance variable when is signed
+- **SRML:** Substrate standard runtime library (SRML), is a set of highly reusable Substrate modules.
 
+- **AURA:** Component of consensus responsible for block authoring.
 
-#### Extrinsics
+- **GRANDPA:** Component of consensus responsible for block finality.
 
+<!--
+## Format
 
+[Read here to understand the format of this specification.](specification-format.md)
 
-##### Errors
+-->
 
-All errors have their own precondition. The errors are listed in the order which corresponds to what order they would be invoked if _multiple_ error conditions were satisified simultanously. If this cannot be expressed as a single linear list, the section must reflect this informaiton in some other way in a fully unambigous manner.
+## Overview
 
-Error scenarios, which thus have no side effects, and no events. The section title is used as error message. The full precondition for each case is not only the listed condition in the same row, but also the combined failure of all listed preconditions of prior rows.
+The Acropolis testnet features the following roles
 
-##### Side effects
+- **Validator**: Block producer and validator.
+- **Council Member:** Council participant, currently only involved in voting on runtime upgrades.
+- **Storage Provider**: Does storage and distribution of content, peer provider synchronisation, as well as upload liaison.
+- **Forum Moderator**: A single actor role for managing the new on-chain forum.
 
-Assume that all error preconditions are simultnaously false, denoted by predicate `NO_ERROR`.
+This release also sees the introduction of a new storage infrastructure based on IPFS for distribution and synchronisation, and IPNS for host resolution. A generalised host resolution module is also introduced as part of making the latter functionality possible, and it will be reused for host resolution across the platform.
 
-##### Terminiantion
-Important to notice that its very deeply specified, where even the order of error triggering in scenarios with mulitple simultanous errors, is commited to up front, compared to a loser standard of saying that, if you have one of these problems, you will get at least one fo these errors,w hich would drop order.
+A full featured hierarchical topic based, and single moderator, membership forum is also introduced.
 
-- **pre-condition:** first order predicate in the runtime state and the transaction paramters which must hold _exactly_ for transaction to be accepted. e.g. that proper person has isgned?
-- **post-condition**: first order predicate in the runtime state and the transaction parameters which must hold _exactly_ when the transaction is accepted. The value of state variable `X` _after_ a transaction is handled, is denoted by `X'`. Hence, as an example, the condition that an integer variable `foo` has been incremented after a transaction is captured by the following predicate: `foo' == foo + 1`. Notice that blockchain state, like event logs ands o on, are not part of this, hence they are not in post-condition. (perhaps change?). It is OK to use separately defined functions to define this predicate, but these cannot have side effects.
+## Substrate Runtime
 
-Notice that no _iomplementaiton_ is ever provided, only how transaction generate new state constraints. This allows us to avoid any implementation specific types, and also allows all modules to be defiend in terms of what actual types are instantioned in the parametric `T::` trait, rather than introduce lots of trait abstractions.
+### Runtime Version
 
+- **spec_name:** `joystream-node`
+- **impl_name:** `joystream-node`
+- **authoring_version:** `5`
+- **spec_version:** `4`
+- **impl_version:** `0`
+- **apis:** `RUNTIME_API_VERSIONS`
 
-cponditionals are basically valid Rust code.
+### Native Version
 
-side ffects are pure, no
+- **runtime_version:** [Runtime Version](#runtime-version)
+<!-- - **can_author_with:** Default::default() -->
 
-functions used can only be pure, i.e. only depend on explicit parameters, and also have 0 side effcts.
+### Substrate Version
 
+`1.0.0`
 
-Always read stroage variables of any module through type, not varible name.
+### Modules
 
-##### REsult
+These are the Joystream specific modules, for each module, there is either a link to a module specification document, or no link, for already implemented modules (see [caveat](#caveat)). Standard configurations, for example based on values from the System module, are omitted.
 
-Here, all values are either before or after execution, using same tag symbol.
+An integrated explanation of the modules constituting the storage system is found [here](storage-system.md).
 
-##### Events
+#### Forum
 
-Same as result
+- **Description**: An on-chain discussion forum for members.
+- **Specification**: [**READ HERE**](runtime/forum-module.md)
+- **Status:** New.
+- **Configuration:**
+  - _ForumUserRegistry_: Proxy call to `get_profile` on [Membership](#membership) module.
 
-### Protocols
+#### Proposals
 
-<here we write stuff about how to read and understand our protocols>
+- **Description**: Proposal system, currently only supports runtime upgrades.
+- **Specification**: [**NA**](#)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _Members_ : [Membership](#membership) module.
 
+#### CouncilElection
 
-## Glossary
+- **Description**: Council election manager for council system.
+- **Specification**: [**NA**](#)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _CouncilElected_: [Council](#council) module
+  - _Members_: [Membership](#membership) module.
 
-- **Substrate:** A blockchain SDK
-- **Runtime:** Application specific consensus code written for the Substrate SDK. Includes state and transaction rules specific to the application, but excludes consensus algorithm and p2p networking.
-- **Substrate Module:** A substrate rutnime is partitoned into state and corresponding transaction types .. <= bad explanation.
-- **SRML:** Substrate standard runtime library (srml), is a set of highly reusable Substrate modules which come with the
-- **GRANDPA:** Consensus algorthm used.
+#### Council
 
-## Notation
+- **Description**: Council system.
+- **Specification**: [**NA**](#)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _CouncilTermEnded_: [CouncilElection](#councilelection) module.
 
-- Code is written in Rust.
-- When describing state variables, the standard storage encoding,decoding offered by Substrate `decl_storage` is used, in particular
- - xx
- - xx
- - xx
-- In some cases transaction logic may be written in psuedocode, or just free form, over fully valid Rust.
+#### Memo
 
-## Specification
+- **Description**: Account based public message field.
+- **Specification**: [**NA**](#)
+- **Status:** Unchanged from Athens.
+- **Configuration:** Standard only.
 
-### Overview
+#### Membership
 
-something high level?
+- **Description**: Membership registry.
+- **Specification**: [**NA**](#)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _Roles_: [Actors](#actors) module
+  - _MemberId_: `u64`
+  - _PaidTermId_: `u64`
+  - _SubscriptionId_: `u64`
 
-### Substrate Runtime
+#### Discovery
 
-#### WIP: API
+- **Description**: Host resolution system for public keys.
+- **Specification**: [**READ-HERE**](runtime/discovery-module.md)
+- **Status:** New.
+- **Configuration:**
+  - _Roles_: Shim trait which enables account lookup and by proxying to [Actors](#actors) module. Keeping this brief, since it will change.
 
-put lots of stuff here about what is in impl_runtime_apis! {}?
+#### Migration
 
-#### Substrate Version
+- **Description**: Runs migration & initialisation routines after on-chain upgrade from past testnet (Athens).
+- **Specification**: [**READ HERE**](runtime/migration-module.md)
+- **Status:** Updated to include initialisation of new forum after upgrade.
+- **Configuration:** Standard only.
 
-`1.0.0`
-
-#### [Types](#types)
+#### Actors
 
-#### functions
+- **Description**: Staking manager for storage system.
+- **Specification**: [**READ HERE**](runtime/staking-module.md)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _Members_: [Membership](#membership) module.
+  - _OnActorRemoved_: Proxy call to `remove_account_info` on [Discovery](#discovery).
 
-like snure signed_
+#### DataObjectTypeRegistry
 
-https://crates.parity.io/srml_system/fn.ensure_signed.html
+- **Description**:
+- **Specification**: [**READ HERE**](runtime/data-object-type-registry-module.md)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _DataObjectTypeId_: `u64`
 
-#### Modules
+#### DataDirectory
 
-These are the Joystream specific modules, and thus the only ones that actually need to have implementation done or altered.
+- **Description**:
+- **Specification**: [**READ HERE**](runtime/data-directory-module.md)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _ContentId_: `primitives::H256`
+  - _SchemaId_: `u64`
+  - _Members_: [Membership](#membership) module.
+  - _Roles_: same as `Roles` configuration of [Discovery](#discovery) module.
+  - _IsActiveDataObjectType_: [DataObjectTypeRegistry](#dataobjecttyperegistry)
 
-- [**Proposals**](proposal-module.md)
-- [**CouncilElection**](council-election-module.md)
-- [**Council**](council-module.md)
-- [**Memo**](memo-module.md)
-- [**Members**](members-module.md)
-  -  MemberId : String
-- [**Migration**](migration-module.md)
-- [**Actors**](actors-module.md)
-- [**DataObjectTypeRegistry**](data-object-type-registry-module.md)
-- [**DataDirectory**](data-directory-module.md)
-- [**DataObjectStorageRegistry**](data-object-storage-registry-module.md)
-- [**DownloadSessions**](download-sessions-module.md)
-
-##### SRML
+#### DataObjectStorageRegistry
+
+- **Description**:
+- **Specification**: [**READ HERE**](runtime/data-object-storage-registry-module.md)
+- **Status:** Unchanged from Athens.
+- **Configuration:**
+  - _DataObjectStorageRelationshipId_: `u64`
+  - _Members_: [Membership](#membership) module.
+  - _Roles_: same as `Roles` configuration of [Discovery](#discovery) module.
+  - _ContentIdExists_: [DataDirectory](#datadirectory)
+
+#### DownloadSessions
+
+- **Description**: Manages download sessions in storage system.
+- **Specification**: [**NA**](#)
+- **Status:** Not used.
+- **Configuration:**
+  - _DownloadSessionId_: `u64`
+  - _ContentHasStorage_: [DataObjectStorageRegistry](#dataobjectstorageregistry)
+
+### SRML Modules
 
 These modules are part of the runtime, but are already implemented part of the SRML.
 
-- [**System**](system-module.md)
-- [**Timestamp**](timestamp-module.md)
-- [**Consensus**](consensus-module.md)
-- [**Aura**](aura-module.md)
-- [**Indices**](indices-module.md)
-- [**Balances**](balance-module.md)
-- [**Session**](session-module.md)
-- [**Staking**](proposal-module.md)
-- [**Sudo**](proposal-module.md)
-- [**Grandpa**](proposal-module.md)
+- **System**: The system module provides low-level access to core types and cross-cutting utilities.
+- **Timestamp**: The Timestamp module provides functionality to get and set the on-chain time.
+- **Consensus**: The consensus module manages the authority set for the native code.
+- **Aura**: The Aura module extends Aura consensus by managing offline reporting.
+- **Indices**: An index is a short form of an address. This module handles allocation of indices for a newly created accounts.
+- **Balances**: The balances module provides functionality for handling accounts and balances.
+- **Session**: Is told the validators and allows them to manage their session keys for the consensus module.
+- **Staking**: The staking module is the means by which a set of network maintainers (known as _authorities_ in some contexts and _validators_ in others) are chosen based upon those who voluntarily place funds under deposit.
+- **Sudo**: The sudo module allows for a single account (called the "sudo key") to execute dispatchable functions that require a `Root` call or designate a new account to replace them as the sudo key.
+- **Grandpa**: This manages the GRANDPA authority set ready for the native code.
+
+### Runtime APIs
 
-#### MISSING STUFF
+The runtime implements the following set of APIs.
 
-#### Migrations
+#### [Core](https://crates.parity.io/substrate_client/runtime_api/trait.Core.html)
 
-list of what other runtimes one will introduce a migration from....
+- **version**: Return [Runtime Version](#runtime-version)
+- **execute_block**: Executive module `execute_block` routine.
+- **initialize_block**: Executive module `initialize_block` routine.
+- **authorities**: Executive module `apply_extrinsic` routine.
 
-"HOW TO DESCRIBE A MIGRATION"
+#### [Metadata](https://crates.parity.io/substrate_client/runtime_api/trait.Metadata.html)
 
-### Protocols
+- **metadata**: Runtime `metadata` routine.
 
-xxxx
+#### [BlockBuilder](https://crates.parity.io/substrate_client/block_builder/api/trait.BlockBuilder.html)
 
-#### Roles
+- **apply_extrinsic**: Executive module `apply_extrinsic` routine.
+- **finalize_block**: Executive module `finalize_block` routine.
+- **inherent_extrinsics**: `create_extrinsics` routine on inherent data.
+- **check_inherents**: Inherent `check_extrinsics` routine on block.
+- **random_seed**: System module `random_seed` routine.
 
-- role 1
-- role 2
+#### [TaggedTransactionQueue](https://crates.parity.io/substrate_client/runtime_api/trait.TaggedTransactionQueue.html)
 
-#### RPC
+- **validate_transaction**: Executive module `validate_transaction` routine.
 
-xxxx
+#### [OffchainWorkerApi](https://crates.parity.io/substrate_offchain/trait.OffchainWorkerApi.html)
 
-#### Peer To Peer
+- **offchain_worker**: Executive module `offchain_worker` routine.
 
-##### Messages
+#### [GrandpaApi](https://crates.parity.io/substrate_finality_grandpa_primitives/trait.GrandpaApi.html)
 
-###### Join
+- **grandpa_pending_change**, **grandpa_forced_change**, **grandpa_authorities**: Default.
 
-xxxxx
+#### [AuraApi](https://crates.parity.io/substrate_consensus_aura/trait.AuraApi.html)
 
-###### Leave
+- **slot_duration**: Auro module `slot_duration` routine.
 
-xxx
+#### [AuthoritiesApi](#)
 
-###### Advertise
+- **authorities**: Consensus module `authorities` routine.
 
-xxxxx
+<!--
 
+## Communication Protocols
 
-## References
+**TBD.**
 
-1. xxxx
+-->

+ 0 - 90
testnets/acropolis/specification/runtime-types.md

@@ -1,90 +0,0 @@
-# Types
-
-These are all public non-native Rust types that are part of the runtime. They are public in the sense that they are parameters exposed in the runtime metadata, due to being part of transactions, events or storage. Any other types that may appear in a particular implementation, for example generic types and traits/interfaces related to software engineering abstractions, are not included.
-
-something about type unoacking...?
-
-## Vec
-
-[parity_codec::alloc::vec<T>]()
-
-## ensure_signed
-
-[srml_system::ensure_signed](https://crates.parity.io/srml_system/fn.ensure_signed.html)
-
-## MemberId
-
-u64
-
-## PaidTermId
-
-u64
-
-## AccountId
-
-**cant find!**
-
-## BlockNumber
-
-u64
-
-## Moment
-
-u64
-
-## SubscriptionId
-
-u64
-
-## PaidMembershipTerms
-
-**struct**
-
-| Field                                 | Type                              |
-| :------------------------------------ |:----------------------------------|
-| `id`                                  | [`PaidTermId`](#PaidTermId)       |
-| `fee`                                 | `BalanceOf<T>`                    |
-| `text`                                | [`Vec<u8>`](#Vec)                 |
-
-## CheckedUserInfo
-
-**struct**
-
-| Field                                 | Type                              |
-| :------------------------------------ |:----------------------------------|
-| `handle`                              | [`Vec`](#Vec)&lt;`u8`&gt;          |
-| `avatar_uri`                          | [`Vec`](#Vec)&lt;`u8`&gt;                 |
-| `about`                               | [`Vec`](#Vec)&lt;`u8`&gt;                 |
-
-## EntryMethod
-
-**enum**
-
-- `Paid`([`PaidTermId`](#PaidTermId))
-- `Screening`([`AccountId`](#AccountId))
-
-## Profile
-
-**struct**
-
-| Field                                 | Type                              |
-| :------------------------------------ |:----------------------------------|
-| `id`                                  | [`MemberId`](#MemberId)           |
-| `handle`                              | [`Vec`](#Vec)&lt;`u8`&gt;                 |
-| `avatar_uri`                          | [`Vec`](#Vec)&lt;`u8`&gt;                 |
-| `about`                               | [`Vec`](#Vec)&lt;`u8`&gt;                 |
-| `registered_at_block`                 | [`BlockNumber`](#BlockNumber)     |
-| `registered_at_time`                  | [`Moment`](#Moment)                       |
-| `entry`                               | [`EntryMethod`](#EntryMethod)                     |
-| `suspended`                           | `bool`                            |
-| `subscription`                        | [`Option`](#option)&lt;[`SubscriptionId`](#SubscriptionId)&gt; |
-
-## UserInfo
-
-**struct**
-
-| Field                                  | Type                          |
-| :------------------------------------ |:------------------------------|
-| `handle`                              | `Option<Vec<u8>>`             |
-| `avatar_uri`                          | `Option<Vec<u8>>`             |
-| `about`                               | `Option<Vec<u8>>`             |

+ 2 - 10
testnets/acropolis/specification/content-module.md → testnets/acropolis/specification/runtime/content-directory.md

@@ -1,6 +1,6 @@
 # Content Directory
 
-## Table Of Content
+## Table Of Contents
 
 - [Name](#name)
 - [Dependencies](#dependencies)
@@ -18,7 +18,7 @@
 
 ## Dependencies
 
-- The [Storage Module](./storage-module.md).
+- The [Storage System](storage-system.md).
 
 ## Design
 
@@ -101,14 +101,6 @@ The content creation protocol is as follows:
 1. Publish the root `ContentMetadata` (see the [Hierarchy](#hierarchy)
   section) to make content discoverable.
 
-## Future TODOs
-
-1. Dispatchable methods take a relatively long time to return. For
-  hierarchical `ContentMetadata` that may be modified piecemeal, it
-  would be good to provide variations of [add_metadata](#add_metadata)
-  and [update_metadata](#update_metadata) that accept vectors of
-  content metadata (update) objects to process in a single transaction.
-
 ## State
 
 - `MetadataByContentId`: a map of `ContentId` to matching `ContentMetadata`

+ 2 - 10
testnets/acropolis/specification/storage-module/data-directory.md → testnets/acropolis/specification/runtime/data-directory-module.md

@@ -1,11 +1,10 @@
-# Storage Module - Data Directory
+# Data Directory Module
 
-## Table Of Content
+## Table Of Contents
 
 - [Name](#name)
 - [Dependencies](#dependencies)
 - [Design](#design)
-- [Future TODOs](#future-todos)
 - [State](#state)
 - [Events](#events)
 - [Dispatchable Methods](#dispatchable-methods)
@@ -100,13 +99,6 @@ data to the *Liaison*, not too much time should pass. If there is a reason for
 the *Liaison* to un-stake before re-distributing the content, then the
 `DataObject` cannot be uploaded, and a new `DataObject` needs to be created.
 
-## Future TODOs
-
-1. Purge state of all Pending `DataObjects` older than a configurable
-   period.
-1. Concoct a scheme for content signing, perhaps as described in the
-   [signing/verification issue](https://github.com/Joystream/storage-node-joystream/issues/5#issuecomment-495552847)
-   on the storage node.
 
 ## State
 

+ 2 - 7
testnets/acropolis/specification/storage-module/data-object-storage-registry.md → testnets/acropolis/specification/runtime/data-object-storage-registry-module.md

@@ -1,6 +1,6 @@
-# Storage Module - Data Object Storage Registry
+# Data Object Storage Registry Module
 
-## Table Of Content
+## Table Of Contents
 
 - [Name](#name)
 - [Dependencies](#dependencies)
@@ -44,11 +44,6 @@ This permits indiciating an intent to fulfil on the runtime by providing
 an inactive relationship, then synchronizing content, and finally updating
 the relationship when content can be served.
 
-## Future TODOs
-
-1. Purge all `StorageRelationships` which have the `available` flag unset
-   for a configurable period of time.
-
 ## State
 
 - `StorageRelationships`: a map of `ContentId` to a vector of

+ 2 - 2
testnets/acropolis/specification/storage-module/data-object-type-registry.md → testnets/acropolis/specification/runtime/data-object-type-registry-module.md

@@ -1,6 +1,6 @@
-# Storage Module - Data Object Type Registry
+# Data Object Type Registry Module
 
-## Table Of Content
+## Table Of Contents
 
 - [Name](#name)
 - [Dependencies](#dependencies)

+ 5 - 5
testnets/acropolis/specification/discovery-module.md → testnets/acropolis/specification/runtime/discovery-module.md

@@ -19,9 +19,7 @@
 
 ### Motivation
 
-Various services on the Joystream network need to be discovered by each other
-or the [pioneer app](https://github.com/Joystream/apps). This module describes
-data structures and dispatchable methods for helping discover these services.
+Accessing most services requires resolving a host corresponding the public key of some service provider. This module describes the on-chain component of making this possible.
 
 ### Basic Functionality
 
@@ -45,8 +43,8 @@ peformed. This current version uses [IPNS](https://docs.ipfs.io/guides/concepts/
 as a building block for discovery. The *publishing workflow* includes modifying
 on-chain data, albeit relatively rarely.
 
-This document is concerned only with *on-chain* operations. For the full,
-high-level documentation see [TODO](#TODO).
+<-- This document is concerned only with *on-chain* operations. For the full,
+high-level documentation see [TODO](#TODO). -->
 
 ## Name
 
@@ -185,5 +183,7 @@ Allows well-behaving actors to clear their IPNS peer ID, e.g. when shutting down
 
 ## Other
 
+<!--  bad format, underspecified , change later to use on_initlize -->
+
 Every block, outdated entries are removed and an `AccountInfoUpdated` event is
 raised for each removed entry.

+ 1 - 2
testnets/acropolis/specification/forum-module.md → testnets/acropolis/specification/runtime/forum-module.md

@@ -1,7 +1,6 @@
-
 # Forum Module
 
-## Table Of Content
+## Table Of Contents
 
 - [Design](#design)
 - [Dependencies](#dependencies)

+ 2 - 3
testnets/acropolis/specification/members-module.md → testnets/acropolis/specification/runtime/members-module.md

@@ -1,7 +1,6 @@
+# Members Module: is not part of Acropolis spec, only kept for future purposes.
 
-# Members Module
-
-## Table Of Content
+## Table Of Contents
 
 - [Design](#design)
 - [Dependencies](#dependencies)

+ 86 - 0
testnets/acropolis/specification/runtime/migration-module.md

@@ -0,0 +1,86 @@
+# Migration Module
+
+## Table of Contents
+
+- [Design](#design)
+- [Name](#name)
+- [Dependencies](#dependencies)
+- [Concepts](#concepts)
+- [State](#state)
+- [Events](#events)
+- [on_initialize](#on_initialize)
+
+## Design
+
+### Motivation
+
+The purpose of this module is to run migration routines required in the upgrading from Athens to Acropolis network through an on-chain runtime upgrade.
+
+### Function
+
+Routines run when the `on_initialize` dispatchable is invoked. In the upgrade to Acropolis there are no other modules which have similar code in their own handler of this callback which depend on the migration having being executed. This means it is immaterial in what order the migration module is invoked, however in the future care must be made to guarantee the migration module running first.
+
+## Name
+
+`Migration`
+
+## Dependencies
+
+ - [Data Directory Module](./substrate-runtime/data-directory-module.md)
+
+ - [Data Object Storage Registry Module](./substrate-runtime/data-object-storage-registry.md)
+
+ - [Sudo SRML Module](#)
+
+## Concepts
+
+Standard.
+
+## State
+
+- `SpecVersion`: If set, what runtime spec version the store was initialised, otherwise not set.
+
+## Events
+
+- `Migrated`: Runtime migration code was executed
+  - block number of migration
+  - spec version
+
+## on_initialize
+
+### Description
+
+Pre block execution code which actually performs migration and initilization under suitable conditions, namely
+
+- `SpecVersion` is not set, which would possibly be the case from genesis
+- `SpecVersion` is less than the runtime [spec version](../README.md#runtime-version)
+
+### Event(s)
+
+- `Migrated`
+
+### Side effect(s)
+
+- `SpecVersion` is set to [spec version](../README.md#runtime-version).
+
+#### Forum
+
+- `NextCategoryId` is `1`
+- `NextThreadId` is `1`
+- `NextPostId` is `1`
+- `ForumSudo` is `key` in `Sudo` module.
+- `CategoryTitleConstraint` is `(10,90)`
+- `CategoryDescriptionConstraint` is `(10, 490)`
+- `ThreadTitleConstraint` is `(10, 90)`
+- `PostTextConstraint` is `(10, 990)`
+- `ThreadModerationRationaleConstraint` is `(10, 290)`
+- `PostModerationRationaleConstraint` is `(10, 290)`
+
+#### DataDirectory
+
+- `PrimaryLiaisonAccountId` is gone.
+- `KnownContentIds`, `DataObjectByContentId` and `MetadataByContentId` are all empty.
+
+#### DataObjectStorageRegirstry
+
+- `RelationshipsByContentId` is empty.

+ 18 - 31
testnets/acropolis/specification/storage-module.md → testnets/acropolis/specification/runtime/storage-modules.md

@@ -1,64 +1,49 @@
-# Storage Module
+# Storage Modules
 
-## Table Of Content
+## Table Of Contents
 
-- [Name](#name)
-- [Dependencies](#dependencies)
 - [Design](#design)
 - [Concepts](#concepts)
 - [Architecture](#architecture)
 - [Traits](#traits)
 
-## Name
-
-`Storage`
-
-## Dependencies
-
-None.
-
 ## Design
 
 ### Motivation
 
-The storage module contains all runtime functionality pertaining to managing
+The storage modules contains all runtime functionality pertaining to managing
 the Joystream storage and distribution network. As such it contains information
 on actors participating in the network, as well as data that should be
 retrievable.
 
 ### Structure
 
-The module is structured into several sub-modules with their own distinct
-documentation:
+There are the following modules, with their own detailed specifications.
 
-1. [Data Object Type Registry](./storage-module/data-object-type-registry.md):
+1. [Data Object Type Registry](data-object-type-registry-module.md):
    manages how data may be stored on the network.
-1. [Data Directory](./storage-module/data-directory.md):
+2. [Data Directory](data-directory-module.md):
    manages *what* data exists on the network.
-1. [Data Object Storage Registry](./storage-module/data-object-storage-registry.md):
+3. [Data Object Storage Registry](data-object-storage-registry-module.md):
    manages  *where* data exists on the network.
-1. A [Staking](./storage-module/staking.md) sub-module, for joining and leaving
-   storage *Tranches*.
-
-Currently, all sub-modules are separate Substrate modules. This is going to
-change with the Acropolis release, where they'll be merged into a single
-`Storage` module.
+4. [Storage Staking](storage-staking-module.md) manages joining and leaving
+   storage *tranches*.
 
-Also related is the [Content Directory](./content-module.md), which provides
-information for users to discover stored content.
+Also related is the [Content Directory](content-directory.md), which provides
+information for users to discover stored content, but it is not a proper module.
 
 ## Concepts
 
 - `DataObjectType`: a structure describing the type of data objects that can be
   stored. This is not to be confused with file types. Instead, data object
   types will be used to group files that should follow the same storage
-  patterns. See the [Data Object Type Registry](./storage-module/data-object-type-registry.md)
+  patterns. See the [Data Object Type Registry](data-object-type-registry-module.md)
   for details.
 
 - `ContentId`: a unique identifier for `DataObject` and `ContentMetadata`
   entries.
 
-- `DataObject`: an entry in the [Data Directory](./storage-module/data-directory.md)
+- `DataObject`: an entry in the [Data Directory](data-directory-module.md)
   describing a single piece of content in the network.
 
 - `ContentMetadata`: a structure for describing content metadata in a
@@ -70,7 +55,7 @@ information for users to discover stored content.
 - `Liaison`: the actor account that is responsible for accepting uploads for
   a `DataObject`, and making the content available to other storage nodes.
 
-- `StorageRelationship`: an entry in the [Data Object Storage Registry](./storage-module/data-object-storage-registry.md),
+- `StorageRelationship`: an entry in the [Data Object Storage Registry](data-object-storage-registry-module.md),
   describing which actor has stored a particular `DataObject`.
 
 - A storage provider is an `actor` who has staked for a storage tranche.
@@ -105,7 +90,7 @@ information on where storage machines are to be contacted, such as IP addresses
 or host names. This is not true.
 
 At the level of abstraction of the storage module, *only* actor account IDs are
-managed. It is the purpose of the [Discovery Module](./discovery-module.md) to
+managed. It is the purpose of the [Discovery Module](discovery-module.md) to
 resolve actor account IDs further to currently up-to-date contact information.
 
 ### Architecture
@@ -144,9 +129,11 @@ derivates.
 
 ## Traits
 
+<!-- This section must be reworked and renamed, we dont ahve this in standard. -->
+
 Most of the storage module's sub-modules only make use of each other, so
 there is not much need for documenting traits as interfaces between them.
-However, one public trait, to be used by the related [Content Directory](./content-module.md)
+However, one public trait, to be used by the related [Content Directory](content-directory.md)
 does exist:
 
 - `DataObjectHasActiveStorageRelationships`: implements a method

+ 4 - 2
testnets/acropolis/specification/storage-module/staking.md → testnets/acropolis/specification/runtime/storage-staking-module.md

@@ -1,4 +1,4 @@
-# Storage Role Staking
+# Storage Staking Module
 
 ## Table Of Contents
 
@@ -18,7 +18,9 @@
 
 ## Name
 
-`StorageStaking`
+`Actors`
+
+NB: Irregular naming, should be `StorageStaking`
 
 ## Dependencies
 

+ 0 - 37
testnets/acropolis/specification/shared-types.md

@@ -1,37 +0,0 @@
-
-# Shared Types
-
-Here we list shared types which are used across multiple modules in the same runtime in various ways. Most, if not all, these types may eventually be dropped, as we make our modules more isolated, and define new stronger guidelines on runtime architecture, but for now its all listed here.
-
-## GovernanceCurrency
-
-```Rust
-pub trait GovernanceCurrency: system::Trait + Sized {
-    type Currency: Currency<Self::AccountId>
-        + ReservableCurrency<Self::AccountId>
-        + LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>;
-}
-```
-
-## Members
-
-```Rust
-pub trait Members<T: system::Trait> {
-    type Id: Parameter
-        + Member
-        + SimpleArithmetic
-        + Codec
-        + Default
-        + Copy
-        + As<usize>
-        + As<u64>
-        + MaybeSerializeDebug
-        + PartialEq;
-
-    fn is_active_member(account_id: &T::AccountId) -> bool;
-
-    fn lookup_member_id(account_id: &T::AccountId) -> Result<Self::Id, &'static str>;
-
-    fn lookup_account_by_member_id(member_id: Self::Id) -> Result<T::AccountId, &'static str>;
-}
-```

+ 82 - 0
testnets/acropolis/specification/specification-format.md

@@ -0,0 +1,82 @@
+# WIP: Specification Format
+
+This specification consists of two complementary components
+
+1. The Substrate runtime and consensus system.
+
+2. A collection of peer-to-peer and client-server communication protocol.
+
+
+## Substrate Modules
+
+**TBD**
+
+should migration stuff be here?
+
+
+
+### Extrinsics
+
+
+
+**Errors**
+
+All errors have their own precondition. The errors are listed in the order which corresponds to what order they would be invoked if _multiple_ error conditions were satisified simultanously. If this cannot be expressed as a single linear list, the section must reflect this informaiton in some other way in a fully unambigous manner.
+
+Error scenarios, which thus have no side effects, and no events. The section title is used as error message. The full precondition for each case is not only the listed condition in the same row, but also the combined failure of all listed preconditions of prior rows.
+
+**Side effects**
+
+Assume that all error preconditions are simultnaously false, denoted by predicate `NO_ERROR`.
+
+#### Terminiantion
+Important to notice that its very deeply specified, where even the order of error triggering in scenarios with mulitple simultanous errors, is commited to up front, compared to a loser standard of saying that, if you have one of these problems, you will get at least one fo these errors,w hich would drop order.
+
+- **pre-condition:** first order predicate in the runtime state and the transaction paramters which must hold _exactly_ for transaction to be accepted. e.g. that proper person has isgned?
+- **post-condition**: first order predicate in the runtime state and the transaction parameters which must hold _exactly_ when the transaction is accepted. The value of state variable `X` _after_ a transaction is handled, is denoted by `X'`. Hence, as an example, the condition that an integer variable `foo` has been incremented after a transaction is captured by the following predicate: `foo' == foo + 1`. Notice that blockchain state, like event logs ands o on, are not part of this, hence they are not in post-condition. (perhaps change?). It is OK to use separately defined functions to define this predicate, but these cannot have side effects.
+
+Notice that no _iomplementaiton_ is ever provided, only how transaction generate new state constraints. This allows us to avoid any implementation specific types, and also allows all modules to be defiend in terms of what actual types are instantioned in the parametric `T::` trait, rather than introduce lots of trait abstractions.
+
+
+cponditionals are basically valid Rust code.
+
+side ffects are pure, no
+
+functions used can only be pure, i.e. only depend on explicit parameters, and also have 0 side effcts.
+
+
+Always read stroage variables of any module through type, not varible name.
+
+#### Rrsult
+
+Here, all values are either before or after execution, using same tag symbol.
+
+**Events**
+
+Same as result
+
+
+
+## Substrate Runtime
+
+
+- how to find modules toeghet
+- what types are actually used
+- consensus decisions
+- cofngiuration stuff
+
+- migration!
+
+We are speicfying what:
+
+-  explain how to intereprt speciciation, so we understand `map`, build et.
+- xxxx
+
+
+## Communication Protocols
+
+<here we write stuff about how to read and understand our protocols>
+
+
+
+-->