diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index 034782271b..85dfe3cc72 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -118,7 +118,7 @@ pub fn run(args: I, exit: mpsc::Receiver<()>) -> error::Result<()> where let rpc_port: u16 = port.parse().expect("Invalid RPC port value specified."); address.set_port(rpc_port); } - let handler = rpc::rpc_handler(service.client()); + let handler = rpc::rpc_handler(service.client(), service.transaction_pool()); let _server = rpc::start_http(&address, handler)?; exit.recv().ok(); @@ -150,6 +150,7 @@ fn default_base_path() -> PathBuf { &app_info, ).expect("app directories exist on all supported platforms; qed") } + fn init_logger(pattern: &str) { let mut builder = env_logger::LogBuilder::new(); // Disable info logging by default for some modules: diff --git a/polkadot/consensus/src/lib.rs b/polkadot/consensus/src/lib.rs index d6f9398486..53cf39b6c8 100644 --- a/polkadot/consensus/src/lib.rs +++ b/polkadot/consensus/src/lib.rs @@ -570,9 +570,13 @@ impl bft::Proposer for Proposer { } let polkadot_block = block_builder.bake(); + info!("Proposing block [number: {}; extrinsics: [{}], parent_hash: {}]", polkadot_block.header.number, polkadot_block.extrinsics.len(), polkadot_block.header.parent_hash); + let substrate_block = Slicable::decode(&mut polkadot_block.encode().as_slice()) .expect("polkadot blocks defined to serialize to substrate blocks correctly; qed"); + assert!(evaluate_proposal(&substrate_block, &*self.client, current_timestamp(), &self.parent_hash, &self.parent_id).is_ok()); + Ok(substrate_block) } diff --git a/polkadot/runtime/wasm/genesis.wasm b/polkadot/runtime/wasm/genesis.wasm index e5393d0d09..b7adff2d53 100644 Binary files a/polkadot/runtime/wasm/genesis.wasm and b/polkadot/runtime/wasm/genesis.wasm differ diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm index e5393d0d09..b7adff2d53 100644 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm differ diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm index 08b69ae04f..d4e3dd6dd3 100755 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm differ diff --git a/polkadot/transaction-pool/Cargo.toml b/polkadot/transaction-pool/Cargo.toml index 6efc3cc3fe..d80384c23c 100644 --- a/polkadot/transaction-pool/Cargo.toml +++ b/polkadot/transaction-pool/Cargo.toml @@ -9,6 +9,8 @@ error-chain = "0.11" polkadot-api = { path = "../api" } polkadot-primitives = { path = "../primitives" } polkadot-runtime = { path = "../runtime" } +substrate-client = { path = "../../substrate/client" } +substrate-rpc = { path = "../../substrate/rpc" } substrate-primitives = { path = "../../substrate/primitives" } substrate-runtime-primitives = { path = "../../substrate/runtime/primitives" } substrate-codec = { path = "../../substrate/codec" } diff --git a/polkadot/transaction-pool/src/lib.rs b/polkadot/transaction-pool/src/lib.rs index f2473053dc..47fc7c99bd 100644 --- a/polkadot/transaction-pool/src/lib.rs +++ b/polkadot/transaction-pool/src/lib.rs @@ -17,6 +17,7 @@ extern crate ed25519; extern crate ethereum_types; extern crate substrate_codec as codec; +extern crate substrate_rpc; extern crate substrate_primitives as substrate_primitives; extern crate substrate_runtime_primitives as substrate_runtime_primitives; extern crate polkadot_runtime as runtime; @@ -31,8 +32,10 @@ use std::collections::HashMap; use std::cmp::Ordering; use std::sync::Arc; +use codec::Slicable; use polkadot_api::PolkadotApi; use primitives::{AccountId, Timestamp}; +use substrate_primitives::block::Extrinsic; use runtime::{Block, UncheckedExtrinsic, TimestampCall, Call}; use substrate_runtime_primitives::traits::Checkable; use transaction_pool::{Pool, Readiness}; @@ -371,6 +374,16 @@ impl TransactionPool { } } +impl substrate_rpc::author::AsyncAuthorApi for TransactionPool { + fn submit_extrinsic(&mut self, xt: Extrinsic) -> substrate_rpc::author::error::Result<()> { + self.import(xt + .using_encoded(|ref mut s| UncheckedExtrinsic::decode(s)) + .ok_or(substrate_rpc::author::error::ErrorKind::InvalidFormat)?) + .map(|_| ()) + .map_err(|_| substrate_rpc::author::error::ErrorKind::PoolError.into()) + } +} + #[cfg(test)] mod tests { }