From d6ddbc8bb5086f471b81c3defa3fd99f9c3a6924 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 17 Aug 2018 14:06:10 +0200 Subject: [PATCH] Paranoid mode --- polkadot/Cargo.lock | 1 + polkadot/api/Cargo.toml | 1 + polkadot/api/src/full.rs | 13 ++++++++++--- polkadot/api/src/lib.rs | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index ef63b511a3..ae69c6e059 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/Cargo.lock @@ -1705,6 +1705,7 @@ name = "polkadot-api" version = "0.1.0" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "polkadot-executor 0.1.0", "polkadot-primitives 0.1.0", "polkadot-runtime 0.1.0", diff --git a/polkadot/api/Cargo.toml b/polkadot/api/Cargo.toml index 019b2339ac..92d8ca81b8 100644 --- a/polkadot/api/Cargo.toml +++ b/polkadot/api/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Parity Technologies "] [dependencies] error-chain = "0.12" +log = "0.3" polkadot-executor = { path = "../executor" } polkadot-runtime = { path = "../runtime" } polkadot-primitives = { path = "../primitives" } diff --git a/polkadot/api/src/full.rs b/polkadot/api/src/full.rs index 66cee7d720..e0568f9394 100644 --- a/polkadot/api/src/full.rs +++ b/polkadot/api/src/full.rs @@ -22,7 +22,7 @@ use client::{self, Client, LocalCallExecutor, CallExecutor}; use codec::{Encode, Decode}; use polkadot_executor::Executor as LocalDispatch; use substrate_executor::NativeExecutor; -use state_machine; +use state_machine::ExecutionManager; use runtime::Address; use primitives::{ @@ -50,19 +50,26 @@ where }; client.state_at(&parent).map_err(Error::from).and_then(|state| { let mut overlay = Default::default(); + let execution_manager = || ExecutionManager::Both(|wasm_result, native_result| { + warn!("Consensus error between wasm and native runtime execution at block {:?}", at); + warn!(" Method {:?}", method); + warn!(" Native result {:?}", native_result); + warn!(" Wasm result {:?}", wasm_result); + wasm_result + }); client.executor().call_at_state( &state, &mut overlay, "initialise_block", &header.encode(), - state_machine::native_when_possible() + execution_manager() )?; let (r, _) = client.executor().call_at_state( &state, &mut overlay, method, input, - state_machine::native_when_possible() + execution_manager() )?; Ok(R::decode(&mut &r[..]) .ok_or_else(|| client::error::Error::from(client::error::ErrorKind::CallResultDecode(method)))?) diff --git a/polkadot/api/src/lib.rs b/polkadot/api/src/lib.rs index 8c1e4b1de8..1265faf961 100644 --- a/polkadot/api/src/lib.rs +++ b/polkadot/api/src/lib.rs @@ -32,6 +32,9 @@ extern crate substrate_state_machine as state_machine; #[macro_use] extern crate error_chain; +#[macro_use] +extern crate log; + #[cfg(test)] extern crate substrate_keyring as keyring;