diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock
index 8f333b159e..e58fd510ed 100644
--- a/substrate/Cargo.lock
+++ b/substrate/Cargo.lock
@@ -986,30 +986,20 @@ name = "polkadot-cli"
version = "0.1.0"
dependencies = [
"clap 2.29.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "polkadot-client 0.1.0",
- "polkadot-rpc-servers 0.1.0",
- "substrate-executor 0.1.0",
- "substrate-primitives 0.1.0",
-]
-
-[[package]]
-name = "polkadot-client"
-version = "0.1.0"
-dependencies = [
"ed25519 0.1.0",
+ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"native-runtime 0.1.0",
- "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "polkadot-executor 0.1.0",
"polkadot-primitives 0.1.0",
+ "polkadot-rpc-servers 0.1.0",
+ "substrate-client 0.1.0",
"substrate-codec 0.1.0",
"substrate-executor 0.1.0",
"substrate-primitives 0.1.0",
- "substrate-serializer 0.1.0",
+ "substrate-runtime-io 0.1.0",
"substrate-state-machine 0.1.0",
"triehash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1023,6 +1013,22 @@ dependencies = [
"substrate-primitives 0.1.0",
]
+[[package]]
+name = "polkadot-executor"
+version = "0.1.0"
+dependencies = [
+ "ed25519 0.1.0",
+ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "native-runtime 0.1.0",
+ "polkadot-primitives 0.1.0",
+ "substrate-codec 0.1.0",
+ "substrate-executor 0.1.0",
+ "substrate-primitives 0.1.0",
+ "substrate-runtime-io 0.1.0",
+ "substrate-state-machine 0.1.0",
+ "triehash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "polkadot-network"
version = "0.1.0"
@@ -1036,7 +1042,6 @@ dependencies = [
"ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "polkadot-client 0.1.0",
"polkadot-primitives 0.1.0",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1044,6 +1049,7 @@ dependencies = [
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "substrate-client 0.1.0",
"substrate-primitives 0.1.0",
"substrate-serializer 0.1.0",
"substrate-state-machine 0.1.0",
@@ -1070,7 +1076,8 @@ dependencies = [
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc.git)",
"jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git)",
- "polkadot-client 0.1.0",
+ "polkadot-executor 0.1.0",
+ "substrate-client 0.1.0",
"substrate-executor 0.1.0",
"substrate-primitives 0.1.0",
"substrate-state-machine 0.1.0",
@@ -1413,6 +1420,23 @@ name = "strsim"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[[package]]
+name = "substrate-client"
+version = "0.1.0"
+dependencies = [
+ "ed25519 0.1.0",
+ "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "substrate-codec 0.1.0",
+ "substrate-executor 0.1.0",
+ "substrate-primitives 0.1.0",
+ "substrate-serializer 0.1.0",
+ "substrate-state-machine 0.1.0",
+ "triehash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[[package]]
name = "substrate-codec"
version = "0.1.0"
@@ -1430,9 +1454,7 @@ dependencies = [
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "native-runtime 0.1.0",
"parity-wasm 0.15.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "polkadot-primitives 0.1.0",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml
index 4780426456..5d275c2caa 100644
--- a/substrate/Cargo.toml
+++ b/substrate/Cargo.toml
@@ -22,6 +22,7 @@ members = [
"rpc",
"codec",
"polkadot-primitives",
+ "polkadot-executor",
"runtime-io",
"runtime-std",
"serializer",
diff --git a/substrate/cli/Cargo.toml b/substrate/cli/Cargo.toml
index 74299ec2eb..aa8989d2af 100644
--- a/substrate/cli/Cargo.toml
+++ b/substrate/cli/Cargo.toml
@@ -9,7 +9,16 @@ clap = { version = "2.27", features = ["yaml"] }
env_logger = "0.4"
error-chain = "0.11"
log = "0.3"
-polkadot-client = { path = "../client" }
+hex-literal = "0.1"
+ed25519 = { path = "../ed25519" }
+triehash = { version = "0.1" }
+substrate-client = { path = "../client" }
+substrate-codec = { path = "../codec" }
+substrate-runtime-io = { path = "../runtime-io" }
+substrate-state-machine = { path = "../state-machine" }
substrate-executor = { path = "../executor" }
substrate-primitives = { path = "../primitives" }
polkadot-rpc-servers = { path = "../rpc-servers" }
+polkadot-primitives = { path = "../polkadot-primitives" }
+polkadot-executor = { path = "../polkadot-executor" }
+native-runtime = { path = "../native-runtime" }
diff --git a/substrate/client/src/genesis.rs b/substrate/cli/src/genesis.rs
similarity index 94%
rename from substrate/client/src/genesis.rs
rename to substrate/cli/src/genesis.rs
index 788513ffa6..25c1744ab1 100644
--- a/substrate/client/src/genesis.rs
+++ b/substrate/cli/src/genesis.rs
@@ -1,18 +1,18 @@
// Copyright 2017 Parity Technologies (UK) Ltd.
-// This file is part of Polkadot.
+// This file is part of Substrate.
-// Polkadot is free software: you can redistribute it and/or modify
+// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-// Polkadot is distributed in the hope that it will be useful,
+// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with Polkadot. If not, see .
+// along with Substrate. If not, see .
//! Tool for creating the genesis block.
diff --git a/substrate/cli/src/lib.rs b/substrate/cli/src/lib.rs
index faad72526e..d18c40b013 100644
--- a/substrate/cli/src/lib.rs
+++ b/substrate/cli/src/lib.rs
@@ -19,11 +19,22 @@
#![warn(missing_docs)]
extern crate env_logger;
-extern crate polkadot_client as client;
-extern crate substrate_executor as executor;
+extern crate ed25519;
+extern crate triehash;
+extern crate substrate_codec as codec;
+extern crate substrate_state_machine as state_machine;
+extern crate substrate_client as client;
+extern crate substrate_executor;
extern crate substrate_primitives as primitives;
+extern crate substrate_runtime_io as runtime_io;
extern crate polkadot_rpc_servers as rpc;
+extern crate polkadot_primitives;
+extern crate polkadot_executor as executor;
+extern crate native_runtime;
+#[cfg(test)]
+#[macro_use]
+extern crate hex_literal;
#[macro_use]
extern crate clap;
#[macro_use]
@@ -31,6 +42,14 @@ extern crate error_chain;
#[macro_use]
extern crate log;
+// TODO: move into own crate.
+#[cfg(test)]
+macro_rules! map {
+ ($( $name:expr => $value:expr ),*) => (
+ vec![ $( ( $name, $value ) ),* ].into_iter().collect()
+ )
+}
+
pub mod error;
/// Parse command line arguments and start the node.
@@ -54,7 +73,7 @@ pub fn run(args: I) -> error::Result<()> where
// Create client
let executor = executor::executor();
- let client = client::new_in_mem(executor)?;
+ let client = client::new_in_mem(executor)?; // TODO: pass in genesis builder.
let address = "127.0.0.1:9933".parse().unwrap();
let handler = rpc::rpc_handler(client);
@@ -94,4 +113,3 @@ fn init_logger(pattern: &str) {
builder.init().expect("Logger initialized only once.");
}
-
diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml
index b5ee065dbb..ebe3adba77 100644
--- a/substrate/client/Cargo.toml
+++ b/substrate/client/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "polkadot-client"
+name = "substrate-client"
version = "0.1.0"
authors = ["Parity Technologies "]
@@ -7,13 +7,11 @@ authors = ["Parity Technologies "]
error-chain = "0.11"
log = "0.3"
parking_lot = "0.4"
-polkadot-primitives = { path = "../polkadot-primitives", version = "0.1" }
substrate-primitives = { path = "../primitives", version = "0.1" }
substrate-state-machine = { path = "../state-machine", version = "0.1" }
substrate-serializer = { path = "../serializer" }
substrate-executor = { path = "../executor" }
substrate-codec = { path = "../codec", version = "0.1" }
-native-runtime = { path = "../native-runtime" }
triehash = "0.1"
hex-literal = "0.1"
ed25519 = { path = "../ed25519", version = "0.1" }
diff --git a/substrate/client/src/lib.rs b/substrate/client/src/lib.rs
index f0d1fd1a63..3f29842c00 100644
--- a/substrate/client/src/lib.rs
+++ b/substrate/client/src/lib.rs
@@ -18,13 +18,11 @@
#![warn(missing_docs)]
-extern crate polkadot_primitives;
extern crate substrate_primitives as primitives;
extern crate substrate_state_machine as state_machine;
extern crate substrate_serializer as ser;
extern crate substrate_codec as codec;
extern crate substrate_executor;
-extern crate native_runtime;
extern crate ed25519;
extern crate triehash;
@@ -41,10 +39,6 @@ pub mod blockchain;
pub mod backend;
pub mod in_mem;
-mod genesis;
-
-pub use genesis::construct_genesis_block;
-
pub use blockchain::Info as ChainInfo;
pub use blockchain::BlockId;
@@ -109,7 +103,6 @@ pub enum BlockStatus {
Unknown,
}
-
/// Create an instance of in-memory client.
pub fn new_in_mem(executor: E) -> error::Result> where E: state_machine::CodeExecutor {
Client::new(in_mem::Backend::new(), executor)
@@ -124,7 +117,7 @@ impl Client where
pub fn new(backend: B, executor: E) -> error::Result {
if backend.blockchain().header(BlockId::Number(0))?.is_none() {
trace!("Empty database, writing genesis block");
- // TODO: spec
+ // TODO: spec, coming in from new_in_mem's params.
let genesis_header = block::Header {
parent_hash: Default::default(),
number: 0,
diff --git a/substrate/executor/Cargo.toml b/substrate/executor/Cargo.toml
index 8d2643d585..7a4a5c8af0 100644
--- a/substrate/executor/Cargo.toml
+++ b/substrate/executor/Cargo.toml
@@ -19,9 +19,6 @@ rustc-hex = "1.0.0"
triehash = "0.1.0"
hex-literal = "0.1.0"
log = "0.3"
-# TODO: Remove these and split out tests and a concrete executor.
-native-runtime = { path = "../native-runtime" }
-polkadot-primitives = { path = "../polkadot-primitives" }
[dev-dependencies]
assert_matches = "1.1"
diff --git a/substrate/executor/src/lib.rs b/substrate/executor/src/lib.rs
index 88c52c9389..44656fab5b 100644
--- a/substrate/executor/src/lib.rs
+++ b/substrate/executor/src/lib.rs
@@ -41,10 +41,6 @@ extern crate rustc_hex;
extern crate triehash;
#[macro_use] extern crate log;
-// TODO: Remove and split out into polkadot-specific crate.
-extern crate native_runtime;
-extern crate polkadot_primitives;
-
#[cfg(test)]
#[macro_use]
extern crate hex_literal;
@@ -55,14 +51,18 @@ extern crate error_chain;
#[cfg(test)]
extern crate assert_matches;
+// TODO: move into own crate
+macro_rules! map {
+ ($( $name:expr => $value:expr ),*) => (
+ vec![ $( ( $name, $value ) ),* ].into_iter().collect()
+ )
+}
+
#[macro_use]
mod wasm_utils;
mod wasm_executor;
mod native_executor;
pub mod error;
-
-/// Creates new RustExecutor for contracts.
-pub fn executor() -> native_executor::NativeExecutor {
- native_executor::NativeExecutor
-}
+pub use wasm_executor::WasmExecutor;
+pub use native_executor::{NativeExecutionDispatch, NativeExecutor};
diff --git a/substrate/executor/src/native_executor.rs b/substrate/executor/src/native_executor.rs
index e4812be894..eef18be128 100644
--- a/substrate/executor/src/native_executor.rs
+++ b/substrate/executor/src/native_executor.rs
@@ -15,20 +15,26 @@
// along with Substrate. If not, see .
use error::{Error, ErrorKind, Result};
-use native_runtime as runtime;
use runtime_io;
use state_machine::{Externalities, CodeExecutor};
use wasm_executor::WasmExecutor;
use std::panic::catch_unwind;
-pub struct NativeExecutor;
+pub trait NativeExecutionDispatch {
+ fn native_equivalent() -> &'static [u8];
+ fn dispatch(method: &str, data: &[u8]) -> Option>;
+}
-fn safe_call Vec>(f: F) -> Result> {
+pub struct NativeExecutor {
+ pub _dummy: ::std::marker::PhantomData,
+}
+
+fn safe_call Option>>(f: F) -> Result