[big refactor] Remove crate aliasing. (#4395)

* Rename: Phase 1.

* Unify codec.

* Fixing: Phase 2

* Fixing: Phase 3.

* Fixing: Phase 4.

* Fixing: Phase 5.

* Fixing: Phase 6.

* Fixing: Phase 7.

* Fixing: Phase 8. Tests

* Fixing: Phase 9. Tests!!!

* Fixing: Phase 10. Moar tests!

* Finally done!

* More fixes.

* Rename primitives:: to sp_core::

* Apply renames in finality-grandpa.

* Fix benches.

* Fix benches 2.

* Revert node-template.

* Fix frame-system in our modules.
This commit is contained in:
Tomasz Drwięga
2019-12-16 13:36:49 +01:00
committed by Gavin Wood
parent f14d98a439
commit 8778ca7dc8
485 changed files with 4023 additions and 4005 deletions
+11 -12
View File
@@ -8,17 +8,17 @@ edition = "2018"
derive_more = "0.99.2"
codec = { package = "parity-scale-codec", version = "1.0.0" }
sp-io = { path = "../../primitives/io" }
primitives = { package = "sp-core", path = "../../primitives/core" }
trie = { package = "sp-trie", path = "../../primitives/trie" }
serializer = { package = "sp-serializer", path = "../../primitives/serializer" }
runtime_version = { package = "sp-version", path = "../../primitives/version" }
panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" }
sp-core = { path = "../../primitives/core" }
sp-trie = { path = "../../primitives/trie" }
sp-serializer = { path = "../../primitives/serializer" }
sp-version = { path = "../../primitives/version" }
sp-panic-handler = { path = "../../primitives/panic-handler" }
wasmi = "0.6.2"
parity-wasm = "0.41.0"
lazy_static = "1.4.0"
wasm-interface = { package = "sp-wasm-interface", path = "../../primitives/wasm-interface" }
runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" }
externalities = { package = "sp-externalities", path = "../../primitives/externalities" }
sp-wasm-interface = { path = "../../primitives/wasm-interface" }
sp-runtime-interface = { path = "../../primitives/runtime-interface" }
sp-externalities = { path = "../../primitives/externalities" }
parking_lot = "0.9.0"
log = "0.4.8"
libsecp256k1 = "0.3.2"
@@ -36,10 +36,9 @@ wasmtime-runtime = { version = "0.8", optional = true }
assert_matches = "1.3.0"
wabt = "0.9.2"
hex-literal = "0.2.1"
runtime-test = { package = "sc-runtime-test", path = "runtime-test" }
test-runtime = { package = "substrate-test-runtime", path = "../../test-utils/runtime" }
runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" }
state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" }
sc-runtime-test = { path = "runtime-test" }
substrate-test-runtime = { path = "../../test-utils/runtime" }
sp-state-machine = { path = "../../primitives/state-machine" }
test-case = "0.3.3"
[features]
@@ -8,13 +8,13 @@ build = "build.rs"
[dependencies]
sp-std = { path = "../../../primitives/std", default-features = false }
sp-io = { path = "../../../primitives/io", default-features = false }
sandbox = { package = "sp-sandbox", path = "../../../primitives/sandbox", default-features = false }
primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false }
sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false }
sp-sandbox = { path = "../../../primitives/sandbox", default-features = false }
sp-core = { path = "../../../primitives/core", default-features = false }
sp-runtime = { path = "../../../primitives/runtime", default-features = false }
[build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" }
[features]
default = [ "std" ]
std = ["sp-io/std", "sandbox/std", "sp-std/std"]
std = ["sp-io/std", "sp-sandbox/std", "sp-std/std"]
@@ -16,9 +16,9 @@ use sp_io::{
#[cfg(not(feature = "std"))]
use sp_runtime::{print, traits::{BlakeTwo256, Hash}};
#[cfg(not(feature = "std"))]
use primitives::{ed25519, sr25519};
use sp_core::{ed25519, sr25519};
primitives::wasm_export_functions! {
sp_core::wasm_export_functions! {
fn test_data_in(input: Vec<u8>) -> Vec<u8> {
print("set_storage");
storage::set(b"input", &input);
@@ -112,8 +112,8 @@ primitives::wasm_export_functions! {
execute_sandboxed(
&code,
&[
sandbox::TypedValue::I32(0x12345678),
sandbox::TypedValue::I64(0x1234567887654321),
sp_sandbox::TypedValue::I32(0x12345678),
sp_sandbox::TypedValue::I64(0x1234567887654321),
],
).is_ok()
}
@@ -122,10 +122,10 @@ primitives::wasm_export_functions! {
let ok = match execute_sandboxed(
&code,
&[
sandbox::TypedValue::I32(0x1336),
sp_sandbox::TypedValue::I32(0x1336),
]
) {
Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(0x1337))) => true,
Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(0x1337))) => true,
_ => false,
};
@@ -133,19 +133,19 @@ primitives::wasm_export_functions! {
}
fn test_sandbox_instantiate(code: Vec<u8>) -> u8 {
let env_builder = sandbox::EnvironmentDefinitionBuilder::new();
let code = match sandbox::Instance::new(&code, &env_builder, &mut ()) {
let env_builder = sp_sandbox::EnvironmentDefinitionBuilder::new();
let code = match sp_sandbox::Instance::new(&code, &env_builder, &mut ()) {
Ok(_) => 0,
Err(sandbox::Error::Module) => 1,
Err(sandbox::Error::Execution) => 2,
Err(sandbox::Error::OutOfBounds) => 3,
Err(sp_sandbox::Error::Module) => 1,
Err(sp_sandbox::Error::Execution) => 2,
Err(sp_sandbox::Error::OutOfBounds) => 3,
};
code
}
fn test_offchain_local_storage() -> bool {
let kind = primitives::offchain::StorageKind::PERSISTENT;
let kind = sp_core::offchain::StorageKind::PERSISTENT;
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None);
sp_io::offchain::local_storage_set(kind, b"test", b"asd");
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"asd".to_vec()));
@@ -161,7 +161,7 @@ primitives::wasm_export_functions! {
}
fn test_offchain_local_storage_with_none() {
let kind = primitives::offchain::StorageKind::PERSISTENT;
let kind = sp_core::offchain::StorageKind::PERSISTENT;
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None);
let res = sp_io::offchain::local_storage_compare_and_set(kind, b"test", None, b"value");
@@ -170,7 +170,7 @@ primitives::wasm_export_functions! {
}
fn test_offchain_http() -> bool {
use primitives::offchain::HttpRequestStatus;
use sp_core::offchain::HttpRequestStatus;
let run = || -> Option<()> {
let id = sp_io::offchain::http_request_start(
"POST",
@@ -201,45 +201,45 @@ primitives::wasm_export_functions! {
#[cfg(not(feature = "std"))]
fn execute_sandboxed(
code: &[u8],
args: &[sandbox::TypedValue],
) -> Result<sandbox::ReturnValue, sandbox::HostError> {
args: &[sp_sandbox::TypedValue],
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> {
struct State {
counter: u32,
}
fn env_assert(
_e: &mut State,
args: &[sandbox::TypedValue],
) -> Result<sandbox::ReturnValue, sandbox::HostError> {
args: &[sp_sandbox::TypedValue],
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> {
if args.len() != 1 {
return Err(sandbox::HostError);
return Err(sp_sandbox::HostError);
}
let condition = args[0].as_i32().ok_or_else(|| sandbox::HostError)?;
let condition = args[0].as_i32().ok_or_else(|| sp_sandbox::HostError)?;
if condition != 0 {
Ok(sandbox::ReturnValue::Unit)
Ok(sp_sandbox::ReturnValue::Unit)
} else {
Err(sandbox::HostError)
Err(sp_sandbox::HostError)
}
}
fn env_inc_counter(
e: &mut State,
args: &[sandbox::TypedValue],
) -> Result<sandbox::ReturnValue, sandbox::HostError> {
args: &[sp_sandbox::TypedValue],
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> {
if args.len() != 1 {
return Err(sandbox::HostError);
return Err(sp_sandbox::HostError);
}
let inc_by = args[0].as_i32().ok_or_else(|| sandbox::HostError)?;
let inc_by = args[0].as_i32().ok_or_else(|| sp_sandbox::HostError)?;
e.counter += inc_by as u32;
Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(e.counter as i32)))
Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(e.counter as i32)))
}
let mut state = State { counter: 0 };
let env_builder = {
let mut env_builder = sandbox::EnvironmentDefinitionBuilder::new();
let mut env_builder = sp_sandbox::EnvironmentDefinitionBuilder::new();
env_builder.add_host_func("env", "assert", env_assert);
env_builder.add_host_func("env", "inc_counter", env_inc_counter);
let memory = match sandbox::Memory::new(1, Some(16)) {
let memory = match sp_sandbox::Memory::new(1, Some(16)) {
Ok(m) => m,
Err(_) => unreachable!("
Memory::new() can return Err only if parameters are borked; \
@@ -251,8 +251,8 @@ fn execute_sandboxed(
env_builder
};
let mut instance = sandbox::Instance::new(code, &env_builder, &mut state)?;
let mut instance = sp_sandbox::Instance::new(code, &env_builder, &mut state)?;
let result = instance.invoke("call", args, &mut state);
result.map_err(|_| sandbox::HostError)
result.map_err(|_| sp_sandbox::HostError)
}
+1 -1
View File
@@ -50,7 +50,7 @@ use crate::error::{Error, Result};
use log::trace;
use std::convert::{TryFrom, TryInto};
use std::ops::Range;
use wasm_interface::{Pointer, WordSize};
use sp_wasm_interface::{Pointer, WordSize};
// The pointers need to be aligned to 8 bytes. This is because the
// maximum value type handled by wasm32 is u64.
@@ -18,12 +18,12 @@
use codec::Encode;
use std::{convert::TryFrom, str};
use primitives::{
use sp_core::{
blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, keccak_256, Blake2Hasher, Pair,
crypto::KeyTypeId, offchain,
};
use trie::{TrieConfiguration, trie_types::Layout};
use wasm_interface::{
use sp_trie::{TrieConfiguration, trie_types::Layout};
use sp_wasm_interface::{
Pointer, WordSize, WritePrimitive, ReadPrimitive, FunctionContext, Result as WResult,
};
+2 -2
View File
@@ -16,7 +16,7 @@
//! Rust executor possible errors.
use serializer;
use sp_serializer;
use wasmi;
#[cfg(feature = "wasmtime")]
use wasmtime_jit::{ActionError, SetupError};
@@ -28,7 +28,7 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
/// Unserializable Data
InvalidData(serializer::Error),
InvalidData(sp_serializer::Error),
/// Trap occured during execution
Trap(wasmi::Trap),
/// Wasmi loading/instantiating error
@@ -18,15 +18,15 @@ mod sandbox;
use codec::{Encode, Decode};
use hex_literal::hex;
use primitives::{
use sp_core::{
Blake2Hasher, blake2_128, blake2_256, ed25519, sr25519, map, Pair,
offchain::{OffchainExt, testing},
traits::Externalities,
};
use runtime_test::WASM_BINARY;
use state_machine::TestExternalities as CoreTestExternalities;
use sc_runtime_test::WASM_BINARY;
use sp_state_machine::TestExternalities as CoreTestExternalities;
use test_case::test_case;
use trie::{TrieConfiguration, trie_types::Layout};
use sp_trie::{TrieConfiguration, trie_types::Layout};
use crate::WasmExecutionMethod;
@@ -128,7 +128,7 @@ fn storage_should_work(wasm_method: WasmExecutionMethod) {
assert_eq!(output, b"all ok!".to_vec().encode());
}
let expected = TestExternalities::new(primitives::storage::Storage {
let expected = TestExternalities::new(sp_core::storage::Storage {
top: map![
b"input".to_vec() => b"Hello world".to_vec(),
b"foo".to_vec() => b"bar".to_vec(),
@@ -165,7 +165,7 @@ fn clear_prefix_should_work(wasm_method: WasmExecutionMethod) {
assert_eq!(output, b"all ok!".to_vec().encode());
}
let expected = TestExternalities::new(primitives::storage::Storage {
let expected = TestExternalities::new(sp_core::storage::Storage {
top: map![
b"aaa".to_vec() => b"1".to_vec(),
b"aab".to_vec() => b"2".to_vec(),
@@ -443,7 +443,7 @@ fn ordered_trie_root_should_work(wasm_method: WasmExecutionMethod) {
#[test_case(WasmExecutionMethod::Interpreted)]
#[cfg_attr(feature = "wasmtime", test_case(WasmExecutionMethod::Compiled))]
fn offchain_local_storage_should_work(wasm_method: WasmExecutionMethod) {
use primitives::offchain::OffchainStorage;
use sp_core::offchain::OffchainStorage;
let mut ext = TestExternalities::default();
let (offchain, state) = testing::TestOffchainExt::new();
@@ -18,7 +18,7 @@ use super::{TestExternalities, call_in_wasm};
use crate::WasmExecutionMethod;
use codec::Encode;
use runtime_test::WASM_BINARY;
use sc_runtime_test::WASM_BINARY;
use test_case::test_case;
use wabt;
+5 -5
View File
@@ -46,12 +46,12 @@ mod integration_tests;
pub mod error;
pub use wasmi;
pub use native_executor::{with_native_environment, NativeExecutor, NativeExecutionDispatch};
pub use runtime_version::{RuntimeVersion, NativeVersion};
pub use sp_version::{RuntimeVersion, NativeVersion};
pub use codec::Codec;
#[doc(hidden)]
pub use primitives::traits::Externalities;
pub use sp_core::traits::Externalities;
#[doc(hidden)]
pub use wasm_interface;
pub use sp_wasm_interface;
pub use wasm_runtime::WasmExecutionMethod;
/// Call the given `function` in the given wasm `code`.
@@ -64,7 +64,7 @@ pub use wasm_runtime::WasmExecutionMethod;
/// - `heap_pages`: The number of heap pages to allocate.
///
/// Returns the `Vec<u8>` that contains the return value of the function.
pub fn call_in_wasm<E: Externalities, HF: wasm_interface::HostFunctions>(
pub fn call_in_wasm<E: Externalities, HF: sp_wasm_interface::HostFunctions>(
function: &str,
call_data: &[u8],
execution_method: WasmExecutionMethod,
@@ -93,7 +93,7 @@ pub trait RuntimeInfo {
#[cfg(test)]
mod tests {
use super::*;
use runtime_test::WASM_BINARY;
use sc_runtime_test::WASM_BINARY;
use sp_io::TestExternalities;
#[test]
@@ -19,17 +19,17 @@ use crate::{
wasm_runtime::{RuntimesCache, WasmExecutionMethod, WasmRuntime},
};
use runtime_version::{NativeVersion, RuntimeVersion};
use sp_version::{NativeVersion, RuntimeVersion};
use codec::{Decode, Encode};
use primitives::{NativeOrEncoded, traits::{CodeExecutor, Externalities}};
use sp_core::{NativeOrEncoded, traits::{CodeExecutor, Externalities}};
use log::trace;
use std::{result, cell::RefCell, panic::{UnwindSafe, AssertUnwindSafe}};
use wasm_interface::{HostFunctions, Function};
use sp_wasm_interface::{HostFunctions, Function};
thread_local! {
static RUNTIMES_CACHE: RefCell<RuntimesCache> = RefCell::new(RuntimesCache::new());
@@ -43,7 +43,7 @@ pub(crate) 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();
let _guard = sp_panic_handler::AbortGuard::force_unwind();
std::panic::catch_unwind(f).map_err(|_| Error::Runtime)
}
@@ -53,7 +53,7 @@ pub(crate) fn safe_call<F, U>(f: F) -> Result<U>
pub fn with_native_environment<F, U>(ext: &mut dyn Externalities, f: F) -> Result<U>
where F: UnwindSafe + FnOnce() -> U
{
externalities::set_and_run_with_externalities(ext, move || safe_call(f))
sp_externalities::set_and_run_with_externalities(ext, move || safe_call(f))
}
/// Delegate for dispatching a CodeExecutor call.
@@ -267,8 +267,8 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
/// ```
/// sc_executor::native_executor_instance!(
/// pub MyExecutor,
/// test_runtime::api::dispatch,
/// test_runtime::native_version,
/// substrate_test_runtime::api::dispatch,
/// substrate_test_runtime::native_version,
/// );
/// ```
///
@@ -278,7 +278,7 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
/// executor aware of the host functions for these interfaces.
///
/// ```
/// # use runtime_interface::runtime_interface;
/// # use sp_runtime_interface::runtime_interface;
///
/// #[runtime_interface]
/// trait MyInterface {
@@ -289,8 +289,8 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
///
/// sc_executor::native_executor_instance!(
/// pub MyExecutor,
/// test_runtime::api::dispatch,
/// test_runtime::native_version,
/// substrate_test_runtime::api::dispatch,
/// substrate_test_runtime::native_version,
/// my_interface::HostFunctions,
/// );
/// ```
@@ -337,7 +337,7 @@ macro_rules! native_executor_instance {
#[cfg(test)]
mod tests {
use super::*;
use runtime_interface::runtime_interface;
use sp_runtime_interface::runtime_interface;
#[runtime_interface]
trait MyInterface {
@@ -348,8 +348,8 @@ mod tests {
native_executor_instance!(
pub MyExecutor,
test_runtime::api::dispatch,
test_runtime::native_version,
substrate_test_runtime::api::dispatch,
substrate_test_runtime::native_version,
(my_interface::HostFunctions, my_interface::HostFunctions),
);
+2 -2
View File
@@ -21,12 +21,12 @@
use crate::error::{Result, Error};
use std::{collections::HashMap, rc::Rc};
use codec::{Decode, Encode};
use primitives::sandbox as sandbox_primitives;
use sp_core::sandbox as sandbox_primitives;
use wasmi::{
Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance,
ModuleRef, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages,
};
use wasm_interface::{Pointer, WordSize};
use sp_wasm_interface::{Pointer, WordSize};
/// Index of a function inside the supervisor.
///
@@ -26,12 +26,12 @@ use log::{trace, warn};
use codec::Decode;
use primitives::{storage::well_known_keys, traits::Externalities};
use sp_core::{storage::well_known_keys, traits::Externalities};
use runtime_version::RuntimeVersion;
use sp_version::RuntimeVersion;
use std::{collections::hash_map::{Entry, HashMap}, panic::AssertUnwindSafe};
use wasm_interface::Function;
use sp_wasm_interface::Function;
/// The Substrate Wasm runtime.
pub trait WasmRuntime {
@@ -259,7 +259,7 @@ fn create_versioned_wasm_runtime<E: Externalities>(
#[cfg(test)]
mod tests {
use wasm_interface::HostFunctions;
use sp_wasm_interface::HostFunctions;
#[test]
fn host_functions_are_equal() {
+15 -15
View File
@@ -16,28 +16,28 @@
//! Utilities for defining the wasm host environment.
use wasm_interface::{Pointer, WordSize};
use sp_wasm_interface::{Pointer, WordSize};
/// Converts arguments into respective WASM types.
#[macro_export]
macro_rules! convert_args {
() => ([]);
( $( $t:ty ),* ) => ( [ $( <$t as $crate::wasm_interface::IntoValue>::VALUE_TYPE, )* ] );
( $( $t:ty ),* ) => ( [ $( <$t as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE, )* ] );
}
/// Generates a WASM signature for given list of parameters.
#[macro_export]
macro_rules! gen_signature {
( ( $( $params: ty ),* ) ) => (
$crate::wasm_interface::Signature {
$crate::sp_wasm_interface::Signature {
args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]),
return_value: None,
}
);
( ( $( $params: ty ),* ) -> $returns:ty ) => (
$crate::wasm_interface::Signature {
$crate::sp_wasm_interface::Signature {
args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]),
return_value: Some(<$returns as $crate::wasm_interface::IntoValue>::VALUE_TYPE),
return_value: Some(<$returns as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE),
}
);
}
@@ -63,18 +63,18 @@ macro_rules! gen_functions {
struct $name;
#[allow(unused)]
impl $crate::wasm_interface::Function for $name {
impl $crate::sp_wasm_interface::Function for $name {
fn name(&self) -> &str {
stringify!($name)
}
fn signature(&self) -> $crate::wasm_interface::Signature {
fn signature(&self) -> $crate::sp_wasm_interface::Signature {
gen_signature!( ( $( $params ),* ) $( -> $returns )? )
}
fn execute(
&self,
context: &mut dyn $crate::wasm_interface::FunctionContext,
args: &mut dyn Iterator<Item=$crate::wasm_interface::Value>,
) -> ::std::result::Result<Option<$crate::wasm_interface::Value>, String> {
context: &mut dyn $crate::sp_wasm_interface::FunctionContext,
args: &mut dyn Iterator<Item=$crate::sp_wasm_interface::Value>,
) -> ::std::result::Result<Option<$crate::sp_wasm_interface::Value>, String> {
let mut $context = context;
marshall! {
args,
@@ -83,7 +83,7 @@ macro_rules! gen_functions {
}
}
&$name as &dyn $crate::wasm_interface::Function
&$name as &dyn $crate::sp_wasm_interface::Function
},
}
$context,
@@ -103,7 +103,7 @@ macro_rules! unmarshall_args {
$(
let $names : $params =
$args_iter.next()
.and_then(|val| <$params as $crate::wasm_interface::TryFromValue>::try_from_value(val))
.and_then(|val| <$params as $crate::sp_wasm_interface::TryFromValue>::try_from_value(val))
.expect(
"`$args_iter` comes from an argument of Externals::execute_function;
args to an external call always matches the signature of the external;
@@ -140,7 +140,7 @@ macro_rules! marshall {
unmarshall_args!($body, $args_iter, $( $names : $params ),*)
});
let r = body()?;
return Ok(Some($crate::wasm_interface::IntoValue::into_value(r)))
return Ok(Some($crate::sp_wasm_interface::IntoValue::into_value(r)))
});
( $args_iter:ident, ( $( $names:ident : $params:ty ),* ) => $body:tt ) => ({
let body = $crate::wasm_utils::constrain_closure::<(), _>(|| {
@@ -162,9 +162,9 @@ macro_rules! impl_wasm_host_interface {
)*
}
) => (
impl $crate::wasm_interface::HostFunctions for $interface_name {
impl $crate::sp_wasm_interface::HostFunctions for $interface_name {
#[allow(non_camel_case_types)]
fn host_functions() -> Vec<&'static dyn $crate::wasm_interface::Function> {
fn host_functions() -> Vec<&'static dyn $crate::sp_wasm_interface::Function> {
gen_functions!(
$context,
$( $name( $( $names: $params ),* ) $( -> $returns )? { $( $body )* } )*
@@ -23,14 +23,14 @@ use wasmi::{
};
use crate::error::{Error, WasmError};
use codec::{Encode, Decode};
use primitives::{sandbox as sandbox_primitives, traits::Externalities};
use sp_core::{sandbox as sandbox_primitives, traits::Externalities};
use crate::sandbox;
use crate::allocator;
use crate::wasm_utils::interpret_runtime_api_result;
use crate::wasm_runtime::WasmRuntime;
use log::{error, trace};
use parity_wasm::elements::{deserialize_buffer, DataSegment, Instruction, Module as RawModule};
use wasm_interface::{
use sp_wasm_interface::{
FunctionContext, Pointer, WordSize, Sandbox, MemoryId, Result as WResult, Function,
};
@@ -273,7 +273,7 @@ impl<'a> wasmi::ModuleImportResolver for Resolver<'a> {
fn resolve_func(&self, name: &str, signature: &wasmi::Signature)
-> std::result::Result<wasmi::FuncRef, wasmi::Error>
{
let signature = wasm_interface::Signature::from(signature);
let signature = sp_wasm_interface::Signature::from(signature);
for (function_index, function) in self.0.iter().enumerate() {
if name == function.name() {
if signature == function.signature() {
@@ -364,7 +364,7 @@ fn call_in_wasm_module(
let offset = fec.allocate_memory(data.len() as u32)?;
fec.write_memory(offset, data)?;
let result = externalities::set_and_run_with_externalities(
let result = sp_externalities::set_and_run_with_externalities(
ext,
|| module_instance.invoke_export(
method,
@@ -25,12 +25,12 @@ use codec::{Decode, Encode};
use cranelift_codegen::ir;
use cranelift_codegen::isa::TargetFrontendConfig;
use log::trace;
use primitives::sandbox as sandbox_primitives;
use sp_core::sandbox as sandbox_primitives;
use std::{cmp, mem, ptr};
use wasmtime_environ::translate_signature;
use wasmtime_jit::{ActionError, Compiler};
use wasmtime_runtime::{Export, VMCallerCheckedAnyfunc, VMContext, wasmtime_call_trampoline};
use wasm_interface::{
use sp_wasm_interface::{
FunctionContext, MemoryId, Pointer, Result as WResult, Sandbox, Signature, Value, ValueType,
WordSize,
};
@@ -33,7 +33,7 @@ use std::cell::RefCell;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::rc::Rc;
use wasm_interface::{Pointer, WordSize, Function};
use sp_wasm_interface::{Pointer, WordSize, Function};
use wasmtime_environ::{Module, translate_signature};
use wasmtime_jit::{
ActionOutcome, ActionError, CodeMemory, CompilationStrategy, CompiledModule, Compiler, Context,
@@ -175,7 +175,7 @@ fn call_method(
let args = [RuntimeValue::I32(u32::from(data_ptr) as i32), RuntimeValue::I32(data_len as i32)];
// Invoke the function in the runtime.
let outcome = externalities::set_and_run_with_externalities(ext, || {
let outcome = sp_externalities::set_and_run_with_externalities(ext, || {
context
.invoke(&mut instance, method, &args[..])
.map_err(Error::Wasmtime)
@@ -26,7 +26,7 @@ use cranelift_codegen::print_errors::pretty_error;
use wasmtime_jit::{CodeMemory, Compiler};
use wasmtime_environ::CompiledFunction;
use wasmtime_runtime::{VMContext, VMFunctionBody};
use wasm_interface::{Function, Value, ValueType};
use sp_wasm_interface::{Function, Value, ValueType};
use std::{cmp, panic::{self, AssertUnwindSafe}, ptr};
use crate::error::{Error, WasmError};
@@ -18,7 +18,7 @@ use crate::error::{Error, Result};
use cranelift_codegen::{ir, isa};
use std::ops::Range;
use wasm_interface::{Pointer, Signature, ValueType};
use sp_wasm_interface::{Pointer, Signature, ValueType};
/// Read data from a slice of memory into a destination buffer.
///