Rollup of various testnet-related fixes.

fix a deadlock when spawning agreement as non-authority

fix test compilation for BFT

more accurate consensus superseding logic

mild revision to `can_build_on` logic

block evaluation without redundant initialisation

refactor BFT delay: update rhododendron and poll after delaying. (#589)

dropping BFT future before poll doesn't lead to service deadlock
This commit is contained in:
Robert Habermeier
2018-08-22 10:57:12 +02:00
parent f1cc82ae53
commit 430e3920e5
4 changed files with 52 additions and 39 deletions
+26 -9
View File
@@ -96,18 +96,33 @@ impl<B: LocalBackend<Block>> PolkadotApi for Client<B, LocalCallExecutor<B, Nati
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;
use codec::Encode;
use state_machine::ExecutionManager;
use client::CallExecutor;
let encoded = block.encode();
let runtime_block = match RuntimeBlock::decode(&mut &encoded[..]) {
Some(x) => x,
None => return Ok(false),
};
let parent = at;
let res = self.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!(" While executing block {:?}", (block.header.number, block.header.hash()));
warn!(" Native result {:?}", native_result);
warn!(" Wasm result {:?}", wasm_result);
wasm_result
});
let (r, _) = self.executor().call_at_state(
&state,
&mut overlay,
"execute_block",
&block.encode(),
execution_manager()
)?;
Ok(r)
});
let res = with_runtime!(self, at, || ::runtime::Executive::execute_block(runtime_block));
match res {
Ok(()) => Ok(true),
Ok(_) => Ok(true),
Err(err) => match err.kind() {
&ErrorKind::Executor(ExecErrorKind::Runtime) => Ok(false),
_ => Err(err)
@@ -230,6 +245,7 @@ mod tests {
assert_eq!(block.header.number, 1);
assert!(block.header.extrinsics_root != Default::default());
assert!(client.evaluate_block(&id, block).unwrap());
}
#[test]
@@ -252,6 +268,7 @@ mod tests {
assert_eq!(block.header.number, 1);
assert!(block.header.extrinsics_root != Default::default());
assert!(client.evaluate_block(&id, block).unwrap());
}
#[test]
+3
View File
@@ -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;