Traitify Runtime (#104)

* Factor out safe-mix and dispatch

* Refactor dispatch into something more modular.

* Fix wasm build.

* Fix up timestamp

* fix warnings.

* Borked timestamp example

* Fix build

* Timestamp as skeleton for traity runtime.

* New storage macro.

* Dispatch module has traity API.

* Move consensus module to new API

* Refactoring and outer dispatch

* Avoid unnecessary derives.

* Abstract the low-level half of system.

* nicer outer dispatch syntax.

* Make runtime compile again (albeit in a heavily simplified state)

* Reworking runtime and the upper levels of system.

* Initial reworking of runtime:

- Introduced executive module;
- Introduced trait primitives module;
- Provided an API endpoint.

* Expose an additional function in system

* Another couple of functions traitified in executive.

* another function in executive traitified.

* One more function traitified.

* Finish traitifying executive!

* Traitify session module.

* Cleanups and ensure session gets run.

* First part of traitification of staking module.

* Bit more of staking traitified.

* Additional stuff in staking. Fix up session.

* Penultimate part of staking module.

* Final part of staking (code)

* Update demo runtime to include staking.

* Final tweaks for staking integration.

* Remove old runtime files.

* Schedule staking.

* Minor fixes

* First bits of democracy.

* Democracy module integrated.

* Fix warning.

* Traitify and integrate council module

* Council voting.

* Runtime binary and tweaks.

* Binary update.

* Fix `*Type` grumble.

* Fix up genesis_map

* Remove NonTrivialSlicable

* Staking "test externalities" stuff along with refactor.

* Add session test externalities constructor

* Fixed executor tests.

* Make one test in executive module work.

* Remove test framework stuff into common module.

* Enable other tests in executive

* Session tests reinstated, minor refactoring of keyring.

* Fix staking tests.

* Fix up democracy tests.

* First few tests in council.

* Council tests reinstated :)

* Avoid hardcoding blake2 into Header.

* Fix last few tests.

* Make all primitives generic.

* Fix tests.

* Refactor runtime to remove genesismap.

* Streamline runtime more with macrofied config.

* Clean paths

* Fix warning.

* Consolidate demo runtime crate.

* Remove stale code.

* Refactor away dodgy trait.

* Add corresponding Aux type.

* Fixes

* Rename Digesty -> Digest

* Rename Headery -> Header

* Blocky -> Block

* Fix wasm build.

* kill warnings

* more docs

* minor cleanups
This commit is contained in:
Gav Wood
2018-04-04 12:06:39 +02:00
committed by GitHub
parent 3ec6d2dde6
commit bd066e27a6
92 changed files with 7890 additions and 5243 deletions
+1
View File
@@ -7,6 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
futures = "0.1.17"
substrate-codec = { path = "../codec" }
substrate-primitives = { path = "../primitives" }
substrate-runtime-support = { path = "../runtime-support" }
ed25519 = { path = "../ed25519" }
tokio-timer = "0.1.2"
parking_lot = "0.4"
+7 -5
View File
@@ -21,6 +21,7 @@ pub mod generic;
extern crate substrate_codec as codec;
extern crate substrate_primitives as primitives;
extern crate substrate_runtime_support as runtime_support;
extern crate ed25519;
extern crate tokio_timer;
extern crate parking_lot;
@@ -37,6 +38,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use codec::Slicable;
use ed25519::LocalizedSignature;
use runtime_support::Hashable;
use primitives::bft::{Message as PrimitiveMessage, Action as PrimitiveAction, Justification as PrimitiveJustification};
use primitives::block::{Block, Id as BlockId, Header, HeaderHash};
use primitives::AuthorityId;
@@ -176,7 +178,7 @@ impl<P: Proposer> generic::Context for BftInstance<P> {
}
fn candidate_digest(&self, proposal: &Block) -> HeaderHash {
proposal.header.hash()
proposal.header.blake2_256().into()
}
fn sign_local(&self, message: Message) -> LocalizedMessage {
@@ -334,7 +336,7 @@ impl<P, I> BftService<P, I>
InStream: Stream<Item=Communication, Error=<<P as ProposerFactory>::Proposer as Proposer>::Error>,
OutSink: Sink<SinkItem=Communication, SinkError=<<P as ProposerFactory>::Proposer as Proposer>::Error>,
{
let hash = header.hash();
let hash = header.blake2_256().into();
let mut _preempted_consensus = None; // defers drop of live to the end.
let authorities = self.client.authorities(&BlockId::Hash(hash))?;
@@ -521,7 +523,7 @@ pub fn sign_message(message: Message, key: &ed25519::Pair, parent_hash: HeaderHa
match message {
::generic::Message::Propose(r, proposal) => {
let header_hash = proposal.header.hash();
let header_hash: HeaderHash = proposal.header.blake2_256().into();
let action_header = PrimitiveAction::ProposeHeader(r as u32, header_hash.clone());
let action_propose = PrimitiveAction::Propose(r as u32, proposal.clone());
@@ -664,11 +666,11 @@ mod tests {
let service = make_service(client);
let first = Header::from_block_number(2);
let first_hash = first.hash();
let first_hash = first.blake2_256().into();
let mut second = Header::from_block_number(3);
second.parent_hash = first_hash;
let second_hash = second.hash();
let second_hash = second.blake2_256().into();
let bft = service.build_upon(&first, stream::empty(), Output(Default::default())).unwrap();
assert!(service.live_agreements.lock().contains_key(&first_hash));