diff --git a/substrate/executor/src/native_executor.rs b/substrate/executor/src/native_executor.rs index 0925762f74..3018157001 100644 --- a/substrate/executor/src/native_executor.rs +++ b/substrate/executor/src/native_executor.rs @@ -8,6 +8,10 @@ use runtime_std; pub struct NativeExecutor; +fn safe_call Vec>(f: F) -> Result> { + catch_unwind(f).map_err(|_| ErrorKind::Runtime.into()) +} + impl CodeExecutor for NativeExecutor { type Error = Error; @@ -23,8 +27,8 @@ impl CodeExecutor for NativeExecutor { let native_equivalent = include_bytes!("../../wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm"); if code == &native_equivalent[..] { runtime_std::with_externalities(ext, || match method { - "execute_block" => catch_unwind(|| runtime::execute_block(&data.0)).map_err(|_| ErrorKind::Runtime.into()), - "execute_transaction" => catch_unwind(|| runtime::execute_transaction(&data.0)).map_err(|_| ErrorKind::Runtime.into()), + "execute_block" => safe_call(|| runtime::execute_block(&data.0)), + "execute_transaction" => safe_call(|| runtime::execute_transaction(&data.0)), _ => Err(ErrorKind::MethodNotFound(method.to_owned()).into()), }) } else {