mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Cleanup of the state-machine crate (#3524)
* Start refactoring state-machine crate * More improvement to state-machine * Fix tests compilation on master and remove warnings * Fix compilation * Apply suggestions from code review Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/state-machine/src/basic.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * Line width * Update core/primitives/src/storage.rs Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com> * Update core/state-machine/src/error.rs Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com> * Review feedback
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
//! Rust executor possible errors.
|
||||
|
||||
use state_machine;
|
||||
use serializer;
|
||||
use wasmi;
|
||||
|
||||
@@ -92,8 +91,6 @@ impl std::error::Error for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl state_machine::Error for Error {}
|
||||
|
||||
impl wasmi::HostError for Error {}
|
||||
|
||||
impl From<String> for Error {
|
||||
|
||||
@@ -43,11 +43,10 @@ pub use wasmi;
|
||||
pub use wasm_executor::WasmExecutor;
|
||||
pub use native_executor::{with_native_environment, NativeExecutor, NativeExecutionDispatch};
|
||||
pub use wasm_runtimes_cache::RuntimesCache;
|
||||
pub use state_machine::Externalities;
|
||||
pub use runtime_version::{RuntimeVersion, NativeVersion};
|
||||
pub use codec::Codec;
|
||||
#[doc(hidden)]
|
||||
pub use primitives::Blake2Hasher;
|
||||
pub use primitives::{Blake2Hasher, traits::Externalities};
|
||||
#[doc(hidden)]
|
||||
pub use wasm_interface;
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
use std::{result, cell::RefCell, panic::UnwindSafe};
|
||||
use crate::error::{Error, Result};
|
||||
use state_machine::{CodeExecutor, Externalities};
|
||||
use crate::wasm_executor::WasmExecutor;
|
||||
use runtime_version::{NativeVersion, RuntimeVersion};
|
||||
use codec::{Decode, Encode};
|
||||
use crate::RuntimeInfo;
|
||||
use primitives::{Blake2Hasher, NativeOrEncoded};
|
||||
use primitives::{Blake2Hasher, NativeOrEncoded, traits::{CodeExecutor, Externalities}};
|
||||
use log::{trace, warn};
|
||||
|
||||
use crate::RuntimesCache;
|
||||
@@ -35,7 +34,7 @@ fn safe_call<F, U>(f: F) -> Result<U>
|
||||
{
|
||||
// Substrate uses custom panic hook that terminates process on panic. Disable termination for the native call.
|
||||
let _guard = panic_handler::AbortGuard::force_unwind();
|
||||
::std::panic::catch_unwind(f).map_err(|_| Error::Runtime)
|
||||
std::panic::catch_unwind(f).map_err(|_| Error::Runtime)
|
||||
}
|
||||
|
||||
/// Set up the externalities and safe calling environment to execute calls to a native runtime.
|
||||
@@ -44,7 +43,7 @@ fn safe_call<F, U>(f: F) -> Result<U>
|
||||
pub fn with_native_environment<F, U>(ext: &mut dyn Externalities<Blake2Hasher>, f: F) -> Result<U>
|
||||
where F: UnwindSafe + FnOnce() -> U
|
||||
{
|
||||
::runtime_io::with_externalities(ext, move || safe_call(f))
|
||||
runtime_io::with_externalities(ext, move || safe_call(f))
|
||||
}
|
||||
|
||||
/// Delegate for dispatching a CodeExecutor call.
|
||||
|
||||
@@ -27,12 +27,12 @@ use wasmi::{
|
||||
Module, ModuleInstance, MemoryInstance, MemoryRef, TableRef, ImportsBuilder, ModuleRef,
|
||||
memory_units::Pages, RuntimeValue::{I32, I64, self},
|
||||
};
|
||||
use state_machine::Externalities;
|
||||
use crate::error::{Error, Result};
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::{
|
||||
blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Pair, crypto::KeyTypeId,
|
||||
offchain, hexdisplay::HexDisplay, sandbox as sandbox_primitives, Blake2Hasher,
|
||||
offchain, hexdisplay::HexDisplay, sandbox as sandbox_primitives, H256, Blake2Hasher,
|
||||
traits::Externalities, child_storage_key::ChildStorageKey,
|
||||
};
|
||||
use trie::{TrieConfiguration, trie_types::Layout};
|
||||
use crate::sandbox;
|
||||
|
||||
@@ -21,13 +21,9 @@ use crate::wasm_executor::WasmExecutor;
|
||||
use log::{trace, warn};
|
||||
use codec::Decode;
|
||||
use parity_wasm::elements::{deserialize_buffer, DataSegment, Instruction, Module as RawModule};
|
||||
use primitives::storage::well_known_keys;
|
||||
use primitives::Blake2Hasher;
|
||||
use primitives::{storage::well_known_keys, Blake2Hasher, traits::Externalities};
|
||||
use runtime_version::RuntimeVersion;
|
||||
use state_machine::Externalities;
|
||||
use std::collections::hash_map::{Entry, HashMap};
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use std::{collections::hash_map::{Entry, HashMap}, mem, rc::Rc};
|
||||
use wasmi::{Module as WasmModule, ModuleRef as WasmModuleInstanceRef, RuntimeValue};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
Reference in New Issue
Block a user