Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
45e0ee8
Genric over hasher
dvdplm Jul 11, 2018
eb26a69
WIP start adding NodeCodec
dvdplm Jul 11, 2018
acf8284
Add codec to TrieBackend
dvdplm Jul 11, 2018
90707dc
Typechecks
dvdplm Jul 11, 2018
4ccc851
Fix error type
dvdplm Jul 11, 2018
21b7892
Cleanup
dvdplm Jul 11, 2018
6b2fa02
Tests build (and fail)
dvdplm Jul 11, 2018
f331b0c
Fix tests: don't use MemoryDB::default()
dvdplm Jul 11, 2018
f0f2413
Lockfile
dvdplm Jul 11, 2018
87740d7
Address grumbles
dvdplm Jul 12, 2018
a34f614
Teach environmental! about generics
dvdplm Jul 12, 2018
c7503ad
Add Finder artifacts
dvdplm Jul 12, 2018
711da4f
whitespace
dvdplm Jul 12, 2018
a70f4a0
Merge branch 'refactor/environmental-generic-traits' into refactor/su…
dvdplm Jul 12, 2018
b4f210a
Add a toy impl of Hasher and plug it in to Externalities
dvdplm Jul 30, 2018
3b5f60b
Use `uint` and `fixed-hash` from `parity-common`
dvdplm Jul 30, 2018
1aeb495
lock file updates
dvdplm Jul 30, 2018
f7c30f4
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Jul 30, 2018
80c96a1
Make hashes Encodable/Decodable
dvdplm Jul 31, 2018
e3277ac
lock file updates
dvdplm Jul 31, 2018
d38216b
Impl FromIterator for TestExternalities so we can collect() and use map!
dvdplm Aug 1, 2018
5f19c7b
Use rustc-hex from crates
dvdplm Aug 1, 2018
848ce8f
Fix tests in runtime-io
dvdplm Aug 1, 2018
1358bb9
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Aug 1, 2018
9b8f417
lockfile shenanigans
dvdplm Aug 1, 2018
ca01909
Add a BlakeHasher impl
dvdplm Aug 1, 2018
9e42668
Use BlakeHasher in runtime-io
dvdplm Aug 1, 2018
0f77d2b
lockfile updates
dvdplm Aug 2, 2018
402c35c
ws
dvdplm Aug 2, 2018
85b5fe1
Add a Blake2/RLP-flavoured NodeCodec
dvdplm Aug 2, 2018
56649b6
Use Blake-flavoured Hasher and NodeCodec
dvdplm Aug 2, 2018
5e5e61e
lockfile
dvdplm Aug 2, 2018
fc14711
Implement PartialEq and Default for TestExternalities
dvdplm Aug 2, 2018
05d8200
Add note about limitations of environmental!
dvdplm Aug 2, 2018
65c4f64
Make it compile, but this is probably broken
dvdplm Aug 2, 2018
56f9ef6
Derive Debug so tests in executor can work
dvdplm Aug 2, 2018
eac3f25
Make executor use BlakeHasher
dvdplm Aug 2, 2018
f3422c5
ws
dvdplm Aug 3, 2018
aa40b78
WIP make client generic
dvdplm Aug 3, 2018
54a2b66
typechecks
dvdplm Aug 3, 2018
277aadd
cleanup
dvdplm Aug 3, 2018
02a302a
client tests pass
dvdplm Aug 3, 2018
dae069b
Fix client/db
dvdplm Aug 3, 2018
7a93cf7
cleanup
dvdplm Aug 3, 2018
6329abb
Fix network
dvdplm Aug 3, 2018
dc7fc67
Fix rpc
dvdplm Aug 3, 2018
d7c0935
Fix service
dvdplm Aug 3, 2018
a553f31
Make TestExternalities work better au lieu d'un HashMap
dvdplm Aug 3, 2018
9bfe799
Fix tests in council
dvdplm Aug 3, 2018
e4cefb3
Fix tests in contract
dvdplm Aug 3, 2018
6277110
Fix tests in council
dvdplm Aug 3, 2018
adc13a2
Fix democracy
dvdplm Aug 3, 2018
252bbd8
Add comment about odd-looking reexports in tests
dvdplm Aug 3, 2018
c94018c
Don't need to load branch
dvdplm Aug 3, 2018
c49609d
Fix staking
dvdplm Aug 3, 2018
0fb6dc1
Fix session
dvdplm Aug 3, 2018
6ebfc7f
Some polkadot fixes and lockfile
dvdplm Aug 3, 2018
056bffd
Fix executive
dvdplm Aug 3, 2018
ccb61a9
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Aug 3, 2018
f565cf9
fixup lockfile
dvdplm Aug 3, 2018
d11d578
Fix polkadot/api
dvdplm Aug 4, 2018
c7334b2
Fix polkadot/service
dvdplm Aug 4, 2018
b6bde9a
Fix polkadot/runtime tests
dvdplm Aug 4, 2018
08f25d3
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Aug 5, 2018
9b139b2
Fix tests in test-runtime
dvdplm Aug 6, 2018
0c82f95
Test fixes
dvdplm Aug 6, 2018
50b4b12
Fix missing component in the `std` feature
dvdplm Aug 6, 2018
111f9fd
Use PhantomData and Result from core
dvdplm Aug 6, 2018
1276733
Fix paths
dvdplm Aug 6, 2018
334e008
load heapsize on wasm
dvdplm Aug 6, 2018
2faff87
implement `HeapSizeOf` for wasm
dvdplm Aug 6, 2018
751fe9e
Add toy impl of `blake2_256` for no_std
dvdplm Aug 6, 2018
81d7278
lockfile
dvdplm Aug 6, 2018
dd551a6
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Aug 7, 2018
dcd9541
Use kvdb* from parity-common and fix errors
dvdplm Aug 7, 2018
2370a16
rebuilt lockfile
dvdplm Aug 7, 2018
0d4a4fe
Add dummy impl of `on_advance_round` for rhododendron::Context
dvdplm Aug 7, 2018
6367815
Fix build after merge
dvdplm Aug 7, 2018
cf7e338
Add HeapSizeOf bound where needed
dvdplm Aug 8, 2018
af1b17e
Sort out dependencies for no_std
dvdplm Aug 8, 2018
ca89697
Add HeapSizeOf bound where needed
dvdplm Aug 8, 2018
da711ef
use temp branch pending PR merges
dvdplm Aug 8, 2018
3b206c2
Remove unneeded tests
dvdplm Aug 8, 2018
8064c6d
Lock file and wasm artifacts
dvdplm Aug 8, 2018
0066026
lockfile
dvdplm Aug 8, 2018
bfcf5df
Use magic commit for libp2p
dvdplm Aug 8, 2018
35b29ba
Cleanup
dvdplm Aug 9, 2018
04b7065
Implement blake2_256 for no_std
dvdplm Aug 9, 2018
8152a78
Back on parity-common master
dvdplm Aug 9, 2018
cafe669
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Aug 9, 2018
11ea517
missing type params
dvdplm Aug 9, 2018
4d14020
Merge branch 'master' into refactor/substrate-state-machine-generic
gavofyork Aug 9, 2018
19d07db
Update Cargo.lock
gavofyork Aug 9, 2018
60df8c1
whitespace
dvdplm Aug 9, 2018
6833f7b
Merge branch 'refactor/substrate-state-machine-generic' of github.com…
dvdplm Aug 9, 2018
c30dff0
Rename concrete Rlp node codec "RlpCodec" and use everywhere
dvdplm Aug 14, 2018
0c66dec
Switch to use KeccakHasher
dvdplm Aug 14, 2018
af96467
Lock file and runtimes
dvdplm Aug 14, 2018
377de91
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Aug 14, 2018
eaea29c
Merge branch 'master' into refactor/substrate-state-machine-generic
dvdplm Aug 14, 2018
a98dd38
fixup lockfile
dvdplm Aug 14, 2018
2325dc8
Fix outstanding issue using concrete types (thanks @gnunicorn)
dvdplm Aug 14, 2018
68665b3
Cleanup
dvdplm Aug 14, 2018
41072eb
More cleanup
dvdplm Aug 14, 2018
58d919d
Comment out Blake2 Hasher
dvdplm Aug 14, 2018
38f4895
implement ext_keccak256
dvdplm Aug 14, 2018
0c19e18
Address todo: FetchChecker is generic
dvdplm Aug 14, 2018
8ef48c1
Merge branch 'master' into refactor/substrate-state-machine-generic
rphmeier Aug 15, 2018
a1a5bc1
all tests passing
rphmeier Aug 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/target/
**/target/
**/*.rs.bk
*.swp
.wasm-binaries
Expand Down
420 changes: 214 additions & 206 deletions Cargo.lock

Large diffs are not rendered by default.

29 changes: 19 additions & 10 deletions demo/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod tests {
use keyring::Keyring;
use runtime_support::{Hashable, StorageValue, StorageMap};
use state_machine::{CodeExecutor, TestExternalities};
use primitives::twox_128;
use primitives::{twox_128, KeccakHasher};
use demo_primitives::{Hash, BlockNumber, AccountId};
use runtime_primitives::traits::Header as HeaderT;
use runtime_primitives::{ApplyOutcome, ApplyError, ApplyResult, MaybeUnsigned};
Expand Down Expand Up @@ -100,7 +100,7 @@ mod tests {

#[test]
fn panic_execution_with_foreign_code_gives_error() {
let mut t: TestExternalities = map![
let mut t: TestExternalities<KeccakHasher> = map![
twox_128(&<staking::FreeBalance<Concrete>>::key_for(alice())).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0],
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![70u8; 8],
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
Expand All @@ -119,7 +119,7 @@ mod tests {

#[test]
fn bad_extrinsic_with_native_equivalent_code_gives_error() {
let mut t: TestExternalities = map![
let mut t: TestExternalities<KeccakHasher> = map![
twox_128(&<staking::FreeBalance<Concrete>>::key_for(alice())).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0],
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![70u8; 8],
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
Expand All @@ -138,7 +138,7 @@ mod tests {

#[test]
fn successful_execution_with_native_equivalent_code_gives_ok() {
let mut t: TestExternalities = map![
let mut t: TestExternalities<KeccakHasher> = map![
twox_128(&<staking::FreeBalance<Concrete>>::key_for(alice())).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0],
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
Expand All @@ -161,7 +161,7 @@ mod tests {

#[test]
fn successful_execution_with_foreign_code_gives_ok() {
let mut t: TestExternalities = map![
let mut t: TestExternalities<KeccakHasher> = map![
twox_128(&<staking::FreeBalance<Concrete>>::key_for(alice())).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0],
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
Expand All @@ -182,7 +182,7 @@ mod tests {
});
}

fn new_test_ext() -> TestExternalities {
fn new_test_ext() -> TestExternalities<KeccakHasher> {
use keyring::Keyring::*;
let three = [3u8; 32].into();
GenesisConfig {
Expand Down Expand Up @@ -212,7 +212,7 @@ mod tests {
democracy: Some(Default::default()),
council: Some(Default::default()),
timestamp: Some(Default::default()),
}.build_storage().unwrap()
}.build_storage().unwrap().into()
}

fn construct_block(number: BlockNumber, parent_hash: Hash, state_root: Hash, extrinsics: Vec<BareExtrinsic>) -> (Vec<u8>, Hash) {
Expand Down Expand Up @@ -247,6 +247,9 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
// Blake
// hex!("3437bf4b182ab17bb322af5c67e55f6be487a77084ad2b4e27ddac7242e4ad21").into(),
// Keccak
hex!("c563199c60df7d914262b1775b284870f3a5da2f24b56d2c6288b37c815a6cd9").into(),
vec![BareExtrinsic {
signed: alice(),
Expand All @@ -260,6 +263,9 @@ mod tests {
construct_block(
2,
block1().1,
// Blake
// hex!("741fcb660e6fa9f625fbcd993b49f6c1cc4040f5e0cc8727afdedf11fd3c464b").into(),
// Keccak
hex!("83f71d5475f63350825b0301de322233d3711a9f3fcfd74050d1534af47a36b3").into(),
vec![
BareExtrinsic {
Expand Down Expand Up @@ -313,6 +319,9 @@ mod tests {
construct_block(
1,
[69u8; 32].into(),
// Blake
// hex!("2c7231a9c210a7aa4bea169d944bc4aaacd517862b244b8021236ffa7f697991").into(),
// Keccak
hex!("06d026c0d687ec583660a6052de6f89acdb24ea964d06be3831c837c3c426966").into(),
vec![BareExtrinsic {
signed: alice(),
Expand Down Expand Up @@ -371,7 +380,7 @@ mod tests {
#[test]
fn native_big_block_import_succeeds() {
let mut t = new_test_ext();

let r = Executor::with_heap_pages(8).call(&mut t, COMPACT_CODE, "execute_block", &block1big().0, true).0;
assert!(r.is_ok());
}
Expand All @@ -386,7 +395,7 @@ mod tests {

#[test]
fn panic_execution_gives_error() {
let mut t: TestExternalities = map![
let mut t: TestExternalities<KeccakHasher> = map![
twox_128(&<staking::FreeBalance<Concrete>>::key_for(alice())).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0],
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![70u8; 8],
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
Expand All @@ -406,7 +415,7 @@ mod tests {

#[test]
fn successful_execution_gives_ok() {
let mut t: TestExternalities = map![
let mut t: TestExternalities<KeccakHasher> = map![
twox_128(&<staking::FreeBalance<Concrete>>::key_for(alice())).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0],
twox_128(<staking::TransactionBaseFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
twox_128(<staking::TransactionByteFee<Concrete>>::key()).to_vec() => vec![0u8; 8],
Expand Down
11 changes: 6 additions & 5 deletions polkadot/api/src/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use primitives::{
SessionKey, Timestamp, UncheckedExtrinsic,
};
use primitives::parachain::{DutyRoster, Id as ParaId};
use substrate_primitives::{KeccakHasher, RlpCodec};

use {BlockBuilder, PolkadotApi, LocalPolkadotApi, ErrorKind, Error, Result};

Expand Down Expand Up @@ -60,7 +61,7 @@ macro_rules! with_runtime {
}}
}

impl<B: LocalBackend<Block>> BlockBuilder for ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block> {
impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> BlockBuilder for ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block, KeccakHasher, RlpCodec> {
fn push_extrinsic(&mut self, extrinsic: UncheckedExtrinsic) -> Result<()> {
self.push(extrinsic).map_err(Into::into)
}
Expand All @@ -71,8 +72,8 @@ impl<B: LocalBackend<Block>> BlockBuilder for ClientBlockBuilder<B, LocalCallExe
}
}

impl<B: LocalBackend<Block>> PolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block> {
type BlockBuilder = ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>;
impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> PolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block> {
type BlockBuilder = ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block, KeccakHasher, RlpCodec>;

fn session_keys(&self, at: &BlockId) -> Result<Vec<SessionKey>> {
with_runtime!(self, at, ::runtime::Consensus::authorities)
Expand Down Expand Up @@ -158,7 +159,7 @@ impl<B: LocalBackend<Block>> PolkadotApi for Client<B, LocalCallExecutor<B, Nati
}
}

impl<B: LocalBackend<Block>> LocalPolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>
impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> LocalPolkadotApi for Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>
{}

#[cfg(test)]
Expand All @@ -184,7 +185,7 @@ mod tests {
]
}

fn client() -> Client<InMemory<Block>, LocalCallExecutor<InMemory<Block>, NativeExecutor<LocalDispatch>>, Block> {
fn client() -> Client<InMemory<Block, KeccakHasher, RlpCodec>, LocalCallExecutor<InMemory<Block, KeccakHasher, RlpCodec>, NativeExecutor<LocalDispatch>>, Block> {
let genesis_config = GenesisConfig {
consensus: Some(ConsensusConfig {
code: LocalDispatch::native_equivalent().to_vec(),
Expand Down
7 changes: 4 additions & 3 deletions polkadot/api/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use primitives::{
use runtime::Address;
use primitives::parachain::{DutyRoster, Id as ParaId};
use {PolkadotApi, BlockBuilder, RemotePolkadotApi, Result, ErrorKind};
use substrate_primitives::{KeccakHasher, RlpCodec};

/// Light block builder. TODO: make this work (efficiently)
#[derive(Clone, Copy)]
Expand All @@ -43,9 +44,9 @@ impl BlockBuilder for LightBlockBuilder {
}

/// Remote polkadot API implementation.
pub struct RemotePolkadotApiWrapper<B: Backend<Block>, E: CallExecutor<Block>>(pub Arc<Client<B, E, Block>>);
pub struct RemotePolkadotApiWrapper<B: Backend<Block, KeccakHasher, RlpCodec>, E: CallExecutor<Block, KeccakHasher, RlpCodec>>(pub Arc<Client<B, E, Block>>);

impl<B: Backend<Block>, E: CallExecutor<Block>> PolkadotApi for RemotePolkadotApiWrapper<B, E> {
impl<B: Backend<Block, KeccakHasher, RlpCodec>, E: CallExecutor<Block, KeccakHasher, RlpCodec>> PolkadotApi for RemotePolkadotApiWrapper<B, E> {
type BlockBuilder = LightBlockBuilder;

fn session_keys(&self, at: &BlockId) -> Result<Vec<SessionKey>> {
Expand Down Expand Up @@ -104,4 +105,4 @@ impl<B: Backend<Block>, E: CallExecutor<Block>> PolkadotApi for RemotePolkadotAp
}
}

impl<B: RemoteBackend<Block>, E: CallExecutor<Block>> RemotePolkadotApi for RemotePolkadotApiWrapper<B, E> {}
impl<B: RemoteBackend<Block, KeccakHasher, RlpCodec>, E: CallExecutor<Block, KeccakHasher, RlpCodec>> RemotePolkadotApi for RemotePolkadotApiWrapper<B, E> {}
6 changes: 3 additions & 3 deletions polkadot/availability-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ parking_lot = "0.4"
log = "0.3"
substrate-codec = { path = "../../substrate/codec" }
substrate-primitives = { path = "../../substrate/primitives" }
kvdb = { git = "https://github.com/paritytech/parity.git" }
kvdb-rocksdb = { git = "https://github.com/paritytech/parity.git" }
kvdb-memorydb = { git = "https://github.com/paritytech/parity.git" }
kvdb = { git = "https://github.com/paritytech/parity-common.git" }
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common.git" }
kvdb-memorydb = { git = "https://github.com/paritytech/parity-common.git" }
21 changes: 3 additions & 18 deletions polkadot/availability-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,6 @@ pub struct Data {
pub extrinsic: Option<Extrinsic>,
}

fn extract_io_err(err: ::kvdb::Error) -> io::Error {
match err {
::kvdb::Error(::kvdb::ErrorKind::Io(io_err), _) => io_err,
::kvdb::Error(::kvdb::ErrorKind::Msg(msg), _) => io::Error::new(
io::ErrorKind::Other,
msg,
),
x => io::Error::new(
io::ErrorKind::Other,
format!("Unexpected error variant: {:?}", x), // only necessary because of nonexaustive match.
)
}
}

fn block_data_key(relay_parent: &Hash, candidate_hash: &Hash) -> Vec<u8> {
(relay_parent, candidate_hash, 0i8).encode()
}
Expand All @@ -99,14 +85,13 @@ impl Store {
pub fn new(config: Config) -> io::Result<Self> {
let mut db_config = DatabaseConfig::with_columns(Some(columns::NUM_COLUMNS));
db_config.memory_budget = config.cache_size;
db_config.wal = true;

let path = config.path.to_str().ok_or_else(|| io::Error::new(
io::ErrorKind::Other,
format!("Bad database path: {:?}", config.path),
))?;

let db = Database::open(&db_config, &path).map_err(extract_io_err)?;
let db = Database::open(&db_config, &path)?;

Ok(Store {
inner: Arc::new(db),
Expand Down Expand Up @@ -151,7 +136,7 @@ impl Store {
);
}

self.inner.write(tx).map_err(extract_io_err)
self.inner.write(tx)
}

/// Note that a set of candidates have been included in a finalized block with given hash and parent hash.
Expand All @@ -175,7 +160,7 @@ impl Store {
}
}

self.inner.write(tx).map_err(extract_io_err)
self.inner.write(tx)
}

/// Query block data.
Expand Down
1 change: 1 addition & 0 deletions polkadot/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ description = "Polkadot node implementation in Rust."

[dependencies]
substrate-executor = { path = "../../substrate/executor" }
substrate-primitives = { path = "../../substrate/primitives" }
polkadot-runtime = { path = "../runtime" }
1 change: 1 addition & 0 deletions polkadot/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@

extern crate polkadot_runtime;
#[macro_use] extern crate substrate_executor;
extern crate substrate_primitives as primitives;

native_executor_instance!(pub Executor, polkadot_runtime::api::dispatch, polkadot_runtime::VERSION, include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm"));
18 changes: 10 additions & 8 deletions polkadot/runtime/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ use substrate_runtime_support::dispatch::Result;
use rstd::marker::PhantomData;

#[cfg(any(feature = "std", test))]
use {runtime_io, runtime_primitives};
use runtime_primitives;

#[cfg(any(feature = "std", test))]
use std::collections::HashMap;

pub trait Trait: system::Trait<Hash = ::primitives::Hash> + session::Trait {
/// The position of the set_heads call in the block.
Expand Down Expand Up @@ -214,8 +217,7 @@ impl<T: Trait> Default for GenesisConfig<T> {
#[cfg(any(feature = "std", test))]
impl<T: Trait> runtime_primitives::BuildStorage for GenesisConfig<T>
{
fn build_storage(mut self) -> ::std::result::Result<runtime_io::TestExternalities, String> {
use std::collections::HashMap;
fn build_storage(mut self) -> ::std::result::Result<HashMap<Vec<u8>, Vec<u8>>, String> {
use codec::Encode;

self.parachains.sort_unstable_by_key(|&(ref id, _, _)| id.clone());
Expand All @@ -235,15 +237,15 @@ impl<T: Trait> runtime_primitives::BuildStorage for GenesisConfig<T>
map.insert(head_key, genesis.encode());
}

Ok(map.into())
Ok(map)
}
}

#[cfg(test)]
mod tests {
use super::*;
use runtime_io::with_externalities;
use substrate_primitives::H256;
use runtime_io::{TestExternalities, with_externalities};
use substrate_primitives::{H256, KeccakHasher};
use runtime_primitives::BuildStorage;
use runtime_primitives::traits::{HasPublicAux, Identity, BlakeTwo256};
use runtime_primitives::testing::{Digest, Header};
Expand Down Expand Up @@ -284,7 +286,7 @@ mod tests {

type Parachains = Module<Test>;

fn new_test_ext(parachains: Vec<(Id, Vec<u8>, Vec<u8>)>) -> runtime_io::TestExternalities {
fn new_test_ext(parachains: Vec<(Id, Vec<u8>, Vec<u8>)>) -> TestExternalities<KeccakHasher> {
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap();
t.extend(consensus::GenesisConfig::<Test>{
code: vec![],
Expand All @@ -299,7 +301,7 @@ mod tests {
parachains: parachains,
phantom: PhantomData,
}.build_storage().unwrap());
t
t.into()
}

#[test]
Expand Down
Loading