Unverified Commit e6fe8379 authored by Arkadiy Paronyan's avatar Arkadiy Paronyan
Browse files

Authoring with WASM runtime

parent 77850952
......@@ -451,7 +451,7 @@ dependencies = [
[[package]]
name = "ed25519"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -491,7 +491,7 @@ dependencies = [
[[package]]
name = "environmental"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
[[package]]
name = "error-chain"
......@@ -1999,7 +1999,7 @@ dependencies = [
[[package]]
name = "pwasm-alloc"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"pwasm-libc 0.1.0 (git+https://github.com/paritytech/substrate)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2008,7 +2008,7 @@ dependencies = [
[[package]]
name = "pwasm-libc"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
[[package]]
name = "quick-error"
......@@ -2508,7 +2508,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "substrate-bft"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2527,7 +2527,7 @@ dependencies = [
[[package]]
name = "substrate-cli"
version = "0.3.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2559,7 +2559,7 @@ dependencies = [
[[package]]
name = "substrate-client"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2589,7 +2589,7 @@ dependencies = [
[[package]]
name = "substrate-client-db"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hashdb 0.2.1 (git+https://github.com/paritytech/parity-common.git)",
"kvdb 0.1.0 (git+https://github.com/paritytech/parity-common.git)",
......@@ -2611,7 +2611,7 @@ dependencies = [
[[package]]
name = "substrate-codec"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -2619,7 +2619,7 @@ dependencies = [
[[package]]
name = "substrate-codec-derive"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2629,7 +2629,7 @@ dependencies = [
[[package]]
name = "substrate-executor"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
......@@ -2637,7 +2637,7 @@ dependencies = [
"hashdb 0.2.1 (git+https://github.com/paritytech/parity-common.git)",
"lazy_static 1.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.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"substrate-codec 0.1.0 (git+https://github.com/paritytech/substrate)",
......@@ -2655,7 +2655,7 @@ dependencies = [
[[package]]
name = "substrate-extrinsic-pool"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2669,7 +2669,7 @@ dependencies = [
[[package]]
name = "substrate-keyring"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2679,7 +2679,7 @@ dependencies = [
[[package]]
name = "substrate-keystore"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2695,7 +2695,7 @@ dependencies = [
[[package]]
name = "substrate-network"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
......@@ -2717,7 +2717,7 @@ dependencies = [
[[package]]
name = "substrate-network-libp2p"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2740,7 +2740,7 @@ dependencies = [
[[package]]
name = "substrate-primitives"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2766,7 +2766,7 @@ dependencies = [
[[package]]
name = "substrate-rpc"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc.git)",
......@@ -2787,7 +2787,7 @@ dependencies = [
[[package]]
name = "substrate-rpc-servers"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc.git)",
"jsonrpc-http-server 8.0.1 (git+https://github.com/paritytech/jsonrpc.git)",
......@@ -2802,7 +2802,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-consensus"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2819,7 +2819,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-council"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)",
......@@ -2843,7 +2843,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-democracy"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2865,7 +2865,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-executive"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2881,7 +2881,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-io"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
"environmental 0.1.0 (git+https://github.com/paritytech/substrate)",
......@@ -2896,7 +2896,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-primitives"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2914,7 +2914,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-sandbox"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"substrate-codec 0.1.0 (git+https://github.com/paritytech/substrate)",
......@@ -2927,7 +2927,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-session"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2948,7 +2948,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-staking"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2971,7 +2971,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-std"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"pwasm-alloc 0.1.0 (git+https://github.com/paritytech/substrate)",
"pwasm-libc 0.1.0 (git+https://github.com/paritytech/substrate)",
......@@ -2981,7 +2981,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-support"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"ed25519 0.1.0 (git+https://github.com/paritytech/substrate)",
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -2996,7 +2996,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-system"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -3013,7 +3013,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-timestamp"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -3031,7 +3031,7 @@ dependencies = [
[[package]]
name = "substrate-runtime-version"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -3044,7 +3044,7 @@ dependencies = [
[[package]]
name = "substrate-serializer"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -3053,7 +3053,7 @@ dependencies = [
[[package]]
name = "substrate-service"
version = "0.3.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"exit-future 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -3085,7 +3085,7 @@ dependencies = [
[[package]]
name = "substrate-state-db"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -3097,7 +3097,7 @@ dependencies = [
[[package]]
name = "substrate-state-machine"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hashdb 0.2.1 (git+https://github.com/paritytech/parity-common.git)",
......@@ -3115,7 +3115,7 @@ dependencies = [
[[package]]
name = "substrate-telemetry"
version = "0.3.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
......
......@@ -18,47 +18,55 @@
use client::backend::LocalBackend;
use client::block_builder::BlockBuilder as ClientBlockBuilder;
use client::{Client, LocalCallExecutor};
use client::{self, Client, LocalCallExecutor, CallExecutor};
use codec::{Encode, Decode};
use polkadot_executor::Executor as LocalDispatch;
use substrate_executor::NativeExecutor;
use state_machine;
use runtime::Address;
use runtime_primitives::traits::AuxLookup;
use primitives::{
AccountId, Block, Header, BlockId, Hash, Index, InherentData,
SessionKey, Timestamp, UncheckedExtrinsic,
};
use primitives::parachain::{DutyRoster, Id as ParaId};
use substrate_primitives::{KeccakHasher, RlpCodec};
use {BlockBuilder, PolkadotApi, LocalPolkadotApi, ErrorKind, Error, Result};
// set up the necessary scaffolding to execute a set of calls to the runtime.
// this creates a new block on top of the given ID and initialises it.
macro_rules! with_runtime {
($client: ident, $at: expr, $exec: expr) => {{
let parent = $at;
let header = Header {
parent_hash: $client.block_hash_from_id(&parent)?
.ok_or_else(|| ErrorKind::UnknownBlock(format!("{:?}", parent)))?,
number: $client.block_number_from_id(&parent)?
use {BlockBuilder, PolkadotApi, LocalPolkadotApi, Error, ErrorKind, Result};
fn call<B, R>(client: &Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>, at: &BlockId, method: &'static str, input: &[u8]) -> Result<R>
where
R: Decode,
B: LocalBackend<Block, KeccakHasher, RlpCodec>,
{
let parent = at;
let header = Header {
parent_hash: client.block_hash_from_id(&parent)?
.ok_or_else(|| ErrorKind::UnknownBlock(format!("{:?}", parent)))?,
number: client.block_number_from_id(&parent)?
.ok_or_else(|| ErrorKind::UnknownBlock(format!("{:?}", parent)))? + 1,
state_root: Default::default(),
extrinsics_root: Default::default(),
digest: Default::default(),
};
$client.state_at(&parent).map_err(Error::from).and_then(|state| {
let mut changes = Default::default();
let mut ext = state_machine::Ext::new(&mut changes, &state);
::substrate_executor::with_native_environment(&mut ext, || {
::runtime::Executive::initialise_block(&header);
($exec)()
}).map_err(Into::into)
})
}}
state_root: Default::default(),
extrinsics_root: Default::default(),
digest: Default::default(),
};
client.state_at(&parent).map_err(Error::from).and_then(|state| {
let mut overlay = Default::default();
client.executor().call_at_state(
&state,
&mut overlay,
"initialise_block",
&header.encode(),
state_machine::native_when_possible()
)?;
let (r, _) = client.executor().call_at_state(
&state,
&mut overlay,
method,
input,
state_machine::native_when_possible()
)?;
Ok(R::decode(&mut &r[..])
.ok_or_else(|| client::error::Error::from(client::error::ErrorKind::CallResultDecode(method)))?)
})
}
impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> BlockBuilder for ClientBlockBuilder<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block, KeccakHasher, RlpCodec> {
......@@ -76,37 +84,29 @@ impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> PolkadotApi for Client<B, L
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)
Ok(self.authorities_at(at)?)
}
fn validators(&self, at: &BlockId) -> Result<Vec<AccountId>> {
with_runtime!(self, at, ::runtime::Session::validators)
call(self, at, "validators", &[])
}
fn random_seed(&self, at: &BlockId) -> Result<Hash> {
with_runtime!(self, at, ::runtime::System::random_seed)
call(self, at, "random_seed", &[])
}
fn duty_roster(&self, at: &BlockId) -> Result<DutyRoster> {
with_runtime!(self, at, ::runtime::Parachains::calculate_duty_roster)
call(self, at, "duty_roster", &[])
}
fn timestamp(&self, at: &BlockId) -> Result<Timestamp> {
with_runtime!(self, at, ::runtime::Timestamp::get)
call(self, at, "timestamp", &[])
}
fn evaluate_block(&self, at: &BlockId, block: Block) -> Result<bool> {
use substrate_executor::error::ErrorKind as ExecErrorKind;
use codec::{Decode, Encode};
use runtime::Block as RuntimeBlock;
let encoded = block.encode();
let runtime_block = match RuntimeBlock::decode(&mut &encoded[..]) {
Some(x) => x,
None => return Ok(false),
};
let res = with_runtime!(self, at, || ::runtime::Executive::execute_block(runtime_block));
let res: Result<()> = call(self, at, "execute_block", &encoded);
match res {
Ok(()) => Ok(true),
Err(err) => match err.kind() {
......@@ -117,23 +117,31 @@ impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> PolkadotApi for Client<B, L
}
fn index(&self, at: &BlockId, account: AccountId) -> Result<Index> {
with_runtime!(self, at, || ::runtime::System::account_nonce(account))
account.using_encoded(|encoded| {
call(self, at, "account_nonce", encoded)
})
}
fn lookup(&self, at: &BlockId, address: Address) -> Result<Option<AccountId>> {
with_runtime!(self, at, || <::runtime::Staking as AuxLookup>::lookup(address).ok())
address.using_encoded(|encoded| {
call(self, at, "lookup_address", encoded)
})
}
fn active_parachains(&self, at: &BlockId) -> Result<Vec<ParaId>> {
with_runtime!(self, at, ::runtime::Parachains::active_parachains)
call(self, at, "active_parachains", &[])
}
fn parachain_code(&self, at: &BlockId, parachain: ParaId) -> Result<Option<Vec<u8>>> {
with_runtime!(self, at, || ::runtime::Parachains::parachain_code(parachain))
parachain.using_encoded(|encoded| {
call(self, at, "parachain_code", encoded)
})
}
fn parachain_head(&self, at: &BlockId, parachain: ParaId) -> Result<Option<Vec<u8>>> {
with_runtime!(self, at, || ::runtime::Parachains::parachain_head(parachain))
parachain.using_encoded(|encoded| {
call(self, at, "parachain_head", encoded)
})
}
fn build_block(&self, at: &BlockId, inherent_data: InherentData) -> Result<Self::BlockBuilder> {
......@@ -146,15 +154,8 @@ impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> PolkadotApi for Client<B, L
}
fn inherent_extrinsics(&self, at: &BlockId, inherent_data: InherentData) -> Result<Vec<UncheckedExtrinsic>> {
use codec::{Encode, Decode};
with_runtime!(self, at, || {
let extrinsics = ::runtime::inherent_extrinsics(inherent_data);
extrinsics.into_iter()
.map(|x| x.encode()) // get encoded representation
.map(|x| Decode::decode(&mut &x[..])) // get byte-vec equivalent to extrinsic
.map(|x| x.expect("UncheckedExtrinsic has encoded representation equivalent to Vec<u8>; qed"))
.collect()
inherent_data.using_encoded(|encoded| {
call(self, at, "inherent_extrinsics", encoded)
})
}
}
......
......@@ -252,7 +252,15 @@ pub mod api {
finalise_block => |()| super::Executive::finalise_block(),
inherent_extrinsics => |inherent| super::inherent_extrinsics(inherent),
validator_count => |()| super::Session::validator_count(),
validators => |()| super::Session::validators()
validators => |()| super::Session::validators(),
duty_roster => |()| super::Parachains::calculate_duty_roster(),
active_parachains => |()| super::Parachains::active_parachains(),
parachain_head => |id| super::Parachains::parachain_head(&id),
parachain_code => |id| super::Parachains::parachain_code(&id),
timestamp => |()| super::Timestamp::get(),
random_seed => |()| super::System::random_seed(),
account_nonce => |account| super::System::account_nonce(&account),
lookup_address => |address| super::Staking::lookup_address(address)
);
}
......
......@@ -84,7 +84,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ed25519"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -105,7 +105,7 @@ dependencies = [
[[package]]
name = "environmental"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
[[package]]
name = "ethbloom"
......@@ -155,7 +155,7 @@ dependencies = [
[[package]]
name = "fixed-hash"
version = "0.2.2"
source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd"
source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264"
dependencies = [
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -185,7 +185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hashdb"
version = "0.2.1"
source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd"
source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264"
dependencies = [
"elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -274,7 +274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "memorydb"
version = "0.2.1"
source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd"
source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264"
dependencies = [
"elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)",
......@@ -317,7 +317,7 @@ dependencies = [
[[package]]
name = "parity-bytes"
version = "0.1.0"
source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd"
source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264"
[[package]]
name = "parity-wasm"
......@@ -350,7 +350,7 @@ dependencies = [
[[package]]
name = "patricia-trie"
version = "0.2.1"
source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd"
source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264"
dependencies = [
"elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)",
......@@ -362,7 +362,7 @@ dependencies = [
[[package]]
name = "plain_hasher"
version = "0.2.0"
source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd"
source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264"
dependencies = [
"crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -428,7 +428,7 @@ dependencies = [
[[package]]
name = "pwasm-alloc"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"pwasm-libc 0.1.0 (git+https://github.com/paritytech/substrate)",
"rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -437,7 +437,7 @@ dependencies = [
[[package]]
name = "pwasm-libc"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
[[package]]
name = "quote"
......@@ -502,7 +502,7 @@ dependencies = [
[[package]]
name = "rlp"
version = "0.2.1"
source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd"
source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264"
dependencies = [
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -596,7 +596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "substrate-codec"
version = "0.1.0"
source = "git+https://github.com/paritytech/substrate#54e6d763a5d091ca1c41f431f8c7e76c384263d5"
source = "git+https://github.com/paritytech/substrate#3697979e8d52673dd350103d810ec557f5959e9c"
dependencies = [
"arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -604,7 +604,7 @@ dependencies = [