mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 00:31:02 +00:00
Bumped substrate
This commit is contained in:
@@ -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<_>)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user