Make substrate generic (#169)

* Some initial work on RPC and client

* Rephrase as params

* More work on traitifying substrate.

* Traitify in_mem.rs

* traitify client.rs

* Make new primitives (mainly traits) build again.

* Many (superficial) build fixes throughout.

* Fix remaining build issues up to bft interface.

* Make bft primitives be generic.

* Switch out MisBehaviorReport for generic version.

* Merge Hashing into Header.

* Update runtime for new generics (with Hashing).

* Update demo runtime.

* Make runtime compile.

* Build fixes for runtime

* Remove old modules.

* port substrate-bft to use generic substrate types

* port client

* port substrate-test-runtime

* mostly port test-runtime to get compiling for std

* Ensure `AccountId` has a `Default`.

* Fix type deps.

* finish porting

* initialize test_runtime from genesis correctly

* remove commented code

* maybe unsigned signatures

* runtimes compile

* port over most of network

* serialization for generic types

* fix comment

* remove some unnecessary trait bounds

* network compiles

* tests compile for sync

* fix deserialization

* temporarily remove deserialize derives

* workarounds for serde issues for deriving deserialization

* get demo-runtime compiling on std

* port extrinsic-pool

* primitives reshuffling

* get network compiling again

* remove debugging file

* runtime tests now passing

* port client-db

* start to port over substrate-rpc

* mostly port over PolkadotApi

* test_runtime follows normal conventions

* substrate runtime tests pass

* deal with inherent extrinsics correctly in polkadot-api

* port transaction-pool

* port polkadot-consensus

* port substrate-rpc

* everything compiles

* tests compile

* fix grumbles

* test-runtime uses its own transfer type

* switch to master branch of jsonrpc

* fix network tests and some warnings

* all tests pass locally

* [ci-skip] add another comment about issue

* remove some curlies
This commit is contained in:
Gav Wood
2018-06-06 17:58:45 +02:00
committed by Robert Habermeier
parent 4e844760a3
commit b94cf078af
132 changed files with 4695 additions and 4303 deletions
+25 -7
View File
@@ -22,11 +22,18 @@
extern crate substrate_runtime_io as runtime_io;
#[macro_use]
extern crate substrate_runtime_support as runtime_support;
extern crate substrate_runtime_support;
#[macro_use]
extern crate substrate_runtime_primitives as runtime_primitives;
#[cfg(feature = "std")]
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "std")]
extern crate serde;
extern crate substrate_runtime_std as rstd;
extern crate substrate_runtime_consensus as consensus;
extern crate substrate_runtime_council as council;
@@ -39,10 +46,9 @@ extern crate substrate_runtime_timestamp as timestamp;
extern crate demo_primitives;
use rstd::prelude::*;
use runtime_io::BlakeTwo256;
use demo_primitives::{AccountId, Balance, BlockNumber, Hash, Index, SessionKey, Signature};
use runtime_primitives::generic;
use runtime_primitives::traits::{Identity, HasPublicAux};
use runtime_primitives::traits::{Convert, HasPublicAux, BlakeTwo256};
#[cfg(any(feature = "std", test))]
pub use runtime_primitives::BuildExternalities;
@@ -61,7 +67,7 @@ impl system::Trait for Concrete {
type Hashing = BlakeTwo256;
type Digest = generic::Digest<Vec<u8>>;
type AccountId = AccountId;
type Header = generic::Header<BlockNumber, Hash, Vec<u8>>;
type Header = generic::Header<BlockNumber, BlakeTwo256, Vec<u8>>;
}
/// System module for this concrete runtime.
@@ -84,8 +90,16 @@ impl timestamp::Trait for Concrete {
/// Timestamp module for this concrete runtime.
pub type Timestamp = timestamp::Module<Concrete>;
/// Session key conversion.
pub struct SessionKeyConversion;
impl Convert<AccountId, SessionKey> for SessionKeyConversion {
fn convert(a: AccountId) -> SessionKey {
a.0
}
}
impl session::Trait for Concrete {
type ConvertAccountIdToSessionKey = Identity;
type ConvertAccountIdToSessionKey = SessionKeyConversion;
}
/// Session module for this concrete runtime.
@@ -114,6 +128,8 @@ pub type Council = council::Module<Concrete>;
pub type CouncilVoting = council::voting::Module<Concrete>;
impl_outer_dispatch! {
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum Call where aux: <Concrete as HasPublicAux>::PublicAux {
Consensus = 0,
Session = 1,
@@ -124,6 +140,8 @@ impl_outer_dispatch! {
CouncilVoting = 7,
}
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum PrivCall {
Consensus = 0,
Session = 1,
@@ -135,9 +153,9 @@ impl_outer_dispatch! {
}
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, Hash, Vec<u8>>;
pub type Header = generic::Header<BlockNumber, BlakeTwo256, Vec<u8>>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<BlockNumber, Hash, Vec<u8>, AccountId, Index, Call, Signature>;
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, Index, Call, Signature>;
/// Extrinsic type as expected by this runtime.