Unverified Commit 1576ad9d authored by Arkadiy Paronyan's avatar Arkadiy Paronyan
Browse files

Bumped substrate

parents e17e5b31 d12426b6
This diff is collapsed.
......@@ -15,7 +15,7 @@ be what used to be Polkadot, along with its branches and releases.
Things will be a little odd for a while. Polkadot PoC-2 remains as a branch `v0.2` in the **Substrate**
repo. Polkadot PoC-3 *will be* in branch `v0.3` in the **Polkadot** repo. To play on the ("Krumme Lancke")
testnet, you'll want the PoC-2 code which is in the **Substrate** repo. These instructions are up to date
with this, but if you see "substrate" and are wondering why i you need it for Polkadot, now you know.
with this, but if you see "substrate" and are wondering why you need it for Polkadot, now you know.
== To play
......@@ -127,7 +127,7 @@ The easiest/faster option is to use the latest image.
.First run
Let´s first check the version we have. The first time you run this command, the polkadot docker image will be downloaded. This takes a bit of time and bandwidth, be patient:
Let's first check the version we have. The first time you run this command, the polkadot docker image will be downloaded. This takes a bit of time and bandwidth, be patient:
[source, shell]
docker run --rm -it chevdor/polkadot:latest polkadot --version
......
......@@ -33,7 +33,12 @@ use primitives::parachain::{DutyRoster, Id as ParaId};
use substrate_primitives::{KeccakHasher, RlpCodec};
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>
fn call<B, R>(
client: &Client<B, LocalCallExecutor<B, NativeExecutor<LocalDispatch>>, Block>,
at: &BlockId,
function: &'static str,
input: &[u8])
-> Result<R>
where
R: Decode,
B: LocalBackend<Block, KeccakHasher, RlpCodec>,
......@@ -52,7 +57,7 @@ where
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!(" Function {:?}", function);
warn!(" Native result {:?}", native_result);
warn!(" Wasm result {:?}", wasm_result);
wasm_result
......@@ -67,12 +72,12 @@ where
let (r, _) = client.executor().call_at_state(
&state,
&mut overlay,
method,
function,
input,
execution_manager()
)?;
Ok(R::decode(&mut &r[..])
.ok_or_else(|| client::error::Error::from(client::error::ErrorKind::CallResultDecode(method)))?)
.ok_or_else(|| client::error::Error::from(client::error::ErrorKind::CallResultDecode(function)))?)
})
}
......@@ -111,13 +116,12 @@ impl<B: LocalBackend<Block, KeccakHasher, RlpCodec>> PolkadotApi for Client<B, L
}
fn evaluate_block(&self, at: &BlockId, block: Block) -> Result<bool> {
use substrate_executor::error::ErrorKind as ExecErrorKind;
let encoded = block.encode();
let res: Result<()> = call(self, at, "execute_block", &encoded);
match res {
Ok(()) => Ok(true),
Err(err) => match err.kind() {
&ErrorKind::Executor(ExecErrorKind::Runtime) => Ok(false),
&ErrorKind::Execution(_) => Ok(false),
_ => Err(err)
}
}
......
......@@ -60,6 +60,11 @@ error_chain! {
description("Unknown block")
display("Unknown block {}", b)
}
/// Execution error.
Execution(e: String) {
description("Execution error")
display("Execution error: {}", e)
}
/// Some other error.
// TODO: allow to be specified as associated type of PolkadotApi
Other(e: Box<::std::error::Error + Send>) {
......@@ -67,16 +72,14 @@ error_chain! {
display("Other error: {}", e.description())
}
}
links {
Executor(substrate_executor::error::Error, substrate_executor::error::ErrorKind);
}
}
impl From<client::error::Error> for Error {
fn from(e: client::error::Error) -> Error {
match e {
client::error::Error(client::error::ErrorKind::UnknownBlock(b), _) => Error::from_kind(ErrorKind::UnknownBlock(b)),
client::error::Error(client::error::ErrorKind::Execution(e), _) =>
Error::from_kind(ErrorKind::Execution(format!("{}", e))),
other => Error::from_kind(ErrorKind::Other(Box::new(other) as Box<_>)),
}
}
......
......@@ -224,7 +224,11 @@ impl Service {
interval.map_err(|e| debug!("Timer error: {:?}", e)).for_each(move |_| {
if let Ok(best_block) = c.best_block_header() {
let hash = best_block.hash();
if hash == prev_best && s.live_agreement() != Some(hash) {
let last_agreement = s.last_agreement();
let can_build_upon = last_agreement
.map_or(true, |x| !x.live || x.parent_hash != hash);
if hash == prev_best && can_build_upon {
debug!("Starting consensus round after a timeout");
start_bft(best_block, s.clone());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment