From ecfb6dc92862213bab56e5b5462a5f2bc054b2c4 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 6 May 2020 17:57:21 +0700 Subject: [PATCH 01/88] Add comments and refactor Sandbox module --- client/executor/common/src/sandbox.rs | 49 ++++++++++++++++++--------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index b2c35b7582718..42127bd81e3bd 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -46,33 +46,44 @@ impl From for usize { /// Index of a function within guest index space. /// -/// This index is supposed to be used with as index for `Externals`. +/// This index is supposed to be used as index for `Externals`. #[derive(Copy, Clone, Debug, PartialEq)] struct GuestFuncIndex(usize); /// This struct holds a mapping from guest index space to supervisor. struct GuestToSupervisorFunctionMapping { + /// Position of elements in this vector are interpreted + /// as indices of guest functions and are mappeed to + /// corresponding supervisor function indices. funcs: Vec, } impl GuestToSupervisorFunctionMapping { + /// Create an empty function mapping fn new() -> GuestToSupervisorFunctionMapping { GuestToSupervisorFunctionMapping { funcs: Vec::new() } } + /// Add a new supervisor function to the mapping. + /// Returns a newly assigned guest function index. fn define(&mut self, supervisor_func: SupervisorFuncIndex) -> GuestFuncIndex { let idx = self.funcs.len(); self.funcs.push(supervisor_func); GuestFuncIndex(idx) } + /// Find supervisor function index by its corresponding guest function index fn func_by_guest_index(&self, guest_func_idx: GuestFuncIndex) -> Option { self.funcs.get(guest_func_idx.0).cloned() } } +/// Holds sandbox function and memory imports and performs name resolution struct Imports { + /// Maps qualified function name to its guest function index func_map: HashMap<(Vec, Vec), GuestFuncIndex>, + + /// Maps qualified field name to its memory reference memories_map: HashMap<(Vec, Vec), MemoryRef>, } @@ -148,6 +159,7 @@ impl ImportResolver for Imports { /// Note that this functions are only called in the `supervisor` context. pub trait SandboxCapabilities: FunctionContext { /// Represents a function reference into the supervisor environment. + /// Provides an abstraction over execution environment. type SupervisorFuncRef; /// Invoke a function in the supervisor environment. @@ -155,7 +167,7 @@ pub trait SandboxCapabilities: FunctionContext { /// This first invokes the dispatch_thunk function, passing in the function index of the /// desired function to call and serialized arguments. The thunk calls the desired function /// with the deserialized arguments, then serializes the result into memory and returns - /// reference. The pointer to and length of the result in linear memory is encoded into an i64, + /// reference. The pointer to and length of the result in linear memory is encoded into an `i64`, /// with the upper 32 bits representing the pointer and the lower 32 bits representing the /// length. /// @@ -178,15 +190,22 @@ pub trait SandboxCapabilities: FunctionContext { /// /// [`Externals`]: ../wasmi/trait.Externals.html pub struct GuestExternals<'a, FE: SandboxCapabilities + 'a> { + /// Supervisor function environment supervisor_externals: &'a mut FE, + + /// Instance of sandboxed module to be dispatched sandbox_instance: &'a SandboxInstance, + + /// Opaque pointer to outer context, see the `instantiate` function state: u32, } +/// Construct trap error from specified message fn trap(msg: &'static str) -> Trap { TrapKind::Host(Box::new(Error::Other(msg.into()))).into() } +/// Deserialize bytes into `Result` fn deserialize_result(serialized_result: &[u8]) -> std::result::Result, Trap> { use self::sandbox_primitives::HostError; use sp_wasm_interface::ReturnValue; @@ -211,6 +230,7 @@ impl<'a, FE: SandboxCapabilities + 'a> Externals for GuestExternals<'a, FE> { // Make `index` typesafe again. let index = GuestFuncIndex(index); + // Convert function index from guest to supervisor space let func_idx = self.sandbox_instance .guest_to_supervisor_mapping .func_by_guest_index(index) @@ -231,7 +251,7 @@ impl<'a, FE: SandboxCapabilities + 'a> Externals for GuestExternals<'a, FE> { let state = self.state; - // Move serialized arguments inside the memory and invoke dispatch thunk and + // Move serialized arguments inside the memory, invoke dispatch thunk and // then free allocated memory. let invoke_args_len = invoke_args_data.len() as WordSize; let invoke_args_ptr = self @@ -421,7 +441,10 @@ fn decode_environment_definition( /// An environment in which the guest module is instantiated. pub struct GuestEnvironment { + /// Function and memory imports of the guest module imports: Imports, + + /// Supervisor functinons mapped to guest index space guest_to_supervisor_mapping: GuestToSupervisorFunctionMapping, } @@ -462,26 +485,20 @@ impl UnregisteredInstance { /// Instantiate a guest module and return it's index in the store. /// /// The guest module's code is specified in `wasm`. Environment that will be available to -/// guest module is specified in `raw_env_def` (serialized version of [`EnvironmentDefinition`]). -/// `dispatch_thunk` is used as function that handle calls from guests. -/// -/// # Errors -/// -/// Returns `Err` if any of the following conditions happens: -/// -/// - `raw_env_def` can't be deserialized as a [`EnvironmentDefinition`]. -/// - Module in `wasm` is invalid or couldn't be instantiated. +/// guest module is specified in `guest_env`, `dispatch_thunk` is used as function that +/// handle calls from guests. `state` is an opaque pointer to caller's arbitrary context +/// normally created by `sp_sandbox::Instance` primitive. /// -/// [`EnvironmentDefinition`]: ../sandbox/struct.EnvironmentDefinition.html +/// Returns uninitialized sandboxed module instance or an instantiation error. pub fn instantiate<'a, FE: SandboxCapabilities>( supervisor_externals: &mut FE, dispatch_thunk: FE::SupervisorFuncRef, wasm: &[u8], - host_env: GuestEnvironment, + guest_env: GuestEnvironment, state: u32, ) -> std::result::Result, InstantiationError> { let module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - let instance = ModuleInstance::new(&module, &host_env.imports) + let instance = ModuleInstance::new(&module, &guest_env.imports) .map_err(|_| InstantiationError::Instantiation)?; let sandbox_instance = Rc::new(SandboxInstance { @@ -490,7 +507,7 @@ pub fn instantiate<'a, FE: SandboxCapabilities>( // for the purpose of running `start` function which should be ok. instance: instance.not_started_instance().clone(), dispatch_thunk, - guest_to_supervisor_mapping: host_env.guest_to_supervisor_mapping, + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, }); with_guest_externals( From ac137b2d994e5c410e17c472d680bfd41cd602f0 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 25 May 2020 13:40:46 +0700 Subject: [PATCH 02/88] Adds some comments --- client/executor/common/src/sandbox.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 42127bd81e3bd..4c66a44485439 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -354,9 +354,17 @@ impl SandboxInstance { /// these syscall implementations. pub fn invoke>( &self, + + /// function to call that is exported from the module export_name: &str, + + /// arguments passed to the function args: &[RuntimeValue], + + /// supervisor environment provided to the module supervisor_externals: &mut FE, + + /// arbitraty context data of the call state: u32, ) -> std::result::Result, wasmi::Error> { with_guest_externals( @@ -364,6 +372,8 @@ impl SandboxInstance { self, state, |guest_externals| { + + // This is in Wasmi already! self.instance .invoke_export(export_name, args, guest_externals) }, From 063bf429b6e892ef44c4f7895695a0636c43a87a Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 9 Jun 2020 18:09:39 +0700 Subject: [PATCH 03/88] Add wasmtime instance to the sandbox and delegate calls --- Cargo.lock | 1 + client/executor/common/Cargo.toml | 1 + client/executor/common/src/sandbox.rs | 96 ++++++++++++++++--- .../executor/wasmtime/src/instance_wrapper.rs | 21 ++-- 4 files changed, 99 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86744c2537bfe..a7e235126d495 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6302,6 +6302,7 @@ dependencies = [ "sp-runtime-interface", "sp-serializer", "sp-wasm-interface", + "substrate-wasmtime", "wasmi", ] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index e9d2586e365b8..21d6da1b486c1 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -23,6 +23,7 @@ sp-allocator = { version = "2.0.0-rc3", path = "../../../primitives/allocator" } sp-wasm-interface = { version = "2.0.0-rc3", path = "../../../primitives/wasm-interface" } sp-runtime-interface = { version = "2.0.0-rc3", path = "../../../primitives/runtime-interface" } sp-serializer = { version = "2.0.0-rc3", path = "../../../primitives/serializer" } +wasmtime = { package = "substrate-wasmtime", version = "0.16.0-threadsafe.4" } [features] default = [] diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 4c66a44485439..0b4208217774b 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -25,10 +25,19 @@ use crate::error::{Result, Error}; use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; + use wasmi::{ Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages, }; + +use sp_wasm_interface::Value; +use wasmtime::Val; + +// use crate::sandbox:: wasmtime::instance_wrapper::InstanceWrapper; + +// use wasmtime::{Store, Instance, Module, Memory, Table, Val, Func, Extern, Global}; + use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; /// Index of a function inside the supervisor. @@ -339,7 +348,8 @@ where /// /// [`invoke`]: #method.invoke pub struct SandboxInstance { - instance: ModuleRef, + wasmi_instance: ModuleRef, + wasmtime_instance: wasmtime::Instance, dispatch_thunk: FR, guest_to_supervisor_mapping: GuestToSupervisorFunctionMapping, } @@ -355,16 +365,16 @@ impl SandboxInstance { pub fn invoke>( &self, - /// function to call that is exported from the module + // function to call that is exported from the module export_name: &str, - /// arguments passed to the function + // arguments passed to the function args: &[RuntimeValue], - /// supervisor environment provided to the module + // supervisor environment provided to the module supervisor_externals: &mut FE, - /// arbitraty context data of the call + // arbitraty context data of the call state: u32, ) -> std::result::Result, wasmi::Error> { with_guest_externals( @@ -373,9 +383,42 @@ impl SandboxInstance { state, |guest_externals| { - // This is in Wasmi already! - self.instance - .invoke_export(export_name, args, guest_externals) + let wasmi_result = self.wasmi_instance + .invoke_export(export_name, args, guest_externals)?; + + let wasmtime_function = self + .wasmtime_instance + .get_func(export_name) + .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; + + let args: Vec = args + .iter() + .map(|v| match *v { + RuntimeValue::I32(val) => Val::I32(val), + RuntimeValue::I64(val) => Val::I64(val), + RuntimeValue::F32(val) => Val::F32(val.into()), + RuntimeValue::F64(val) => Val::F64(val.into()), + }) + .collect(); + + let wasmtime_result = wasmtime_function + .call(&args) + .map_err(|e| wasmi::Error::Function(e.to_string()))?; + + assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); + if let Some(wasmi_value) = wasmi_result { + let wasmtime_value = match *wasmtime_result.first().unwrap() { + Val::I32(val) => RuntimeValue::I32(val), + Val::I64(val) => RuntimeValue::I64(val), + Val::F32(val) => RuntimeValue::F32(val.into()), + Val::F64(val) => RuntimeValue::F64(val.into()), + _ => unreachable!(), + }; + + assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); + } + + Ok(wasmi_result) }, ) } @@ -384,12 +427,24 @@ impl SandboxInstance { /// /// Returns `Some(_)` if the global could be found. pub fn get_global_val(&self, name: &str) -> Option { - let global = self.instance + let wasmi_global = self.wasmi_instance .export_by_name(name)? .as_global()? .get(); + let wasmi_value = wasmi_global.into(); + + let wasmtime_global = self.wasmtime_instance.get_global(name)?.get(); + let wasmtime_value = match wasmtime_global { + Val::I32(val) => Value::I32(val), + Val::I64(val) => Value::I64(val), + Val::F32(val) => Value::F32(val), + Val::F64(val) => Value::F64(val), + _ => None?, + }; - Some(global.into()) + assert_eq!(wasmi_value, wasmtime_value); + + Some(wasmi_value) } } @@ -507,15 +562,28 @@ pub fn instantiate<'a, FE: SandboxCapabilities>( guest_env: GuestEnvironment, state: u32, ) -> std::result::Result, InstantiationError> { - let module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - let instance = ModuleInstance::new(&module, &guest_env.imports) + let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) .map_err(|_| InstantiationError::Instantiation)?; + let mut config = wasmtime::Config::new(); + config.cranelift_opt_level(wasmtime::OptLevel::Speed); + config.strategy(wasmtime::Strategy::Lightbeam).map_err(|_| InstantiationError::ModuleDecoding)?; + + let wasmtime_engine = wasmtime::Engine::new(&config); + let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); + + let wasmtime_module = wasmtime::Module::new(&wasmtime_store, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + + // TODO &guest_env.imports); + let wasmtime_instance = wasmtime::Instance::new(&wasmtime_module, &[]).map_err(|_| InstantiationError::Instantiation)?; + let sandbox_instance = Rc::new(SandboxInstance { // In general, it's not a very good idea to use `.not_started_instance()` for anything // but for extracting memory and tables. But in this particular case, we are extracting // for the purpose of running `start` function which should be ok. - instance: instance.not_started_instance().clone(), + wasmi_instance: wasmi_instance.not_started_instance().clone(), + wasmtime_instance, dispatch_thunk, guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, }); @@ -525,7 +593,7 @@ pub fn instantiate<'a, FE: SandboxCapabilities>( &sandbox_instance, state, |guest_externals| { - instance + wasmi_instance .run_start(guest_externals) .map_err(|_| InstantiationError::StartTrapped) }, diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index 9026b8054e652..b4ce62d86c472 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -77,15 +77,24 @@ impl ModuleWrapper { /// This struct is a handy wrapper around a wasmtime `Instance` that provides substrate specific /// routines. pub struct InstanceWrapper { + /// Instantiated WebAssembly module instance: Instance, + + /// Number of globals declared by WebAssembly module globals_count: u32, + + /// Number of globals imported by a WebAssembly module imported_globals_count: u32, + // The memory instance of the `instance`. // // It is important to make sure that we don't make any copies of this to make it easier to proof // See `memory_as_slice` and `memory_as_slice_mut`. memory: Memory, + + /// Indirect functions table of the module table: Option, + // Make this struct explicitly !Send & !Sync. _not_send_nor_sync: marker::PhantomData<*const ()>, } @@ -134,7 +143,7 @@ impl InstanceWrapper { None => { let memory = get_linear_memory(&instance)?; if !memory.grow(heap_pages).is_ok() { - return Err("failed top increase the linear memory size".into()); + return Err("failed to increase the linear memory size".into()); } memory }, @@ -250,13 +259,13 @@ impl InstanceWrapper { /// Read data from a slice of memory into a destination buffer. /// /// Returns an error if the read would go out of the memory bounds. - pub fn read_memory_into(&self, address: Pointer, dest: &mut [u8]) -> Result<()> { + pub fn read_memory_into(&self, source_addr: Pointer, dest: &mut [u8]) -> Result<()> { unsafe { // This should be safe since we don't grow up memory while caching this reference and // we give up the reference before returning from this function. let memory = self.memory_as_slice(); - let range = util::checked_range(address.into(), dest.len(), memory.len()) + let range = util::checked_range(source_addr.into(), dest.len(), memory.len()) .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; dest.copy_from_slice(&memory[range]); Ok(()) @@ -266,15 +275,15 @@ impl InstanceWrapper { /// Write data to a slice of memory. /// /// Returns an error if the write would go out of the memory bounds. - pub fn write_memory_from(&self, address: Pointer, data: &[u8]) -> Result<()> { + pub fn write_memory_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { unsafe { // This should be safe since we don't grow up memory while caching this reference and // we give up the reference before returning from this function. let memory = self.memory_as_slice_mut(); - let range = util::checked_range(address.into(), data.len(), memory.len()) + let range = util::checked_range(dest_addr.into(), source.len(), memory.len()) .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; - &mut memory[range].copy_from_slice(data); + &mut memory[range].copy_from_slice(source); Ok(()) } } From 1be139b24ad29b1e7e28c11109ade3c2c1aaa7a6 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 19 Jun 2020 12:32:36 +0700 Subject: [PATCH 04/88] Adds module imports stub --- client/executor/common/src/sandbox.rs | 22 ++++++++++++++++++++-- client/executor/wasmtime/src/runtime.rs | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 0b4208217774b..490465da83659 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -575,8 +575,24 @@ pub fn instantiate<'a, FE: SandboxCapabilities>( let wasmtime_module = wasmtime::Module::new(&wasmtime_store, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - // TODO &guest_env.imports); - let wasmtime_instance = wasmtime::Instance::new(&wasmtime_module, &[]).map_err(|_| InstantiationError::Instantiation)?; + let module_imports: Vec<_> = wasmtime_module + .imports() + .filter_map(|import| { + if let wasmtime::ExternType::Func(func_ty) = import.ty() { + Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, + move |_, _, _| Err(wasmtime::Trap::new(format!( + "Sandbox function stub", + // func_ty.to_string(), + // func_ty.name().to_string() + ))) + ))) + } else { + None + } + }) + .collect(); + + let wasmtime_instance = wasmtime::Instance::new(&wasmtime_module, &module_imports).map_err(|_| InstantiationError::Instantiation)?; let sandbox_instance = Rc::new(SandboxInstance { // In general, it's not a very good idea to use `.not_started_instance()` for anything @@ -596,6 +612,8 @@ pub fn instantiate<'a, FE: SandboxCapabilities>( wasmi_instance .run_start(guest_externals) .map_err(|_| InstantiationError::StartTrapped) + + // Note: no need to run start on wasmtime instance, since it's done automatically }, )?; diff --git a/client/executor/wasmtime/src/runtime.rs b/client/executor/wasmtime/src/runtime.rs index a2ad3bada4ba0..7adbaeaefed2b 100644 --- a/client/executor/wasmtime/src/runtime.rs +++ b/client/executor/wasmtime/src/runtime.rs @@ -80,7 +80,7 @@ pub struct WasmtimeInstance { } // This is safe because `WasmtimeInstance` does not leak reference to `self.imports` -// and all imports don't reference any anything, other than host functions and memory +// and all imports don't reference anything, other than host functions and memory unsafe impl Send for WasmtimeInstance {} impl WasmInstance for WasmtimeInstance { From 4e770b4f3b72a84b5d0900d57cebeee26c77598c Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 13 Jul 2020 23:57:52 +0700 Subject: [PATCH 05/88] WIP state holder via *mut --- client/executor/common/src/sandbox.rs | 154 +++++++++++++++----------- client/executor/wasmi/src/lib.rs | 20 +++- client/executor/wasmtime/src/host.rs | 48 +++++++- 3 files changed, 154 insertions(+), 68 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 490465da83659..2e589217f7922 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -362,7 +362,9 @@ impl SandboxInstance { /// /// The `state` parameter can be used to provide custom data for /// these syscall implementations. - pub fn invoke>( + pub fn invoke + //> + ( &self, // function to call that is exported from the module @@ -372,55 +374,58 @@ impl SandboxInstance { args: &[RuntimeValue], // supervisor environment provided to the module - supervisor_externals: &mut FE, + // supervisor_externals: &mut FE, // arbitraty context data of the call state: u32, ) -> std::result::Result, wasmi::Error> { - with_guest_externals( - supervisor_externals, - self, - state, - |guest_externals| { - let wasmi_result = self.wasmi_instance - .invoke_export(export_name, args, guest_externals)?; - - let wasmtime_function = self - .wasmtime_instance - .get_func(export_name) - .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; - - let args: Vec = args - .iter() - .map(|v| match *v { - RuntimeValue::I32(val) => Val::I32(val), - RuntimeValue::I64(val) => Val::I64(val), - RuntimeValue::F32(val) => Val::F32(val.into()), - RuntimeValue::F64(val) => Val::F64(val.into()), - }) - .collect(); - - let wasmtime_result = wasmtime_function - .call(&args) - .map_err(|e| wasmi::Error::Function(e.to_string()))?; - - assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); - if let Some(wasmi_value) = wasmi_result { - let wasmtime_value = match *wasmtime_result.first().unwrap() { - Val::I32(val) => RuntimeValue::I32(val), - Val::I64(val) => RuntimeValue::I64(val), - Val::F32(val) => RuntimeValue::F32(val.into()), - Val::F64(val) => RuntimeValue::F64(val.into()), - _ => unreachable!(), - }; - - assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); - } - - Ok(wasmi_result) - }, - ) + SCH::with_sandbox_capabilities( |supervisor_externals| { + with_guest_externals( + supervisor_externals, + self, + state, + |guest_externals| { + + let wasmi_result = self.wasmi_instance + .invoke_export(export_name, args, guest_externals)?; + + let wasmtime_function = self + .wasmtime_instance + .get_func(export_name) + .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; + + let args: Vec = args + .iter() + .map(|v| match *v { + RuntimeValue::I32(val) => Val::I32(val), + RuntimeValue::I64(val) => Val::I64(val), + RuntimeValue::F32(val) => Val::F32(val.into()), + RuntimeValue::F64(val) => Val::F64(val.into()), + }) + .collect(); + + let wasmtime_result = wasmtime_function + .call(&args) + .map_err(|e| wasmi::Error::Function(e.to_string()))?; + + assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); + if let Some(wasmi_value) = wasmi_result { + let wasmtime_value = match *wasmtime_result.first().unwrap() { + Val::I32(val) => RuntimeValue::I32(val), + Val::I64(val) => RuntimeValue::I64(val), + Val::F32(val) => RuntimeValue::F32(val.into()), + Val::F64(val) => RuntimeValue::F64(val.into()), + _ => unreachable!(), + }; + + assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); + } + + Ok(wasmi_result) + }, + ) + }) } /// Get the value from a global with the given `name`. @@ -547,6 +552,13 @@ impl UnregisteredInstance { } } +pub trait SandboxCapabiliesHolder<'a> { + type SupervisorFuncRef; + type SC: SandboxCapabilities + 'a; + + fn with_sandbox_capabilities R>(f: F) -> R; +} + /// Instantiate a guest module and return it's index in the store. /// /// The guest module's code is specified in `wasm`. Environment that will be available to @@ -555,13 +567,17 @@ impl UnregisteredInstance { /// normally created by `sp_sandbox::Instance` primitive. /// /// Returns uninitialized sandboxed module instance or an instantiation error. -pub fn instantiate<'a, FE: SandboxCapabilities>( - supervisor_externals: &mut FE, +pub fn instantiate<'a, FE, SCH>( + // supervisor_externals: &mut FE, dispatch_thunk: FE::SupervisorFuncRef, wasm: &[u8], guest_env: GuestEnvironment, state: u32, -) -> std::result::Result, InstantiationError> { +) -> std::result::Result, InstantiationError> +where + FE: SandboxCapabilities + 'a, + SCH: SandboxCapabiliesHolder<'a, SupervisorFuncRef = FE::SupervisorFuncRef, SC = FE>, +{ let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) .map_err(|_| InstantiationError::Instantiation)?; @@ -580,11 +596,19 @@ pub fn instantiate<'a, FE: SandboxCapabilities>( .filter_map(|import| { if let wasmtime::ExternType::Func(func_ty) = import.ty() { Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, - move |_, _, _| Err(wasmtime::Trap::new(format!( - "Sandbox function stub", - // func_ty.to_string(), - // func_ty.name().to_string() - ))) + move |_, _, _| { + SCH::with_sandbox_capabilities(|sc| { + // sc.invoke(); + }); + + Ok(()) + } + + // Err(wasmtime::Trap::new(format!( + // "Sandbox function stub", + // // func_ty.to_string(), + // // func_ty.name().to_string() + // ))) ))) } else { None @@ -604,18 +628,20 @@ pub fn instantiate<'a, FE: SandboxCapabilities>( guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, }); - with_guest_externals( - supervisor_externals, - &sandbox_instance, - state, - |guest_externals| { - wasmi_instance - .run_start(guest_externals) - .map_err(|_| InstantiationError::StartTrapped) + SCH::with_sandbox_capabilities( |supervisor_externals| { + with_guest_externals( + supervisor_externals, + &sandbox_instance, + state, + |guest_externals| { + wasmi_instance + .run_start(guest_externals) + .map_err(|_| InstantiationError::StartTrapped) - // Note: no need to run start on wasmtime instance, since it's done automatically - }, - )?; + // Note: no need to run start on wasmtime instance, since it's done automatically + }, + ) + })?; Ok(UnregisteredInstance { sandbox_instance }) } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index e4b4aca40967d..23001be351ab0 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -198,7 +198,7 @@ impl<'a> Sandbox for FunctionExecutor<'a> { .collect::>(); let instance = self.sandbox_store.instance(instance_id).map_err(|e| e.to_string())?; - let result = instance.invoke(export_name, &args, self, state); + let result = instance.invoke(export_name, &args, state); match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -242,8 +242,24 @@ impl<'a> Sandbox for FunctionExecutor<'a> { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; + struct Adapter; + + impl<'a> sandbox::SandboxCapabiliesHolder<'a> for Adapter { + type SupervisorFuncRef = wasmi::FuncRef; + type SC = FunctionExecutor<'static>; + + fn with_sandbox_capabilities R>(f: F) -> R { + todo!(); + + // FOO.with(|fe| { + // let mut fe = fe.borrow_mut(); + // f(fe.deref_mut()) + // }); + } + } + let instance_idx_or_err_code = - match sandbox::instantiate(self, dispatch_thunk, wasm, guest_env, state) + match sandbox::instantiate::<_, Adapter>(dispatch_thunk, wasm, guest_env, state) .map(|i| i.register(&mut self.sandbox_store)) { Ok(instance_idx) => instance_idx, diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 8c481e95c4371..42a1fcacb036d 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -28,6 +28,7 @@ use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; use wasmtime::{Func, Val}; +use sandbox::SandboxCapabiliesHolder; /// Wrapper type for pointer to a Wasm table entry. /// @@ -75,6 +76,36 @@ impl HostState { /// a longer-living `HostState`. pub struct HostContext<'a>(&'a HostState); +scoped_tls::scoped_thread_local!(static HOST_CONTEXT: *mut HostContext<'_>); + +impl<'a> SandboxCapabiliesHolder<'a> for HostContext<'a> { + type SupervisorFuncRef = SupervisorFuncRef; + type SC = HostContext<'static>; + + fn with_sandbox_capabilities R>(f: F) -> R { + use std::ops::DerefMut; + + HOST_CONTEXT.with(|fe| { + // Safe because of a limited scope in which the value exists + let fe = unsafe { &mut **fe }; + + f(fe) + }) + } +} + +impl<'a> HostContext<'a> { + fn set_sandbox_capabilities R>(&mut self, f: F) -> R { + unsafe { + // Erasing lifetime of `HostContext` to put it into scoped TLS. This is safe because + // the pointer will never leave this scope and is semantically equivalent to `&'a mut`. + let self_ptr: *mut HostContext<'static> = std::mem::transmute(self as *mut HostContext<'a>); + + HOST_CONTEXT.set(&self_ptr, f) + } + } +} + impl<'a> std::ops::Deref for HostContext<'a> { type Target = HostState; fn deref(&self) -> &HostState { @@ -262,7 +293,20 @@ impl<'a> Sandbox for HostContext<'a> { .borrow() .instance(instance_id) .map_err(|e| e.to_string())?; - let result = instance.invoke(export_name, &args, self, state); + + let result = self.set_sandbox_capabilities(|| { + instance.invoke(export_name, &args, state) + }); + + // let result = unsafe { + // // Erasing lifetime of `HostContext` to put it into scoped TLS. This is safe because + // // the pointer will never leave this scope and is semantically equivalent to `&'a mut`. + // let self_ptr: *mut HostContext<'static> = std::mem::transmute(self as *mut HostContext<'a>); + + // HOST_CONTEXT.set(&self_ptr, || { + // instance.invoke(export_name, &args, self, state) + // }) + // }; match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -319,7 +363,7 @@ impl<'a> Sandbox for HostContext<'a> { }; let instance_idx_or_err_code = - match sandbox::instantiate(self, dispatch_thunk, wasm, guest_env, state) + match sandbox::instantiate::<_, Self>(dispatch_thunk, wasm, guest_env, state) .map(|i| i.register(&mut *self.sandbox_store.borrow_mut())) { Ok(instance_idx) => instance_idx, From 4cf68d2d16ae12573479c5370c67e0cb324e3063 Mon Sep 17 00:00:00 2001 From: Sergei Shulepov Date: Mon, 13 Jul 2020 20:52:10 +0200 Subject: [PATCH 06/88] My take at the problem --- client/executor/common/src/sandbox.rs | 108 +++++++------- client/executor/wasmi/src/lib.rs | 2 +- client/executor/wasmtime/src/host.rs | 141 ++++++++----------- client/executor/wasmtime/src/state_holder.rs | 8 +- 4 files changed, 120 insertions(+), 139 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 2e589217f7922..e867639111c4f 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -362,9 +362,7 @@ impl SandboxInstance { /// /// The `state` parameter can be used to provide custom data for /// these syscall implementations. - pub fn invoke - //> - ( + pub fn invoke( &self, // function to call that is exported from the module @@ -379,53 +377,53 @@ impl SandboxInstance { // arbitraty context data of the call state: u32, ) -> std::result::Result, wasmi::Error> { - - SCH::with_sandbox_capabilities( |supervisor_externals| { - with_guest_externals( - supervisor_externals, - self, - state, - |guest_externals| { - - let wasmi_result = self.wasmi_instance - .invoke_export(export_name, args, guest_externals)?; - - let wasmtime_function = self - .wasmtime_instance - .get_func(export_name) - .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; - - let args: Vec = args - .iter() - .map(|v| match *v { - RuntimeValue::I32(val) => Val::I32(val), - RuntimeValue::I64(val) => Val::I64(val), - RuntimeValue::F32(val) => Val::F32(val.into()), - RuntimeValue::F64(val) => Val::F64(val.into()), - }) - .collect(); - - let wasmtime_result = wasmtime_function - .call(&args) - .map_err(|e| wasmi::Error::Function(e.to_string()))?; - - assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); - if let Some(wasmi_value) = wasmi_result { - let wasmtime_value = match *wasmtime_result.first().unwrap() { - Val::I32(val) => RuntimeValue::I32(val), - Val::I64(val) => RuntimeValue::I64(val), - Val::F32(val) => RuntimeValue::F32(val.into()), - Val::F64(val) => RuntimeValue::F64(val.into()), - _ => unreachable!(), - }; - - assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); - } - - Ok(wasmi_result) - }, - ) - }) + // SCH::with_sandbox_capabilities( |supervisor_externals| { + // with_guest_externals( + // supervisor_externals, + // self, + // state, + // |guest_externals| { + + // let wasmi_result = self.wasmi_instance + // .invoke_export(export_name, args, guest_externals)?; + + // let wasmtime_function = self + // .wasmtime_instance + // .get_func(export_name) + // .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; + + // let args: Vec = args + // .iter() + // .map(|v| match *v { + // RuntimeValue::I32(val) => Val::I32(val), + // RuntimeValue::I64(val) => Val::I64(val), + // RuntimeValue::F32(val) => Val::F32(val.into()), + // RuntimeValue::F64(val) => Val::F64(val.into()), + // }) + // .collect(); + + // let wasmtime_result = wasmtime_function + // .call(&args) + // .map_err(|e| wasmi::Error::Function(e.to_string()))?; + + // assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); + // if let Some(wasmi_value) = wasmi_result { + // let wasmtime_value = match *wasmtime_result.first().unwrap() { + // Val::I32(val) => RuntimeValue::I32(val), + // Val::I64(val) => RuntimeValue::I64(val), + // Val::F32(val) => RuntimeValue::F32(val.into()), + // Val::F64(val) => RuntimeValue::F64(val.into()), + // _ => unreachable!(), + // }; + + // assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); + // } + + // Ok(wasmi_result) + // }, + // ) + // }) + todo!() } /// Get the value from a global with the given `name`. @@ -552,9 +550,9 @@ impl UnregisteredInstance { } } -pub trait SandboxCapabiliesHolder<'a> { +pub trait SandboxCapabiliesHolder { type SupervisorFuncRef; - type SC: SandboxCapabilities + 'a; + type SC: SandboxCapabilities; fn with_sandbox_capabilities R>(f: F) -> R; } @@ -573,10 +571,10 @@ pub fn instantiate<'a, FE, SCH>( wasm: &[u8], guest_env: GuestEnvironment, state: u32, -) -> std::result::Result, InstantiationError> +) -> std::result::Result, InstantiationError> where FE: SandboxCapabilities + 'a, - SCH: SandboxCapabiliesHolder<'a, SupervisorFuncRef = FE::SupervisorFuncRef, SC = FE>, + SCH: SandboxCapabiliesHolder, { let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) @@ -603,7 +601,7 @@ where Ok(()) } - + // Err(wasmtime::Trap::new(format!( // "Sandbox function stub", // // func_ty.to_string(), diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 23001be351ab0..02b8c7269d30c 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -244,7 +244,7 @@ impl<'a> Sandbox for FunctionExecutor<'a> { struct Adapter; - impl<'a> sandbox::SandboxCapabiliesHolder<'a> for Adapter { + impl sandbox::SandboxCapabiliesHolder for Adapter { type SupervisorFuncRef = wasmi::FuncRef; type SC = FunctionExecutor<'static>; diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 42a1fcacb036d..6febc7e6a43c0 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -40,7 +40,12 @@ pub struct SupervisorFuncRef(Func); /// The state required to construct a HostContext context. The context only lasts for one host /// call, whereas the state is maintained for the duration of a Wasm runtime call, which may make /// many different host calls that must share state. +#[derive(Clone)] pub struct HostState { + inner: Rc, +} + +struct Inner { // We need some interior mutability here since the host state is shared between all host // function handlers and the wasmtime backend's `impl WasmRuntime`. // @@ -59,61 +64,16 @@ impl HostState { /// Constructs a new `HostState`. pub fn new(allocator: FreeingBumpHeapAllocator, instance: Rc) -> Self { HostState { - sandbox_store: RefCell::new(sandbox::Store::new()), - allocator: RefCell::new(allocator), - instance, - } - } - - /// Materialize `HostContext` that can be used to invoke a substrate host `dyn Function`. - pub fn materialize<'a>(&'a self) -> HostContext<'a> { - HostContext(self) - } -} - -/// A `HostContext` implements `FunctionContext` for making host calls from a Wasmtime -/// runtime. The `HostContext` exists only for the lifetime of the call and borrows state from -/// a longer-living `HostState`. -pub struct HostContext<'a>(&'a HostState); - -scoped_tls::scoped_thread_local!(static HOST_CONTEXT: *mut HostContext<'_>); - -impl<'a> SandboxCapabiliesHolder<'a> for HostContext<'a> { - type SupervisorFuncRef = SupervisorFuncRef; - type SC = HostContext<'static>; - - fn with_sandbox_capabilities R>(f: F) -> R { - use std::ops::DerefMut; - - HOST_CONTEXT.with(|fe| { - // Safe because of a limited scope in which the value exists - let fe = unsafe { &mut **fe }; - - f(fe) - }) - } -} - -impl<'a> HostContext<'a> { - fn set_sandbox_capabilities R>(&mut self, f: F) -> R { - unsafe { - // Erasing lifetime of `HostContext` to put it into scoped TLS. This is safe because - // the pointer will never leave this scope and is semantically equivalent to `&'a mut`. - let self_ptr: *mut HostContext<'static> = std::mem::transmute(self as *mut HostContext<'a>); - - HOST_CONTEXT.set(&self_ptr, f) + inner: Rc::new(Inner { + sandbox_store: RefCell::new(sandbox::Store::new()), + allocator: RefCell::new(allocator), + instance, + }) } } } -impl<'a> std::ops::Deref for HostContext<'a> { - type Target = HostState; - fn deref(&self) -> &HostState { - self.0 - } -} - -impl<'a> SandboxCapabilities for HostContext<'a> { +impl SandboxCapabilities for HostState { type SupervisorFuncRef = SupervisorFuncRef; fn invoke( @@ -153,32 +113,36 @@ impl<'a> SandboxCapabilities for HostContext<'a> { } } -impl<'a> sp_wasm_interface::FunctionContext for HostContext<'a> { +impl sp_wasm_interface::FunctionContext for HostState { fn read_memory_into( &self, address: Pointer, dest: &mut [u8], ) -> sp_wasm_interface::Result<()> { - self.instance + self.inner + .instance .read_memory_into(address, dest) .map_err(|e| e.to_string()) } fn write_memory(&mut self, address: Pointer, data: &[u8]) -> sp_wasm_interface::Result<()> { - self.instance + self.inner + .instance .write_memory_from(address, data) .map_err(|e| e.to_string()) } fn allocate_memory(&mut self, size: WordSize) -> sp_wasm_interface::Result> { - self.instance - .allocate(&mut *self.allocator.borrow_mut(), size) + self.inner + .instance + .allocate(&mut *self.inner.allocator.borrow_mut(), size) .map_err(|e| e.to_string()) } fn deallocate_memory(&mut self, ptr: Pointer) -> sp_wasm_interface::Result<()> { - self.instance - .deallocate(&mut *self.allocator.borrow_mut(), ptr) + self.inner + .instance + .deallocate(&mut *self.inner.allocator.borrow_mut(), ptr) .map_err(|e| e.to_string()) } @@ -187,7 +151,7 @@ impl<'a> sp_wasm_interface::FunctionContext for HostContext<'a> { } } -impl<'a> Sandbox for HostContext<'a> { +impl Sandbox for HostState { fn memory_get( &mut self, memory_id: MemoryId, @@ -196,6 +160,7 @@ impl<'a> Sandbox for HostContext<'a> { buf_len: WordSize, ) -> sp_wasm_interface::Result { let sandboxed_memory = self + .inner .sandbox_store .borrow() .memory(memory_id) @@ -207,12 +172,12 @@ impl<'a> Sandbox for HostContext<'a> { Some(range) => range, None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - let supervisor_mem_size = self.instance.memory_size() as usize; + let supervisor_mem_size = self.inner.instance.memory_size() as usize; let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { Some(range) => range, None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - self.instance + self.inner.instance .write_memory_from( Pointer::new(dst_range.start as u32), &sandboxed_memory[src_range], @@ -229,14 +194,14 @@ impl<'a> Sandbox for HostContext<'a> { val_ptr: Pointer, val_len: WordSize, ) -> sp_wasm_interface::Result { - let sandboxed_memory = self + let sandboxed_memory = self.inner .sandbox_store .borrow() .memory(memory_id) .map_err(|e| e.to_string())?; sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { let len = val_len as usize; - let supervisor_mem_size = self.instance.memory_size() as usize; + let supervisor_mem_size = self.inner.instance.memory_size() as usize; let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { Some(range) => range, None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), @@ -246,7 +211,7 @@ impl<'a> Sandbox for HostContext<'a> { Some(range) => range, None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - self.instance + self.inner.instance .read_memory_into( Pointer::new(src_range.start as u32), &mut sandboxed_memory[dst_range], @@ -257,14 +222,16 @@ impl<'a> Sandbox for HostContext<'a> { } fn memory_teardown(&mut self, memory_id: MemoryId) -> sp_wasm_interface::Result<()> { - self.sandbox_store + self.inner + .sandbox_store .borrow_mut() .memory_teardown(memory_id) .map_err(|e| e.to_string()) } fn memory_new(&mut self, initial: u32, maximum: MemoryId) -> sp_wasm_interface::Result { - self.sandbox_store + self.inner + .sandbox_store .borrow_mut() .new_memory(initial, maximum) .map_err(|e| e.to_string()) @@ -289,14 +256,13 @@ impl<'a> Sandbox for HostContext<'a> { .collect::>(); let instance = self + .inner .sandbox_store .borrow() .instance(instance_id) .map_err(|e| e.to_string())?; - let result = self.set_sandbox_capabilities(|| { - instance.invoke(export_name, &args, state) - }); + let result = instance.invoke(export_name, &args, state); // let result = unsafe { // // Erasing lifetime of `HostContext` to put it into scoped TLS. This is safe because @@ -316,7 +282,7 @@ impl<'a> Sandbox for HostContext<'a> { if val.len() > return_val_len as usize { Err("Return value buffer is too small")?; } - ::write_memory(self, return_val, val) + ::write_memory(self, return_val, val) .map_err(|_| "can't write return value")?; Ok(sandbox_primitives::ERR_OK) }) @@ -326,7 +292,8 @@ impl<'a> Sandbox for HostContext<'a> { } fn instance_teardown(&mut self, instance_id: u32) -> sp_wasm_interface::Result<()> { - self.sandbox_store + self.inner + .sandbox_store .borrow_mut() .instance_teardown(instance_id) .map_err(|e| e.to_string()) @@ -342,6 +309,7 @@ impl<'a> Sandbox for HostContext<'a> { // Extract a dispatch thunk from the instance's table by the specified index. let dispatch_thunk = { let table_item = self + .inner .instance .table() .as_ref() @@ -356,15 +324,17 @@ impl<'a> Sandbox for HostContext<'a> { SupervisorFuncRef(func_ref) }; - let guest_env = - match sandbox::GuestEnvironment::decode(&*self.sandbox_store.borrow(), raw_env_def) { - Ok(guest_env) => guest_env, - Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), - }; + let guest_env = match sandbox::GuestEnvironment::decode( + &*self.inner.sandbox_store.borrow(), + raw_env_def, + ) { + Ok(guest_env) => guest_env, + Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), + }; let instance_idx_or_err_code = - match sandbox::instantiate::<_, Self>(dispatch_thunk, wasm, guest_env, state) - .map(|i| i.register(&mut *self.sandbox_store.borrow_mut())) + match sandbox::instantiate::<_, Holder>(dispatch_thunk, wasm, guest_env, state) + .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) { Ok(instance_idx) => instance_idx, Err(sandbox::InstantiationError::StartTrapped) => sandbox_primitives::ERR_EXECUTION, @@ -379,10 +349,23 @@ impl<'a> Sandbox for HostContext<'a> { instance_idx: u32, name: &str, ) -> sp_wasm_interface::Result> { - self.sandbox_store + self.inner.sandbox_store .borrow() .instance(instance_idx) .map(|i| i.get_global_val(name)) .map_err(|e| e.to_string()) } } + +struct Holder; + +impl SandboxCapabiliesHolder for Holder { + type SupervisorFuncRef = SupervisorFuncRef; + type SC = HostState; + + fn with_sandbox_capabilities R>(f: F) -> R { + crate::state_holder::with_context(|ctx| { + f(&mut ctx.unwrap()) + }) + } +} diff --git a/client/executor/wasmtime/src/state_holder.rs b/client/executor/wasmtime/src/state_holder.rs index 711d3bb735d7c..23f955677960d 100644 --- a/client/executor/wasmtime/src/state_holder.rs +++ b/client/executor/wasmtime/src/state_holder.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::host::{HostContext, HostState}; +use crate::host::HostState; scoped_tls::scoped_thread_local!(static HOST_STATE: HostState); @@ -36,10 +36,10 @@ where /// context will be `None`. pub fn with_context(f: F) -> R where - F: FnOnce(Option) -> R, + F: FnOnce(Option) -> R, { if !HOST_STATE.is_set() { - return f(None) + return f(None); } - HOST_STATE.with(|state| f(Some(state.materialize()))) + HOST_STATE.with(|state| f(Some(state.clone()))) } From 1525a80855b9c758bc949cf4958c46a2a7b11c31 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 14 Jul 2020 14:49:43 +0700 Subject: [PATCH 07/88] Brings back invoke and instantiate implementation details --- client/executor/common/src/sandbox.rs | 183 +++++++++++++++++--------- client/executor/wasmi/src/lib.rs | 36 ++--- client/executor/wasmtime/src/host.rs | 14 +- 3 files changed, 138 insertions(+), 95 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index e867639111c4f..58975908f6a34 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -96,6 +96,12 @@ struct Imports { memories_map: HashMap<(Vec, Vec), MemoryRef>, } +impl Imports { + fn func_by_name(&self, module_name: &str, func_name: &str) -> Option { + self.func_map.get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())).cloned() + } +} + impl ImportResolver for Imports { fn resolve_func( &self, @@ -362,7 +368,7 @@ impl SandboxInstance { /// /// The `state` parameter can be used to provide custom data for /// these syscall implementations. - pub fn invoke( + pub fn invoke<'a, FE, SCH>( &self, // function to call that is exported from the module @@ -376,54 +382,58 @@ impl SandboxInstance { // arbitraty context data of the call state: u32, - ) -> std::result::Result, wasmi::Error> { - // SCH::with_sandbox_capabilities( |supervisor_externals| { - // with_guest_externals( - // supervisor_externals, - // self, - // state, - // |guest_externals| { - - // let wasmi_result = self.wasmi_instance - // .invoke_export(export_name, args, guest_externals)?; - - // let wasmtime_function = self - // .wasmtime_instance - // .get_func(export_name) - // .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; - - // let args: Vec = args - // .iter() - // .map(|v| match *v { - // RuntimeValue::I32(val) => Val::I32(val), - // RuntimeValue::I64(val) => Val::I64(val), - // RuntimeValue::F32(val) => Val::F32(val.into()), - // RuntimeValue::F64(val) => Val::F64(val.into()), - // }) - // .collect(); - - // let wasmtime_result = wasmtime_function - // .call(&args) - // .map_err(|e| wasmi::Error::Function(e.to_string()))?; - - // assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); - // if let Some(wasmi_value) = wasmi_result { - // let wasmtime_value = match *wasmtime_result.first().unwrap() { - // Val::I32(val) => RuntimeValue::I32(val), - // Val::I64(val) => RuntimeValue::I64(val), - // Val::F32(val) => RuntimeValue::F32(val.into()), - // Val::F64(val) => RuntimeValue::F64(val.into()), - // _ => unreachable!(), - // }; - - // assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); - // } - - // Ok(wasmi_result) - // }, - // ) - // }) - todo!() + ) -> std::result::Result, wasmi::Error> + where + FR: 'a, + FE: SandboxCapabilities + 'a, + SCH: SandboxCapabiliesHolder + { + SCH::with_sandbox_capabilities( |supervisor_externals| { + with_guest_externals( + supervisor_externals, + self, + state, + |guest_externals| { + + let wasmi_result = self.wasmi_instance + .invoke_export(export_name, args, guest_externals)?; + + let wasmtime_function = self + .wasmtime_instance + .get_func(export_name) + .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; + + let args: Vec = args + .iter() + .map(|v| match *v { + RuntimeValue::I32(val) => Val::I32(val), + RuntimeValue::I64(val) => Val::I64(val), + RuntimeValue::F32(val) => Val::F32(val.into()), + RuntimeValue::F64(val) => Val::F64(val.into()), + }) + .collect(); + + let wasmtime_result = wasmtime_function + .call(&args) + .map_err(|e| wasmi::Error::Function(e.to_string()))?; + + assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); + if let Some(wasmi_value) = wasmi_result { + let wasmtime_value = match *wasmtime_result.first().unwrap() { + Val::I32(val) => RuntimeValue::I32(val), + Val::I64(val) => RuntimeValue::I64(val), + Val::F32(val) => RuntimeValue::F32(val.into()), + Val::F64(val) => RuntimeValue::F64(val.into()), + _ => unreachable!(), + }; + + assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); + } + + Ok(wasmi_result) + }, + ) + }) } /// Get the value from a global with the given `name`. @@ -565,16 +575,17 @@ pub trait SandboxCapabiliesHolder { /// normally created by `sp_sandbox::Instance` primitive. /// /// Returns uninitialized sandboxed module instance or an instantiation error. -pub fn instantiate<'a, FE, SCH>( +pub fn instantiate<'a, FR, FE, SCH>( // supervisor_externals: &mut FE, - dispatch_thunk: FE::SupervisorFuncRef, + dispatch_thunk: FR, wasm: &[u8], guest_env: GuestEnvironment, state: u32, ) -> std::result::Result, InstantiationError> where - FE: SandboxCapabilities + 'a, - SCH: SandboxCapabiliesHolder, + FR: Clone + 'static, + FE: SandboxCapabilities + 'a, + SCH: SandboxCapabiliesHolder, { let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) @@ -593,20 +604,62 @@ where .imports() .filter_map(|import| { if let wasmtime::ExternType::Func(func_ty) = import.ty() { - Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, - move |_, _, _| { - SCH::with_sandbox_capabilities(|sc| { - // sc.invoke(); - }); + let guest_func_index = guest_env.imports + .func_by_name(import.module(), import.name()).expect("missing import"); - Ok(()) - } + let supervisor_func_index = guest_env.guest_to_supervisor_mapping + .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - // Err(wasmtime::Trap::new(format!( - // "Sandbox function stub", - // // func_ty.to_string(), - // // func_ty.name().to_string() - // ))) + let dispatch_thunk = dispatch_thunk.clone(); + Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, + move |caller, params, result| { + SCH::with_sandbox_capabilities(|supervisor_externals| { + // Serialize arguments into a byte vector. + let invoke_args_data = params + .iter() + .map(|val| match val { + Val::I32(val) => Value::I32(*val), + Val::I64(val) => Value::I64(*val), + Val::F32(val) => Value::F32(*val), + Val::F64(val) => Value::F64(*val), + _ => unimplemented!() + }) + .collect::>() + .encode(); + + // Move serialized arguments inside the memory, invoke dispatch thunk and + // then free allocated memory. + let invoke_args_len = invoke_args_data.len() as WordSize; + let invoke_args_ptr = supervisor_externals + .allocate_memory(invoke_args_len) + .map_err(|_| wasmtime::Trap::new("Can't allocate memory in supervisor for the arguments"))?; + + let deallocate = |fe: &mut FE, ptr, fail_msg| { + fe + .deallocate_memory(ptr) + .map_err(|_| wasmtime::Trap::new(fail_msg)) + }; + + if supervisor_externals + .write_memory(invoke_args_ptr, &invoke_args_data) + .is_err() + { + deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; + return Err(wasmtime::Trap::new("Can't write invoke args into memory")); + } + + let result = supervisor_externals.invoke( + &dispatch_thunk.clone(), + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ); + + // todo deallocate and parse result + Ok(()) + }) + } ))) } else { None diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 02b8c7269d30c..784a08c45f611 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -198,7 +198,7 @@ impl<'a> Sandbox for FunctionExecutor<'a> { .collect::>(); let instance = self.sandbox_store.instance(instance_id).map_err(|e| e.to_string())?; - let result = instance.invoke(export_name, &args, state); + let result = instance.invoke::<_, Holder>(export_name, &args, state); match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -242,24 +242,8 @@ impl<'a> Sandbox for FunctionExecutor<'a> { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; - struct Adapter; - - impl sandbox::SandboxCapabiliesHolder for Adapter { - type SupervisorFuncRef = wasmi::FuncRef; - type SC = FunctionExecutor<'static>; - - fn with_sandbox_capabilities R>(f: F) -> R { - todo!(); - - // FOO.with(|fe| { - // let mut fe = fe.borrow_mut(); - // f(fe.deref_mut()) - // }); - } - } - let instance_idx_or_err_code = - match sandbox::instantiate::<_, Adapter>(dispatch_thunk, wasm, guest_env, state) + match sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state) .map(|i| i.register(&mut self.sandbox_store)) { Ok(instance_idx) => instance_idx, @@ -283,6 +267,22 @@ impl<'a> Sandbox for FunctionExecutor<'a> { } } +struct Holder; + +impl sandbox::SandboxCapabiliesHolder for Holder { + type SupervisorFuncRef = wasmi::FuncRef; + type SC = FunctionExecutor<'static>; + + fn with_sandbox_capabilities R>(f: F) -> R { + todo!(); + + // FOO.with(|fe| { + // let mut fe = fe.borrow_mut(); + // f(fe.deref_mut()) + // }); + } +} + /// Will be used on initialization of a module to resolve function and memory imports. struct Resolver<'a> { /// All the hot functions that we export for the WASM blob. diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 6febc7e6a43c0..b2be5a83b2893 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -262,17 +262,7 @@ impl Sandbox for HostState { .instance(instance_id) .map_err(|e| e.to_string())?; - let result = instance.invoke(export_name, &args, state); - - // let result = unsafe { - // // Erasing lifetime of `HostContext` to put it into scoped TLS. This is safe because - // // the pointer will never leave this scope and is semantically equivalent to `&'a mut`. - // let self_ptr: *mut HostContext<'static> = std::mem::transmute(self as *mut HostContext<'a>); - - // HOST_CONTEXT.set(&self_ptr, || { - // instance.invoke(export_name, &args, self, state) - // }) - // }; + let result = instance.invoke::<_, Holder>(export_name, &args, state); match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -333,7 +323,7 @@ impl Sandbox for HostState { }; let instance_idx_or_err_code = - match sandbox::instantiate::<_, Holder>(dispatch_thunk, wasm, guest_env, state) + match sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state) .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) { Ok(instance_idx) => instance_idx, From 34d6f9533d5ae8906438f1ab629e745eaafb75f7 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 14 Jul 2020 14:52:48 +0700 Subject: [PATCH 08/88] Removes redundant bound --- client/executor/common/src/sandbox.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 58975908f6a34..2ca7a2b3986dd 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -384,7 +384,6 @@ impl SandboxInstance { state: u32, ) -> std::result::Result, wasmi::Error> where - FR: 'a, FE: SandboxCapabilities + 'a, SCH: SandboxCapabiliesHolder { From b8b5e7510330e587f78f4e6c9be3c5e822ce76f8 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 14 Jul 2020 15:21:29 +0700 Subject: [PATCH 09/88] Code cleanup --- client/executor/common/src/sandbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 2ca7a2b3986dd..b460a8a3589a0 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -580,7 +580,7 @@ pub fn instantiate<'a, FR, FE, SCH>( wasm: &[u8], guest_env: GuestEnvironment, state: u32, -) -> std::result::Result, InstantiationError> +) -> std::result::Result, InstantiationError> where FR: Clone + 'static, FE: SandboxCapabilities + 'a, @@ -648,7 +648,7 @@ where } let result = supervisor_externals.invoke( - &dispatch_thunk.clone(), + &dispatch_thunk, invoke_args_ptr, invoke_args_len, state, From c96f96b85d02f6d080ddf783e5c274f9b1cabe28 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 14 Jul 2020 18:42:34 +0700 Subject: [PATCH 10/88] Fixes invoke closure --- client/executor/common/src/sandbox.rs | 36 ++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index b460a8a3589a0..867dee828a4e5 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -647,15 +647,45 @@ where return Err(wasmtime::Trap::new("Can't write invoke args into memory")); } - let result = supervisor_externals.invoke( + let serialized_result = supervisor_externals.invoke( &dispatch_thunk, invoke_args_ptr, invoke_args_len, state, supervisor_func_index, - ); + ) + .map_err(|e| wasmtime::Trap::new(e.to_string()))?; + + // dispatch_thunk returns pointer to serialized arguments. + // Unpack pointer and len of the serialized result data. + let (serialized_result_val_ptr, serialized_result_val_len) = { + // Cast to u64 to use zero-extension. + let v = serialized_result as u64; + let ptr = (v as u64 >> 32) as u32; + let len = (v & 0xFFFFFFFF) as u32; + (Pointer::new(ptr), len) + }; + + let serialized_result_val = supervisor_externals + .read_memory(serialized_result_val_ptr, serialized_result_val_len) + .map_err(|_| wasmtime::Trap::new("Can't read the serialized result from dispatch thunk")); + + let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmtime::Trap::new(e.to_string())) + })?; + + if let Some(value) = deserialized_result { + result[0] = match value { + RuntimeValue::I32(val) => Val::I32(val), + RuntimeValue::I64(val) => Val::I64(val), + RuntimeValue::F32(val) => Val::F32(val.into()), + RuntimeValue::F64(val) => Val::F64(val.into()), + } + } - // todo deallocate and parse result Ok(()) }) } From a57110a5e97abf9404d9d3de093f0d5424877d66 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 17 Jul 2020 14:33:45 +0700 Subject: [PATCH 11/88] Refactors FunctionExecutor to eliminate lifetime --- client/executor/wasmi/src/lib.rs | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 784a08c45f611..449edc1c906cf 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -36,24 +36,24 @@ use sc_executor_common::{ }; use sc_executor_common::util::{DataSegmentsSnapshot, WasmModuleInfo}; -struct FunctionExecutor<'a> { +struct FunctionExecutor { sandbox_store: sandbox::Store, heap: sp_allocator::FreeingBumpHeapAllocator, memory: MemoryRef, table: Option, - host_functions: &'a [&'static dyn Function], + host_functions: Arc>, allow_missing_func_imports: bool, - missing_functions: &'a [String], + missing_functions: Arc>, } -impl<'a> FunctionExecutor<'a> { +impl FunctionExecutor { fn new( m: MemoryRef, heap_base: u32, t: Option, - host_functions: &'a [&'static dyn Function], + host_functions: Arc>, allow_missing_func_imports: bool, - missing_functions: &'a [String], + missing_functions: Arc>, ) -> Result { Ok(FunctionExecutor { sandbox_store: sandbox::Store::new(), @@ -67,7 +67,7 @@ impl<'a> FunctionExecutor<'a> { } } -impl<'a> sandbox::SandboxCapabilities for FunctionExecutor<'a> { +impl sandbox::SandboxCapabilities for FunctionExecutor { type SupervisorFuncRef = wasmi::FuncRef; fn invoke( @@ -96,7 +96,7 @@ impl<'a> sandbox::SandboxCapabilities for FunctionExecutor<'a> { } } -impl<'a> FunctionContext for FunctionExecutor<'a> { +impl FunctionContext for FunctionExecutor { fn read_memory_into(&self, address: Pointer, dest: &mut [u8]) -> WResult<()> { self.memory.get_into(address.into(), dest).map_err(|e| e.to_string()) } @@ -124,7 +124,7 @@ impl<'a> FunctionContext for FunctionExecutor<'a> { } } -impl<'a> Sandbox for FunctionExecutor<'a> { +impl Sandbox for FunctionExecutor { fn memory_get( &mut self, memory_id: MemoryId, @@ -271,7 +271,7 @@ struct Holder; impl sandbox::SandboxCapabiliesHolder for Holder { type SupervisorFuncRef = wasmi::FuncRef; - type SC = FunctionExecutor<'static>; + type SC = FunctionExecutor; fn with_sandbox_capabilities R>(f: F) -> R { todo!(); @@ -397,13 +397,13 @@ impl<'a> wasmi::ModuleImportResolver for Resolver<'a> { } } -impl<'a> wasmi::Externals for FunctionExecutor<'a> { +impl wasmi::Externals for FunctionExecutor { fn invoke_index(&mut self, index: usize, args: wasmi::RuntimeArgs) -> Result, wasmi::Trap> { let mut args = args.as_ref().iter().copied().map(Into::into); - if let Some(function) = self.host_functions.get(index) { + if let Some(function) = self.host_functions.clone().get(index) { function.execute(self, &mut args) .map_err(|msg| Error::FunctionExecution(function.name().to_string(), msg)) .map_err(wasmi::Trap::from) @@ -453,9 +453,9 @@ fn call_in_wasm_module( memory: &MemoryRef, method: &str, data: &[u8], - host_functions: &[&'static dyn Function], + host_functions: Arc>, allow_missing_func_imports: bool, - missing_functions: &Vec, + missing_functions: Arc>, ) -> Result, Error> { // Initialize FunctionExecutor. let table: Option = module_instance @@ -623,7 +623,7 @@ impl WasmModule for WasmiRuntime { data_segments_snapshot: self.data_segments_snapshot.clone(), host_functions: self.host_functions.clone(), allow_missing_func_imports: self.allow_missing_func_imports, - missing_functions, + missing_functions: Arc::new(missing_functions), })) } } @@ -687,7 +687,7 @@ pub struct WasmiInstance { /// These stubs will error when the wasm blob trie to call them. allow_missing_func_imports: bool, /// List of missing functions detected during function resolution - missing_functions: Vec, + missing_functions: Arc>, } // This is safe because `WasmiInstance` does not leak any references to `self.memory` and `self.instance` @@ -719,9 +719,9 @@ impl WasmInstance for WasmiInstance { &self.memory, method, data, - self.host_functions.as_ref(), + self.host_functions.clone(), self.allow_missing_func_imports, - self.missing_functions.as_ref(), + self.missing_functions.clone(), ) } From 63176e120ef0846df79a30b910c39904ba1da6c5 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 17 Jul 2020 14:55:34 +0700 Subject: [PATCH 12/88] Wraps `FunctionExecutor::sandbox_store` in `RefCell` --- client/executor/wasmi/src/lib.rs | 43 ++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 449edc1c906cf..0facda2b0551b 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -37,7 +37,7 @@ use sc_executor_common::{ use sc_executor_common::util::{DataSegmentsSnapshot, WasmModuleInfo}; struct FunctionExecutor { - sandbox_store: sandbox::Store, + sandbox_store: RefCell>, heap: sp_allocator::FreeingBumpHeapAllocator, memory: MemoryRef, table: Option, @@ -56,7 +56,7 @@ impl FunctionExecutor { missing_functions: Arc>, ) -> Result { Ok(FunctionExecutor { - sandbox_store: sandbox::Store::new(), + sandbox_store: RefCell::new(sandbox::Store::new()), heap: sp_allocator::FreeingBumpHeapAllocator::new(heap_base), memory: m, table: t, @@ -132,7 +132,10 @@ impl Sandbox for FunctionExecutor { buf_ptr: Pointer, buf_len: WordSize, ) -> WResult { - let sandboxed_memory = self.sandbox_store.memory(memory_id).map_err(|e| e.to_string())?; + let sandboxed_memory = self + .sandbox_store + .borrow() + .memory(memory_id).map_err(|e| e.to_string())?; match MemoryInstance::transfer( &sandboxed_memory, @@ -153,7 +156,10 @@ impl Sandbox for FunctionExecutor { val_ptr: Pointer, val_len: WordSize, ) -> WResult { - let sandboxed_memory = self.sandbox_store.memory(memory_id).map_err(|e| e.to_string())?; + let sandboxed_memory = self + .sandbox_store + .borrow() + .memory(memory_id).map_err(|e| e.to_string())?; match MemoryInstance::transfer( &self.memory, @@ -168,7 +174,10 @@ impl Sandbox for FunctionExecutor { } fn memory_teardown(&mut self, memory_id: MemoryId) -> WResult<()> { - self.sandbox_store.memory_teardown(memory_id).map_err(|e| e.to_string()) + self + .sandbox_store + .borrow_mut() + .memory_teardown(memory_id).map_err(|e| e.to_string()) } fn memory_new( @@ -176,7 +185,10 @@ impl Sandbox for FunctionExecutor { initial: u32, maximum: u32, ) -> WResult { - self.sandbox_store.new_memory(initial, maximum).map_err(|e| e.to_string()) + self + .sandbox_store + .borrow_mut() + .new_memory(initial, maximum).map_err(|e| e.to_string()) } fn invoke( @@ -197,7 +209,11 @@ impl Sandbox for FunctionExecutor { .map(Into::into) .collect::>(); - let instance = self.sandbox_store.instance(instance_id).map_err(|e| e.to_string())?; + let instance = self + .sandbox_store + .borrow() + .instance(instance_id).map_err(|e| e.to_string())?; + let result = instance.invoke::<_, Holder>(export_name, &args, state); match result { @@ -217,7 +233,10 @@ impl Sandbox for FunctionExecutor { } fn instance_teardown(&mut self, instance_id: u32) -> WResult<()> { - self.sandbox_store.instance_teardown(instance_id).map_err(|e| e.to_string()) + self + .sandbox_store + .borrow_mut() + .instance_teardown(instance_id).map_err(|e| e.to_string()) } fn instance_new( @@ -237,14 +256,17 @@ impl Sandbox for FunctionExecutor { .clone() }; - let guest_env = match sandbox::GuestEnvironment::decode(&self.sandbox_store, raw_env_def) { + let guest_env = match sandbox::GuestEnvironment::decode( + &*self.sandbox_store.borrow(), + raw_env_def + ) { Ok(guest_env) => guest_env, Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; let instance_idx_or_err_code = match sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state) - .map(|i| i.register(&mut self.sandbox_store)) + .map(|i| i.register(&mut *self.sandbox_store.borrow_mut())) { Ok(instance_idx) => instance_idx, Err(sandbox::InstantiationError::StartTrapped) => @@ -261,6 +283,7 @@ impl Sandbox for FunctionExecutor { name: &str, ) -> WResult> { self.sandbox_store + .borrow() .instance(instance_idx) .map(|i| i.get_global_val(name)) .map_err(|e| e.to_string()) From 96cb57d1872b0a9e5c89016a32d76125b60f76d8 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 17 Jul 2020 14:59:06 +0700 Subject: [PATCH 13/88] Renames `FunctionExecutor::heap` to `allocator` --- client/executor/wasmi/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 0facda2b0551b..33eb3a42c7d23 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -38,7 +38,7 @@ use sc_executor_common::util::{DataSegmentsSnapshot, WasmModuleInfo}; struct FunctionExecutor { sandbox_store: RefCell>, - heap: sp_allocator::FreeingBumpHeapAllocator, + allocator: sp_allocator::FreeingBumpHeapAllocator, memory: MemoryRef, table: Option, host_functions: Arc>, @@ -57,7 +57,7 @@ impl FunctionExecutor { ) -> Result { Ok(FunctionExecutor { sandbox_store: RefCell::new(sandbox::Store::new()), - heap: sp_allocator::FreeingBumpHeapAllocator::new(heap_base), + allocator: sp_allocator::FreeingBumpHeapAllocator::new(heap_base), memory: m, table: t, host_functions, @@ -106,14 +106,14 @@ impl FunctionContext for FunctionExecutor { } fn allocate_memory(&mut self, size: WordSize) -> WResult> { - let heap = &mut self.heap; + let heap = &mut self.allocator; self.memory.with_direct_access_mut(|mem| { heap.allocate(mem, size).map_err(|e| e.to_string()) }) } fn deallocate_memory(&mut self, ptr: Pointer) -> WResult<()> { - let heap = &mut self.heap; + let heap = &mut self.allocator; self.memory.with_direct_access_mut(|mem| { heap.deallocate(mem, ptr).map_err(|e| e.to_string()) }) From b246aeee9d03624d7e35f5ad52b9f094bb04df2c Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 17 Jul 2020 15:04:08 +0700 Subject: [PATCH 14/88] Wraps `FunctionExecutor::allocator` in `RefCell` --- client/executor/wasmi/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 33eb3a42c7d23..51eb3eb139c99 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -38,7 +38,7 @@ use sc_executor_common::util::{DataSegmentsSnapshot, WasmModuleInfo}; struct FunctionExecutor { sandbox_store: RefCell>, - allocator: sp_allocator::FreeingBumpHeapAllocator, + allocator: RefCell, memory: MemoryRef, table: Option, host_functions: Arc>, @@ -57,7 +57,7 @@ impl FunctionExecutor { ) -> Result { Ok(FunctionExecutor { sandbox_store: RefCell::new(sandbox::Store::new()), - allocator: sp_allocator::FreeingBumpHeapAllocator::new(heap_base), + allocator: RefCell::new(sp_allocator::FreeingBumpHeapAllocator::new(heap_base)), memory: m, table: t, host_functions, @@ -108,14 +108,14 @@ impl FunctionContext for FunctionExecutor { fn allocate_memory(&mut self, size: WordSize) -> WResult> { let heap = &mut self.allocator; self.memory.with_direct_access_mut(|mem| { - heap.allocate(mem, size).map_err(|e| e.to_string()) + heap.borrow_mut().allocate(mem, size).map_err(|e| e.to_string()) }) } fn deallocate_memory(&mut self, ptr: Pointer) -> WResult<()> { let heap = &mut self.allocator; self.memory.with_direct_access_mut(|mem| { - heap.deallocate(mem, ptr).map_err(|e| e.to_string()) + heap.borrow_mut().deallocate(mem, ptr).map_err(|e| e.to_string()) }) } From b496e99daa47739bc50fa5f1b0a4745e4d3b4a41 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 17 Jul 2020 15:13:56 +0700 Subject: [PATCH 15/88] Refactors FunctionExecutor to `Rc` pattern --- client/executor/wasmi/src/lib.rs | 71 +++++++++++++++++++------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 51eb3eb139c99..9b3238e3e7541 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -16,7 +16,7 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. -use std::{str, cell::RefCell, sync::Arc}; +use std::{str, cell::RefCell, sync::Arc, rc::Rc}; use wasmi::{ Module, ModuleInstance, MemoryInstance, MemoryRef, TableRef, ImportsBuilder, ModuleRef, memory_units::Pages, @@ -36,7 +36,12 @@ use sc_executor_common::{ }; use sc_executor_common::util::{DataSegmentsSnapshot, WasmModuleInfo}; +#[derive(Clone)] struct FunctionExecutor { + inner: Rc, +} + +struct Inner { sandbox_store: RefCell>, allocator: RefCell, memory: MemoryRef, @@ -56,13 +61,15 @@ impl FunctionExecutor { missing_functions: Arc>, ) -> Result { Ok(FunctionExecutor { - sandbox_store: RefCell::new(sandbox::Store::new()), - allocator: RefCell::new(sp_allocator::FreeingBumpHeapAllocator::new(heap_base)), - memory: m, - table: t, - host_functions, - allow_missing_func_imports, - missing_functions, + inner: Rc::new(Inner { + sandbox_store: RefCell::new(sandbox::Store::new()), + allocator: RefCell::new(sp_allocator::FreeingBumpHeapAllocator::new(heap_base)), + memory: m, + table: t, + host_functions, + allow_missing_func_imports, + missing_functions, + }) }) } } @@ -98,24 +105,24 @@ impl sandbox::SandboxCapabilities for FunctionExecutor { impl FunctionContext for FunctionExecutor { fn read_memory_into(&self, address: Pointer, dest: &mut [u8]) -> WResult<()> { - self.memory.get_into(address.into(), dest).map_err(|e| e.to_string()) + self.inner.memory.get_into(address.into(), dest).map_err(|e| e.to_string()) } fn write_memory(&mut self, address: Pointer, data: &[u8]) -> WResult<()> { - self.memory.set(address.into(), data).map_err(|e| e.to_string()) + self.inner.memory.set(address.into(), data).map_err(|e| e.to_string()) } fn allocate_memory(&mut self, size: WordSize) -> WResult> { - let heap = &mut self.allocator; - self.memory.with_direct_access_mut(|mem| { - heap.borrow_mut().allocate(mem, size).map_err(|e| e.to_string()) + let heap = &mut self.inner.allocator.borrow_mut(); + self.inner.memory.with_direct_access_mut(|mem| { + heap.allocate(mem, size).map_err(|e| e.to_string()) }) } fn deallocate_memory(&mut self, ptr: Pointer) -> WResult<()> { - let heap = &mut self.allocator; - self.memory.with_direct_access_mut(|mem| { - heap.borrow_mut().deallocate(mem, ptr).map_err(|e| e.to_string()) + let heap = &mut self.inner.allocator.borrow_mut(); + self.inner.memory.with_direct_access_mut(|mem| { + heap.deallocate(mem, ptr).map_err(|e| e.to_string()) }) } @@ -133,6 +140,7 @@ impl Sandbox for FunctionExecutor { buf_len: WordSize, ) -> WResult { let sandboxed_memory = self + .inner .sandbox_store .borrow() .memory(memory_id).map_err(|e| e.to_string())?; @@ -140,7 +148,7 @@ impl Sandbox for FunctionExecutor { match MemoryInstance::transfer( &sandboxed_memory, offset as usize, - &self.memory, + &self.inner.memory, buf_ptr.into(), buf_len as usize, ) { @@ -157,12 +165,13 @@ impl Sandbox for FunctionExecutor { val_len: WordSize, ) -> WResult { let sandboxed_memory = self + .inner .sandbox_store .borrow() .memory(memory_id).map_err(|e| e.to_string())?; match MemoryInstance::transfer( - &self.memory, + &self.inner.memory, val_ptr.into(), &sandboxed_memory, offset as usize, @@ -175,6 +184,7 @@ impl Sandbox for FunctionExecutor { fn memory_teardown(&mut self, memory_id: MemoryId) -> WResult<()> { self + .inner .sandbox_store .borrow_mut() .memory_teardown(memory_id).map_err(|e| e.to_string()) @@ -186,6 +196,7 @@ impl Sandbox for FunctionExecutor { maximum: u32, ) -> WResult { self + .inner .sandbox_store .borrow_mut() .new_memory(initial, maximum).map_err(|e| e.to_string()) @@ -210,6 +221,7 @@ impl Sandbox for FunctionExecutor { .collect::>(); let instance = self + .inner .sandbox_store .borrow() .instance(instance_id).map_err(|e| e.to_string())?; @@ -234,6 +246,7 @@ impl Sandbox for FunctionExecutor { fn instance_teardown(&mut self, instance_id: u32) -> WResult<()> { self + .inner .sandbox_store .borrow_mut() .instance_teardown(instance_id).map_err(|e| e.to_string()) @@ -248,7 +261,7 @@ impl Sandbox for FunctionExecutor { ) -> WResult { // Extract a dispatch thunk from instance's table by the specified index. let dispatch_thunk = { - let table = self.table.as_ref() + let table = self.inner.table.as_ref() .ok_or_else(|| "Runtime doesn't have a table; sandbox is unavailable")?; table.get(dispatch_thunk_id) .map_err(|_| "dispatch_thunk_idx is out of the table bounds")? @@ -257,7 +270,7 @@ impl Sandbox for FunctionExecutor { }; let guest_env = match sandbox::GuestEnvironment::decode( - &*self.sandbox_store.borrow(), + &*self.inner.sandbox_store.borrow(), raw_env_def ) { Ok(guest_env) => guest_env, @@ -266,7 +279,7 @@ impl Sandbox for FunctionExecutor { let instance_idx_or_err_code = match sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state) - .map(|i| i.register(&mut *self.sandbox_store.borrow_mut())) + .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) { Ok(instance_idx) => instance_idx, Err(sandbox::InstantiationError::StartTrapped) => @@ -282,7 +295,9 @@ impl Sandbox for FunctionExecutor { instance_idx: u32, name: &str, ) -> WResult> { - self.sandbox_store + self + .inner + .sandbox_store .borrow() .instance(instance_idx) .map(|i| i.get_global_val(name)) @@ -426,18 +441,18 @@ impl wasmi::Externals for FunctionExecutor { { let mut args = args.as_ref().iter().copied().map(Into::into); - if let Some(function) = self.host_functions.clone().get(index) { + if let Some(function) = self.inner.host_functions.clone().get(index) { function.execute(self, &mut args) .map_err(|msg| Error::FunctionExecution(function.name().to_string(), msg)) .map_err(wasmi::Trap::from) .map(|v| v.map(Into::into)) - } else if self.allow_missing_func_imports - && index >= self.host_functions.len() - && index < self.host_functions.len() + self.missing_functions.len() + } else if self.inner.allow_missing_func_imports + && index >= self.inner.host_functions.len() + && index < self.inner.host_functions.len() + self.inner.missing_functions.len() { Err(Error::from(format!( "Function `{}` is only a stub. Calling a stub is not allowed.", - self.missing_functions[index - self.host_functions.len()], + self.inner.missing_functions[index - self.inner.host_functions.len()], )).into()) } else { Err(Error::from(format!("Could not find host function with index: {}", index)).into()) @@ -713,7 +728,7 @@ pub struct WasmiInstance { missing_functions: Arc>, } -// This is safe because `WasmiInstance` does not leak any references to `self.memory` and `self.instance` +// This is safe because `WasmiInstance` does not leak any references to `self.inner.memory` and `self.instance` unsafe impl Send for WasmiInstance {} impl WasmInstance for WasmiInstance { From 796604bbe4180800a6c5b32dafa83331619fba6b Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 17 Jul 2020 15:55:39 +0700 Subject: [PATCH 16/88] Implements scoped TLS for FunctionExecutor --- Cargo.lock | 1 + client/executor/wasmi/Cargo.toml | 1 + client/executor/wasmi/src/lib.rs | 13 ++++++------- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7e235126d495..16bbe6af19b10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6313,6 +6313,7 @@ dependencies = [ "log", "parity-scale-codec", "sc-executor-common", + "scoped-tls", "sp-allocator", "sp-core", "sp-runtime-interface", diff --git a/client/executor/wasmi/Cargo.toml b/client/executor/wasmi/Cargo.toml index 94f28f744bbd5..f1b9f2947ff67 100644 --- a/client/executor/wasmi/Cargo.toml +++ b/client/executor/wasmi/Cargo.toml @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] log = "0.4.8" +scoped-tls = "1.0" wasmi = "0.6.2" codec = { package = "parity-scale-codec", version = "1.3.0" } sc-executor-common = { version = "0.8.0-rc3", path = "../common" } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 9b3238e3e7541..f864e5dbc123c 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -226,7 +226,9 @@ impl Sandbox for FunctionExecutor { .borrow() .instance(instance_id).map_err(|e| e.to_string())?; - let result = instance.invoke::<_, Holder>(export_name, &args, state); + let result = EXECUTOR.set(self, || { + instance.invoke::<_, Holder>(export_name, &args, state) + }); match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -307,17 +309,14 @@ impl Sandbox for FunctionExecutor { struct Holder; +scoped_tls::scoped_thread_local!(static EXECUTOR: FunctionExecutor); + impl sandbox::SandboxCapabiliesHolder for Holder { type SupervisorFuncRef = wasmi::FuncRef; type SC = FunctionExecutor; fn with_sandbox_capabilities R>(f: F) -> R { - todo!(); - - // FOO.with(|fe| { - // let mut fe = fe.borrow_mut(); - // f(fe.deref_mut()) - // }); + EXECUTOR.with(|executor| f(&mut executor.clone())) } } From 0482e601d0d13c101e44f6dcf1a73f0742a326b9 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 21 Jul 2020 16:19:48 +0700 Subject: [PATCH 17/88] Fixes wasmi instancing --- client/executor/common/src/sandbox.rs | 4 ++-- client/executor/wasmi/src/lib.rs | 5 ++++- client/executor/wasmtime/src/host.rs | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 867dee828a4e5..c9c419ff4f832 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -592,7 +592,7 @@ where let mut config = wasmtime::Config::new(); config.cranelift_opt_level(wasmtime::OptLevel::Speed); - config.strategy(wasmtime::Strategy::Lightbeam).map_err(|_| InstantiationError::ModuleDecoding)?; + // config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmtime_engine = wasmtime::Engine::new(&config); let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); @@ -611,7 +611,7 @@ where let dispatch_thunk = dispatch_thunk.clone(); Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, - move |caller, params, result| { + move |_caller, params, result| { SCH::with_sandbox_capabilities(|supervisor_externals| { // Serialize arguments into a byte vector. let invoke_args_data = params diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index f864e5dbc123c..056b869c9bed7 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -279,8 +279,10 @@ impl Sandbox for FunctionExecutor { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; + let result = EXECUTOR.set(self, || sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state)); + let instance_idx_or_err_code = - match sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state) + match result .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) { Ok(instance_idx) => instance_idx, @@ -316,6 +318,7 @@ impl sandbox::SandboxCapabiliesHolder for Holder { type SC = FunctionExecutor; fn with_sandbox_capabilities R>(f: F) -> R { + assert!(EXECUTOR.is_set(), "wasmi executor is not set"); EXECUTOR.with(|executor| f(&mut executor.clone())) } } diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index b2be5a83b2893..a89168637b06d 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -355,7 +355,7 @@ impl SandboxCapabiliesHolder for Holder { fn with_sandbox_capabilities R>(f: F) -> R { crate::state_holder::with_context(|ctx| { - f(&mut ctx.unwrap()) + f(&mut ctx.expect("wasmtime executor is not set")) }) } } From d25f97e46ff09420dc6a9ab7849a3217630ac16b Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 21 Jul 2020 16:29:58 +0700 Subject: [PATCH 18/88] Fixes sandbox asserts --- client/executor/common/src/sandbox.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index c9c419ff4f832..39f68069c1920 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -416,9 +416,10 @@ impl SandboxInstance { .call(&args) .map_err(|e| wasmi::Error::Function(e.to_string()))?; - assert_eq!(wasmtime_result.len(), 1, "multiple return types are not supported yet"); + assert!(wasmtime_result.len() < 2, "multiple return types are not supported yet"); + if let Some(wasmi_value) = wasmi_result { - let wasmtime_value = match *wasmtime_result.first().unwrap() { + let wasmtime_value = match *wasmtime_result.first().expect("value should exist") { Val::I32(val) => RuntimeValue::I32(val), Val::I64(val) => RuntimeValue::I64(val), Val::F32(val) => RuntimeValue::F32(val.into()), From 1653a0949927254b8455f3a4938de50f02fe0375 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 27 Jul 2020 16:18:53 +0700 Subject: [PATCH 19/88] Makes sandbox compile after wasmtime API change --- client/executor/common/src/sandbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 39f68069c1920..d58213630787e 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -598,7 +598,7 @@ where let wasmtime_engine = wasmtime::Engine::new(&config); let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); - let wasmtime_module = wasmtime::Module::new(&wasmtime_store, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let module_imports: Vec<_> = wasmtime_module .imports() @@ -697,7 +697,7 @@ where }) .collect(); - let wasmtime_instance = wasmtime::Instance::new(&wasmtime_module, &module_imports).map_err(|_| InstantiationError::Instantiation)?; + let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|_| InstantiationError::Instantiation)?; let sandbox_instance = Rc::new(SandboxInstance { // In general, it's not a very good idea to use `.not_started_instance()` for anything From ff13eb2568017b6630592b535cd38ac27a94b1cc Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 27 Jul 2020 17:46:44 +0700 Subject: [PATCH 20/88] Uses Vurich/wasmtime for the Lightbeam backend --- Cargo.lock | 305 +++++++++++++++++--------- client/executor/common/Cargo.toml | 3 +- client/executor/common/src/sandbox.rs | 2 +- client/executor/wasmtime/Cargo.toml | 3 +- 4 files changed, 212 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fe5c2400b4ce..c92efea3fed0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -812,13 +812,40 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "cranelift-entity 0.65.0", +] + [[package]] name = "cranelift-bforest" version = "0.66.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dcc286b052ee24a1e5a222e7c1125e6010ad35b0f248709b9b3737a8fedcfdf" dependencies = [ - "cranelift-entity", + "cranelift-entity 0.66.0", +] + +[[package]] +name = "cranelift-codegen" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "byteorder", + "cranelift-bforest 0.65.0", + "cranelift-codegen-meta 0.65.0", + "cranelift-codegen-shared 0.65.0", + "cranelift-entity 0.65.0", + "gimli 0.21.0", + "log", + "regalloc 0.0.26", + "serde", + "smallvec 1.4.1", + "target-lexicon", + "thiserror", ] [[package]] @@ -828,35 +855,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d9badfe36176cb653506091693bc2bb1970c9bddfcd6ec7fac404f7eaec6f38" dependencies = [ "byteorder", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-bforest 0.66.0", + "cranelift-codegen-meta 0.66.0", + "cranelift-codegen-shared 0.66.0", + "cranelift-entity 0.66.0", "gimli 0.21.0", "log", - "regalloc", + "regalloc 0.0.27", "serde", "smallvec 1.4.1", "target-lexicon", "thiserror", ] +[[package]] +name = "cranelift-codegen-meta" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "cranelift-codegen-shared 0.65.0", + "cranelift-entity 0.65.0", +] + [[package]] name = "cranelift-codegen-meta" version = "0.66.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c3f460031861e4f4ad510be62b2ae50bba6cc886b598a36f9c0a970feab9598" dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-codegen-shared 0.66.0", + "cranelift-entity 0.66.0", ] +[[package]] +name = "cranelift-codegen-shared" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" + [[package]] name = "cranelift-codegen-shared" version = "0.66.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76ad12409e922e7697cd0bdc7dc26992f64a77c31880dfe5e3c7722f4710206d" +[[package]] +name = "cranelift-entity" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "serde", +] + [[package]] name = "cranelift-entity" version = "0.66.0" @@ -866,13 +915,24 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "cranelift-codegen 0.65.0", + "log", + "smallvec 1.4.1", + "target-lexicon", +] + [[package]] name = "cranelift-frontend" version = "0.66.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ef419efb4f94ecc02e5d9fbcc910d2bb7f0040e2de570e63a454f883bc891d6" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.66.0", "log", "smallvec 1.4.1", "target-lexicon", @@ -880,24 +940,37 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e69d44d59826eef6794066ac2c0f4ad3975f02d97030c60dbc04e3886adf36e" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.65.0", "raw-cpuid", "target-lexicon", ] +[[package]] +name = "cranelift-wasm" +version = "0.65.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "cranelift-codegen 0.65.0", + "cranelift-entity 0.65.0", + "cranelift-frontend 0.65.0", + "log", + "serde", + "thiserror", + "wasmparser 0.57.0", +] + [[package]] name = "cranelift-wasm" version = "0.66.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "979df666b1304624abe99738e9e0e7c7479ee5523ba4b8b237df9ff49996acbb" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", + "cranelift-codegen 0.66.0", + "cranelift-entity 0.66.0", + "cranelift-frontend 0.66.0", "log", "serde", "thiserror", @@ -4034,20 +4107,20 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" +checksum = "e5666bbb90bc4d1e5bdcb26c0afda1822d25928341e9384ab187a9b37ab69e36" +dependencies = [ + "crc32fast", + "indexmap", + "target-lexicon", +] [[package]] name = "object" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" -dependencies = [ - "crc32fast", - "indexmap", - "wasmparser 0.57.0", -] [[package]] name = "once_cell" @@ -5862,6 +5935,17 @@ dependencies = [ "syn 1.0.33", ] +[[package]] +name = "regalloc" +version = "0.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +dependencies = [ + "log", + "rustc-hash", + "smallvec 1.4.1", +] + [[package]] name = "regalloc" version = "0.0.27" @@ -6596,8 +6680,8 @@ dependencies = [ "sp-runtime-interface", "sp-serializer", "sp-wasm-interface", - "substrate-wasmtime", "wasmi", + "wasmtime", ] [[package]] @@ -6620,8 +6704,8 @@ name = "sc-executor-wasmtime" version = "0.8.0-rc5" dependencies = [ "assert_matches", - "cranelift-codegen", - "cranelift-wasm", + "cranelift-codegen 0.66.0", + "cranelift-wasm 0.66.0", "log", "parity-scale-codec", "parity-wasm 0.41.0", @@ -6631,9 +6715,9 @@ dependencies = [ "sp-core", "sp-runtime-interface", "sp-wasm-interface", - "substrate-wasmtime", - "wasmtime-environ", - "wasmtime-runtime", + "wasmtime", + "wasmtime-environ 0.19.0", + "wasmtime-runtime 0.19.0", ] [[package]] @@ -8666,31 +8750,6 @@ dependencies = [ name = "substrate-wasm-builder-runner" version = "1.0.6" -[[package]] -name = "substrate-wasmtime" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a69f5b3afef86e3e372529bf3fb1f7219b20287c4490e4cb4b4e91970f4f5" -dependencies = [ - "anyhow", - "backtrace", - "cfg-if", - "lazy_static", - "libc", - "log", - "region", - "rustc-demangle", - "smallvec 1.4.1", - "target-lexicon", - "wasmparser 0.59.0", - "wasmtime-environ", - "wasmtime-jit", - "wasmtime-profiling", - "wasmtime-runtime", - "wat", - "winapi 0.3.8", -] - [[package]] name = "subtle" version = "1.0.0" @@ -9739,36 +9798,55 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a950e6a618f62147fd514ff445b2a0b53120d382751960797f85f058c7eda9b9" +[[package]] +name = "wasmtime" +version = "0.18.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "anyhow", + "backtrace", + "cfg-if", + "lazy_static", + "libc", + "log", + "region", + "rustc-demangle", + "target-lexicon", + "wasmparser 0.57.0", + "wasmtime-environ 0.18.0", + "wasmtime-jit", + "wasmtime-profiling", + "wasmtime-runtime 0.18.0", + "wat", + "winapi 0.3.8", +] + [[package]] name = "wasmtime-debug" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e634af9067a3af6cf2c7d33dc3b84767ddaf5d010ba68e80eecbcea73d4a349" +version = "0.18.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" dependencies = [ "anyhow", "gimli 0.21.0", "more-asserts", - "object 0.20.0", + "object 0.18.0", "target-lexicon", "thiserror", - "wasmparser 0.59.0", - "wasmtime-environ", + "wasmparser 0.57.0", + "wasmtime-environ 0.18.0", ] [[package]] name = "wasmtime-environ" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f85619a94ee4034bd5bb87fc3dcf71fd2237b81c840809da1201061eec9ab3" +version = "0.18.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" dependencies = [ "anyhow", "base64 0.12.3", "bincode", - "cfg-if", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "cranelift-wasm", + "cranelift-codegen 0.65.0", + "cranelift-entity 0.65.0", + "cranelift-wasm 0.65.0", "directories", "errno", "file-per-thread-logger", @@ -9781,71 +9859,102 @@ dependencies = [ "sha2 0.8.1", "thiserror", "toml", - "wasmparser 0.59.0", + "wasmparser 0.57.0", "winapi 0.3.8", "zstd", ] [[package]] -name = "wasmtime-jit" +name = "wasmtime-environ" version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e914c013c7a9f15f4e429d5431f2830fb8adb56e40567661b69c5ec1d645be23" +checksum = "08f85619a94ee4034bd5bb87fc3dcf71fd2237b81c840809da1201061eec9ab3" dependencies = [ "anyhow", + "base64 0.12.3", + "bincode", "cfg-if", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "cranelift-native", - "cranelift-wasm", - "gimli 0.21.0", + "cranelift-codegen 0.66.0", + "cranelift-entity 0.66.0", + "cranelift-frontend 0.66.0", + "cranelift-wasm 0.66.0", + "directories", + "errno", + "file-per-thread-logger", + "indexmap", + "libc", "log", "more-asserts", - "object 0.20.0", - "region", - "target-lexicon", + "serde", + "sha2 0.8.1", "thiserror", + "toml", "wasmparser 0.59.0", - "wasmtime-debug", - "wasmtime-environ", - "wasmtime-obj", - "wasmtime-profiling", - "wasmtime-runtime", "winapi 0.3.8", + "zstd", ] [[package]] -name = "wasmtime-obj" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e81d8e02e9bc9fe2da9b6d48bbc217f96e089f7df613f11a28a3958abc44641e" +name = "wasmtime-jit" +version = "0.18.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" dependencies = [ "anyhow", + "cfg-if", + "cranelift-codegen 0.65.0", + "cranelift-entity 0.65.0", + "cranelift-frontend 0.65.0", + "cranelift-native", + "cranelift-wasm 0.65.0", + "gimli 0.21.0", + "log", "more-asserts", - "object 0.20.0", + "region", "target-lexicon", + "thiserror", + "wasmparser 0.57.0", "wasmtime-debug", - "wasmtime-environ", + "wasmtime-environ 0.18.0", + "wasmtime-profiling", + "wasmtime-runtime 0.18.0", + "winapi 0.3.8", ] [[package]] name = "wasmtime-profiling" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8d4d1af8dd5f7096cfcc89dd668d358e52980c38cce199643372ffd6590e27" +version = "0.18.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" dependencies = [ "anyhow", "cfg-if", "gimli 0.21.0", "lazy_static", "libc", - "object 0.19.0", + "object 0.18.0", "scroll", "serde", "target-lexicon", - "wasmtime-environ", - "wasmtime-runtime", + "wasmtime-environ 0.18.0", + "wasmtime-runtime 0.18.0", +] + +[[package]] +name = "wasmtime-runtime" +version = "0.18.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +dependencies = [ + "backtrace", + "cc", + "cfg-if", + "indexmap", + "lazy_static", + "libc", + "memoffset", + "more-asserts", + "region", + "thiserror", + "wasmtime-environ 0.18.0", + "winapi 0.3.8", ] [[package]] @@ -9865,7 +9974,7 @@ dependencies = [ "more-asserts", "region", "thiserror", - "wasmtime-environ", + "wasmtime-environ 0.19.0", "winapi 0.3.8", ] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index 5527bbfa0512a..cc11d7fe89d32 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -23,7 +23,8 @@ sp-allocator = { version = "2.0.0-rc5", path = "../../../primitives/allocator" } sp-wasm-interface = { version = "2.0.0-rc5", path = "../../../primitives/wasm-interface" } sp-runtime-interface = { version = "2.0.0-rc5", path = "../../../primitives/runtime-interface" } sp-serializer = { version = "2.0.0-rc5", path = "../../../primitives/serializer" } -wasmtime = { package = "substrate-wasmtime", version = "0.19.0" } +# wasmtime = { package = "substrate-wasmtime", version = "0.19.0" } +wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="stress-test" } [features] default = [] diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index d58213630787e..8de28cd7b4c61 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -593,7 +593,7 @@ where let mut config = wasmtime::Config::new(); config.cranelift_opt_level(wasmtime::OptLevel::Speed); - // config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; + config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmtime_engine = wasmtime::Engine::new(&config); let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index b7891c5affc08..3c929b17ef4bd 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -21,7 +21,8 @@ sp-wasm-interface = { version = "2.0.0-rc5", path = "../../../primitives/wasm-in sp-runtime-interface = { version = "2.0.0-rc5", path = "../../../primitives/runtime-interface" } sp-core = { version = "2.0.0-rc5", path = "../../../primitives/core" } sp-allocator = { version = "2.0.0-rc5", path = "../../../primitives/allocator" } -wasmtime = { package = "substrate-wasmtime", version = "0.19.0" } +# wasmtime = { package = "substrate-wasmtime", version = "0.19.0" } +wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="stress-test" } wasmtime-runtime = { version = "0.19.0" } wasmtime-environ = { version = "0.19.0" } cranelift-wasm = { version = "0.66.0" } From d1d50faf921144383265782b3997108f08ae81f9 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 28 Jul 2020 15:24:45 +0700 Subject: [PATCH 21/88] Uses wasmtime instead of wasmi for sandbox API results --- client/executor/common/src/sandbox.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 8de28cd7b4c61..b981a77caaee4 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -418,7 +418,7 @@ impl SandboxInstance { assert!(wasmtime_result.len() < 2, "multiple return types are not supported yet"); - if let Some(wasmi_value) = wasmi_result { + let wasmtime_result = if let Some(wasmi_value) = wasmi_result { let wasmtime_value = match *wasmtime_result.first().expect("value should exist") { Val::I32(val) => RuntimeValue::I32(val), Val::I64(val) => RuntimeValue::I64(val), @@ -428,9 +428,12 @@ impl SandboxInstance { }; assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); - } + Some(wasmtime_value) + } else { + None + }; - Ok(wasmi_result) + Ok(wasmtime_result) }, ) }) @@ -444,7 +447,8 @@ impl SandboxInstance { .export_by_name(name)? .as_global()? .get(); - let wasmi_value = wasmi_global.into(); + + let wasmi_value: sp_wasm_interface::Value = wasmi_global.into(); let wasmtime_global = self.wasmtime_instance.get_global(name)?.get(); let wasmtime_value = match wasmtime_global { @@ -457,7 +461,7 @@ impl SandboxInstance { assert_eq!(wasmi_value, wasmtime_value); - Some(wasmi_value) + Some(wasmtime_value) } } From 14d3d3ce525645fe4e83cbd4556cd7ab0f1cce03 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 7 Aug 2020 17:15:47 +0700 Subject: [PATCH 22/88] Refactors sandbox to use one of the execution backends at a time --- client/executor/common/src/sandbox.rs | 417 ++++++++++++++------------ client/executor/wasmi/src/lib.rs | 9 +- client/executor/wasmtime/src/host.rs | 10 +- 3 files changed, 241 insertions(+), 195 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index b981a77caaee4..db79684b762b1 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -339,6 +339,11 @@ where f(&mut guest_externals) } +enum BackendInstance { + Wasmi(wasmi::ModuleRef), + Wasmtime(wasmtime::Instance), +} + /// Sandboxed instance of a wasm module. /// /// It's primary purpose is to [`invoke`] exported functions on it. @@ -354,8 +359,7 @@ where /// /// [`invoke`]: #method.invoke pub struct SandboxInstance { - wasmi_instance: ModuleRef, - wasmtime_instance: wasmtime::Instance, + backend_instance: BackendInstance, dispatch_thunk: FR, guest_to_supervisor_mapping: GuestToSupervisorFunctionMapping, } @@ -393,47 +397,52 @@ impl SandboxInstance { self, state, |guest_externals| { + match &self.backend_instance { + BackendInstance::Wasmi(wasmi_instance) => { + let wasmi_result = wasmi_instance + .invoke_export(export_name, args, guest_externals)?; + + Ok(wasmi_result) + } + + BackendInstance::Wasmtime(wasmtime_instance) => { + let wasmtime_function = wasmtime_instance + .get_func(export_name) + .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; + + let args: Vec = args + .iter() + .map(|v| match *v { + RuntimeValue::I32(val) => Val::I32(val), + RuntimeValue::I64(val) => Val::I64(val), + RuntimeValue::F32(val) => Val::F32(val.into()), + RuntimeValue::F64(val) => Val::F64(val.into()), + }) + .collect(); + + let wasmtime_result = wasmtime_function + .call(&args) + .map_err(|e| wasmi::Error::Function(e.to_string()))?; + + assert!(wasmtime_result.len() < 2, "multiple return types are not supported yet"); + + let wasmtime_result = if let Some(wasmtime_value) = wasmtime_result.first() { + let wasmtime_value = match *wasmtime_value { + Val::I32(val) => RuntimeValue::I32(val), + Val::I64(val) => RuntimeValue::I64(val), + Val::F32(val) => RuntimeValue::F32(val.into()), + Val::F64(val) => RuntimeValue::F64(val.into()), + _ => unreachable!(), + }; + + Some(wasmtime_value) + } else { + None + }; - let wasmi_result = self.wasmi_instance - .invoke_export(export_name, args, guest_externals)?; - - let wasmtime_function = self - .wasmtime_instance - .get_func(export_name) - .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; - - let args: Vec = args - .iter() - .map(|v| match *v { - RuntimeValue::I32(val) => Val::I32(val), - RuntimeValue::I64(val) => Val::I64(val), - RuntimeValue::F32(val) => Val::F32(val.into()), - RuntimeValue::F64(val) => Val::F64(val.into()), - }) - .collect(); - - let wasmtime_result = wasmtime_function - .call(&args) - .map_err(|e| wasmi::Error::Function(e.to_string()))?; - - assert!(wasmtime_result.len() < 2, "multiple return types are not supported yet"); - - let wasmtime_result = if let Some(wasmi_value) = wasmi_result { - let wasmtime_value = match *wasmtime_result.first().expect("value should exist") { - Val::I32(val) => RuntimeValue::I32(val), - Val::I64(val) => RuntimeValue::I64(val), - Val::F32(val) => RuntimeValue::F32(val.into()), - Val::F64(val) => RuntimeValue::F64(val.into()), - _ => unreachable!(), - }; - - assert_eq!(wasmi_value, wasmtime_value, "return values do not match"); - Some(wasmtime_value) - } else { - None - }; - - Ok(wasmtime_result) + Ok(wasmtime_result) + } + } }, ) }) @@ -443,25 +452,29 @@ impl SandboxInstance { /// /// Returns `Some(_)` if the global could be found. pub fn get_global_val(&self, name: &str) -> Option { - let wasmi_global = self.wasmi_instance - .export_by_name(name)? - .as_global()? - .get(); - - let wasmi_value: sp_wasm_interface::Value = wasmi_global.into(); - - let wasmtime_global = self.wasmtime_instance.get_global(name)?.get(); - let wasmtime_value = match wasmtime_global { - Val::I32(val) => Value::I32(val), - Val::I64(val) => Value::I64(val), - Val::F32(val) => Value::F32(val), - Val::F64(val) => Value::F64(val), - _ => None?, - }; - - assert_eq!(wasmi_value, wasmtime_value); + match &self.backend_instance { + BackendInstance::Wasmi(wasmi_instance) => { + let wasmi_global = wasmi_instance + .export_by_name(name)? + .as_global()? + .get(); + + Some(wasmi_global.into()) + } - Some(wasmtime_value) + BackendInstance::Wasmtime(wasmtime_instance) => { + let wasmtime_global = wasmtime_instance.get_global(name)?.get(); + let wasmtime_value = match wasmtime_global { + Val::I32(val) => Value::I32(val), + Val::I64(val) => Value::I64(val), + Val::F32(val) => Value::F32(val), + Val::F64(val) => Value::F64(val), + _ => None?, + }; + + Some(wasmtime_value) + } + } } } @@ -571,6 +584,11 @@ pub trait SandboxCapabiliesHolder { fn with_sandbox_capabilities R>(f: F) -> R; } +pub enum SandboxBackend { + Wasmi, + Wasmtime, +} + /// Instantiate a guest module and return it's index in the store. /// /// The guest module's code is specified in `wasm`. Environment that will be available to @@ -581,6 +599,7 @@ pub trait SandboxCapabiliesHolder { /// Returns uninitialized sandboxed module instance or an instantiation error. pub fn instantiate<'a, FR, FE, SCH>( // supervisor_externals: &mut FE, + sandbox_backend: SandboxBackend, dispatch_thunk: FR, wasm: &[u8], guest_env: GuestEnvironment, @@ -591,142 +610,156 @@ where FE: SandboxCapabilities + 'a, SCH: SandboxCapabiliesHolder, { - let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) - .map_err(|_| InstantiationError::Instantiation)?; - - let mut config = wasmtime::Config::new(); - config.cranelift_opt_level(wasmtime::OptLevel::Speed); - config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; - - let wasmtime_engine = wasmtime::Engine::new(&config); - let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); - - let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - - let module_imports: Vec<_> = wasmtime_module - .imports() - .filter_map(|import| { - if let wasmtime::ExternType::Func(func_ty) = import.ty() { - let guest_func_index = guest_env.imports - .func_by_name(import.module(), import.name()).expect("missing import"); - - let supervisor_func_index = guest_env.guest_to_supervisor_mapping - .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - - let dispatch_thunk = dispatch_thunk.clone(); - Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, - move |_caller, params, result| { - SCH::with_sandbox_capabilities(|supervisor_externals| { - // Serialize arguments into a byte vector. - let invoke_args_data = params - .iter() - .map(|val| match val { - Val::I32(val) => Value::I32(*val), - Val::I64(val) => Value::I64(*val), - Val::F32(val) => Value::F32(*val), - Val::F64(val) => Value::F64(*val), - _ => unimplemented!() - }) - .collect::>() - .encode(); - - // Move serialized arguments inside the memory, invoke dispatch thunk and - // then free allocated memory. - let invoke_args_len = invoke_args_data.len() as WordSize; - let invoke_args_ptr = supervisor_externals - .allocate_memory(invoke_args_len) - .map_err(|_| wasmtime::Trap::new("Can't allocate memory in supervisor for the arguments"))?; - - let deallocate = |fe: &mut FE, ptr, fail_msg| { - fe - .deallocate_memory(ptr) - .map_err(|_| wasmtime::Trap::new(fail_msg)) - }; - - if supervisor_externals - .write_memory(invoke_args_ptr, &invoke_args_data) - .is_err() - { - deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; - return Err(wasmtime::Trap::new("Can't write invoke args into memory")); - } - - let serialized_result = supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) - .map_err(|e| wasmtime::Trap::new(e.to_string()))?; - - // dispatch_thunk returns pointer to serialized arguments. - // Unpack pointer and len of the serialized result data. - let (serialized_result_val_ptr, serialized_result_val_len) = { - // Cast to u64 to use zero-extension. - let v = serialized_result as u64; - let ptr = (v as u64 >> 32) as u32; - let len = (v & 0xFFFFFFFF) as u32; - (Pointer::new(ptr), len) - }; - - let serialized_result_val = supervisor_externals - .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmtime::Trap::new("Can't read the serialized result from dispatch thunk")); - let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") - .and_then(|_| serialized_result_val) - .and_then(|serialized_result_val| { - deserialize_result(&serialized_result_val) - .map_err(|e| wasmtime::Trap::new(e.to_string())) - })?; + let sandbox_instance = match sandbox_backend { + SandboxBackend::Wasmi => { + let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) + .map_err(|_| InstantiationError::Instantiation)?; + + let sandbox_instance = Rc::new(SandboxInstance { + // In general, it's not a very good idea to use `.not_started_instance()` for anything + // but for extracting memory and tables. But in this particular case, we are extracting + // for the purpose of running `start` function which should be ok. + backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), + dispatch_thunk, + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }); + + SCH::with_sandbox_capabilities( |supervisor_externals| { + with_guest_externals( + supervisor_externals, + &sandbox_instance, + state, + |guest_externals| { + wasmi_instance + .run_start(guest_externals) + .map_err(|_| InstantiationError::StartTrapped) + + // Note: no need to run start on wasmtime instance, since it's done automatically + }, + ) + })?; + + sandbox_instance + } - if let Some(value) = deserialized_result { - result[0] = match value { - RuntimeValue::I32(val) => Val::I32(val), - RuntimeValue::I64(val) => Val::I64(val), - RuntimeValue::F32(val) => Val::F32(val.into()), - RuntimeValue::F64(val) => Val::F64(val.into()), - } + SandboxBackend::Wasmtime => { + let mut config = wasmtime::Config::new(); + config.cranelift_opt_level(wasmtime::OptLevel::Speed); + config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; + + let wasmtime_engine = wasmtime::Engine::new(&config); + let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); + + let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + + let module_imports: Vec<_> = wasmtime_module + .imports() + .filter_map(|import| { + if let wasmtime::ExternType::Func(func_ty) = import.ty() { + let guest_func_index = guest_env.imports + .func_by_name(import.module(), import.name()).expect("missing import"); + + let supervisor_func_index = guest_env.guest_to_supervisor_mapping + .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); + + let dispatch_thunk = dispatch_thunk.clone(); + Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, + move |_caller, params, result| { + SCH::with_sandbox_capabilities(|supervisor_externals| { + // Serialize arguments into a byte vector. + let invoke_args_data = params + .iter() + .map(|val| match val { + Val::I32(val) => Value::I32(*val), + Val::I64(val) => Value::I64(*val), + Val::F32(val) => Value::F32(*val), + Val::F64(val) => Value::F64(*val), + _ => unimplemented!() + }) + .collect::>() + .encode(); + + // Move serialized arguments inside the memory, invoke dispatch thunk and + // then free allocated memory. + let invoke_args_len = invoke_args_data.len() as WordSize; + let invoke_args_ptr = supervisor_externals + .allocate_memory(invoke_args_len) + .map_err(|_| wasmtime::Trap::new("Can't allocate memory in supervisor for the arguments"))?; + + let deallocate = |fe: &mut FE, ptr, fail_msg| { + fe + .deallocate_memory(ptr) + .map_err(|_| wasmtime::Trap::new(fail_msg)) + }; + + if supervisor_externals + .write_memory(invoke_args_ptr, &invoke_args_data) + .is_err() + { + deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; + return Err(wasmtime::Trap::new("Can't write invoke args into memory")); + } + + let serialized_result = supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + .map_err(|e| wasmtime::Trap::new(e.to_string()))?; + + // dispatch_thunk returns pointer to serialized arguments. + // Unpack pointer and len of the serialized result data. + let (serialized_result_val_ptr, serialized_result_val_len) = { + // Cast to u64 to use zero-extension. + let v = serialized_result as u64; + let ptr = (v as u64 >> 32) as u32; + let len = (v & 0xFFFFFFFF) as u32; + (Pointer::new(ptr), len) + }; + + let serialized_result_val = supervisor_externals + .read_memory(serialized_result_val_ptr, serialized_result_val_len) + .map_err(|_| wasmtime::Trap::new("Can't read the serialized result from dispatch thunk")); + + let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmtime::Trap::new(e.to_string())) + })?; + + if let Some(value) = deserialized_result { + result[0] = match value { + RuntimeValue::I32(val) => Val::I32(val), + RuntimeValue::I64(val) => Val::I64(val), + RuntimeValue::F32(val) => Val::F32(val.into()), + RuntimeValue::F64(val) => Val::F64(val.into()), + } + } + + Ok(()) + }) } - - Ok(()) - }) + ))) + } else { + None } - ))) - } else { - None - } - }) - .collect(); - - let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|_| InstantiationError::Instantiation)?; - - let sandbox_instance = Rc::new(SandboxInstance { - // In general, it's not a very good idea to use `.not_started_instance()` for anything - // but for extracting memory and tables. But in this particular case, we are extracting - // for the purpose of running `start` function which should be ok. - wasmi_instance: wasmi_instance.not_started_instance().clone(), - wasmtime_instance, - dispatch_thunk, - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }); - - SCH::with_sandbox_capabilities( |supervisor_externals| { - with_guest_externals( - supervisor_externals, - &sandbox_instance, - state, - |guest_externals| { - wasmi_instance - .run_start(guest_externals) - .map_err(|_| InstantiationError::StartTrapped) - - // Note: no need to run start on wasmtime instance, since it's done automatically - }, - ) - })?; + }) + .collect(); + + let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|_| InstantiationError::Instantiation)?; + + Rc::new(SandboxInstance { + backend_instance: BackendInstance::Wasmtime(wasmtime_instance), + dispatch_thunk, + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }) + } + }; Ok(UnregisteredInstance { sandbox_instance }) } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 039f5aa0868ad..9d0765e34ed8e 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -35,6 +35,7 @@ use sc_executor_common::{ sandbox, }; use sc_executor_common::util::{DataSegmentsSnapshot, WasmModuleInfo}; +use sandbox::SandboxBackend; #[derive(Clone)] struct FunctionExecutor { @@ -278,7 +279,13 @@ impl Sandbox for FunctionExecutor { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; - let result = EXECUTOR.set(self, || sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state)); + let result = EXECUTOR.set(self, || sandbox::instantiate::<_, _, Holder>( + SandboxBackend::Wasmi, + dispatch_thunk, + wasm, + guest_env, + state + )); let instance_idx_or_err_code = match result diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 76780bcd04626..1358fec14babe 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -28,7 +28,7 @@ use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; use wasmtime::{Func, Val}; -use sandbox::SandboxCapabiliesHolder; +use sandbox::{SandboxBackend, SandboxCapabiliesHolder}; /// Wrapper type for pointer to a Wasm table entry. /// @@ -324,7 +324,13 @@ impl Sandbox for HostState { }; let instance_idx_or_err_code = - match sandbox::instantiate::<_, _, Holder>(dispatch_thunk, wasm, guest_env, state) + match sandbox::instantiate::<_, _, Holder>( + SandboxBackend::Wasmtime, + dispatch_thunk, + wasm, + guest_env, + state + ) .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) { Ok(instance_idx) => instance_idx, From d98584cbdbc090aa8b8b9bf900132a979c548e1a Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 1 Sep 2020 13:12:35 +0700 Subject: [PATCH 23/88] Fixes wasmtime module instantiation --- client/executor/common/src/sandbox.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index db79684b762b1..42a7bc5436fc5 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -651,15 +651,18 @@ where let wasmtime_engine = wasmtime::Engine::new(&config); let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); - let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let module_imports: Vec<_> = wasmtime_module .imports() .filter_map(|import| { if let wasmtime::ExternType::Func(func_ty) = import.ty() { - let guest_func_index = guest_env.imports - .func_by_name(import.module(), import.name()).expect("missing import"); + let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { + index + } else { + // Missing import + return None; + }; let supervisor_func_index = guest_env.guest_to_supervisor_mapping .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); @@ -751,7 +754,13 @@ where }) .collect(); - let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|_| InstantiationError::Instantiation)?; + let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|error| + if let Ok(trap) = error.downcast::() { + InstantiationError::StartTrapped + } else { + InstantiationError::Instantiation + } + )?; Rc::new(SandboxInstance { backend_instance: BackendInstance::Wasmtime(wasmtime_instance), From 6729db100002c4d14c4d4de970fa01c9aec8934f Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Oct 2020 12:40:53 +0700 Subject: [PATCH 24/88] TEMP vurich branch stuff --- Cargo.lock | 345 +++++++++++--------------- client/executor/Cargo.toml | 2 +- client/executor/common/Cargo.toml | 5 +- client/executor/common/src/sandbox.rs | 2 +- client/executor/wasmtime/Cargo.toml | 23 +- 5 files changed, 163 insertions(+), 214 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c92efea3fed0d..2ffa44ac6ce9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -597,6 +597,24 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24508e28c677875c380c20f4d28124fab6f8ed4ef929a1397d7b1a31e92f1005" +[[package]] +name = "capstone" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031ba51c39151a1d6336ec859646153187204b0147c7b3f6fe2de636f1b8dbb3" +dependencies = [ + "capstone-sys", +] + +[[package]] +name = "capstone-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fae25eddcb80e24f98c35952c37a91ff7f8d0f60dbbdafb9763e8d5cc566b8d7" +dependencies = [ + "cc", +] + [[package]] name = "cargo_metadata" version = "0.10.0" @@ -815,53 +833,24 @@ checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-entity 0.65.0", -] - -[[package]] -name = "cranelift-bforest" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dcc286b052ee24a1e5a222e7c1125e6010ad35b0f248709b9b3737a8fedcfdf" -dependencies = [ - "cranelift-entity 0.66.0", + "cranelift-entity", ] [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" -dependencies = [ - "byteorder", - "cranelift-bforest 0.65.0", - "cranelift-codegen-meta 0.65.0", - "cranelift-codegen-shared 0.65.0", - "cranelift-entity 0.65.0", - "gimli 0.21.0", - "log", - "regalloc 0.0.26", - "serde", - "smallvec 1.4.1", - "target-lexicon", - "thiserror", -] - -[[package]] -name = "cranelift-codegen" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9badfe36176cb653506091693bc2bb1970c9bddfcd6ec7fac404f7eaec6f38" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "byteorder", - "cranelift-bforest 0.66.0", - "cranelift-codegen-meta 0.66.0", - "cranelift-codegen-shared 0.66.0", - "cranelift-entity 0.66.0", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", "gimli 0.21.0", "log", - "regalloc 0.0.27", + "regalloc", "serde", "smallvec 1.4.1", "target-lexicon", @@ -871,46 +860,21 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" -dependencies = [ - "cranelift-codegen-shared 0.65.0", - "cranelift-entity 0.65.0", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3f460031861e4f4ad510be62b2ae50bba6cc886b598a36f9c0a970feab9598" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen-shared 0.66.0", - "cranelift-entity 0.66.0", + "cranelift-codegen-shared", + "cranelift-entity", ] [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" - -[[package]] -name = "cranelift-codegen-shared" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ad12409e922e7697cd0bdc7dc26992f64a77c31880dfe5e3c7722f4710206d" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" -dependencies = [ - "serde", -] - -[[package]] -name = "cranelift-entity" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97cdc58972ea065d107872cfb9079f4c92ade78a8af85aaff519a65b5d13f71" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "serde", ] @@ -918,21 +882,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" -dependencies = [ - "cranelift-codegen 0.65.0", - "log", - "smallvec 1.4.1", - "target-lexicon", -] - -[[package]] -name = "cranelift-frontend" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef419efb4f94ecc02e5d9fbcc910d2bb7f0040e2de570e63a454f883bc891d6" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen 0.66.0", + "cranelift-codegen", "log", "smallvec 1.4.1", "target-lexicon", @@ -941,9 +893,9 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen 0.65.0", + "cranelift-codegen", "raw-cpuid", "target-lexicon", ] @@ -951,30 +903,15 @@ dependencies = [ [[package]] name = "cranelift-wasm" version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" -dependencies = [ - "cranelift-codegen 0.65.0", - "cranelift-entity 0.65.0", - "cranelift-frontend 0.65.0", - "log", - "serde", - "thiserror", - "wasmparser 0.57.0", -] - -[[package]] -name = "cranelift-wasm" -version = "0.66.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "979df666b1304624abe99738e9e0e7c7479ee5523ba4b8b237df9ff49996acbb" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen 0.66.0", - "cranelift-entity 0.66.0", - "cranelift-frontend 0.66.0", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", "log", "serde", "thiserror", - "wasmparser 0.59.0", + "wasmparser", ] [[package]] @@ -1213,6 +1150,17 @@ dependencies = [ "syn 1.0.33", ] +[[package]] +name = "derive_utils" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df5480412da86cdf5d6b7f3b682422c84359ff7399aa658df1d15ee83244b1d" +dependencies = [ + "proc-macro2", + "quote 1.0.6", + "syn 1.0.33", +] + [[package]] name = "difference" version = "2.0.0" @@ -1302,6 +1250,31 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c53dc3a653e0f64081026e4bf048d48fec9fce90c66e8326ca7292df0ff2d82" +[[package]] +name = "dynasm" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" +dependencies = [ + "bitflags", + "byteorder", + "lazy_static", + "owning_ref", + "proc-macro2", + "quote 1.0.6", + "syn 1.0.33", +] + +[[package]] +name = "dynasmrt" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" +dependencies = [ + "byteorder", + "memmap", +] + [[package]] name = "ed25519" version = "1.0.1" @@ -2516,7 +2489,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" dependencies = [ "autocfg 1.0.0", - "serde", ] [[package]] @@ -2556,6 +2528,17 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" +[[package]] +name = "iter-enum" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cdea9771bec3d95893f6c665a4fcd477af7858446a46bc2772f560534eee43b" +dependencies = [ + "derive_utils", + "quote 1.0.6", + "syn 1.0.33", +] + [[package]] name = "itertools" version = "0.8.2" @@ -3239,6 +3222,24 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "lightbeam" +version = "0.18.0" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" +dependencies = [ + "capstone", + "cranelift-codegen", + "derive_more", + "dynasm", + "dynasmrt", + "iter-enum", + "itertools 0.8.2", + "memoffset", + "more-asserts", + "thiserror", + "wasmparser", +] + [[package]] name = "linked-hash-map" version = "0.5.2" @@ -4107,13 +4108,12 @@ dependencies = [ [[package]] name = "object" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5666bbb90bc4d1e5bdcb26c0afda1822d25928341e9384ab187a9b37ab69e36" +checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" dependencies = [ "crc32fast", "indexmap", - "target-lexicon", ] [[package]] @@ -5946,17 +5946,6 @@ dependencies = [ "smallvec 1.4.1", ] -[[package]] -name = "regalloc" -version = "0.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ba8aaf5fe7cf307c6dbdaeed85478961d29e25e3bee5169e11b92fa9f027a8" -dependencies = [ - "log", - "rustc-hash", - "smallvec 1.4.1", -] - [[package]] name = "regex" version = "1.3.6" @@ -6704,8 +6693,8 @@ name = "sc-executor-wasmtime" version = "0.8.0-rc5" dependencies = [ "assert_matches", - "cranelift-codegen 0.66.0", - "cranelift-wasm 0.66.0", + "cranelift-codegen", + "cranelift-wasm", "log", "parity-scale-codec", "parity-wasm 0.41.0", @@ -6716,8 +6705,8 @@ dependencies = [ "sp-runtime-interface", "sp-wasm-interface", "wasmtime", - "wasmtime-environ 0.19.0", - "wasmtime-runtime 0.19.0", + "wasmtime-environ", + "wasmtime-runtime", ] [[package]] @@ -9792,31 +9781,26 @@ version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" -[[package]] -name = "wasmparser" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a950e6a618f62147fd514ff445b2a0b53120d382751960797f85f058c7eda9b9" - [[package]] name = "wasmtime" version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "anyhow", "backtrace", "cfg-if", + "itertools 0.9.0", "lazy_static", "libc", "log", "region", "rustc-demangle", "target-lexicon", - "wasmparser 0.57.0", - "wasmtime-environ 0.18.0", + "wasmparser", + "wasmtime-environ", "wasmtime-jit", "wasmtime-profiling", - "wasmtime-runtime 0.18.0", + "wasmtime-runtime", "wat", "winapi 0.3.8", ] @@ -9824,34 +9808,35 @@ dependencies = [ [[package]] name = "wasmtime-debug" version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "anyhow", "gimli 0.21.0", "more-asserts", - "object 0.18.0", + "object 0.19.0", "target-lexicon", "thiserror", - "wasmparser 0.57.0", - "wasmtime-environ 0.18.0", + "wasmparser", + "wasmtime-environ", ] [[package]] name = "wasmtime-environ" version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "anyhow", "base64 0.12.3", "bincode", - "cranelift-codegen 0.65.0", - "cranelift-entity 0.65.0", - "cranelift-wasm 0.65.0", + "cranelift-codegen", + "cranelift-entity", + "cranelift-wasm", "directories", "errno", "file-per-thread-logger", "indexmap", "libc", + "lightbeam", "log", "more-asserts", "rayon", @@ -9859,37 +9844,7 @@ dependencies = [ "sha2 0.8.1", "thiserror", "toml", - "wasmparser 0.57.0", - "winapi 0.3.8", - "zstd", -] - -[[package]] -name = "wasmtime-environ" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f85619a94ee4034bd5bb87fc3dcf71fd2237b81c840809da1201061eec9ab3" -dependencies = [ - "anyhow", - "base64 0.12.3", - "bincode", - "cfg-if", - "cranelift-codegen 0.66.0", - "cranelift-entity 0.66.0", - "cranelift-frontend 0.66.0", - "cranelift-wasm 0.66.0", - "directories", - "errno", - "file-per-thread-logger", - "indexmap", - "libc", - "log", - "more-asserts", - "serde", - "sha2 0.8.1", - "thiserror", - "toml", - "wasmparser 0.59.0", + "wasmparser", "winapi 0.3.8", "zstd", ] @@ -9897,71 +9852,51 @@ dependencies = [ [[package]] name = "wasmtime-jit" version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "anyhow", "cfg-if", - "cranelift-codegen 0.65.0", - "cranelift-entity 0.65.0", - "cranelift-frontend 0.65.0", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", "cranelift-native", - "cranelift-wasm 0.65.0", + "cranelift-wasm", "gimli 0.21.0", "log", "more-asserts", "region", "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser", "wasmtime-debug", - "wasmtime-environ 0.18.0", + "wasmtime-environ", "wasmtime-profiling", - "wasmtime-runtime 0.18.0", + "wasmtime-runtime", "winapi 0.3.8", ] [[package]] name = "wasmtime-profiling" version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "anyhow", "cfg-if", "gimli 0.21.0", "lazy_static", "libc", - "object 0.18.0", + "object 0.19.0", "scroll", "serde", "target-lexicon", - "wasmtime-environ 0.18.0", - "wasmtime-runtime 0.18.0", + "wasmtime-environ", + "wasmtime-runtime", ] [[package]] name = "wasmtime-runtime" version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=stress-test#69c57cd4a793c3f3f0374c6f694d375cd5f74c3b" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "indexmap", - "lazy_static", - "libc", - "memoffset", - "more-asserts", - "region", - "thiserror", - "wasmtime-environ 0.18.0", - "winapi 0.3.8", -] - -[[package]] -name = "wasmtime-runtime" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a25f140bbbaadb07c531cba99ce1a966dba216138dc1b2a0ddecec851a01a93" +source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "backtrace", "cc", @@ -9974,7 +9909,7 @@ dependencies = [ "more-asserts", "region", "thiserror", - "wasmtime-environ 0.19.0", + "wasmtime-environ", "winapi 0.3.8", ] diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 0c0282b8d7157..99fa47e888346 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -49,7 +49,7 @@ sc-tracing = { version = "2.0.0-rc5", path = "../tracing" } tracing = "0.1.14" [features] -default = [ "std" ] +default = [ "std", "wasmtime" ] # This crate does not have `no_std` support, we just require this for tests std = [] wasm-extern-trace = [] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index cc11d7fe89d32..ac1c37710e9d8 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -24,7 +24,10 @@ sp-wasm-interface = { version = "2.0.0-rc5", path = "../../../primitives/wasm-in sp-runtime-interface = { version = "2.0.0-rc5", path = "../../../primitives/runtime-interface" } sp-serializer = { version = "2.0.0-rc5", path = "../../../primitives/serializer" } # wasmtime = { package = "substrate-wasmtime", version = "0.19.0" } -wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="stress-test" } + +wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } + +#wasmtime = { path = "../../../../wasmtime/crates/wasmtime" } [features] default = [] diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 42a7bc5436fc5..1d97a24e23cf3 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -646,7 +646,7 @@ where SandboxBackend::Wasmtime => { let mut config = wasmtime::Config::new(); - config.cranelift_opt_level(wasmtime::OptLevel::Speed); + config.cranelift_opt_level(wasmtime::OptLevel::None); config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmtime_engine = wasmtime::Engine::new(&config); diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 3c929b17ef4bd..b6a8a8087cf0b 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -21,13 +21,24 @@ sp-wasm-interface = { version = "2.0.0-rc5", path = "../../../primitives/wasm-in sp-runtime-interface = { version = "2.0.0-rc5", path = "../../../primitives/runtime-interface" } sp-core = { version = "2.0.0-rc5", path = "../../../primitives/core" } sp-allocator = { version = "2.0.0-rc5", path = "../../../primitives/allocator" } -# wasmtime = { package = "substrate-wasmtime", version = "0.19.0" } -wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="stress-test" } -wasmtime-runtime = { version = "0.19.0" } -wasmtime-environ = { version = "0.19.0" } -cranelift-wasm = { version = "0.66.0" } -cranelift-codegen = { version = "0.66.0" } +#wasmtime = { package = "substrate-wasmtime", version = "0.19.0" } +wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master", features=["lightbeam"] } +#wasmtime = { path = "../../../../wasmtime/crates/wasmtime" } +#wasmtime-runtime = { path = "../../../../wasmtime/crates/runtime" } +#wasmtime-environ = { path = "../../../../wasmtime/crates/environ" } + +wasmtime-runtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +wasmtime-environ = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +#wasmtime-runtime = { version = "0.19.0" } +#wasmtime-environ = { version = "0.19.0" } + +cranelift-wasm = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +cranelift-codegen = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +#cranelift-wasm = { version = "0.66.0" } +#cranelift-codegen = { version = "0.66.0" } +#cranelift-wasm = { path = "../../../../wasmtime/cranelift/wasm" } +#cranelift-codegen = { path = "../../../../wasmtime/cranelift/codegen" } [dev-dependencies] assert_matches = "1.3.0" From 74f9887fddba4d77322a33308df445ee0694ede7 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Oct 2020 15:31:44 +0700 Subject: [PATCH 25/88] Adds wasmer impl stub --- Cargo.lock | 424 ++++++++++++++++++++++++-- client/executor/common/Cargo.toml | 3 + client/executor/common/src/sandbox.rs | 39 +++ client/executor/wasmtime/src/host.rs | 2 +- 4 files changed, 441 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31f77e0d8bc14..7047bd9e5a712 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -380,7 +380,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "which", + "which 3.1.1", ] [[package]] @@ -724,7 +724,7 @@ checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" dependencies = [ "glob", "libc", - "libloading", + "libloading 0.5.2", ] [[package]] @@ -736,7 +736,7 @@ dependencies = [ "ansi_term 0.11.0", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", @@ -837,12 +837,41 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" +dependencies = [ + "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cranelift-bforest" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-entity", + "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", +] + +[[package]] +name = "cranelift-codegen" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" +dependencies = [ + "byteorder 1.3.4", + "cranelift-bforest 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen-meta 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen-shared 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gimli 0.21.0", + "log", + "regalloc", + "serde", + "smallvec 1.4.1", + "target-lexicon", + "thiserror", ] [[package]] @@ -851,10 +880,10 @@ version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "byteorder 1.3.4", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-bforest 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-codegen-meta 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-codegen-shared 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "gimli 0.21.0", "log", "regalloc", @@ -864,20 +893,45 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cranelift-codegen-meta" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" +dependencies = [ + "cranelift-codegen-shared 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cranelift-codegen-meta" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen-shared", - "cranelift-entity", + "cranelift-codegen-shared 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", ] +[[package]] +name = "cranelift-codegen-shared" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" + [[package]] name = "cranelift-codegen-shared" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" +[[package]] +name = "cranelift-entity" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +dependencies = [ + "serde", +] + [[package]] name = "cranelift-entity" version = "0.65.0" @@ -886,12 +940,24 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" +dependencies = [ + "cranelift-codegen 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log", + "smallvec 1.4.1", + "target-lexicon", +] + [[package]] name = "cranelift-frontend" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "log", "smallvec 1.4.1", "target-lexicon", @@ -902,7 +968,7 @@ name = "cranelift-native" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen", + "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "raw-cpuid", "target-lexicon", ] @@ -912,9 +978,9 @@ name = "cranelift-wasm" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", + "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-frontend 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "log", "serde", "thiserror", @@ -1104,6 +1170,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "darling" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.9.3", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "data-encoding" version = "2.2.1" @@ -1241,6 +1342,21 @@ dependencies = [ "syn", ] +[[package]] +name = "dynasm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" +dependencies = [ + "bitflags", + "byteorder 1.3.4", + "lazy_static", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "dynasmrt" version = "0.5.2" @@ -1251,6 +1367,17 @@ dependencies = [ "memmap", ] +[[package]] +name = "dynasmrt" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" +dependencies = [ + "byteorder 1.3.4", + "dynasm 1.0.0", + "memmap", +] + [[package]] name = "ed25519" version = "1.0.1" @@ -1300,6 +1427,28 @@ dependencies = [ "syn", ] +[[package]] +name = "enumset" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" +dependencies = [ + "enumset_derive", + "num-traits", +] + +[[package]] +name = "enumset_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -1747,7 +1896,7 @@ checksum = "921d332c89b3b61a826de38c61ee5b6e02c56806cade1b0e5d81bd71f57a71bb" dependencies = [ "lazy_static", "libc", - "libloading", + "libloading 0.5.2", "winapi 0.3.9", ] @@ -2392,6 +2541,12 @@ dependencies = [ "webpki", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.1.5" @@ -2460,6 +2615,7 @@ checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" dependencies = [ "autocfg 1.0.0", "hashbrown 0.8.1", + "serde", ] [[package]] @@ -2807,6 +2963,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "libloading" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9" +dependencies = [ + "cfg-if", + "winapi 0.3.9", +] + [[package]] name = "libm" version = "0.2.1" @@ -3268,10 +3434,10 @@ version = "0.18.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" dependencies = [ "capstone", - "cranelift-codegen", + "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "derive_more", - "dynasm", - "dynasmrt", + "dynasm 0.5.2", + "dynasmrt 0.5.2", "iter-enum", "itertools 0.8.2", "memoffset", @@ -5667,7 +5833,7 @@ dependencies = [ "prost", "prost-types", "tempfile", - "which", + "which 3.1.1", ] [[package]] @@ -6792,6 +6958,9 @@ dependencies = [ "sp-runtime-interface", "sp-serializer", "sp-wasm-interface", + "wasmer", + "wasmer-compiler-singlepass", + "wasmer-engine-jit", "wasmi", "wasmtime", ] @@ -6816,7 +6985,7 @@ name = "sc-executor-wasmtime" version = "0.8.0" dependencies = [ "assert_matches", - "cranelift-codegen", + "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "cranelift-wasm", "log", "parity-scale-codec", @@ -7589,6 +7758,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" +dependencies = [ + "serde", +] + [[package]] name = "serde_cbor" version = "0.11.1" @@ -8624,6 +8802,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" + [[package]] name = "structopt" version = "0.3.15" @@ -9931,6 +10115,184 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasmer" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc770914c1c0b5b5bc065db787d40f07a6fee208d3bd71d817dd0ace410e8c07" +dependencies = [ + "cfg-if", + "indexmap", + "more-asserts", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-engine", + "wasmer-engine-jit", + "wasmer-engine-native", + "wasmer-types", + "wasmer-vm", + "wat", + "winapi 0.3.9", +] + +[[package]] +name = "wasmer-compiler" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b77e50cd83c1b2511b89ce94cbdde077d788c18beca589069e520705a5e00507" +dependencies = [ + "enumset", + "raw-cpuid", + "serde", + "serde_bytes", + "smallvec 1.4.1", + "target-lexicon", + "thiserror", + "wasmer-types", + "wasmer-vm", + "wasmparser", +] + +[[package]] +name = "wasmer-compiler-cranelift" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3fdb46f15f7ac3b9d8a27864e67b3be90454f7090d45804226dd5621eb9cb46" +dependencies = [ + "cranelift-codegen 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-frontend 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gimli 0.21.0", + "more-asserts", + "rayon", + "serde", + "tracing", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-compiler-singlepass" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d896ae60370b768a286566549c9d999c5cb8cfcad61b83a86fc73a9b61f8f618" +dependencies = [ + "byteorder 1.3.4", + "dynasm 1.0.0", + "dynasmrt 1.0.0", + "lazy_static", + "more-asserts", + "rayon", + "serde", + "smallvec 1.4.1", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63090cbbdd037431489f1d39c0b4c3f024fa9c3fdaf93d15840695a3223664ad" +dependencies = [ + "backtrace", + "bincode", + "lazy_static", + "more-asserts", + "rustc-demangle", + "serde", + "serde_bytes", + "target-lexicon", + "thiserror", + "wasmer-compiler", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-engine-jit" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0229a22fe24df530e739224ac2b755702a1e4408100537cb0a90a5bbf349e7f8" +dependencies = [ + "bincode", + "cfg-if", + "region", + "serde", + "serde_bytes", + "wasmer-compiler", + "wasmer-engine", + "wasmer-types", + "wasmer-vm", + "winapi 0.3.9", +] + +[[package]] +name = "wasmer-engine-native" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b2adb25608bcc4624d644cb7e646790ac3b7a5a547030aefd60d99208076be" +dependencies = [ + "bincode", + "cfg-if", + "leb128", + "libloading 0.6.3", + "serde", + "tempfile", + "tracing", + "wasmer-compiler", + "wasmer-engine", + "wasmer-object", + "wasmer-types", + "wasmer-vm", + "which 4.0.2", +] + +[[package]] +name = "wasmer-object" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0e912d69e5db8437836dbdf2b01bf2527fc3694ec0699dfa5b3f1f542d89f4e" +dependencies = [ + "object 0.19.0", + "thiserror", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-types" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b64a1de3bd91b43208bba4f956f9a8a1819cc8c785d65ac8199f70bbb1eaa4" +dependencies = [ + "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", +] + +[[package]] +name = "wasmer-vm" +version = "1.0.0-alpha3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2971a31765cbe3711d39a63f58edc380554c01bf63a6a2d4e9c4c473b9a7a01" +dependencies = [ + "backtrace", + "cc", + "cfg-if", + "indexmap", + "libc", + "memoffset", + "more-asserts", + "region", + "serde", + "thiserror", + "wasmer-types", + "winapi 0.3.9", +] + [[package]] name = "wasmi" version = "0.6.2" @@ -10008,8 +10370,8 @@ dependencies = [ "anyhow", "base64 0.12.3", "bincode", - "cranelift-codegen", - "cranelift-entity", + "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "cranelift-wasm", "directories", "errno", @@ -10036,9 +10398,9 @@ source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551d dependencies = [ "anyhow", "cfg-if", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", + "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", + "cranelift-frontend 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "cranelift-native", "cranelift-wasm", "gimli 0.21.0", @@ -10167,6 +10529,16 @@ dependencies = [ "libc", ] +[[package]] +name = "which" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index fafa5ad513355..db3a7cc110c61 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -25,6 +25,9 @@ sp-wasm-interface = { version = "2.0.0", path = "../../../primitives/wasm-interf sp-runtime-interface = { version = "2.0.0", path = "../../../primitives/runtime-interface" } sp-serializer = { version = "2.0.0", path = "../../../primitives/serializer" } wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +wasmer = "1.0.0-alpha3" +wasmer-compiler-singlepass = "1.0.0-alpha3" +wasmer-engine-jit = "1.0.0-alpha3" [features] default = [] diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 1d97a24e23cf3..da6a61bbffc32 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -40,6 +40,10 @@ use wasmtime::Val; use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; +// use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; +use wasmer_compiler_singlepass::Singlepass; +use wasmer_engine_jit::JIT; + /// Index of a function inside the supervisor. /// /// This is a typically an index in the default table of the supervisor, however @@ -342,6 +346,7 @@ where enum BackendInstance { Wasmi(wasmi::ModuleRef), Wasmtime(wasmtime::Instance), + Wasmer(wasmer::Instance), } /// Sandboxed instance of a wasm module. @@ -442,6 +447,8 @@ impl SandboxInstance { Ok(wasmtime_result) } + + BackendInstance::Wasmer(_) => { todo!() } } }, ) @@ -474,6 +481,10 @@ impl SandboxInstance { Some(wasmtime_value) } + + BackendInstance::Wasmer(wasmer_instance) => { + todo!() + } } } } @@ -587,6 +598,7 @@ pub trait SandboxCapabiliesHolder { pub enum SandboxBackend { Wasmi, Wasmtime, + Wasmer, } /// Instantiate a guest module and return it's index in the store. @@ -768,6 +780,33 @@ where guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, }) } + + SandboxBackend::Wasmer => { + let compiler = Singlepass::default(); + let store = wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()); + + println!("Decoding module..."); + let module = wasmer::Module::new(&store, wasm).map_err(|error| { + println!("{:?}", error); + InstantiationError::ModuleDecoding + })?; + + let import_object = wasmer::imports! {}; + + println!("Instantiating module..."); + let instance = wasmer::Instance::new(&module, &import_object) + .map_err(|error| { + println!("{:?}", error); + InstantiationError::Instantiation + })?; + + println!("Creating SandboxInstance..."); + Rc::new(SandboxInstance { + backend_instance: BackendInstance::Wasmer(instance), + dispatch_thunk, + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }) + } }; Ok(UnregisteredInstance { sandbox_instance }) diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 1358fec14babe..f78a43c8dcfac 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -325,7 +325,7 @@ impl Sandbox for HostState { let instance_idx_or_err_code = match sandbox::instantiate::<_, _, Holder>( - SandboxBackend::Wasmtime, + SandboxBackend::Wasmer, dispatch_thunk, wasm, guest_env, From c719155047fda51748abf92cebd192d15eaece64 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Oct 2020 15:52:25 +0700 Subject: [PATCH 26/88] Adds get global --- client/executor/common/src/sandbox.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index da6a61bbffc32..06276edc191ec 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -483,7 +483,16 @@ impl SandboxInstance { } BackendInstance::Wasmer(wasmer_instance) => { - todo!() + let global = wasmer_instance.exports.get_global(name).ok()?; + let wasmtime_value = match global.get() { + wasmer::Val::I32(val) => Value::I32(val), + wasmer::Val::I64(val) => Value::I64(val), + wasmer::Val::F32(val) => Value::F32(val as u32), + wasmer::Val::F64(val) => Value::F64(val as u64), + _ => None?, + }; + + Some(wasmtime_value) } } } From adff0993e1ad2c6a5b2374ffb2cb4b3ac6eb3288 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Oct 2020 15:57:58 +0700 Subject: [PATCH 27/88] Fixes warnings --- client/executor/common/src/sandbox.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 06276edc191ec..fd23d295910b1 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -28,7 +28,7 @@ use sp_core::sandbox as sandbox_primitives; use wasmi::{ Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance, - ModuleRef, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages, + RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages, }; use sp_wasm_interface::Value; @@ -42,7 +42,6 @@ use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; // use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer_compiler_singlepass::Singlepass; -use wasmer_engine_jit::JIT; /// Index of a function inside the supervisor. /// @@ -597,16 +596,27 @@ impl UnregisteredInstance { } } +/// Helper type to provide sandbox capabilities to the inner context pub trait SandboxCapabiliesHolder { + /// Supervisor function reference type SupervisorFuncRef; + + /// Capabilities trait type SC: SandboxCapabilities; + /// Wrapper that provides sandbox capabilities in a limited context fn with_sandbox_capabilities R>(f: F) -> R; } +/// Sandbox backend to use pub enum SandboxBackend { + /// Wasm interpreter Wasmi, + + /// Wasmtime environment Wasmtime, + + /// Wasmer environment Wasmer, } @@ -776,7 +786,7 @@ where .collect(); let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|error| - if let Ok(trap) = error.downcast::() { + if let Ok(_trap) = error.downcast::() { InstantiationError::StartTrapped } else { InstantiationError::Instantiation From cd445345e31f41032ae69491d1dfeca841ffad5f Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Oct 2020 16:09:57 +0700 Subject: [PATCH 28/88] Adds wasmer invoke impl --- client/executor/common/src/sandbox.rs | 42 ++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index fd23d295910b1..f024f9b05c640 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -447,7 +447,47 @@ impl SandboxInstance { Ok(wasmtime_result) } - BackendInstance::Wasmer(_) => { todo!() } + BackendInstance::Wasmer(wasmer_instance) => { + let function = wasmer_instance + .exports + .get_function(export_name) + .map_err(|error| { + println!("{:?}", error); + wasmi::Error::Function("wasmer function failed".to_string()) + })?; + + let args: Vec = args + .iter() + .map(|v| match *v { + RuntimeValue::I32(val) => wasmer::Val::I32(val), + RuntimeValue::I64(val) => wasmer::Val::I64(val), + RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), + RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), + }) + .collect(); + + let wasmer_result = function + .call(&args) + .map_err(|e| wasmi::Error::Function(e.to_string()))?; + + assert!(wasmer_result.len() < 2, "multiple return types are not supported yet"); + + let wasmer_result = if let Some(wasmer_value) = wasmer_result.first() { + let wasmer_value = match *wasmer_value { + wasmer::Val::I32(val) => RuntimeValue::I32(val), + wasmer::Val::I64(val) => RuntimeValue::I64(val), + wasmer::Val::F32(val) => RuntimeValue::F32(val.into()), + wasmer::Val::F64(val) => RuntimeValue::F64(val.into()), + _ => unreachable!(), + }; + + Some(wasmer_value) + } else { + None + }; + + Ok(wasmer_result) + } } }, ) From 5ed937ff0fc6136f313da9f8db1a04912daf7d3b Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 8 Oct 2020 15:22:09 +0700 Subject: [PATCH 29/88] Implements host function interface for wasmer --- Cargo.lock | 252 +++++++++++++++++++++++++- client/executor/common/Cargo.toml | 1 + client/executor/common/src/sandbox.rs | 113 +++++++++++- 3 files changed, 355 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7047bd9e5a712..f39186bafaf1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,6 +465,21 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "blake3" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" +dependencies = [ + "arrayref", + "arrayvec 0.5.1", + "cc", + "cfg-if", + "constant_time_eq", + "crypto-mac 0.8.0", + "digest 0.9.0", +] + [[package]] name = "block-buffer" version = "0.7.3" @@ -837,6 +852,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cranelift-bforest" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" +dependencies = [ + "cranelift-entity 0.59.0", +] + [[package]] name = "cranelift-bforest" version = "0.65.0" @@ -854,6 +878,24 @@ dependencies = [ "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", ] +[[package]] +name = "cranelift-codegen" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" +dependencies = [ + "byteorder 1.3.4", + "cranelift-bforest 0.59.0", + "cranelift-codegen-meta 0.59.0", + "cranelift-codegen-shared 0.59.0", + "cranelift-entity 0.59.0", + "gimli 0.20.0", + "log", + "smallvec 1.4.1", + "target-lexicon", + "thiserror", +] + [[package]] name = "cranelift-codegen" version = "0.65.0" @@ -893,6 +935,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cranelift-codegen-meta" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" +dependencies = [ + "cranelift-codegen-shared 0.59.0", + "cranelift-entity 0.59.0", +] + [[package]] name = "cranelift-codegen-meta" version = "0.65.0" @@ -912,6 +964,12 @@ dependencies = [ "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", ] +[[package]] +name = "cranelift-codegen-shared" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" + [[package]] name = "cranelift-codegen-shared" version = "0.65.0" @@ -923,6 +981,12 @@ name = "cranelift-codegen-shared" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" +[[package]] +name = "cranelift-entity" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" + [[package]] name = "cranelift-entity" version = "0.65.0" @@ -963,6 +1027,17 @@ dependencies = [ "target-lexicon", ] +[[package]] +name = "cranelift-native" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" +dependencies = [ + "cranelift-codegen 0.59.0", + "raw-cpuid", + "target-lexicon", +] + [[package]] name = "cranelift-native" version = "0.65.0" @@ -984,7 +1059,7 @@ dependencies = [ "log", "serde", "thiserror", - "wasmparser", + "wasmparser 0.57.0", ] [[package]] @@ -2205,6 +2280,16 @@ dependencies = [ "polyval", ] +[[package]] +name = "gimli" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +dependencies = [ + "byteorder 1.3.4", + "indexmap", +] + [[package]] name = "gimli" version = "0.21.0" @@ -3443,7 +3528,7 @@ dependencies = [ "memoffset", "more-asserts", "thiserror", - "wasmparser", + "wasmparser 0.57.0", ] [[package]] @@ -3835,6 +3920,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "nix" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "void", +] + [[package]] name = "nix" version = "0.17.0" @@ -3915,7 +4013,7 @@ dependencies = [ "futures 0.3.5", "hex-literal", "log", - "nix", + "nix 0.17.0", "node-executor", "node-inspect", "node-primitives", @@ -4429,6 +4527,16 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "page_size" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" +dependencies = [ + "libc", + "winapi 0.3.9", +] + [[package]] name = "pallet-assets" version = "2.0.0" @@ -6564,7 +6672,7 @@ dependencies = [ "libp2p", "log", "names", - "nix", + "nix 0.17.0", "parity-scale-codec", "parity-util-mem", "rand 0.7.3", @@ -6961,6 +7069,7 @@ dependencies = [ "wasmer", "wasmer-compiler-singlepass", "wasmer-engine-jit", + "wasmer-runtime", "wasmi", "wasmtime", ] @@ -7758,6 +7867,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-bench" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" +dependencies = [ + "byteorder 1.3.4", + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.5" @@ -10137,6 +10256,58 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wasmer-clif-backend" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a2fae69b1c7429316cad6743f3d2ca83cf8957924c477c5a4eff036ec0097a9" +dependencies = [ + "byteorder 1.3.4", + "cranelift-codegen 0.59.0", + "cranelift-entity 0.59.0", + "cranelift-native 0.59.0", + "libc", + "nix 0.15.0", + "rayon", + "serde", + "serde-bench", + "serde_bytes", + "serde_derive", + "target-lexicon", + "wasmer-clif-fork-frontend", + "wasmer-clif-fork-wasm", + "wasmer-runtime-core", + "wasmer-win-exception-handler", + "wasmparser 0.51.4", + "winapi 0.3.9", +] + +[[package]] +name = "wasmer-clif-fork-frontend" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" +dependencies = [ + "cranelift-codegen 0.59.0", + "log", + "smallvec 1.4.1", + "target-lexicon", +] + +[[package]] +name = "wasmer-clif-fork-wasm" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" +dependencies = [ + "cranelift-codegen 0.59.0", + "cranelift-entity 0.59.0", + "log", + "thiserror", + "wasmer-clif-fork-frontend", + "wasmparser 0.51.4", +] + [[package]] name = "wasmer-compiler" version = "1.0.0-alpha3" @@ -10152,7 +10323,7 @@ dependencies = [ "thiserror", "wasmer-types", "wasmer-vm", - "wasmparser", + "wasmparser 0.57.0", ] [[package]] @@ -10263,6 +10434,49 @@ dependencies = [ "wasmer-types", ] +[[package]] +name = "wasmer-runtime" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92a9ae96b193c35c47fc829265198322cf980edc353a9de32bc87a1545d44f3" +dependencies = [ + "lazy_static", + "memmap", + "serde", + "serde_derive", + "wasmer-clif-backend", + "wasmer-runtime-core", +] + +[[package]] +name = "wasmer-runtime-core" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740161245998752cf1a567e860fd6355df0336fedca6be1940ec7aaa59643220" +dependencies = [ + "bincode", + "blake3", + "cc", + "digest 0.8.1", + "errno", + "hex", + "indexmap", + "lazy_static", + "libc", + "nix 0.15.0", + "page_size", + "parking_lot 0.10.2", + "rustc_version", + "serde", + "serde-bench", + "serde_bytes", + "serde_derive", + "smallvec 1.4.1", + "target-lexicon", + "wasmparser 0.51.4", + "winapi 0.3.9", +] + [[package]] name = "wasmer-types" version = "1.0.0-alpha3" @@ -10293,6 +10507,18 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wasmer-win-exception-handler" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd39f3b2bd7964b28ea6f944a7eaa445cfbc91c4f2695d188103f2689bb37d9" +dependencies = [ + "cc", + "libc", + "wasmer-runtime-core", + "winapi 0.3.9", +] + [[package]] name = "wasmi" version = "0.6.2" @@ -10317,6 +10543,12 @@ dependencies = [ "parity-wasm 0.41.0", ] +[[package]] +name = "wasmparser" +version = "0.51.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" + [[package]] name = "wasmparser" version = "0.57.0" @@ -10338,7 +10570,7 @@ dependencies = [ "region", "rustc-demangle", "target-lexicon", - "wasmparser", + "wasmparser 0.57.0", "wasmtime-environ", "wasmtime-jit", "wasmtime-profiling", @@ -10358,7 +10590,7 @@ dependencies = [ "object 0.19.0", "target-lexicon", "thiserror", - "wasmparser", + "wasmparser 0.57.0", "wasmtime-environ", ] @@ -10386,7 +10618,7 @@ dependencies = [ "sha2 0.8.2", "thiserror", "toml", - "wasmparser", + "wasmparser 0.57.0", "winapi 0.3.9", "zstd", ] @@ -10401,7 +10633,7 @@ dependencies = [ "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "cranelift-frontend 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", - "cranelift-native", + "cranelift-native 0.65.0", "cranelift-wasm", "gimli 0.21.0", "log", @@ -10409,7 +10641,7 @@ dependencies = [ "region", "target-lexicon", "thiserror", - "wasmparser", + "wasmparser 0.57.0", "wasmtime-debug", "wasmtime-environ", "wasmtime-profiling", diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index db3a7cc110c61..59395691f97c7 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -28,6 +28,7 @@ wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } wasmer = "1.0.0-alpha3" wasmer-compiler-singlepass = "1.0.0-alpha3" wasmer-engine-jit = "1.0.0-alpha3" +wasmer-runtime = "0.17" [features] default = [] diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index f024f9b05c640..78d7b5f21f54c 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -850,7 +850,118 @@ where InstantiationError::ModuleDecoding })?; - let import_object = wasmer::imports! {}; + + let imports: Vec<_> = module + .imports() + .into_iter() + .filter_map(|import| { + if let wasmer::ExternType::Function(func_ty) = import.ty() { + let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { + index + } else { + // Missing import + return None; + }; + + let supervisor_func_index = guest_env.guest_to_supervisor_mapping + .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); + + let dispatch_thunk = dispatch_thunk.clone(); + let function = wasmer::Function::new(&store, func_ty, move |params| { + SCH::with_sandbox_capabilities(|supervisor_externals| { + // Serialize arguments into a byte vector. + let invoke_args_data = params + .iter() + .map(|val| match val { + wasmer::Val::I32(val) => Value::I32(*val), + wasmer::Val::I64(val) => Value::I64(*val), + wasmer::Val::F32(val) => Value::F32(*val as u32), + wasmer::Val::F64(val) => Value::F64(*val as u64), + _ => unimplemented!() + }) + .collect::>() + .encode(); + + // Move serialized arguments inside the memory, invoke dispatch thunk and + // then free allocated memory. + let invoke_args_len = invoke_args_data.len() as WordSize; + let invoke_args_ptr = supervisor_externals + .allocate_memory(invoke_args_len) + .map_err(|_| wasmer::RuntimeError::new("Can't allocate memory in supervisor for the arguments"))?; + + let deallocate = |fe: &mut FE, ptr, fail_msg| { + fe + .deallocate_memory(ptr) + .map_err(|_| wasmer::RuntimeError::new(fail_msg)) + }; + + if supervisor_externals + .write_memory(invoke_args_ptr, &invoke_args_data) + .is_err() + { + deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; + return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); + } + + let serialized_result = supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + .map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; + + // dispatch_thunk returns pointer to serialized arguments. + // Unpack pointer and len of the serialized result data. + let (serialized_result_val_ptr, serialized_result_val_len) = { + // Cast to u64 to use zero-extension. + let v = serialized_result as u64; + let ptr = (v as u64 >> 32) as u32; + let len = (v & 0xFFFFFFFF) as u32; + (Pointer::new(ptr), len) + }; + + let serialized_result_val = supervisor_externals + .read_memory(serialized_result_val_ptr, serialized_result_val_len) + .map_err(|_| wasmer::RuntimeError::new("Can't read the serialized result from dispatch thunk")); + + let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmer::RuntimeError::new(e.to_string())) + })?; + + if let Some(value) = deserialized_result { + Ok(vec![ + match value { + RuntimeValue::I32(val) => wasmer::Val::I32(val), + RuntimeValue::I64(val) => wasmer::Val::I64(val), + RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), + RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), + } + ]) + } else { + Ok(vec![]) + } + }) + }); + + Some((import.name().to_string(), function)) + } else { + None + } + }) + .collect(); + + let mut import_object = wasmer::ImportObject::new(); + let mut exports = wasmer::Exports::new(); + + for (name, function) in imports { + exports.insert(name, wasmer::Extern::Function(function)); + } + import_object.register("env", exports); println!("Instantiating module..."); let instance = wasmer::Instance::new(&module, &import_object) From 4bb9697dd40e8dfb0626ad4a56dfece5f9b44cd1 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 8 Oct 2020 15:41:59 +0700 Subject: [PATCH 30/88] Fixes wasmer instantiation result --- client/executor/common/src/sandbox.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 78d7b5f21f54c..9b93a671a121d 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -850,7 +850,6 @@ where InstantiationError::ModuleDecoding })?; - let imports: Vec<_> = module .imports() .into_iter() @@ -967,7 +966,11 @@ where let instance = wasmer::Instance::new(&module, &import_object) .map_err(|error| { println!("{:?}", error); - InstantiationError::Instantiation + + match error { + wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, + wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, + } })?; println!("Creating SandboxInstance..."); From a31889c334b6598ca67741fe3738f552e558af10 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 26 Oct 2020 13:44:15 +0700 Subject: [PATCH 31/88] Adds workaround to remove debug_assert --- Cargo.lock | 304 +++--------------------------- client/executor/common/Cargo.toml | 13 +- 2 files changed, 40 insertions(+), 277 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3809ba672855..800682548555c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,21 +465,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "blake3" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" -dependencies = [ - "arrayref", - "arrayvec 0.5.1", - "cc", - "cfg-if", - "constant_time_eq", - "crypto-mac 0.8.0", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.7.3" @@ -853,15 +838,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" -[[package]] -name = "cranelift-bforest" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818" -dependencies = [ - "cranelift-entity 0.59.0", -] - [[package]] name = "cranelift-bforest" version = "0.65.0" @@ -879,24 +855,6 @@ dependencies = [ "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", ] -[[package]] -name = "cranelift-codegen" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e" -dependencies = [ - "byteorder 1.3.4", - "cranelift-bforest 0.59.0", - "cranelift-codegen-meta 0.59.0", - "cranelift-codegen-shared 0.59.0", - "cranelift-entity 0.59.0", - "gimli 0.20.0", - "log", - "smallvec 1.4.1", - "target-lexicon", - "thiserror", -] - [[package]] name = "cranelift-codegen" version = "0.65.0" @@ -936,16 +894,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cranelift-codegen-meta" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9" -dependencies = [ - "cranelift-codegen-shared 0.59.0", - "cranelift-entity 0.59.0", -] - [[package]] name = "cranelift-codegen-meta" version = "0.65.0" @@ -965,12 +913,6 @@ dependencies = [ "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", ] -[[package]] -name = "cranelift-codegen-shared" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d" - [[package]] name = "cranelift-codegen-shared" version = "0.65.0" @@ -982,12 +924,6 @@ name = "cranelift-codegen-shared" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#6c2cb0252551da09b871d6e48bace83b600dcd11" -[[package]] -name = "cranelift-entity" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38" - [[package]] name = "cranelift-entity" version = "0.65.0" @@ -1028,17 +964,6 @@ dependencies = [ "target-lexicon", ] -[[package]] -name = "cranelift-native" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b" -dependencies = [ - "cranelift-codegen 0.59.0", - "raw-cpuid", - "target-lexicon", -] - [[package]] name = "cranelift-native" version = "0.65.0" @@ -1060,7 +985,7 @@ dependencies = [ "log", "serde", "thiserror", - "wasmparser 0.57.0", + "wasmparser", ] [[package]] @@ -2293,16 +2218,6 @@ dependencies = [ "polyval", ] -[[package]] -name = "gimli" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" -dependencies = [ - "byteorder 1.3.4", - "indexmap", -] - [[package]] name = "gimli" version = "0.21.0" @@ -3541,7 +3456,7 @@ dependencies = [ "memoffset", "more-asserts", "thiserror", - "wasmparser 0.57.0", + "wasmparser", ] [[package]] @@ -3933,19 +3848,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "nix" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "void", -] - [[package]] name = "nix" version = "0.17.0" @@ -4026,7 +3928,7 @@ dependencies = [ "futures 0.3.5", "hex-literal", "log", - "nix 0.17.0", + "nix", "node-executor", "node-inspect", "node-primitives", @@ -4543,16 +4445,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "page_size" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "pallet-assets" version = "2.0.0" @@ -6697,7 +6589,7 @@ dependencies = [ "libp2p", "log", "names", - "nix 0.17.0", + "nix", "parity-scale-codec", "parity-util-mem", "rand 0.7.3", @@ -7099,7 +6991,6 @@ dependencies = [ "wasmer", "wasmer-compiler-singlepass", "wasmer-engine-jit", - "wasmer-runtime", "wasmi", "wasmtime", ] @@ -7904,16 +7795,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-bench" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" -dependencies = [ - "byteorder 1.3.4", - "serde", -] - [[package]] name = "serde_bytes" version = "0.11.5" @@ -9967,7 +9848,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" dependencies = [ - "rand 0.7.3", + "rand 0.3.23", ] [[package]] @@ -10297,9 +10178,8 @@ dependencies = [ [[package]] name = "wasmer" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc770914c1c0b5b5bc065db787d40f07a6fee208d3bd71d817dd0ace410e8c07" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "cfg-if", "indexmap", @@ -10317,63 +10197,10 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "wasmer-clif-backend" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a2fae69b1c7429316cad6743f3d2ca83cf8957924c477c5a4eff036ec0097a9" -dependencies = [ - "byteorder 1.3.4", - "cranelift-codegen 0.59.0", - "cranelift-entity 0.59.0", - "cranelift-native 0.59.0", - "libc", - "nix 0.15.0", - "rayon", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", - "target-lexicon", - "wasmer-clif-fork-frontend", - "wasmer-clif-fork-wasm", - "wasmer-runtime-core", - "wasmer-win-exception-handler", - "wasmparser 0.51.4", - "winapi 0.3.9", -] - -[[package]] -name = "wasmer-clif-fork-frontend" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a" -dependencies = [ - "cranelift-codegen 0.59.0", - "log", - "smallvec 1.4.1", - "target-lexicon", -] - -[[package]] -name = "wasmer-clif-fork-wasm" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5" -dependencies = [ - "cranelift-codegen 0.59.0", - "cranelift-entity 0.59.0", - "log", - "thiserror", - "wasmer-clif-fork-frontend", - "wasmparser 0.51.4", -] - [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77e50cd83c1b2511b89ce94cbdde077d788c18beca589069e520705a5e00507" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "enumset", "raw-cpuid", @@ -10384,14 +10211,13 @@ dependencies = [ "thiserror", "wasmer-types", "wasmer-vm", - "wasmparser 0.57.0", + "wasmparser", ] [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3fdb46f15f7ac3b9d8a27864e67b3be90454f7090d45804226dd5621eb9cb46" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "cranelift-codegen 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-frontend 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -10407,9 +10233,8 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d896ae60370b768a286566549c9d999c5cb8cfcad61b83a86fc73a9b61f8f618" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "byteorder 1.3.4", "dynasm 1.0.0", @@ -10426,9 +10251,8 @@ dependencies = [ [[package]] name = "wasmer-engine" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63090cbbdd037431489f1d39c0b4c3f024fa9c3fdaf93d15840695a3223664ad" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "backtrace", "bincode", @@ -10446,9 +10270,8 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0229a22fe24df530e739224ac2b755702a1e4408100537cb0a90a5bbf349e7f8" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "bincode", "cfg-if", @@ -10464,9 +10287,8 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b2adb25608bcc4624d644cb7e646790ac3b7a5a547030aefd60d99208076be" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "bincode", "cfg-if", @@ -10485,9 +10307,8 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e912d69e5db8437836dbdf2b01bf2527fc3694ec0699dfa5b3f1f542d89f4e" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "object 0.19.0", "thiserror", @@ -10495,54 +10316,10 @@ dependencies = [ "wasmer-types", ] -[[package]] -name = "wasmer-runtime" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92a9ae96b193c35c47fc829265198322cf980edc353a9de32bc87a1545d44f3" -dependencies = [ - "lazy_static", - "memmap", - "serde", - "serde_derive", - "wasmer-clif-backend", - "wasmer-runtime-core", -] - -[[package]] -name = "wasmer-runtime-core" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740161245998752cf1a567e860fd6355df0336fedca6be1940ec7aaa59643220" -dependencies = [ - "bincode", - "blake3", - "cc", - "digest 0.8.1", - "errno", - "hex", - "indexmap", - "lazy_static", - "libc", - "nix 0.15.0", - "page_size", - "parking_lot 0.10.2", - "rustc_version", - "serde", - "serde-bench", - "serde_bytes", - "serde_derive", - "smallvec 1.4.1", - "target-lexicon", - "wasmparser 0.51.4", - "winapi 0.3.9", -] - [[package]] name = "wasmer-types" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b64a1de3bd91b43208bba4f956f9a8a1819cc8c785d65ac8199f70bbb1eaa4" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", @@ -10550,9 +10327,8 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "1.0.0-alpha3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2971a31765cbe3711d39a63f58edc380554c01bf63a6a2d4e9c4c473b9a7a01" +version = "1.0.0-alpha4" +source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "backtrace", "cc", @@ -10568,18 +10344,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "wasmer-win-exception-handler" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd39f3b2bd7964b28ea6f944a7eaa445cfbc91c4f2695d188103f2689bb37d9" -dependencies = [ - "cc", - "libc", - "wasmer-runtime-core", - "winapi 0.3.9", -] - [[package]] name = "wasmi" version = "0.6.2" @@ -10604,12 +10368,6 @@ dependencies = [ "parity-wasm 0.41.0", ] -[[package]] -name = "wasmparser" -version = "0.51.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" - [[package]] name = "wasmparser" version = "0.57.0" @@ -10631,7 +10389,7 @@ dependencies = [ "region", "rustc-demangle", "target-lexicon", - "wasmparser 0.57.0", + "wasmparser", "wasmtime-environ", "wasmtime-jit", "wasmtime-profiling", @@ -10651,7 +10409,7 @@ dependencies = [ "object 0.19.0", "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser", "wasmtime-environ", ] @@ -10679,7 +10437,7 @@ dependencies = [ "sha2 0.8.2", "thiserror", "toml", - "wasmparser 0.57.0", + "wasmparser", "winapi 0.3.9", "zstd", ] @@ -10694,7 +10452,7 @@ dependencies = [ "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", "cranelift-frontend 0.65.0 (git+https://github.com/Vurich/wasmtime.git)", - "cranelift-native 0.65.0", + "cranelift-native", "cranelift-wasm", "gimli 0.21.0", "log", @@ -10702,7 +10460,7 @@ dependencies = [ "region", "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser", "wasmtime-debug", "wasmtime-environ", "wasmtime-profiling", diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index 59395691f97c7..b604c47c83951 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -25,10 +25,15 @@ sp-wasm-interface = { version = "2.0.0", path = "../../../primitives/wasm-interf sp-runtime-interface = { version = "2.0.0", path = "../../../primitives/runtime-interface" } sp-serializer = { version = "2.0.0", path = "../../../primitives/serializer" } wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -wasmer = "1.0.0-alpha3" -wasmer-compiler-singlepass = "1.0.0-alpha3" -wasmer-engine-jit = "1.0.0-alpha3" -wasmer-runtime = "0.17" + +wasmer = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } +wasmer-compiler-singlepass = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } +wasmer-engine-jit = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } + +#wasmer = "1.0.0-alpha3" +#wasmer-compiler-singlepass = "1.0.0-alpha3" +#wasmer-engine-jit = "1.0.0-alpha3" +#wasmer-runtime = "0.17" [features] default = [] From be7b41df99df733a67acb7322ad30ba3c3f242d9 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 22 Jan 2021 19:00:54 +0700 Subject: [PATCH 32/88] Fixes import object generation for wasmer --- client/executor/common/src/sandbox.rs | 72 ++++++++++++++++++++------- client/executor/wasmi/src/lib.rs | 2 + client/executor/wasmtime/src/host.rs | 2 + 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 9b93a671a121d..10e48113c203b 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -26,10 +26,7 @@ use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; -use wasmi::{ - Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance, - RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages, -}; +use wasmi::{Externals, ImportResolver, MemoryDescriptor, MemoryInstance, MemoryRef, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages}; use sp_wasm_interface::Value; use wasmtime::Val; @@ -103,6 +100,15 @@ impl Imports { fn func_by_name(&self, module_name: &str, func_name: &str) -> Option { self.func_map.get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())).cloned() } + + fn memory_by_name(&self, module_name: &str, memory_name: &str) -> Option { + let key = ( + module_name.as_bytes().to_vec(), + memory_name.as_bytes().to_vec(), + ); + + self.memories_map.get(&key).cloned() + } } impl ImportResolver for Imports { @@ -723,7 +729,7 @@ where let wasmtime_engine = wasmtime::Engine::new(&config); let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - + let module_imports: Vec<_> = wasmtime_module .imports() .filter_map(|import| { @@ -843,23 +849,54 @@ where SandboxBackend::Wasmer => { let compiler = Singlepass::default(); let store = wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()); - +wasmer::im println!("Decoding module..."); let module = wasmer::Module::new(&store, wasm).map_err(|error| { println!("{:?}", error); InstantiationError::ModuleDecoding })?; - let imports: Vec<_> = module + println!("Module name is {}", module.name().unwrap_or("(unknown)")); + + type Exports = HashMap; + let mut exports_map = Exports::new(); + + for import in module .imports() .into_iter() - .filter_map(|import| { - if let wasmer::ExternType::Function(func_ty) = import.ty() { + { + match import.ty() { + wasmer::ExternType::Global(global) => { + println!("Importing global '{}' :: '{}' {}", import.module(), import.name(), global.to_string()); + } + + wasmer::ExternType::Table(table) => { + println!("Importing table '{}' :: '{}' {}", import.module(), import.name(), table.to_string()); + } + + wasmer::ExternType::Memory(memory_type) => { + println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); + let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); + + // let memory = guest_env.imports.memory_by_name(import.module(), import.name()); + + if let Ok(memory) = wasmer::Memory::new(&store, *memory_type) { + exports.insert(import.name(), wasmer::Extern::Memory(memory)); + } else { + println!("Failed to import memory '{}' :: '{}'", import.module(), import.name()); + continue; + } + } + + wasmer::ExternType::Function(func_ty) => { + println!("Importing function '{}' :: '{}' {}", import.module(), import.name(), func_ty.to_string()); + let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { index } else { // Missing import - return None; + println!("Missing import '{}' :: '{}'", import.module(), import.name()); + continue; }; let supervisor_func_index = guest_env.guest_to_supervisor_mapping @@ -947,20 +984,17 @@ where }) }); - Some((import.name().to_string(), function)) - } else { - None + let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); + exports.insert(import.name(), wasmer::Extern::Function(function)); } - }) - .collect(); + } + } let mut import_object = wasmer::ImportObject::new(); - let mut exports = wasmer::Exports::new(); - for (name, function) in imports { - exports.insert(name, wasmer::Extern::Function(function)); + for (module_name, exports) in exports_map.into_iter() { + import_object.register(module_name, exports); } - import_object.register("env", exports); println!("Instantiating module..."); let instance = wasmer::Instance::new(&module, &import_object) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index a61a97259f8c1..d993132296c33 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -279,6 +279,8 @@ impl Sandbox for FunctionExecutor { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; + println!("Instantiating sandbox from wasmi"); + let result = EXECUTOR.set(self, || sandbox::instantiate::<_, _, Holder>( SandboxBackend::Wasmi, dispatch_thunk, diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index f518517f18653..54aea1562803d 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -323,6 +323,8 @@ impl Sandbox for HostState { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; + println!("Instantiating sandbox from host"); + let instance_idx_or_err_code = match sandbox::instantiate::<_, _, Holder>( SandboxBackend::Wasmer, From b58c30cd2ca646cc7fae4b0bfc0e8c9144c2dc53 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 25 Jan 2021 17:56:03 +0700 Subject: [PATCH 33/88] Attempt to propagate wasmer::Store through sandbox::Store --- client/executor/common/src/sandbox.rs | 141 ++++++++++++++++++-------- client/executor/wasmi/src/lib.rs | 2 +- client/executor/wasmtime/src/host.rs | 13 +-- 3 files changed, 107 insertions(+), 49 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 10e48113c203b..5970a5103a1d4 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -22,7 +22,7 @@ //! a compiled execution engine. use crate::error::{Result, Error}; -use std::{collections::HashMap, rc::Rc}; +use std::{collections::HashMap, convert::TryInto, rc::Rc, todo}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; @@ -38,7 +38,7 @@ use wasmtime::Val; use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; // use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; -use wasmer_compiler_singlepass::Singlepass; +use wasmer_compiler_singlepass::{Singlepass, SinglepassCompiler}; /// Index of a function inside the supervisor. /// @@ -100,15 +100,6 @@ impl Imports { fn func_by_name(&self, module_name: &str, func_name: &str) -> Option { self.func_map.get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())).cloned() } - - fn memory_by_name(&self, module_name: &str, memory_name: &str) -> Option { - let key = ( - module_name.as_bytes().to_vec(), - memory_name.as_bytes().to_vec(), - ); - - self.memories_map.get(&key).cloned() - } } impl ImportResolver for Imports { @@ -616,8 +607,8 @@ impl GuestEnvironment { store: &Store, raw_env_def: &[u8], ) -> std::result::Result { - let (imports, guest_to_supervisor_mapping) = - decode_environment_definition(raw_env_def, &store.memories)?; + let (imports, guest_to_supervisor_mapping) = todo!(); + //decode_environment_definition(raw_env_def, &store.memories)?; Ok(Self { imports, guest_to_supervisor_mapping, @@ -675,8 +666,7 @@ pub enum SandboxBackend { /// /// Returns uninitialized sandboxed module instance or an instantiation error. pub fn instantiate<'a, FR, FE, SCH>( - // supervisor_externals: &mut FE, - sandbox_backend: SandboxBackend, + store: &Store, dispatch_thunk: FR, wasm: &[u8], guest_env: GuestEnvironment, @@ -688,8 +678,8 @@ where SCH: SandboxCapabiliesHolder, { - let sandbox_instance = match sandbox_backend { - SandboxBackend::Wasmi => { + let sandbox_instance = match &store.backend_context { + BackendContext::Wasmi => { let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) .map_err(|_| InstantiationError::Instantiation)?; @@ -721,7 +711,7 @@ where sandbox_instance } - SandboxBackend::Wasmtime => { + BackendContext::Wasmtime => { let mut config = wasmtime::Config::new(); config.cranelift_opt_level(wasmtime::OptLevel::None); config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; @@ -846,12 +836,12 @@ where }) } - SandboxBackend::Wasmer => { - let compiler = Singlepass::default(); - let store = wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()); -wasmer::im + BackendContext::Wasmer(context) => { + // let compiler = Singlepass::default(); + // let store = wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()); + println!("Decoding module..."); - let module = wasmer::Module::new(&store, wasm).map_err(|error| { + let module = wasmer::Module::new(&context.store, wasm).map_err(|error| { println!("{:?}", error); InstantiationError::ModuleDecoding })?; @@ -877,15 +867,12 @@ wasmer::im wasmer::ExternType::Memory(memory_type) => { println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); + let memory = store + .new_memory(memory_type.minimum.0, memory_type.maximum.map(|m| m.0).unwrap_or(sandbox_primitives::MEM_UNLIMITED)) + .and_then(|index| store.memory(index)) + .map_err(|_| InstantiationError::ModuleDecoding)?; - // let memory = guest_env.imports.memory_by_name(import.module(), import.name()); - - if let Ok(memory) = wasmer::Memory::new(&store, *memory_type) { - exports.insert(import.name(), wasmer::Extern::Memory(memory)); - } else { - println!("Failed to import memory '{}' :: '{}'", import.module(), import.name()); - continue; - } + exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); } wasmer::ExternType::Function(func_ty) => { @@ -903,7 +890,7 @@ wasmer::im .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); let dispatch_thunk = dispatch_thunk.clone(); - let function = wasmer::Function::new(&store, func_ty, move |params| { + let function = wasmer::Function::new(&context.store, func_ty, move |params| { SCH::with_sandbox_capabilities(|supervisor_externals| { // Serialize arguments into a byte vector. let invoke_args_data = params @@ -1019,21 +1006,77 @@ wasmer::im Ok(UnregisteredInstance { sandbox_instance }) } +#[derive(Clone, Debug)] +pub enum Memory { + Wasmi(MemoryRef), + // Wasmtime(todo), + Wasmer(wasmer::Memory), +} + +impl Memory { + pub fn as_wasmi(&self) -> Option { + match self { + Memory::Wasmi(memory) => Some(memory.clone()), + _ => None, + } + } + + pub fn as_wasmer(&self) -> Option { + match self { + Memory::Wasmer(memory) => Some(memory.clone()), + _ => None, + } + } +} + +struct WasmerBackend { + compiler: Singlepass, + store: wasmer::Store, +} + +enum BackendContext { + Wasmi, + Wasmtime, + Wasmer(WasmerBackend), +} + +impl BackendContext { + pub fn new(backend: SandboxBackend) -> BackendContext { + match backend { + SandboxBackend::Wasmi => BackendContext::Wasmi, + SandboxBackend::Wasmtime => todo!(), + + SandboxBackend::Wasmer => { + let compiler = Singlepass::default(); + + BackendContext::Wasmer( + WasmerBackend { + store: wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()), + compiler, + } + ) + } + } + } +} + /// This struct keeps track of all sandboxed components. /// /// This is generic over a supervisor function reference type. pub struct Store { // Memories and instances are `Some` until torn down. instances: Vec>>>, - memories: Vec>, + memories: Vec>, + backend_context: BackendContext, } impl Store { /// Create a new empty sandbox store. - pub fn new() -> Self { + pub fn new(backend: SandboxBackend) -> Self { Store { instances: Vec::new(), memories: Vec::new(), + backend_context: BackendContext::new(backend), } } @@ -1046,17 +1089,31 @@ impl Store { pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { let maximum = match maximum { sandbox_primitives::MEM_UNLIMITED => None, - specified_limit => Some(Pages(specified_limit as usize)), + specified_limit => Some(specified_limit), }; - let mem = - MemoryInstance::alloc( - Pages(initial as usize), - maximum, - )?; + let memory = match &self.backend_context { + BackendContext::Wasmi => { + Memory::Wasmi(MemoryInstance::alloc( + Pages(initial as usize), + maximum.map(|m| Pages(m as usize)), + )?) + } + + BackendContext::Wasmer(context) => { + let ty = wasmer::MemoryType::new(initial, maximum, false); + + Memory::Wasmer( + wasmer::Memory::new(&context.store, ty) + .map_err(|_| Error::InvalidMemoryReference)? + ) + } + + BackendContext::Wasmtime => todo!(), + }; let mem_idx = self.memories.len(); - self.memories.push(Some(mem)); + self.memories.push(Some(memory)); Ok(mem_idx as u32) } @@ -1080,7 +1137,7 @@ impl Store { /// /// Returns `Err` If `memory_idx` isn't a valid index of an memory or /// if memory has been torn down. - pub fn memory(&self, memory_idx: u32) -> Result { + pub fn memory(&self, memory_idx: u32) -> Result { self.memories .get(memory_idx as usize) .cloned() diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index d993132296c33..a0b968ca455bf 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -63,7 +63,7 @@ impl FunctionExecutor { ) -> Result { Ok(FunctionExecutor { inner: Rc::new(Inner { - sandbox_store: RefCell::new(sandbox::Store::new()), + sandbox_store: RefCell::new(sandbox::Store::new(sandbox::SandboxBackend::Wasmi)), allocator: RefCell::new(sp_allocator::FreeingBumpHeapAllocator::new(heap_base)), memory: m, table: t, diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 54aea1562803d..5e296151383f7 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -65,7 +65,7 @@ impl HostState { pub fn new(allocator: FreeingBumpHeapAllocator, instance: Rc) -> Self { HostState { inner: Rc::new(Inner { - sandbox_store: RefCell::new(sandbox::Store::new()), + sandbox_store: RefCell::new(sandbox::Store::new(sandbox::SandboxBackend::Wasmer)), allocator: RefCell::new(allocator), instance, }) @@ -315,8 +315,9 @@ impl Sandbox for HostState { SupervisorFuncRef(func_ref) }; + let store = &*self.inner.sandbox_store.borrow(); let guest_env = match sandbox::GuestEnvironment::decode( - &*self.inner.sandbox_store.borrow(), + store, raw_env_def, ) { Ok(guest_env) => guest_env, @@ -327,10 +328,10 @@ impl Sandbox for HostState { let instance_idx_or_err_code = match sandbox::instantiate::<_, _, Holder>( - SandboxBackend::Wasmer, - dispatch_thunk, - wasm, - guest_env, + store, + dispatch_thunk, + wasm, + guest_env, state ) .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) From 861ee6c710a3aed40dd7a44c1df66355312e23ee Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 26 Jan 2021 12:39:03 +0700 Subject: [PATCH 34/88] Wraps `sandbox::Store::memories` in `RefCell` --- client/executor/common/src/sandbox.rs | 63 ++++++++++++++++----------- client/executor/wasmtime/src/host.rs | 5 +-- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 5970a5103a1d4..aa373c5dfff38 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -22,7 +22,7 @@ //! a compiled execution engine. use crate::error::{Result, Error}; -use std::{collections::HashMap, convert::TryInto, rc::Rc, todo}; +use std::{cell::RefCell, collections::HashMap, convert::TryInto, rc::Rc, todo}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; @@ -867,9 +867,13 @@ where wasmer::ExternType::Memory(memory_type) => { println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); - let memory = store - .new_memory(memory_type.minimum.0, memory_type.maximum.map(|m| m.0).unwrap_or(sandbox_primitives::MEM_UNLIMITED)) - .and_then(|index| store.memory(index)) + let (_memory_index, memory) = store + .allocate_memory( + memory_type.minimum.0, + memory_type.maximum + .map(|m| m.0) + .unwrap_or(sandbox_primitives::MEM_UNLIMITED) + ) .map_err(|_| InstantiationError::ModuleDecoding)?; exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); @@ -1066,27 +1070,12 @@ impl BackendContext { pub struct Store { // Memories and instances are `Some` until torn down. instances: Vec>>>, - memories: Vec>, + memories: RefCell>>, backend_context: BackendContext, } impl Store { - /// Create a new empty sandbox store. - pub fn new(backend: SandboxBackend) -> Self { - Store { - instances: Vec::new(), - memories: Vec::new(), - backend_context: BackendContext::new(backend), - } - } - - /// Create a new memory instance and return it's index. - /// - /// # Errors - /// - /// Returns `Err` if the memory couldn't be created. - /// Typically happens if `initial` is more than `maximum`. - pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { + fn allocate_memory(&self, initial: u32, maximum: u32) -> Result<(u32, Memory)> { let maximum = match maximum { sandbox_primitives::MEM_UNLIMITED => None, specified_limit => Some(specified_limit), @@ -1112,9 +1101,32 @@ impl Store { BackendContext::Wasmtime => todo!(), }; - let mem_idx = self.memories.len(); - self.memories.push(Some(memory)); - Ok(mem_idx as u32) + let mut memories = self.memories.borrow_mut(); + let mem_idx = memories.len(); + memories.push(Some(memory.clone())); + + Ok((mem_idx as u32, memory)) + } +} + +impl Store { + /// Create a new empty sandbox store. + pub fn new(backend: SandboxBackend) -> Self { + Store { + instances: Vec::new(), + memories: RefCell::new(Vec::new()), + backend_context: BackendContext::new(backend), + } + } + + /// Create a new memory instance and return it's index. + /// + /// # Errors + /// + /// Returns `Err` if the memory couldn't be created. + /// Typically happens if `initial` is more than `maximum`. + pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { + self.allocate_memory(initial, maximum).map(|(index, _)| index) } /// Returns `SandboxInstance` by `instance_idx`. @@ -1139,6 +1151,7 @@ impl Store { /// if memory has been torn down. pub fn memory(&self, memory_idx: u32) -> Result { self.memories + .borrow() .get(memory_idx as usize) .cloned() .ok_or_else(|| "Trying to access a non-existent sandboxed memory")? @@ -1152,7 +1165,7 @@ impl Store { /// Returns `Err` if `memory_idx` isn't a valid index of an memory or /// if it has been torn down. pub fn memory_teardown(&mut self, memory_idx: u32) -> Result<()> { - match self.memories.get_mut(memory_idx as usize) { + match self.memories.borrow_mut().get_mut(memory_idx as usize) { None => Err("Trying to teardown a non-existent sandboxed memory".into()), Some(None) => Err("Double teardown of a sandboxed memory".into()), Some(memory) => { diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 5e296151383f7..f62cc0ad3731a 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -315,9 +315,8 @@ impl Sandbox for HostState { SupervisorFuncRef(func_ref) }; - let store = &*self.inner.sandbox_store.borrow(); let guest_env = match sandbox::GuestEnvironment::decode( - store, + &*self.inner.sandbox_store.borrow(), raw_env_def, ) { Ok(guest_env) => guest_env, @@ -328,7 +327,7 @@ impl Sandbox for HostState { let instance_idx_or_err_code = match sandbox::instantiate::<_, _, Holder>( - store, + &mut *self.inner.sandbox_store.borrow_mut(), dispatch_thunk, wasm, guest_env, From caaf5e3975ad4ce26c255a6bae771608e25a0e20 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 26 Jan 2021 16:25:40 +0700 Subject: [PATCH 35/88] Moves `sandbox::instantiate` to `sandbox::Store` --- client/executor/common/src/sandbox.rs | 706 +++++++++++++------------- client/executor/wasmi/src/lib.rs | 38 +- client/executor/wasmtime/src/host.rs | 86 ++-- 3 files changed, 416 insertions(+), 414 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index aa373c5dfff38..cbdfb1de1f81b 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -657,359 +657,6 @@ pub enum SandboxBackend { Wasmer, } -/// Instantiate a guest module and return it's index in the store. -/// -/// The guest module's code is specified in `wasm`. Environment that will be available to -/// guest module is specified in `guest_env`, `dispatch_thunk` is used as function that -/// handle calls from guests. `state` is an opaque pointer to caller's arbitrary context -/// normally created by `sp_sandbox::Instance` primitive. -/// -/// Returns uninitialized sandboxed module instance or an instantiation error. -pub fn instantiate<'a, FR, FE, SCH>( - store: &Store, - dispatch_thunk: FR, - wasm: &[u8], - guest_env: GuestEnvironment, - state: u32, -) -> std::result::Result, InstantiationError> -where - FR: Clone + 'static, - FE: SandboxCapabilities + 'a, - SCH: SandboxCapabiliesHolder, -{ - - let sandbox_instance = match &store.backend_context { - BackendContext::Wasmi => { - let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) - .map_err(|_| InstantiationError::Instantiation)?; - - let sandbox_instance = Rc::new(SandboxInstance { - // In general, it's not a very good idea to use `.not_started_instance()` for anything - // but for extracting memory and tables. But in this particular case, we are extracting - // for the purpose of running `start` function which should be ok. - backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), - dispatch_thunk, - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }); - - SCH::with_sandbox_capabilities( |supervisor_externals| { - with_guest_externals( - supervisor_externals, - &sandbox_instance, - state, - |guest_externals| { - wasmi_instance - .run_start(guest_externals) - .map_err(|_| InstantiationError::StartTrapped) - - // Note: no need to run start on wasmtime instance, since it's done automatically - }, - ) - })?; - - sandbox_instance - } - - BackendContext::Wasmtime => { - let mut config = wasmtime::Config::new(); - config.cranelift_opt_level(wasmtime::OptLevel::None); - config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; - - let wasmtime_engine = wasmtime::Engine::new(&config); - let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); - let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - - let module_imports: Vec<_> = wasmtime_module - .imports() - .filter_map(|import| { - if let wasmtime::ExternType::Func(func_ty) = import.ty() { - let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { - index - } else { - // Missing import - return None; - }; - - let supervisor_func_index = guest_env.guest_to_supervisor_mapping - .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - - let dispatch_thunk = dispatch_thunk.clone(); - Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, - move |_caller, params, result| { - SCH::with_sandbox_capabilities(|supervisor_externals| { - // Serialize arguments into a byte vector. - let invoke_args_data = params - .iter() - .map(|val| match val { - Val::I32(val) => Value::I32(*val), - Val::I64(val) => Value::I64(*val), - Val::F32(val) => Value::F32(*val), - Val::F64(val) => Value::F64(*val), - _ => unimplemented!() - }) - .collect::>() - .encode(); - - // Move serialized arguments inside the memory, invoke dispatch thunk and - // then free allocated memory. - let invoke_args_len = invoke_args_data.len() as WordSize; - let invoke_args_ptr = supervisor_externals - .allocate_memory(invoke_args_len) - .map_err(|_| wasmtime::Trap::new("Can't allocate memory in supervisor for the arguments"))?; - - let deallocate = |fe: &mut FE, ptr, fail_msg| { - fe - .deallocate_memory(ptr) - .map_err(|_| wasmtime::Trap::new(fail_msg)) - }; - - if supervisor_externals - .write_memory(invoke_args_ptr, &invoke_args_data) - .is_err() - { - deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; - return Err(wasmtime::Trap::new("Can't write invoke args into memory")); - } - - let serialized_result = supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) - .map_err(|e| wasmtime::Trap::new(e.to_string()))?; - - // dispatch_thunk returns pointer to serialized arguments. - // Unpack pointer and len of the serialized result data. - let (serialized_result_val_ptr, serialized_result_val_len) = { - // Cast to u64 to use zero-extension. - let v = serialized_result as u64; - let ptr = (v as u64 >> 32) as u32; - let len = (v & 0xFFFFFFFF) as u32; - (Pointer::new(ptr), len) - }; - - let serialized_result_val = supervisor_externals - .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmtime::Trap::new("Can't read the serialized result from dispatch thunk")); - - let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") - .and_then(|_| serialized_result_val) - .and_then(|serialized_result_val| { - deserialize_result(&serialized_result_val) - .map_err(|e| wasmtime::Trap::new(e.to_string())) - })?; - - if let Some(value) = deserialized_result { - result[0] = match value { - RuntimeValue::I32(val) => Val::I32(val), - RuntimeValue::I64(val) => Val::I64(val), - RuntimeValue::F32(val) => Val::F32(val.into()), - RuntimeValue::F64(val) => Val::F64(val.into()), - } - } - - Ok(()) - }) - } - ))) - } else { - None - } - }) - .collect(); - - let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|error| - if let Ok(_trap) = error.downcast::() { - InstantiationError::StartTrapped - } else { - InstantiationError::Instantiation - } - )?; - - Rc::new(SandboxInstance { - backend_instance: BackendInstance::Wasmtime(wasmtime_instance), - dispatch_thunk, - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }) - } - - BackendContext::Wasmer(context) => { - // let compiler = Singlepass::default(); - // let store = wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()); - - println!("Decoding module..."); - let module = wasmer::Module::new(&context.store, wasm).map_err(|error| { - println!("{:?}", error); - InstantiationError::ModuleDecoding - })?; - - println!("Module name is {}", module.name().unwrap_or("(unknown)")); - - type Exports = HashMap; - let mut exports_map = Exports::new(); - - for import in module - .imports() - .into_iter() - { - match import.ty() { - wasmer::ExternType::Global(global) => { - println!("Importing global '{}' :: '{}' {}", import.module(), import.name(), global.to_string()); - } - - wasmer::ExternType::Table(table) => { - println!("Importing table '{}' :: '{}' {}", import.module(), import.name(), table.to_string()); - } - - wasmer::ExternType::Memory(memory_type) => { - println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); - let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); - let (_memory_index, memory) = store - .allocate_memory( - memory_type.minimum.0, - memory_type.maximum - .map(|m| m.0) - .unwrap_or(sandbox_primitives::MEM_UNLIMITED) - ) - .map_err(|_| InstantiationError::ModuleDecoding)?; - - exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); - } - - wasmer::ExternType::Function(func_ty) => { - println!("Importing function '{}' :: '{}' {}", import.module(), import.name(), func_ty.to_string()); - - let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { - index - } else { - // Missing import - println!("Missing import '{}' :: '{}'", import.module(), import.name()); - continue; - }; - - let supervisor_func_index = guest_env.guest_to_supervisor_mapping - .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - - let dispatch_thunk = dispatch_thunk.clone(); - let function = wasmer::Function::new(&context.store, func_ty, move |params| { - SCH::with_sandbox_capabilities(|supervisor_externals| { - // Serialize arguments into a byte vector. - let invoke_args_data = params - .iter() - .map(|val| match val { - wasmer::Val::I32(val) => Value::I32(*val), - wasmer::Val::I64(val) => Value::I64(*val), - wasmer::Val::F32(val) => Value::F32(*val as u32), - wasmer::Val::F64(val) => Value::F64(*val as u64), - _ => unimplemented!() - }) - .collect::>() - .encode(); - - // Move serialized arguments inside the memory, invoke dispatch thunk and - // then free allocated memory. - let invoke_args_len = invoke_args_data.len() as WordSize; - let invoke_args_ptr = supervisor_externals - .allocate_memory(invoke_args_len) - .map_err(|_| wasmer::RuntimeError::new("Can't allocate memory in supervisor for the arguments"))?; - - let deallocate = |fe: &mut FE, ptr, fail_msg| { - fe - .deallocate_memory(ptr) - .map_err(|_| wasmer::RuntimeError::new(fail_msg)) - }; - - if supervisor_externals - .write_memory(invoke_args_ptr, &invoke_args_data) - .is_err() - { - deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; - return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); - } - - let serialized_result = supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) - .map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; - - // dispatch_thunk returns pointer to serialized arguments. - // Unpack pointer and len of the serialized result data. - let (serialized_result_val_ptr, serialized_result_val_len) = { - // Cast to u64 to use zero-extension. - let v = serialized_result as u64; - let ptr = (v as u64 >> 32) as u32; - let len = (v & 0xFFFFFFFF) as u32; - (Pointer::new(ptr), len) - }; - - let serialized_result_val = supervisor_externals - .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmer::RuntimeError::new("Can't read the serialized result from dispatch thunk")); - - let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") - .and_then(|_| serialized_result_val) - .and_then(|serialized_result_val| { - deserialize_result(&serialized_result_val) - .map_err(|e| wasmer::RuntimeError::new(e.to_string())) - })?; - - if let Some(value) = deserialized_result { - Ok(vec![ - match value { - RuntimeValue::I32(val) => wasmer::Val::I32(val), - RuntimeValue::I64(val) => wasmer::Val::I64(val), - RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), - RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), - } - ]) - } else { - Ok(vec![]) - } - }) - }); - - let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); - exports.insert(import.name(), wasmer::Extern::Function(function)); - } - } - } - - let mut import_object = wasmer::ImportObject::new(); - - for (module_name, exports) in exports_map.into_iter() { - import_object.register(module_name, exports); - } - - println!("Instantiating module..."); - let instance = wasmer::Instance::new(&module, &import_object) - .map_err(|error| { - println!("{:?}", error); - - match error { - wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, - wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, - } - })?; - - println!("Creating SandboxInstance..."); - Rc::new(SandboxInstance { - backend_instance: BackendInstance::Wasmer(instance), - dispatch_thunk, - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }) - } - }; - - Ok(UnregisteredInstance { sandbox_instance }) -} - #[derive(Clone, Debug)] pub enum Memory { Wasmi(MemoryRef), @@ -1197,4 +844,357 @@ impl Store { self.instances.push(Some(sandbox_instance)); instance_idx as u32 } + + /// Instantiate a guest module and return it's index in the store. + /// + /// The guest module's code is specified in `wasm`. Environment that will be available to + /// guest module is specified in `guest_env`, `dispatch_thunk` is used as function that + /// handle calls from guests. `state` is an opaque pointer to caller's arbitrary context + /// normally created by `sp_sandbox::Instance` primitive. + /// + /// Returns uninitialized sandboxed module instance or an instantiation error. + pub fn instantiate<'a, FE, SCH>( + &mut self, + dispatch_thunk: FR, + wasm: &[u8], + guest_env: GuestEnvironment, + state: u32, + ) -> std::result::Result, InstantiationError> + where + FR: Clone + 'static, + FE: SandboxCapabilities + 'a, + SCH: SandboxCapabiliesHolder, + { + let sandbox_instance = match &self.backend_context { + BackendContext::Wasmi => { + let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) + .map_err(|_| InstantiationError::Instantiation)?; + + let sandbox_instance = Rc::new(SandboxInstance { + // In general, it's not a very good idea to use `.not_started_instance()` for anything + // but for extracting memory and tables. But in this particular case, we are extracting + // for the purpose of running `start` function which should be ok. + backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), + dispatch_thunk, + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }); + + SCH::with_sandbox_capabilities( |supervisor_externals| { + with_guest_externals( + supervisor_externals, + &sandbox_instance, + state, + |guest_externals| { + wasmi_instance + .run_start(guest_externals) + .map_err(|_| InstantiationError::StartTrapped) + + // Note: no need to run start on wasmtime instance, since it's done automatically + }, + ) + })?; + + sandbox_instance + } + + BackendContext::Wasmtime => { + let mut config = wasmtime::Config::new(); + config.cranelift_opt_level(wasmtime::OptLevel::None); + config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; + + let wasmtime_engine = wasmtime::Engine::new(&config); + let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); + let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + + let module_imports: Vec<_> = wasmtime_module + .imports() + .filter_map(|import| { + if let wasmtime::ExternType::Func(func_ty) = import.ty() { + let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { + index + } else { + // Missing import + return None; + }; + + let supervisor_func_index = guest_env.guest_to_supervisor_mapping + .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); + + let dispatch_thunk = dispatch_thunk.clone(); + Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, + move |_caller, params, result| { + SCH::with_sandbox_capabilities(|supervisor_externals| { + // Serialize arguments into a byte vector. + let invoke_args_data = params + .iter() + .map(|val| match val { + Val::I32(val) => Value::I32(*val), + Val::I64(val) => Value::I64(*val), + Val::F32(val) => Value::F32(*val), + Val::F64(val) => Value::F64(*val), + _ => unimplemented!() + }) + .collect::>() + .encode(); + + // Move serialized arguments inside the memory, invoke dispatch thunk and + // then free allocated memory. + let invoke_args_len = invoke_args_data.len() as WordSize; + let invoke_args_ptr = supervisor_externals + .allocate_memory(invoke_args_len) + .map_err(|_| wasmtime::Trap::new("Can't allocate memory in supervisor for the arguments"))?; + + let deallocate = |fe: &mut FE, ptr, fail_msg| { + fe + .deallocate_memory(ptr) + .map_err(|_| wasmtime::Trap::new(fail_msg)) + }; + + if supervisor_externals + .write_memory(invoke_args_ptr, &invoke_args_data) + .is_err() + { + deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; + return Err(wasmtime::Trap::new("Can't write invoke args into memory")); + } + + let serialized_result = supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + .map_err(|e| wasmtime::Trap::new(e.to_string()))?; + + // dispatch_thunk returns pointer to serialized arguments. + // Unpack pointer and len of the serialized result data. + let (serialized_result_val_ptr, serialized_result_val_len) = { + // Cast to u64 to use zero-extension. + let v = serialized_result as u64; + let ptr = (v as u64 >> 32) as u32; + let len = (v & 0xFFFFFFFF) as u32; + (Pointer::new(ptr), len) + }; + + let serialized_result_val = supervisor_externals + .read_memory(serialized_result_val_ptr, serialized_result_val_len) + .map_err(|_| wasmtime::Trap::new("Can't read the serialized result from dispatch thunk")); + + let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmtime::Trap::new(e.to_string())) + })?; + + if let Some(value) = deserialized_result { + result[0] = match value { + RuntimeValue::I32(val) => Val::I32(val), + RuntimeValue::I64(val) => Val::I64(val), + RuntimeValue::F32(val) => Val::F32(val.into()), + RuntimeValue::F64(val) => Val::F64(val.into()), + } + } + + Ok(()) + }) + } + ))) + } else { + None + } + }) + .collect(); + + let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|error| + if let Ok(_trap) = error.downcast::() { + InstantiationError::StartTrapped + } else { + InstantiationError::Instantiation + } + )?; + + Rc::new(SandboxInstance { + backend_instance: BackendInstance::Wasmtime(wasmtime_instance), + dispatch_thunk, + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }) + } + + BackendContext::Wasmer(context) => { + // let compiler = Singlepass::default(); + // let store = wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()); + + println!("Decoding module..."); + let module = wasmer::Module::new(&context.store, wasm).map_err(|error| { + println!("{:?}", error); + InstantiationError::ModuleDecoding + })?; + + println!("Module name is {}", module.name().unwrap_or("(unknown)")); + + type Exports = HashMap; + let mut exports_map = Exports::new(); + + for import in module + .imports() + .into_iter() + { + match import.ty() { + wasmer::ExternType::Global(global) => { + println!("Importing global '{}' :: '{}' {}", import.module(), import.name(), global.to_string()); + } + + wasmer::ExternType::Table(table) => { + println!("Importing table '{}' :: '{}' {}", import.module(), import.name(), table.to_string()); + } + + wasmer::ExternType::Memory(memory_type) => { + println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); + let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); + let (_memory_index, memory) = self + .allocate_memory( + memory_type.minimum.0, + memory_type.maximum + .map(|m| m.0) + .unwrap_or(sandbox_primitives::MEM_UNLIMITED) + ) + .map_err(|_| InstantiationError::ModuleDecoding)?; + + exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); + } + + wasmer::ExternType::Function(func_ty) => { + println!("Importing function '{}' :: '{}' {}", import.module(), import.name(), func_ty.to_string()); + + let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { + index + } else { + // Missing import + println!("Missing import '{}' :: '{}'", import.module(), import.name()); + continue; + }; + + let supervisor_func_index = guest_env.guest_to_supervisor_mapping + .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); + + let dispatch_thunk = dispatch_thunk.clone(); + let function = wasmer::Function::new(&context.store, func_ty, move |params| { + SCH::with_sandbox_capabilities(|supervisor_externals| { + // Serialize arguments into a byte vector. + let invoke_args_data = params + .iter() + .map(|val| match val { + wasmer::Val::I32(val) => Value::I32(*val), + wasmer::Val::I64(val) => Value::I64(*val), + wasmer::Val::F32(val) => Value::F32(*val as u32), + wasmer::Val::F64(val) => Value::F64(*val as u64), + _ => unimplemented!() + }) + .collect::>() + .encode(); + + // Move serialized arguments inside the memory, invoke dispatch thunk and + // then free allocated memory. + let invoke_args_len = invoke_args_data.len() as WordSize; + let invoke_args_ptr = supervisor_externals + .allocate_memory(invoke_args_len) + .map_err(|_| wasmer::RuntimeError::new("Can't allocate memory in supervisor for the arguments"))?; + + let deallocate = |fe: &mut FE, ptr, fail_msg| { + fe + .deallocate_memory(ptr) + .map_err(|_| wasmer::RuntimeError::new(fail_msg)) + }; + + if supervisor_externals + .write_memory(invoke_args_ptr, &invoke_args_data) + .is_err() + { + deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; + return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); + } + + let serialized_result = supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + .map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; + + // dispatch_thunk returns pointer to serialized arguments. + // Unpack pointer and len of the serialized result data. + let (serialized_result_val_ptr, serialized_result_val_len) = { + // Cast to u64 to use zero-extension. + let v = serialized_result as u64; + let ptr = (v as u64 >> 32) as u32; + let len = (v & 0xFFFFFFFF) as u32; + (Pointer::new(ptr), len) + }; + + let serialized_result_val = supervisor_externals + .read_memory(serialized_result_val_ptr, serialized_result_val_len) + .map_err(|_| wasmer::RuntimeError::new("Can't read the serialized result from dispatch thunk")); + + let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmer::RuntimeError::new(e.to_string())) + })?; + + if let Some(value) = deserialized_result { + Ok(vec![ + match value { + RuntimeValue::I32(val) => wasmer::Val::I32(val), + RuntimeValue::I64(val) => wasmer::Val::I64(val), + RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), + RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), + } + ]) + } else { + Ok(vec![]) + } + }) + }); + + let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); + exports.insert(import.name(), wasmer::Extern::Function(function)); + } + } + } + + let mut import_object = wasmer::ImportObject::new(); + + for (module_name, exports) in exports_map.into_iter() { + import_object.register(module_name, exports); + } + + println!("Instantiating module..."); + let instance = wasmer::Instance::new(&module, &import_object) + .map_err(|error| { + println!("{:?}", error); + + match error { + wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, + wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, + } + })?; + + println!("Creating SandboxInstance..."); + Rc::new(SandboxInstance { + backend_instance: BackendInstance::Wasmer(instance), + dispatch_thunk, + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }) + } + }; + + Ok(UnregisteredInstance { sandbox_instance }) + } + } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index a0b968ca455bf..20a9935e993f3 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -147,7 +147,7 @@ impl Sandbox for FunctionExecutor { .memory(memory_id).map_err(|e| e.to_string())?; match MemoryInstance::transfer( - &sandboxed_memory, + todo!(), // &sandboxed_memory, offset as usize, &self.inner.memory, buf_ptr.into(), @@ -174,7 +174,7 @@ impl Sandbox for FunctionExecutor { match MemoryInstance::transfer( &self.inner.memory, val_ptr.into(), - &sandboxed_memory, + todo!(), //&sandboxed_memory, offset as usize, val_len as usize, ) { @@ -281,23 +281,23 @@ impl Sandbox for FunctionExecutor { println!("Instantiating sandbox from wasmi"); - let result = EXECUTOR.set(self, || sandbox::instantiate::<_, _, Holder>( - SandboxBackend::Wasmi, - dispatch_thunk, - wasm, - guest_env, - state - )); - - let instance_idx_or_err_code = - match result - .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) - { - Ok(instance_idx) => instance_idx, - Err(sandbox::InstantiationError::StartTrapped) => - sandbox_primitives::ERR_EXECUTION, - Err(_) => sandbox_primitives::ERR_MODULE, - }; + // let result = EXECUTOR.set(self, || sandbox::instantiate::<_, _, Holder>( + // SandboxBackend::Wasmi, + // dispatch_thunk, + // wasm, + // guest_env, + // state + // )); + + let instance_idx_or_err_code: u32 = todo!(); + // match result + // .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) + // { + // Ok(instance_idx) => instance_idx, + // Err(sandbox::InstantiationError::StartTrapped) => + // sandbox_primitives::ERR_EXECUTION, + // Err(_) => sandbox_primitives::ERR_MODULE, + // }; Ok(instance_idx_or_err_code as u32) } diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index f62cc0ad3731a..0964fcb2d25ee 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -165,26 +165,27 @@ impl Sandbox for HostState { .borrow() .memory(memory_id) .map_err(|e| e.to_string())?; - sandboxed_memory.with_direct_access(|sandboxed_memory| { - let len = buf_len as usize; - let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) - { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - self.inner.instance - .write_memory_from( - Pointer::new(dst_range.start as u32), - &sandboxed_memory[src_range], - ) - .expect("ranges are checked above; write can't fail; qed"); - Ok(sandbox_primitives::ERR_OK) - }) + todo!(); + // sandboxed_memory.with_direct_access(|sandboxed_memory| { + // let len = buf_len as usize; + // let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) + // { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + // let supervisor_mem_size = self.inner.instance.memory_size() as usize; + // let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + // self.inner.instance + // .write_memory_from( + // Pointer::new(dst_range.start as u32), + // &sandboxed_memory[src_range], + // ) + // .expect("ranges are checked above; write can't fail; qed"); + // Ok(sandbox_primitives::ERR_OK) + // }) } fn memory_set( @@ -199,26 +200,27 @@ impl Sandbox for HostState { .borrow() .memory(memory_id) .map_err(|e| e.to_string())?; - sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { - let len = val_len as usize; - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) - { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - self.inner.instance - .read_memory_into( - Pointer::new(src_range.start as u32), - &mut sandboxed_memory[dst_range], - ) - .expect("ranges are checked above; read can't fail; qed"); - Ok(sandbox_primitives::ERR_OK) - }) + todo!(); + // sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { + // let len = val_len as usize; + // let supervisor_mem_size = self.inner.instance.memory_size() as usize; + // let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + // let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) + // { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + // self.inner.instance + // .read_memory_into( + // Pointer::new(src_range.start as u32), + // &mut sandboxed_memory[dst_range], + // ) + // .expect("ranges are checked above; read can't fail; qed"); + // Ok(sandbox_primitives::ERR_OK) + // }) } fn memory_teardown(&mut self, memory_id: MemoryId) -> sp_wasm_interface::Result<()> { @@ -325,9 +327,9 @@ impl Sandbox for HostState { println!("Instantiating sandbox from host"); + let store = &mut *self.inner.sandbox_store.borrow_mut(); let instance_idx_or_err_code = - match sandbox::instantiate::<_, _, Holder>( - &mut *self.inner.sandbox_store.borrow_mut(), + match store.instantiate::<_, Holder>( dispatch_thunk, wasm, guest_env, From 042449cc285837462180477d88f28ede4e5cc090 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 26 Jan 2021 16:35:40 +0700 Subject: [PATCH 36/88] Eliminate `RefCell` --- client/executor/common/src/sandbox.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index cbdfb1de1f81b..454f33d8900cf 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -717,18 +717,18 @@ impl BackendContext { pub struct Store { // Memories and instances are `Some` until torn down. instances: Vec>>>, - memories: RefCell>>, + memories: Vec>, backend_context: BackendContext, } impl Store { - fn allocate_memory(&self, initial: u32, maximum: u32) -> Result<(u32, Memory)> { + fn allocate_memory(memories: &mut Vec>, backend_context: &BackendContext, initial: u32, maximum: u32) -> Result<(u32, Memory)> { let maximum = match maximum { sandbox_primitives::MEM_UNLIMITED => None, specified_limit => Some(specified_limit), }; - let memory = match &self.backend_context { + let memory = match &backend_context { BackendContext::Wasmi => { Memory::Wasmi(MemoryInstance::alloc( Pages(initial as usize), @@ -748,7 +748,6 @@ impl Store { BackendContext::Wasmtime => todo!(), }; - let mut memories = self.memories.borrow_mut(); let mem_idx = memories.len(); memories.push(Some(memory.clone())); @@ -761,7 +760,7 @@ impl Store { pub fn new(backend: SandboxBackend) -> Self { Store { instances: Vec::new(), - memories: RefCell::new(Vec::new()), + memories: Vec::new(), backend_context: BackendContext::new(backend), } } @@ -773,7 +772,9 @@ impl Store { /// Returns `Err` if the memory couldn't be created. /// Typically happens if `initial` is more than `maximum`. pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { - self.allocate_memory(initial, maximum).map(|(index, _)| index) + let memories = &mut self.memories; + let backend_context = &self.backend_context; + Self::allocate_memory(memories, backend_context, initial, maximum).map(|(index, _)| index) } /// Returns `SandboxInstance` by `instance_idx`. @@ -798,7 +799,7 @@ impl Store { /// if memory has been torn down. pub fn memory(&self, memory_idx: u32) -> Result { self.memories - .borrow() + // .borrow() .get(memory_idx as usize) .cloned() .ok_or_else(|| "Trying to access a non-existent sandboxed memory")? @@ -812,7 +813,7 @@ impl Store { /// Returns `Err` if `memory_idx` isn't a valid index of an memory or /// if it has been torn down. pub fn memory_teardown(&mut self, memory_idx: u32) -> Result<()> { - match self.memories.borrow_mut().get_mut(memory_idx as usize) { + match self.memories.get_mut(memory_idx as usize) { None => Err("Trying to teardown a non-existent sandboxed memory".into()), Some(None) => Err("Double teardown of a sandboxed memory".into()), Some(memory) => { @@ -865,7 +866,10 @@ impl Store { FE: SandboxCapabilities + 'a, SCH: SandboxCapabiliesHolder, { - let sandbox_instance = match &self.backend_context { + let memories = &mut self.memories; + let backend_context = &self.backend_context; + + let sandbox_instance = match backend_context { BackendContext::Wasmi => { let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) @@ -1054,8 +1058,9 @@ impl Store { wasmer::ExternType::Memory(memory_type) => { println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); - let (_memory_index, memory) = self - .allocate_memory( + let (_memory_index, memory) = Self::allocate_memory( + memories, + backend_context, memory_type.minimum.0, memory_type.maximum .map(|m| m.0) From 5b47676ccdf14a0284deb98f6d8b60c9b2c82645 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 27 Jan 2021 13:34:40 +0700 Subject: [PATCH 37/88] Implements `HostState::memory_get/set`, removes accidental `borrow_mut` --- client/executor/wasmtime/src/host.rs | 157 +++++++++++++++++++-------- 1 file changed, 113 insertions(+), 44 deletions(-) diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 0964fcb2d25ee..27405c277f88f 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -19,7 +19,8 @@ use crate::instance_wrapper::InstanceWrapper; use crate::util; -use std::{cell::RefCell, rc::Rc}; +use core::slice; +use std::{cell::RefCell, rc::Rc, vec::Splice}; use log::trace; use codec::{Encode, Decode}; use sp_allocator::FreeingBumpHeapAllocator; @@ -165,27 +166,61 @@ impl Sandbox for HostState { .borrow() .memory(memory_id) .map_err(|e| e.to_string())?; - todo!(); - // sandboxed_memory.with_direct_access(|sandboxed_memory| { - // let len = buf_len as usize; - // let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) - // { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - // let supervisor_mem_size = self.inner.instance.memory_size() as usize; - // let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - // self.inner.instance - // .write_memory_from( - // Pointer::new(dst_range.start as u32), - // &sandboxed_memory[src_range], - // ) - // .expect("ranges are checked above; write can't fail; qed"); - // Ok(sandbox_primitives::ERR_OK) - // }) + + match sandboxed_memory { + sandbox::Memory::Wasmi(sandboxed_memory) => { + sandboxed_memory.with_direct_access(|sandboxed_memory| { + let len = buf_len as usize; + + let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let supervisor_mem_size = self.inner.instance.memory_size() as usize; + let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + self.inner.instance + .write_memory_from( + Pointer::new(dst_range.start as u32), + &sandboxed_memory[src_range], + ) + .expect("ranges are checked above; write can't fail; qed"); + + Ok(sandbox_primitives::ERR_OK) + }) + }, + + sandbox::Memory::Wasmer(sandboxed_memory) => { + let len = buf_len as usize; + + let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let supervisor_mem_size = self.inner.instance.memory_size() as usize; + let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + // TODO Proof of safety + let source = unsafe { slice::from_raw_parts(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + + self.inner.instance + .write_memory_from( + Pointer::new(dst_range.start as u32), + &source[src_range], + ) + .expect("ranges are checked above; write can't fail; qed"); + + Ok(sandbox_primitives::ERR_OK) + } + } } fn memory_set( @@ -200,27 +235,61 @@ impl Sandbox for HostState { .borrow() .memory(memory_id) .map_err(|e| e.to_string())?; - todo!(); - // sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { - // let len = val_len as usize; - // let supervisor_mem_size = self.inner.instance.memory_size() as usize; - // let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - // let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) - // { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - // self.inner.instance - // .read_memory_into( - // Pointer::new(src_range.start as u32), - // &mut sandboxed_memory[dst_range], - // ) - // .expect("ranges are checked above; read can't fail; qed"); - // Ok(sandbox_primitives::ERR_OK) - // }) + + match sandboxed_memory { + sandbox::Memory::Wasmi(sandboxed_memory) => { + sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { + let len = val_len as usize; + let supervisor_mem_size = self.inner.instance.memory_size() as usize; + + let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + self.inner.instance + .read_memory_into( + Pointer::new(src_range.start as u32), + &mut sandboxed_memory[dst_range], + ) + .expect("ranges are checked above; read can't fail; qed"); + + Ok(sandbox_primitives::ERR_OK) + }) + } + + sandbox::Memory::Wasmer(sandboxed_memory) => { + let len = val_len as usize; + let supervisor_mem_size = self.inner.instance.memory_size() as usize; + + let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + // TODO Proof of safety + let dest = unsafe { slice::from_raw_parts_mut(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + + self.inner.instance + .read_memory_into( + Pointer::new(src_range.start as u32), + &mut dest[dst_range], + ) + .expect("ranges are checked above; read can't fail; qed"); + + Ok(sandbox_primitives::ERR_OK) + } + } } fn memory_teardown(&mut self, memory_id: MemoryId) -> sp_wasm_interface::Result<()> { @@ -335,7 +404,7 @@ impl Sandbox for HostState { guest_env, state ) - .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) + .map(|i| i.register(store)) { Ok(instance_idx) => instance_idx, Err(sandbox::InstantiationError::StartTrapped) => sandbox_primitives::ERR_EXECUTION, From 2ee8f4544a56b28daa686d9be9de181a81ae4b79 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 27 Jan 2021 13:49:30 +0700 Subject: [PATCH 38/88] Fixes sandbox memory handling for wasmi --- client/executor/common/src/sandbox.rs | 8 +-- client/executor/wasmi/src/lib.rs | 87 ++++++++++++++++----------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 454f33d8900cf..6569156cbbae9 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -93,7 +93,7 @@ struct Imports { func_map: HashMap<(Vec, Vec), GuestFuncIndex>, /// Maps qualified field name to its memory reference - memories_map: HashMap<(Vec, Vec), MemoryRef>, + memories_map: HashMap<(Vec, Vec), Memory>, } impl Imports { @@ -134,6 +134,7 @@ impl ImportResolver for Imports { ); let mem = self.memories_map .get(&key) + .and_then(|m| m.as_wasmi()) .ok_or_else(|| { wasmi::Error::Instantiation(format!( "Export {}:{} not found", @@ -551,7 +552,7 @@ pub enum InstantiationError { fn decode_environment_definition( raw_env_def: &[u8], - memories: &[Option], + memories: &[Option], ) -> std::result::Result<(Imports, GuestToSupervisorFunctionMapping), InstantiationError> { let env_def = sandbox_primitives::EnvironmentDefinition::decode(&mut &raw_env_def[..]) .map_err(|_| InstantiationError::EnvironmentDefinitionCorrupted)?; @@ -607,8 +608,7 @@ impl GuestEnvironment { store: &Store, raw_env_def: &[u8], ) -> std::result::Result { - let (imports, guest_to_supervisor_mapping) = todo!(); - //decode_environment_definition(raw_env_def, &store.memories)?; + let (imports, guest_to_supervisor_mapping) = decode_environment_definition(raw_env_def, &store.memories)?; Ok(Self { imports, guest_to_supervisor_mapping, diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 20a9935e993f3..190a2a506d429 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -146,16 +146,25 @@ impl Sandbox for FunctionExecutor { .borrow() .memory(memory_id).map_err(|e| e.to_string())?; - match MemoryInstance::transfer( - todo!(), // &sandboxed_memory, - offset as usize, - &self.inner.memory, - buf_ptr.into(), - buf_len as usize, - ) { - Ok(()) => Ok(sandbox_primitives::ERR_OK), - Err(_) => Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + match sandboxed_memory { + sandbox::Memory::Wasmi(sandboxed_memory) => { + match MemoryInstance::transfer( + &sandboxed_memory, + offset as usize, + &self.inner.memory, + buf_ptr.into(), + buf_len as usize, + ) { + Ok(()) => Ok(sandbox_primitives::ERR_OK), + Err(_) => Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + } + } + + sandbox::Memory::Wasmer(sandboxed_memory) => { + todo!() + } } + } fn memory_set( @@ -171,15 +180,23 @@ impl Sandbox for FunctionExecutor { .borrow() .memory(memory_id).map_err(|e| e.to_string())?; - match MemoryInstance::transfer( - &self.inner.memory, - val_ptr.into(), - todo!(), //&sandboxed_memory, - offset as usize, - val_len as usize, - ) { - Ok(()) => Ok(sandbox_primitives::ERR_OK), - Err(_) => Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + match sandboxed_memory { + sandbox::Memory::Wasmi(sandboxed_memory) => { + match MemoryInstance::transfer( + &self.inner.memory, + val_ptr.into(), + &sandboxed_memory, + offset as usize, + val_len as usize, + ) { + Ok(()) => Ok(sandbox_primitives::ERR_OK), + Err(_) => Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + } + } + + sandbox::Memory::Wasmer(sandboxed_memory) => { + todo!() + } } } @@ -281,23 +298,23 @@ impl Sandbox for FunctionExecutor { println!("Instantiating sandbox from wasmi"); - // let result = EXECUTOR.set(self, || sandbox::instantiate::<_, _, Holder>( - // SandboxBackend::Wasmi, - // dispatch_thunk, - // wasm, - // guest_env, - // state - // )); - - let instance_idx_or_err_code: u32 = todo!(); - // match result - // .map(|i| i.register(&mut *self.inner.sandbox_store.borrow_mut())) - // { - // Ok(instance_idx) => instance_idx, - // Err(sandbox::InstantiationError::StartTrapped) => - // sandbox_primitives::ERR_EXECUTION, - // Err(_) => sandbox_primitives::ERR_MODULE, - // }; + let store = &mut *self.inner.sandbox_store.borrow_mut(); + let result = EXECUTOR.set(self, || store.instantiate::<_, Holder>( + dispatch_thunk, + wasm, + guest_env, + state + )); + + let instance_idx_or_err_code: u32 = + match result + .map(|i| i.register(store)) + { + Ok(instance_idx) => instance_idx, + Err(sandbox::InstantiationError::StartTrapped) => + sandbox_primitives::ERR_EXECUTION, + Err(_) => sandbox_primitives::ERR_MODULE, + }; Ok(instance_idx_or_err_code as u32) } From 2eb9ad32a0155e800ca9183b3b6b3ee6cd6e85b8 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 17 Feb 2021 11:54:41 +0700 Subject: [PATCH 39/88] Fix memory allocation --- client/executor/common/src/sandbox.rs | 37 +++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 6569156cbbae9..7b743493f48a7 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -100,6 +100,10 @@ impl Imports { fn func_by_name(&self, module_name: &str, func_name: &str) -> Option { self.func_map.get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())).cloned() } + + fn memory_by_name(&self, module_name: &str, memory_name: &str) -> Option { + self.memories_map.get(&(module_name.as_bytes().to_owned(), memory_name.as_bytes().to_owned())).cloned() + } } impl ImportResolver for Imports { @@ -524,8 +528,8 @@ impl SandboxInstance { let wasmtime_value = match global.get() { wasmer::Val::I32(val) => Value::I32(val), wasmer::Val::I64(val) => Value::I64(val), - wasmer::Val::F32(val) => Value::F32(val as u32), - wasmer::Val::F64(val) => Value::F64(val as u64), + wasmer::Val::F32(val) => Value::F32(f32::to_bits(val)), + wasmer::Val::F64(val) => Value::F64(f64::to_bits(val)), _ => None?, }; @@ -730,6 +734,8 @@ impl Store { let memory = match &backend_context { BackendContext::Wasmi => { + println!("creating wasmi memory {}..{}", initial, maximum.map(|v| v.to_string()).unwrap_or("?".into())); + Memory::Wasmi(MemoryInstance::alloc( Pages(initial as usize), maximum.map(|m| Pages(m as usize)), @@ -738,10 +744,17 @@ impl Store { BackendContext::Wasmer(context) => { let ty = wasmer::MemoryType::new(initial, maximum, false); + println!("creating wasmer memory {:?}", ty); + + // let bt = backtrace::Backtrace::new(); + // println!("{:?}", bt); Memory::Wasmer( wasmer::Memory::new(&context.store, ty) - .map_err(|_| Error::InvalidMemoryReference)? + .map_err(|r| { + println!("Error creating wasmer Memory: {}", r.to_string()); + Error::InvalidMemoryReference + })? ) } @@ -774,7 +787,8 @@ impl Store { pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { let memories = &mut self.memories; let backend_context = &self.backend_context; - Self::allocate_memory(memories, backend_context, initial, maximum).map(|(index, _)| index) + dbg!(initial, maximum); + dbg!(Self::allocate_memory(memories, backend_context, initial, maximum).map(|(index, _)| index)) } /// Returns `SandboxInstance` by `instance_idx`. @@ -799,7 +813,6 @@ impl Store { /// if memory has been torn down. pub fn memory(&self, memory_idx: u32) -> Result { self.memories - // .borrow() .get(memory_idx as usize) .cloned() .ok_or_else(|| "Trying to access a non-existent sandboxed memory")? @@ -1058,15 +1071,7 @@ impl Store { wasmer::ExternType::Memory(memory_type) => { println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); - let (_memory_index, memory) = Self::allocate_memory( - memories, - backend_context, - memory_type.minimum.0, - memory_type.maximum - .map(|m| m.0) - .unwrap_or(sandbox_primitives::MEM_UNLIMITED) - ) - .map_err(|_| InstantiationError::ModuleDecoding)?; + let memory = guest_env.imports.memory_by_name(import.module(), import.name()).ok_or(InstantiationError::ModuleDecoding)?; exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); } @@ -1094,8 +1099,8 @@ impl Store { .map(|val| match val { wasmer::Val::I32(val) => Value::I32(*val), wasmer::Val::I64(val) => Value::I64(*val), - wasmer::Val::F32(val) => Value::F32(*val as u32), - wasmer::Val::F64(val) => Value::F64(*val as u64), + wasmer::Val::F32(val) => Value::F32(f32::to_bits(*val)), + wasmer::Val::F64(val) => Value::F64(f64::to_bits(*val)), _ => unimplemented!() }) .collect::>() From fe3aae52b654d79431006c2b7d92db7613d32aeb Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 1 Mar 2021 17:42:28 +0700 Subject: [PATCH 40/88] Resets Cargo.lock to match master --- Cargo.lock | 1115 ++++++++++++++++++++++++++++------------------------ 1 file changed, 595 insertions(+), 520 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb9e1f459194d..1c4babcaa721c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ "gimli 0.23.0", ] @@ -57,7 +57,7 @@ dependencies = [ "aes", "block-cipher", "ghash", - "subtle 2.3.0", + "subtle 2.4.0", ] [[package]] @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6789e291be47ace86a60303502173d84af8327e3627ecf334356ee0f87a164c" +checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "aho-corasick" @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.34" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" [[package]] name = "approx" @@ -177,9 +177,9 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da" +checksum = "3dc1679af9a1ab4bea16f228b05d18f8363f8327b1fa8db00d2760cfafc6b61e" dependencies = [ "doc-comment", "predicates", @@ -231,12 +231,15 @@ dependencies = [ [[package]] name = "async-global-executor" -version = "1.4.3" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73079b49cd26b8fd5a15f68fc7707fc78698dc2a3d61430f2a7a9430230dfa04" +checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" dependencies = [ + "async-channel", "async-executor", "async-io", + "async-mutex", + "blocking", "futures-lite", "num_cpus", "once_cell", @@ -262,6 +265,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "async-lock" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1996609732bde4a9988bc42125f55f2af5f3c36370e27c778d5191a4a1b63bfb" +dependencies = [ + "event-listener", +] + [[package]] name = "async-mutex" version = "1.4.0" @@ -271,18 +283,35 @@ dependencies = [ "event-listener", ] +[[package]] +name = "async-process" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8cea09c1fb10a317d1b5af8024eeba256d6554763e85ecd90ff8df31c7bbda" +dependencies = [ + "async-io", + "blocking", + "cfg-if 0.1.10", + "event-listener", + "futures-lite", + "once_cell", + "signal-hook", + "winapi 0.3.9", +] + [[package]] name = "async-std" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e82538bc65a25dbdff70e4c5439d52f068048ab97cdea0acd73f131594caa1" +checksum = "d9f06685bad74e0570f5213741bea82158279a4103d988e57bfada11ad230341" dependencies = [ "async-attributes", + "async-channel", "async-global-executor", "async-io", - "async-mutex", - "blocking", - "crossbeam-utils 0.8.0", + "async-lock", + "async-process", + "crossbeam-utils 0.8.1", "futures-channel", "futures-core", "futures-io", @@ -293,7 +322,7 @@ dependencies = [ "memchr", "num_cpus", "once_cell", - "pin-project-lite 0.1.11", + "pin-project-lite 0.2.4", "pin-utils", "slab", "wasm-bindgen-futures", @@ -307,9 +336,9 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-trait" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b246867b8b3b6ae56035f1eb1ed557c1d8eae97f0d53696138a50fa0e3a3b8c0" +checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" dependencies = [ "proc-macro2", "quote", @@ -376,15 +405,15 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.54" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.22.0", + "object 0.23.0", "rustc-demangle", ] @@ -611,9 +640,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" [[package]] name = "byte-slice-cast" @@ -629,9 +658,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" @@ -680,14 +709,24 @@ dependencies = [ "cc", ] +[[package]] +name = "cargo-platform" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7" +dependencies = [ + "serde", +] + [[package]] name = "cargo_metadata" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83f95cf4bf0dda0ac2e65371ae7215d0dce3c187613a9dbf23aaa9374186f97a" +checksum = "7714a157da7991e23d90686b9524b9e12e0407a108647f52e9328f4b3d51ac7f" dependencies = [ + "cargo-platform", "semver 0.11.0", - "semver-parser 0.10.0", + "semver-parser 0.10.2", "serde", "serde_json", ] @@ -703,9 +742,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.62" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" dependencies = [ "jobserver", ] @@ -785,9 +824,9 @@ dependencies = [ [[package]] name = "cid" -version = "0.6.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff0e3bc0b6446b3f9663c1a6aba6ef06c5aeaa1bc92bd18077be337198ab9768" +checksum = "7d88f30b1e74e7063df5711496f3ee6e74a9735d62062242d70cddf77717f18e" dependencies = [ "multibase", "multihash", @@ -847,15 +886,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - [[package]] name = "concurrent-queue" version = "1.2.2" @@ -877,9 +907,9 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "constant_time_eq" @@ -909,6 +939,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +[[package]] +name = "cpuid-bool" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" + [[package]] name = "cranelift-bforest" version = "0.65.0" @@ -940,7 +976,7 @@ dependencies = [ "log", "regalloc", "serde", - "smallvec 1.5.0", + "smallvec 1.6.1", "target-lexicon", "thiserror", ] @@ -960,7 +996,7 @@ dependencies = [ "log", "regalloc", "serde", - "smallvec 1.5.0", + "smallvec 1.6.1", "target-lexicon", "thiserror", ] @@ -1019,7 +1055,7 @@ source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71 dependencies = [ "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", "log", - "smallvec 1.5.0", + "smallvec 1.6.1", "target-lexicon", ] @@ -1031,7 +1067,7 @@ checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" dependencies = [ "cranelift-codegen 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", "log", - "smallvec 1.5.0", + "smallvec 1.6.1", "target-lexicon", ] @@ -1070,16 +1106,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" dependencies = [ "atty", "cast", "clap", "criterion-plot", "csv", - "itertools 0.9.0", + "itertools 0.10.0", "lazy_static", "num-traits", "oorandom", @@ -1111,7 +1147,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.0", + "crossbeam-utils 0.8.1", ] [[package]] @@ -1132,8 +1168,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch 0.9.0", - "crossbeam-utils 0.8.0", + "crossbeam-epoch 0.9.1", + "crossbeam-utils 0.8.1", ] [[package]] @@ -1147,21 +1183,21 @@ dependencies = [ "crossbeam-utils 0.7.2", "lazy_static", "maybe-uninit", - "memoffset", + "memoffset 0.5.6", "scopeguard", ] [[package]] name = "crossbeam-epoch" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" dependencies = [ "cfg-if 1.0.0", "const_fn", - "crossbeam-utils 0.8.0", + "crossbeam-utils 0.8.1", "lazy_static", - "memoffset", + "memoffset 0.6.1", "scopeguard", ] @@ -1189,13 +1225,12 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" +checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ "autocfg", "cfg-if 1.0.0", - "const_fn", "lazy_static", ] @@ -1222,14 +1257,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.4", - "subtle 2.3.0", + "subtle 2.4.0", ] [[package]] name = "csv" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4666154fd004af3fd6f1da2e81a96fd5a81927fe8ddb6ecc79e2aa6e138b54" +checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97" dependencies = [ "bstr", "csv-core", @@ -1258,9 +1293,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484" +checksum = "10bcb9d7dcbf7002aaffbb53eac22906b64cdcc127971dcc387d8eb7c95d5560" dependencies = [ "quote", "syn", @@ -1279,35 +1314,35 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "2.1.0" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5" +checksum = "434e1720189a637d44fe464f4df1e6eb900b4835255b14354497c78af37d9bb8" dependencies = [ "byteorder", "digest 0.8.1", "rand_core 0.5.1", - "subtle 2.3.0", + "subtle 2.4.0", "zeroize", ] [[package]] name = "curve25519-dalek" -version = "3.0.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8492de420e9e60bc9a1d66e2dbb91825390b738a388606600663fc529b4b307" +checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle 2.3.0", + "subtle 2.4.0", "zeroize", ] [[package]] name = "darling" -version = "0.10.2" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +checksum = "a06d4a9551359071d1890820e3571252b91229e0712e7c36b08940e603c5a8fc" dependencies = [ "darling_core", "darling_macro", @@ -1315,23 +1350,23 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.10.2" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +checksum = "b443e5fb0ddd56e0c9bfa47dc060c5306ee500cb731f2b91432dd65589a77684" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.9.3", + "strsim 0.10.0", "syn", ] [[package]] name = "darling_macro" -version = "0.10.2" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +checksum = "c0220073ce504f12a70efc4e7cdaea9e9b1b324872e7ad96a208056d7a638b81" dependencies = [ "darling_core", "quote", @@ -1340,9 +1375,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993a608597367c6377b258c25d7120740f00ed23a2252b729b1932dd7866f908" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" [[package]] name = "data-encoding-macro" @@ -1377,9 +1412,9 @@ dependencies = [ [[package]] name = "derive_utils" -version = "0.11.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64196eb9f551916167225134f1e8a90f0b5774331d3c900d6328fd94bafe3544" +checksum = "532b4c15dccee12c7044f1fcad956e98410860b22231e44a3b827464797ca7bf" dependencies = [ "proc-macro2", "quote", @@ -1485,9 +1520,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d55796afa1b20c2945ca8eabfc421839f2b766619209f1ede813cf2484f31804" +checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" [[package]] name = "dynasm" @@ -1506,9 +1541,9 @@ dependencies = [ [[package]] name = "dynasm" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a59fbab09460c1569eeea9b5e4cf62f13f5198b1c2ba0e5196dd7fdd17cd42" +checksum = "3d7d1242462849390bb2ad38aeed769499f1afc7383affa2ab0c1baa894c0200" dependencies = [ "bitflags", "byteorder", @@ -1531,13 +1566,13 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bec3edae2841d37b1c3dc7f3fd403c9061f26e9ffeeee97a3ea909b1bb2ef1" +checksum = "c1dd4d1d5ca12258cef339a57a7643e8b233a42dea9bb849630ddd9dd7726aa9" dependencies = [ "byteorder", - "dynasm 1.0.0", - "memmap", + "dynasm 1.0.1", + "memmap2", ] [[package]] @@ -1555,11 +1590,11 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.0.0", + "curve25519-dalek 3.0.2", "ed25519", "rand 0.7.3", "serde", - "sha2 0.9.2", + "sha2 0.9.3", "zeroize", ] @@ -1591,19 +1626,18 @@ dependencies = [ [[package]] name = "enumset" -version = "1.0.1" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1" +checksum = "fbd795df6708a599abf1ee10eacc72efd052b7a5f70fdf0715e4d5151a6db9c3" dependencies = [ "enumset_derive", - "num-traits", ] [[package]] name = "enumset_derive" -version = "0.5.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac" +checksum = "e19c52f9ec503c8a68dc04daf71a04b07e690c32ab1a8b68e33897f255269d47" dependencies = [ "darling", "proc-macro2", @@ -1626,9 +1660,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" dependencies = [ "atty", "humantime 2.1.0", @@ -1645,9 +1679,9 @@ checksum = "6576a1755ddffd988788025e75bce9e74b018f7cc226198fe931d077911c6d7e" [[package]] name = "erased-serde" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ca8b296792113e1500fd935ae487be6e00ce318952a6880555554824d6ebf38" +checksum = "0465971a8cc1fa2455c8465aaa377131e1f1cf4983280f474a13e68793aa770c" dependencies = [ "serde", ] @@ -1685,7 +1719,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", ] [[package]] @@ -1757,7 +1791,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6447e2f8178843749e8c8003206def83ec124a7859475395777a28b5338647c" dependencies = [ "either", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "log", "num-traits", @@ -1786,9 +1820,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" [[package]] name = "flate2" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ "cfg-if 1.0.0", "crc32fast", @@ -1829,7 +1863,7 @@ dependencies = [ "hex-literal", "linregress", "parity-scale-codec", - "paste 1.0.3", + "paste 1.0.4", "serde", "sp-api", "sp-io", @@ -1904,10 +1938,10 @@ dependencies = [ "once_cell", "parity-scale-codec", "parity-util-mem", - "paste 1.0.3", + "paste 1.0.4", "pretty_assertions", "serde", - "smallvec 1.5.0", + "smallvec 1.6.1", "sp-api", "sp-arithmetic", "sp-core", @@ -2066,9 +2100,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "funty" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" @@ -2078,9 +2112,9 @@ checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" [[package]] name = "futures" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" dependencies = [ "futures-channel", "futures-core", @@ -2093,9 +2127,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" dependencies = [ "futures-core", "futures-sink", @@ -2103,9 +2137,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" [[package]] name = "futures-cpupool" @@ -2124,7 +2158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdcef58a173af8148b182684c9f2d5250875adbcaff7b5794073894f9d8634a9" dependencies = [ "futures 0.1.30", - "futures 0.3.13", + "futures 0.3.12", "lazy_static", "log", "parking_lot 0.9.0", @@ -2135,9 +2169,9 @@ dependencies = [ [[package]] name = "futures-executor" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" dependencies = [ "futures-core", "futures-task", @@ -2147,30 +2181,30 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" [[package]] name = "futures-lite" -version = "1.11.2" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6c079abfac3ab269e2927ec048dabc89d009ebfdda6b8ee86624f30c689658" +checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb" dependencies = [ "fastrand", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.1.11", + "pin-project-lite 0.2.4", "waker-fn", ] [[package]] name = "futures-macro" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -2191,15 +2225,18 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" [[package]] name = "futures-task" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" +dependencies = [ + "once_cell", +] [[package]] name = "futures-timer" @@ -2219,9 +2256,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.13" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" dependencies = [ "futures 0.1.30", "futures-channel", @@ -2244,19 +2281,6 @@ version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -[[package]] -name = "generator" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cdc09201b2e8ca1b19290cf7e65de2246b8e91fb6874279722189c4de7b94dc" -dependencies = [ - "cc", - "libc", - "log", - "rustc_version", - "winapi 0.3.9", -] - [[package]] name = "generic-array" version = "0.12.3" @@ -2287,11 +2311,12 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", "wasm-bindgen", @@ -2312,10 +2337,11 @@ dependencies = [ [[package]] name = "ghash" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6e27f0689a6e15944bdce7e45425efb87eaa8ab0c6e87f11d0987a9133e2531" +checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" dependencies = [ + "opaque-debug 0.3.0", "polyval", ] @@ -2397,7 +2423,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http 0.2.1", + "http 0.2.3", "indexmap", "slab", "tokio 0.2.25", @@ -2408,15 +2434,15 @@ dependencies = [ [[package]] name = "half" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "handlebars" -version = "3.5.1" +version = "3.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2764f9796c0ddca4b82c07f25dd2cb3db30b9a8f47940e78e1c883d9e95c3db9" +checksum = "964d0e99a61fe9b1b347389b77ebf8b7e1587b70293676aaca7d27e59b9073b2" dependencies = [ "log", "pest", @@ -2452,18 +2478,18 @@ dependencies = [ [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -2519,9 +2545,9 @@ dependencies = [ [[package]] name = "honggfuzz" -version = "0.5.51" +version = "0.5.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f085725a5828d7e959f014f624773094dfe20acc91be310ef106923c30594bc" +checksum = "ead88897bcad1c396806d6ccba260a0363e11da997472e9e19ab9889969083a2" dependencies = [ "arbitrary", "lazy_static", @@ -2541,11 +2567,11 @@ dependencies = [ [[package]] name = "http" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes 0.5.6", + "bytes 1.0.1", "fnv", "itoa", ] @@ -2569,7 +2595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ "bytes 0.5.6", - "http 0.2.1", + "http 0.2.3", ] [[package]] @@ -2640,12 +2666,12 @@ dependencies = [ "futures-core", "futures-util", "h2 0.2.7", - "http 0.2.1", + "http 0.2.3", "http-body 0.3.1", "httparse", "httpdate", "itoa", - "pin-project 1.0.5", + "pin-project 1.0.4", "socket2", "tokio 0.2.25", "tower-service", @@ -2727,7 +2753,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b8538953a3f0d0d3868f0a706eb4273535e10d72acb5c82c1c23ae48835c85" dependencies = [ "async-io", - "futures 0.3.13", + "futures 0.3.12", "futures-lite", "if-addrs", "ipnet", @@ -2767,9 +2793,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg", "hashbrown", @@ -2778,9 +2804,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -2803,7 +2829,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64fa110ec7b8f493f416eed552740d10e7030ad5f63b2308f82c9608ec2df275" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "futures-timer 2.0.2", ] @@ -2830,9 +2856,9 @@ checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" [[package]] name = "iter-enum" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86a94bc12a53bf84b705acee29eb8697a5ea7b4587d836152499e5db0a6d52b9" +checksum = "cad34f24d3b48ceffdff38af2df5ce1b7d1d9cc113e503d8e86fe8cdb889c871" dependencies = [ "derive_utils", "quote", @@ -2857,11 +2883,20 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jobserver" @@ -2874,9 +2909,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.47" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" +checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" dependencies = [ "wasm-bindgen", ] @@ -3047,7 +3082,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8891bd853eff90e33024195d79d578dc984c82f9e0715fcd2b525a0c19d52811" dependencies = [ "parity-util-mem", - "smallvec 1.5.0", + "smallvec 1.6.1", ] [[package]] @@ -3076,7 +3111,7 @@ dependencies = [ "parking_lot 0.11.1", "regex", "rocksdb", - "smallvec 1.5.0", + "smallvec 1.6.1", ] [[package]] @@ -3085,7 +3120,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb1e98ba343d0b35f9009a8844cd2b87fa3192f7e79033ac05b00aeae0f3b0b5" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "js-sys", "kvdb", "kvdb-memorydb", @@ -3117,9 +3152,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.86" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff" [[package]] name = "libloading" @@ -3133,9 +3168,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ "cfg-if 1.0.0", "winapi 0.3.9", @@ -3155,7 +3190,7 @@ checksum = "adc225a49973cf9ab10d0cdd6a4b8f0cda299df9b760824bbb623f15f8f0c95a" dependencies = [ "atomic", "bytes 1.0.1", - "futures 0.3.13", + "futures 0.3.12", "lazy_static", "libp2p-core", "libp2p-deflate", @@ -3180,8 +3215,8 @@ dependencies = [ "libp2p-yamux", "parity-multiaddr", "parking_lot 0.11.1", - "pin-project 1.0.5", - "smallvec 1.5.0", + "pin-project 1.0.4", + "smallvec 1.6.1", "wasm-timer", ] @@ -3196,7 +3231,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "lazy_static", "libsecp256k1", @@ -3205,14 +3240,14 @@ dependencies = [ "multistream-select", "parity-multiaddr", "parking_lot 0.11.1", - "pin-project 1.0.5", + "pin-project 1.0.4", "prost", "prost-build", "rand 0.7.3", "ring", "rw-stream-sink", - "sha2 0.9.2", - "smallvec 1.5.0", + "sha2 0.9.3", + "smallvec 1.6.1", "thiserror", "unsigned-varint 0.7.0", "void", @@ -3226,7 +3261,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d42eed63305f0420736fa487f9acef720c4528bd7852a6a760f5ccde4813345" dependencies = [ "flate2", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", ] @@ -3236,7 +3271,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5153b6db68fd4baa3b304e377db744dd8fea8ff4e4504509ee636abcde88d3e3" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "log", ] @@ -3249,14 +3284,14 @@ checksum = "b3c63dfa06581b24b1d12bf9815b43689a784424be217d6545c800c7c75a207f" dependencies = [ "cuckoofilter", "fnv", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "libp2p-swarm", "log", "prost", "prost-build", "rand 0.7.3", - "smallvec 1.5.0", + "smallvec 1.6.1", ] [[package]] @@ -3270,7 +3305,7 @@ dependencies = [ "byteorder", "bytes 1.0.1", "fnv", - "futures 0.3.13", + "futures 0.3.12", "hex_fmt", "libp2p-core", "libp2p-swarm", @@ -3279,8 +3314,8 @@ dependencies = [ "prost-build", "rand 0.7.3", "regex", - "sha2 0.9.2", - "smallvec 1.5.0", + "sha2 0.9.3", + "smallvec 1.6.1", "unsigned-varint 0.7.0", "wasm-timer", ] @@ -3291,13 +3326,13 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b40fb36a059b7a8cce1514bd8b546fa612e006c9937caa7f5950cb20021fe91e" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "libp2p-swarm", "log", "prost", "prost-build", - "smallvec 1.5.0", + "smallvec 1.6.1", "wasm-timer", ] @@ -3312,15 +3347,15 @@ dependencies = [ "bytes 1.0.1", "either", "fnv", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "libp2p-swarm", "log", "prost", "prost-build", "rand 0.7.3", - "sha2 0.9.2", - "smallvec 1.5.0", + "sha2 0.9.3", + "smallvec 1.6.1", "uint", "unsigned-varint 0.7.0", "void", @@ -3336,14 +3371,14 @@ dependencies = [ "async-io", "data-encoding", "dns-parser", - "futures 0.3.13", + "futures 0.3.12", "if-watch", "lazy_static", "libp2p-core", "libp2p-swarm", "log", "rand 0.7.3", - "smallvec 1.5.0", + "smallvec 1.6.1", "socket2", "void", ] @@ -3356,13 +3391,13 @@ checksum = "350ce8b3923594aedabd5d6e3f875d058435052a29c3f32df378bc70d10be464" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.0.1", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "log", "nohash-hasher", "parking_lot 0.11.1", "rand 0.7.3", - "smallvec 1.5.0", + "smallvec 1.6.1", "unsigned-varint 0.7.0", ] @@ -3373,15 +3408,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4aca322b52a0c5136142a7c3971446fb1e9964923a526c9cc6ef3b7c94e57778" dependencies = [ "bytes 1.0.1", - "curve25519-dalek 3.0.0", - "futures 0.3.13", + "curve25519-dalek 3.0.2", + "futures 0.3.12", "lazy_static", "libp2p-core", "log", "prost", "prost-build", "rand 0.7.3", - "sha2 0.9.2", + "sha2 0.9.3", "snow", "static_assertions", "x25519-dalek", @@ -3394,7 +3429,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f3813276d0708c8db0f500d8beda1bda9ad955723b9cb272c41f4727256f73c" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "libp2p-swarm", "log", @@ -3411,7 +3446,7 @@ checksum = "9d58defcadb646ae4b033e130b48d87410bf76394dc3335496cae99dac803e61" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.0.1", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "log", "prost", @@ -3426,9 +3461,9 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce3374f3b28162db9d3442c9347c4f14cb01e8290052615c7d341d40eae0599" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "log", - "pin-project 1.0.5", + "pin-project 1.0.4", "rand 0.7.3", "salsa20", "sha3", @@ -3442,14 +3477,14 @@ checksum = "10e5552827c33d8326502682da73a0ba4bfa40c1b55b216af3c303f32169dd89" dependencies = [ "async-trait", "bytes 1.0.1", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "libp2p-swarm", "log", "lru", "minicbor", "rand 0.7.3", - "smallvec 1.5.0", + "smallvec 1.6.1", "unsigned-varint 0.7.0", "wasm-timer", ] @@ -3461,11 +3496,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7955b973e1fd2bd61ffd43ce261c1223f61f4aacd5bae362a924993f9a25fd98" dependencies = [ "either", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "log", "rand 0.7.3", - "smallvec 1.5.0", + "smallvec 1.6.1", "void", "wasm-timer", ] @@ -3487,7 +3522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88a5aef80e519a6cb8e2663605142f97baaaea1a252eecbf8756184765f7471b" dependencies = [ "async-io", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "if-watch", "ipnet", @@ -3504,7 +3539,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80ac51ce419f60be966e02103c17f67ff5dc4422ba83ba54d251d6c62a4ed487" dependencies = [ "async-std", - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "log", ] @@ -3515,7 +3550,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6149c46cb76935c80bc8be6ec6e3ebd5f5e1679765a255fb34331d54610f15dd" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -3530,7 +3565,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3b1c6a3431045da8b925ed83384e4c5163e14b990572307fca9c507435d4d22" dependencies = [ "either", - "futures 0.3.13", + "futures 0.3.12", "futures-rustls", "libp2p-core", "log", @@ -3547,7 +3582,7 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4819358c542a86ff95f6ae691efb4b94ddaf477079b01a686f5705b79bfc232a" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "libp2p-core", "parking_lot 0.11.1", "thiserror", @@ -3578,7 +3613,7 @@ dependencies = [ "hmac-drbg", "rand 0.7.3", "sha2 0.8.2", - "subtle 2.3.0", + "subtle 2.4.0", "typenum", ] @@ -3605,7 +3640,7 @@ dependencies = [ "dynasmrt 0.5.2", "iter-enum", "itertools 0.8.2", - "memoffset", + "memoffset 0.5.6", "more-asserts", "thiserror", "wasmparser", @@ -3613,9 +3648,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linked_hash_set" @@ -3665,33 +3700,21 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" dependencies = [ "scopeguard", ] [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "loom" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e8460f2f2121162705187214720353c517b97bdfb3494c0b1e33d83ebe4bed" -dependencies = [ - "cfg-if 0.1.10", - "generator", - "scoped-tls", - "serde", - "serde_json", + "cfg-if 1.0.0", + "value-bag", ] [[package]] @@ -3735,9 +3758,9 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "matrixmultiply" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f7ec66360130972f34830bfad9ef05c6610a43938a467bcc9ab9369ab3478f" +checksum = "916806ba0031cd542105d916a97c8572e1fa6dd79c9c51e7eb43a09ec2dd84c1" dependencies = [ "rawpointer", ] @@ -3766,9 +3789,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.2.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e3e85b970d650e2ae6d70592474087051c11c54da7f7b4949725c5735fbcc6" +checksum = "e73be3b7d04a0123e933fea1d50d126cc7196bbc0362c0ce426694f777194eee" dependencies = [ "libc", ] @@ -3782,6 +3805,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" +dependencies = [ + "autocfg", +] + [[package]] name = "memory-db" version = "0.26.0" @@ -3801,9 +3833,9 @@ checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" [[package]] name = "merlin" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" dependencies = [ "byteorder", "keccak", @@ -3813,18 +3845,18 @@ dependencies = [ [[package]] name = "minicbor" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0164190d1771b1458c3742075b057ed55d25cd9dfb930aade99315a1eb1fe12d" +checksum = "3265a9f5210bb726f81ef9c456ae0aff5321cd95748c0e71889b0e19d8f0332b" dependencies = [ "minicbor-derive", ] [[package]] name = "minicbor-derive" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e071b3159835ee91df62dbdbfdd7ec366b7ea77c838f43aff4acda6b61bcfb9" +checksum = "130b9455e28a3f308f6579671816a6f2621e2e0cbf55dc2f886345bef699481e" dependencies = [ "proc-macro2", "quote", @@ -3880,7 +3912,7 @@ checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" dependencies = [ "log", "mio", - "miow 0.3.5", + "miow 0.3.6", "winapi 0.3.9", ] @@ -3909,9 +3941,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ "socket2", "winapi 0.3.9", @@ -3946,7 +3978,7 @@ dependencies = [ "digest 0.9.0", "generic-array 0.14.4", "multihash-derive", - "sha2 0.9.2", + "sha2 0.9.3", "sha3", "unsigned-varint 0.5.1", ] @@ -3973,16 +4005,16 @@ checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" [[package]] name = "multistream-select" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5df70763c86c98487451f307e1b68b4100da9076f4c12146905fc2054277f4e8" +checksum = "10ddc0eb0117736f19d556355464fc87efc8ad98b29e3fd84f02531eb6e90840" dependencies = [ "bytes 1.0.1", - "futures 0.3.13", + "futures 0.3.12", "log", - "pin-project 1.0.5", - "smallvec 1.5.0", - "unsigned-varint 0.7.0", + "pin-project 1.0.4", + "smallvec 1.6.1", + "unsigned-varint 0.6.0", ] [[package]] @@ -4051,7 +4083,7 @@ version = "0.8.0" dependencies = [ "derive_more", "fs_extra", - "futures 0.3.13", + "futures 0.3.12", "hash-db", "hex", "kvdb", @@ -4087,7 +4119,7 @@ dependencies = [ name = "node-browser-testing" version = "2.0.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "jsonrpc-core", "libp2p", @@ -4109,7 +4141,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-support", "frame-system", - "futures 0.3.13", + "futures 0.3.12", "hex-literal", "log", "nix", @@ -4444,7 +4476,7 @@ dependencies = [ "frame-support", "frame-system", "fs_extra", - "futures 0.3.13", + "futures 0.3.12", "log", "node-executor", "node-primitives", @@ -4577,24 +4609,24 @@ dependencies = [ [[package]] name = "object" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" [[package]] name = "once_cell" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f53cef67919d7d247eb9a2f128ca9e522789967ef1eb4ccd8c71a95a8aedf596" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" dependencies = [ "parking_lot 0.11.1", ] [[package]] name = "oorandom" -version = "11.1.2" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a170cebd8021a008ea92e4db85a72f80b35df514ec664b296fdcbb654eac0b2c" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "opaque-debug" @@ -4815,7 +4847,7 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "parity-wasm 0.41.0", - "paste 1.0.3", + "paste 1.0.4", "pretty_assertions", "pwasm-utils 0.16.0", "rand 0.7.3", @@ -4910,7 +4942,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "parking_lot 0.11.1", - "paste 1.0.3", + "paste 1.0.4", "rand 0.7.3", "serde", "sp-arithmetic", @@ -5141,7 +5173,7 @@ name = "pallet-mmr" version = "3.0.0" dependencies = [ "ckb-merkle-mountain-range", - "env_logger 0.8.3", + "env_logger 0.8.2", "frame-benchmarking", "frame-support", "frame-system", @@ -5534,7 +5566,7 @@ dependencies = [ "parity-scale-codec", "serde", "serde_json", - "smallvec 1.5.0", + "smallvec 1.6.1", "sp-core", "sp-io", "sp-runtime", @@ -5657,9 +5689,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "2.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cd3dab59b5cf4bc81069ade0fc470341a1ef3ad5fa73e5a8943bed2ec12b2e8" +checksum = "75c823fdae1bb5ff5708ee61a62697e6296175dc671710876871c853f48592b3" dependencies = [ "arrayvec 0.5.2", "bitvec", @@ -5670,9 +5702,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "2.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa04976a81fde04924b40cc4036c4d12841e8bb04325a5cf2ada75731a150a7d" +checksum = "9029e65297c7fd6d7013f0579e193ec2b34ae78eabca854c9417504ad8a2d214" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5697,7 +5729,7 @@ dependencies = [ "libc", "log", "mio-named-pipes", - "miow 0.3.5", + "miow 0.3.6", "rand 0.7.3", "tokio 0.1.22", "tokio-named-pipes", @@ -5717,7 +5749,7 @@ dependencies = [ "parity-util-mem-derive", "parking_lot 0.11.1", "primitive-types", - "smallvec 1.5.0", + "smallvec 1.6.1", "winapi 0.3.9", ] @@ -5799,8 +5831,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", - "lock_api 0.4.1", - "parking_lot_core 0.8.0", + "lock_api 0.4.2", + "parking_lot_core 0.8.2", ] [[package]] @@ -5810,11 +5842,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" dependencies = [ "cfg-if 0.1.10", - "cloudabi 0.0.3", + "cloudabi", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "rustc_version", - "smallvec 0.6.13", + "smallvec 0.6.14", "winapi 0.3.9", ] @@ -5825,25 +5857,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ "cfg-if 0.1.10", - "cloudabi 0.0.3", + "cloudabi", "libc", - "redox_syscall", - "smallvec 1.5.0", + "redox_syscall 0.1.57", + "smallvec 1.6.1", "winapi 0.3.9", ] [[package]] name = "parking_lot_core" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" dependencies = [ - "cfg-if 0.1.10", - "cloudabi 0.1.0", + "cfg-if 1.0.0", "instant", "libc", - "redox_syscall", - "smallvec 1.5.0", + "redox_syscall 0.1.57", + "smallvec 1.6.1", "winapi 0.3.9", ] @@ -5859,9 +5890,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7151b083b0664ed58ed669fcdd92f01c3d2fdbf10af4931a301474950b52bfa9" +checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1" [[package]] name = "paste-impl" @@ -5979,11 +6010,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63" +checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" dependencies = [ - "pin-project-internal 1.0.5", + "pin-project-internal 1.0.4", ] [[package]] @@ -5999,9 +6030,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b" +checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" dependencies = [ "proc-macro2", "quote", @@ -6040,16 +6071,32 @@ checksum = "989d43012e2ca1c4a02507c67282691a0a3207f9dc67cec596b43fe925b3d325" [[package]] name = "plotters" -version = "0.2.15" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" dependencies = [ - "js-sys", "num-traits", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + [[package]] name = "polling" version = "2.0.2" @@ -6065,20 +6112,22 @@ dependencies = [ [[package]] name = "poly1305" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ce46de8e53ee414ca4d02bfefac75d8c12fba948b76622a40b4be34dfce980" +checksum = "4b7456bc1ad2d4cf82b3a016be4c2ac48daf11bf990c1603ebd447fe6f30fca8" dependencies = [ + "cpuid-bool 0.2.0", "universal-hash", ] [[package]] name = "polyval" -version = "0.4.1" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5884790f1ce3553ad55fec37b5aaac5882e0e845a2612df744d6c85c9bf046c" +checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" dependencies = [ - "cfg-if 0.1.10", + "cpuid-bool 0.2.0", + "opaque-debug 0.3.0", "universal-hash", ] @@ -6090,9 +6139,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "predicates" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a" +checksum = "eeb433456c1a57cc93554dea3ce40b4c19c4057e41c55d4a0f3d84ea71c325aa" dependencies = [ "difference", "predicates-core", @@ -6100,15 +6149,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" [[package]] name = "predicates-tree" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2" dependencies = [ "predicates-core", "treeline", @@ -6179,9 +6228,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" @@ -6297,7 +6346,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ - "env_logger 0.8.3", + "env_logger 0.8.2", "log", "rand 0.8.3", ] @@ -6315,9 +6364,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2", ] @@ -6357,7 +6406,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.15", + "getrandom 0.1.16", "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", @@ -6373,7 +6422,7 @@ checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", "rand_chacha 0.3.0", - "rand_core 0.6.2", + "rand_core 0.6.1", "rand_hc 0.3.0", ] @@ -6394,7 +6443,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core 0.6.2", + "rand_core 0.6.1", ] [[package]] @@ -6418,14 +6467,14 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.15", + "getrandom 0.1.16", ] [[package]] name = "rand_core" -version = "0.6.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" dependencies = [ "getrandom 0.2.2", ] @@ -6454,7 +6503,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core 0.6.2", + "rand_core 0.6.1", ] [[package]] @@ -6468,9 +6517,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "7.0.3" +version = "7.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" +checksum = "beb71f708fe39b2c5e98076204c3cc094ee5a4c12c4cdb119a2b72dc34164f41" dependencies = [ "bitflags", "cc", @@ -6503,7 +6552,7 @@ checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ "crossbeam-channel", "crossbeam-deque 0.8.0", - "crossbeam-utils 0.8.0", + "crossbeam-utils 0.8.1", "lazy_static", "num_cpus", ] @@ -6523,31 +6572,40 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_syscall" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom 0.1.15", - "redox_syscall", + "getrandom 0.1.16", + "redox_syscall 0.1.57", "rust-argon2", ] [[package]] name = "ref-cast" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17626b2f4bcf35b84bf379072a66e28cfe5c3c6ae58b38e4914bb8891dabece" +checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.3" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c523ccaed8ac4b0288948849a350b37d3035827413c458b6a40ddb614bb4f72" +checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" dependencies = [ "proc-macro2", "quote", @@ -6562,14 +6620,14 @@ checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" dependencies = [ "log", "rustc-hash", - "smallvec 1.5.0", + "smallvec 1.6.1", ] [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -6589,9 +6647,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "region" @@ -6610,8 +6668,8 @@ name = "remote-externalities" version = "0.9.0" dependencies = [ "async-std", - "env_logger 0.8.3", - "futures 0.3.13", + "env_logger 0.8.2", + "futures 0.3.12", "hex-literal", "jsonrpc-core-client", "log", @@ -6640,9 +6698,9 @@ checksum = "53552c6c49e1e13f1a203ef0080ab3bbef0beb570a528993e83df057a9d9bba1" [[package]] name = "ring" -version = "0.16.15" +version = "0.16.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" +checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226" dependencies = [ "cc", "libc", @@ -6665,9 +6723,9 @@ dependencies = [ [[package]] name = "rpassword" -version = "5.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d755237fc0f99d98641540e66abac8bc46a0652f19148ac9e21de2da06b326c9" +checksum = "ffc936cf8a7ea60c58f030fd36a612a48f440610214dc54bc36431f9ea0c3efb" dependencies = [ "libc", "winapi 0.3.9", @@ -6675,14 +6733,14 @@ dependencies = [ [[package]] name = "rust-argon2" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64 0.12.3", + "base64 0.13.0", "blake2b_simd", "constant_time_eq", - "crossbeam-utils 0.7.2", + "crossbeam-utils 0.8.1", ] [[package]] @@ -6762,7 +6820,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "pin-project 0.4.27", "static_assertions", ] @@ -6807,7 +6865,7 @@ dependencies = [ "async-trait", "derive_more", "either", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "libp2p", "log", @@ -6835,7 +6893,7 @@ dependencies = [ name = "sc-basic-authorship" version = "0.9.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -6909,7 +6967,7 @@ version = "0.9.0" dependencies = [ "chrono", "fdlimit", - "futures 0.3.13", + "futures 0.3.12", "hex", "libp2p", "log", @@ -6947,7 +7005,7 @@ version = "3.0.0" dependencies = [ "derive_more", "fnv", - "futures 0.3.13", + "futures 0.3.12", "hash-db", "kvdb", "kvdb-memorydb", @@ -7027,7 +7085,7 @@ name = "sc-consensus-aura" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "getrandom 0.2.2", "log", @@ -7069,7 +7127,7 @@ version = "0.9.0" dependencies = [ "derive_more", "fork-tree", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "log", "merlin", @@ -7123,7 +7181,7 @@ name = "sc-consensus-babe-rpc" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.13", + "futures 0.3.12", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7165,7 +7223,7 @@ version = "0.9.0" dependencies = [ "assert_matches", "derive_more", - "futures 0.3.13", + "futures 0.3.12", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7202,7 +7260,7 @@ name = "sc-consensus-pow" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -7224,7 +7282,7 @@ dependencies = [ name = "sc-consensus-slots" version = "0.9.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -7272,7 +7330,7 @@ dependencies = [ "parity-scale-codec", "parity-wasm 0.41.0", "parking_lot 0.11.1", - "paste 1.0.3", + "paste 1.0.4", "sc-executor-common", "sc-executor-wasmi", "sc-executor-wasmtime", @@ -7363,13 +7421,13 @@ dependencies = [ "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "linked-hash-map", "log", "parity-scale-codec", "parking_lot 0.11.1", - "pin-project 1.0.5", + "pin-project 1.0.4", "rand 0.7.3", "sc-block-builder", "sc-client-api", @@ -7407,7 +7465,7 @@ version = "0.9.0" dependencies = [ "derive_more", "finality-grandpa", - "futures 0.3.13", + "futures 0.3.12", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7437,7 +7495,7 @@ version = "0.9.0" dependencies = [ "derive_more", "finality-grandpa", - "futures 0.3.13", + "futures 0.3.12", "log", "num-traits", "parity-scale-codec", @@ -7462,7 +7520,7 @@ name = "sc-informant" version = "0.9.0" dependencies = [ "ansi_term 0.12.1", - "futures 0.3.13", + "futures 0.3.12", "log", "parity-util-mem", "sc-client-api", @@ -7480,7 +7538,7 @@ version = "3.0.0" dependencies = [ "async-trait", "derive_more", - "futures 0.3.13", + "futures 0.3.12", "futures-util", "hex", "merlin", @@ -7490,7 +7548,7 @@ dependencies = [ "sp-application-crypto", "sp-core", "sp-keystore", - "subtle 2.3.0", + "subtle 2.4.0", "tempfile", ] @@ -7529,7 +7587,7 @@ dependencies = [ "erased-serde", "fnv", "fork-tree", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "hex", "ip_network", @@ -7541,7 +7599,7 @@ dependencies = [ "nohash-hasher", "parity-scale-codec", "parking_lot 0.11.1", - "pin-project 1.0.5", + "pin-project 1.0.4", "prost", "prost-build", "quickcheck", @@ -7551,7 +7609,7 @@ dependencies = [ "sc-peerset", "serde", "serde_json", - "smallvec 1.5.0", + "smallvec 1.6.1", "sp-arithmetic", "sp-blockchain", "sp-consensus", @@ -7577,7 +7635,7 @@ name = "sc-network-gossip" version = "0.9.0" dependencies = [ "async-std", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "libp2p", "log", @@ -7596,7 +7654,7 @@ name = "sc-network-test" version = "0.8.0" dependencies = [ "async-std", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "libp2p", "log", @@ -7624,7 +7682,7 @@ version = "3.0.0" dependencies = [ "bytes 0.5.6", "fnv", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "hyper 0.13.9", "hyper-rustls", @@ -7657,7 +7715,7 @@ dependencies = [ name = "sc-peerset" version = "3.0.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "libp2p", "log", "rand 0.7.3", @@ -7680,7 +7738,7 @@ version = "3.0.0" dependencies = [ "assert_matches", "futures 0.1.30", - "futures 0.3.13", + "futures 0.3.12", "hash-db", "jsonrpc-core", "jsonrpc-pubsub", @@ -7721,7 +7779,7 @@ name = "sc-rpc-api" version = "0.9.0" dependencies = [ "derive_more", - "futures 0.3.13", + "futures 0.3.12", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7778,7 +7836,7 @@ dependencies = [ "directories 3.0.1", "exit-future", "futures 0.1.30", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "hash-db", "jsonrpc-core", @@ -7788,7 +7846,7 @@ dependencies = [ "parity-scale-codec", "parity-util-mem", "parking_lot 0.11.1", - "pin-project 1.0.5", + "pin-project 1.0.4", "rand 0.7.3", "sc-block-builder", "sc-chain-spec", @@ -7847,7 +7905,7 @@ version = "2.0.0" dependencies = [ "fdlimit", "futures 0.1.30", - "futures 0.3.13", + "futures 0.3.12", "hex-literal", "log", "parity-scale-codec", @@ -7915,11 +7973,11 @@ name = "sc-telemetry" version = "3.0.0" dependencies = [ "chrono", - "futures 0.3.13", + "futures 0.3.12", "libp2p", "log", "parking_lot 0.11.1", - "pin-project 1.0.5", + "pin-project 1.0.4", "rand 0.7.3", "serde", "serde_json", @@ -7975,7 +8033,7 @@ dependencies = [ "assert_matches", "criterion", "derive_more", - "futures 0.3.13", + "futures 0.3.12", "linked-hash-map", "log", "parity-scale-codec", @@ -7998,7 +8056,7 @@ name = "sc-transaction-pool" version = "3.0.0" dependencies = [ "assert_matches", - "futures 0.3.13", + "futures 0.3.12", "futures-diagnose", "hex", "intervalier", @@ -8043,14 +8101,14 @@ checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" dependencies = [ "arrayref", "arrayvec 0.5.2", - "curve25519-dalek 2.1.0", - "getrandom 0.1.15", + "curve25519-dalek 2.1.2", + "getrandom 0.1.16", "merlin", "rand 0.7.3", "rand_core 0.5.1", "serde", "sha2 0.8.2", - "subtle 2.3.0", + "subtle 2.4.0", "zeroize", ] @@ -8077,9 +8135,9 @@ dependencies = [ [[package]] name = "scroll_derive" -version = "0.10.4" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b12bd20b94c7cdfda8c7ba9b92ad0d9a56e3fa018c25fca83b51aa664c9b4c0d" +checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0" dependencies = [ "proc-macro2", "quote", @@ -8152,7 +8210,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.0", + "semver-parser 0.10.2", "serde", ] @@ -8164,12 +8222,11 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "semver-parser" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e012c6c5380fb91897ba7b9261a0f565e624e869d42fe1a1d03fa0d68a083d5" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" dependencies = [ "pest", - "pest_derive", ] [[package]] @@ -8186,9 +8243,9 @@ checksum = "930c0acf610d3fdb5e2ab6213019aaa04e227ebe9547b0649ba599b16d788bd7" [[package]] name = "serde" -version = "1.0.117" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" dependencies = [ "serde_derive", ] @@ -8214,9 +8271,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" dependencies = [ "proc-macro2", "quote", @@ -8225,9 +8282,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "itoa", "ryu", @@ -8254,7 +8311,7 @@ checksum = "ce3cdf1b5e620a498ee6f2a171885ac7e22f0e12089ec4b3d22b84921792507c" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpuid-bool", + "cpuid-bool 0.1.2", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -8273,13 +8330,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpuid-bool", + "cpuid-bool 0.1.2", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -8298,12 +8355,11 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127" +checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3" dependencies = [ "lazy_static", - "loom", ] [[package]] @@ -8312,20 +8368,30 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +[[package]] +name = "signal-hook" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ "libc", ] [[package]] name = "signature" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" +checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" [[package]] name = "simba" @@ -8347,18 +8413,18 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" dependencies = [ "maybe-uninit", ] [[package]] name = "smallvec" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "snow" @@ -8373,8 +8439,8 @@ dependencies = [ "rand_core 0.5.1", "ring", "rustc_version", - "sha2 0.9.2", - "subtle 2.3.0", + "sha2 0.9.3", + "subtle 2.4.0", "x25519-dalek", ] @@ -8398,7 +8464,7 @@ dependencies = [ "base64 0.12.3", "bytes 0.5.6", "flate2", - "futures 0.3.13", + "futures 0.3.12", "httparse", "log", "rand 0.7.3", @@ -8548,7 +8614,7 @@ dependencies = [ name = "sp-blockchain" version = "3.0.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "log", "lru", "parity-scale-codec", @@ -8573,7 +8639,7 @@ dependencies = [ name = "sp-consensus" version = "0.9.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "libp2p", "log", @@ -8669,7 +8735,7 @@ dependencies = [ "criterion", "dyn-clonable", "ed25519-dalek", - "futures 0.3.13", + "futures 0.3.12", "hash-db", "hash256-std-hasher", "hex", @@ -8692,7 +8758,7 @@ dependencies = [ "secrecy", "serde", "serde_json", - "sha2 0.9.2", + "sha2 0.9.3", "sp-debug-derive", "sp-externalities", "sp-runtime-interface", @@ -8777,7 +8843,7 @@ dependencies = [ name = "sp-io" version = "3.0.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "hash-db", "libsecp256k1", "log", @@ -8812,7 +8878,7 @@ version = "0.9.0" dependencies = [ "async-trait", "derive_more", - "futures 0.3.13", + "futures 0.3.12", "merlin", "parity-scale-codec", "parking_lot 0.11.1", @@ -8897,7 +8963,7 @@ dependencies = [ "log", "parity-scale-codec", "parity-util-mem", - "paste 1.0.3", + "paste 1.0.4", "rand 0.7.3", "serde", "serde_json", @@ -9035,7 +9101,7 @@ dependencies = [ "parking_lot 0.11.1", "pretty_assertions", "rand 0.7.3", - "smallvec 1.5.0", + "smallvec 1.6.1", "sp-core", "sp-externalities", "sp-panic-handler", @@ -9118,7 +9184,7 @@ name = "sp-transaction-pool" version = "3.0.0" dependencies = [ "derive_more", - "futures 0.3.13", + "futures 0.3.12", "log", "parity-scale-codec", "serde", @@ -9150,7 +9216,7 @@ dependencies = [ name = "sp-utils" version = "3.0.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "futures-core", "futures-timer 3.0.2", "lazy_static", @@ -9232,15 +9298,15 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "strsim" -version = "0.9.3" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "structopt" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126d630294ec449fae0b16f964e35bf3c74f940da9dca17ee9b905f7b3112eb8" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" dependencies = [ "clap", "lazy_static", @@ -9249,9 +9315,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e51c492f9e23a220534971ff5afc14037289de430e3c83f9daf6a1b6ae91e8" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" dependencies = [ "heck", "proc-macro-error", @@ -9309,7 +9375,7 @@ dependencies = [ "chrono", "console_error_panic_hook", "futures 0.1.30", - "futures 0.3.13", + "futures 0.3.12", "futures-timer 3.0.2", "getrandom 0.2.2", "js-sys", @@ -9352,7 +9418,7 @@ version = "3.0.0" dependencies = [ "frame-support", "frame-system", - "futures 0.3.13", + "futures 0.3.12", "jsonrpc-client-transports", "jsonrpc-core", "parity-scale-codec", @@ -9367,7 +9433,7 @@ name = "substrate-frame-rpc-system" version = "3.0.0" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.13", + "futures 0.3.12", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -9405,7 +9471,7 @@ name = "substrate-test-client" version = "2.0.1" dependencies = [ "futures 0.1.30", - "futures 0.3.13", + "futures 0.3.12", "hash-db", "hex", "parity-scale-codec", @@ -9474,7 +9540,7 @@ dependencies = [ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "parity-scale-codec", "sc-block-builder", "sc-client-api", @@ -9495,7 +9561,7 @@ name = "substrate-test-runtime-transaction-pool" version = "2.0.0" dependencies = [ "derive_more", - "futures 0.3.13", + "futures 0.3.12", "parity-scale-codec", "parking_lot 0.11.1", "sc-transaction-graph", @@ -9509,7 +9575,7 @@ dependencies = [ name = "substrate-test-utils" version = "3.0.0" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "sc-service", "substrate-test-utils-derive", "tokio 0.2.25", @@ -9556,9 +9622,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" @@ -9591,9 +9657,9 @@ checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" [[package]] name = "tap" -version = "1.0.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e" [[package]] name = "target-lexicon" @@ -9603,23 +9669,23 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "rand 0.7.3", - "redox_syscall", + "rand 0.8.3", + "redox_syscall 0.2.4", "remove_dir_all", "winapi 0.3.9", ] [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] @@ -9635,18 +9701,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2", "quote", @@ -9655,11 +9721,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -9694,7 +9760,7 @@ dependencies = [ "pbkdf2 0.4.0", "rand 0.7.3", "rustc-hash", - "sha2 0.9.2", + "sha2 0.9.3", "thiserror", "unicode-normalization", "zeroize", @@ -9711,9 +9777,9 @@ dependencies = [ [[package]] name = "tinytemplate" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3dc76004a03cec1c5932bca4cdc2e39aaa798e3f82363dd94f9adf6098c12f" +checksum = "a2ada8616fad06a2d0c455adc530de4ef57605a8120cc65da9653e0e9623ca74" dependencies = [ "serde", "serde_json", @@ -9721,9 +9787,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b78a366903f506d2ad52ca8dc552102ffdd3e937ba8a227f024dc1d1eae28575" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" dependencies = [ "tinyvec_macros", ] @@ -10011,18 +10077,18 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" @@ -10102,7 +10168,7 @@ dependencies = [ "serde", "serde_json", "sharded-slab", - "smallvec 1.5.0", + "smallvec 1.6.1", "thread_local", "tracing", "tracing-core", @@ -10142,7 +10208,7 @@ dependencies = [ "hashbrown", "log", "rustc-hex", - "smallvec 1.5.0", + "smallvec 1.6.1", ] [[package]] @@ -10193,9 +10259,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.41" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99471a206425fba51842a9186315f32d91c56eadc21ea4c21f847b59cf778f8b" +checksum = "1c9594b802f041389d2baac680663573dde3103bb4a4926d61d6aba689465978" dependencies = [ "dissimilar", "glob", @@ -10261,18 +10327,18 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f98e67a4d84f730d343392f9bfff7d21e3fca562b9cb7a43b768350beeddc6" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" @@ -10293,7 +10359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array 0.14.4", - "subtle 2.3.0", + "subtle 2.4.0", ] [[package]] @@ -10355,11 +10421,20 @@ dependencies = [ "percent-encoding 2.1.0", ] +[[package]] +name = "value-bag" +version = "1.0.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b676010e055c99033117c2343b33a40a30b91fecd6c49055ac9cd2d6c305ab1" +dependencies = [ + "ctor", +] + [[package]] name = "vcpkg" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" [[package]] name = "vec-arena" @@ -10473,11 +10548,11 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" +checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -10514,9 +10589,9 @@ checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "wasm-bindgen-test" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d1cdc8b98a557f24733d50a1199c4b0635e465eecba9c45b214544da197f64" +checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25" dependencies = [ "console_error_panic_hook", "js-sys", @@ -10528,9 +10603,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fb9c67be7439ee8ab1b7db502a49c05e51e2835b66796c705134d9b8e1a585" +checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b" dependencies = [ "proc-macro2", "quote", @@ -10553,7 +10628,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "js-sys", "parking_lot 0.11.1", "pin-utils", @@ -10592,7 +10667,7 @@ dependencies = [ "raw-cpuid", "serde", "serde_bytes", - "smallvec 1.5.0", + "smallvec 1.6.1", "target-lexicon", "thiserror", "wasmer-types", @@ -10623,13 +10698,13 @@ version = "1.0.0-alpha4" source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" dependencies = [ "byteorder", - "dynasm 1.0.0", - "dynasmrt 1.0.0", + "dynasm 1.0.1", + "dynasmrt 1.0.1", "lazy_static", "more-asserts", "rayon", "serde", - "smallvec 1.5.0", + "smallvec 1.6.1", "wasmer-compiler", "wasmer-types", "wasmer-vm", @@ -10679,7 +10754,7 @@ dependencies = [ "bincode", "cfg-if 0.1.10", "leb128", - "libloading 0.6.5", + "libloading 0.6.7", "serde", "tempfile", "tracing", @@ -10721,7 +10796,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset", + "memoffset 0.5.6", "more-asserts", "region", "serde", @@ -10884,7 +10959,7 @@ dependencies = [ "lazy_static", "libc", "log", - "memoffset", + "memoffset 0.5.6", "more-asserts", "region", "thiserror", @@ -10894,27 +10969,27 @@ dependencies = [ [[package]] name = "wast" -version = "27.0.0" +version = "32.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2c3ef5f6a72dffa44c24d5811123f704e18a1dbc83637d347b1852b41d3835c" +checksum = "c24a3ee360d01d60ed0a0f960ab76a6acce64348cdb0bf8699c2a866fad57c7c" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835cf59c907f67e2bbc20f50157e08f35006fe2a8444d8ec9f5683e22f937045" +checksum = "5e8f7f34773fa6318e8897283abf7941c1f250faae4e1a52f82df09c3bad7cce" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.47" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" +checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" dependencies = [ "js-sys", "wasm-bindgen", @@ -10922,9 +10997,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ "ring", "untrusted", @@ -11032,7 +11107,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc614d95359fd7afc321b66d2107ede58b246b844cf5d8a0adcca413e439f088" dependencies = [ - "curve25519-dalek 3.0.0", + "curve25519-dalek 3.0.2", "rand_core 0.5.1", "zeroize", ] @@ -11043,7 +11118,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cc7bd8c983209ed5d527f44b01c41b7dc146fd960c61cf9e1d25399841dc271" dependencies = [ - "futures 0.3.13", + "futures 0.3.12", "log", "nohash-hasher", "parking_lot 0.11.1", @@ -11074,18 +11149,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.5.3+zstd.1.4.5" +version = "0.5.4+zstd.1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01b32eaf771efa709e8308605bbf9319bf485dc1503179ec0469b611937c0cd8" +checksum = "69996ebdb1ba8b1517f61387a883857818a66c8a295f487b1ffd8fd9d2c82910" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "2.0.5+zstd.1.4.5" +version = "2.0.6+zstd.1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfb642e0d27f64729a639c52db457e0ae906e7bc6f5fe8f5c453230400f1055" +checksum = "98aa931fb69ecee256d44589d19754e61851ae4769bf963b385119b1cc37a49e" dependencies = [ "libc", "zstd-sys", @@ -11093,9 +11168,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.4.17+zstd.1.4.5" +version = "1.4.18+zstd.1.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89249644df056b522696b1bb9e7c18c87e8ffa3e2f0dc3b0155875d6498f01b" +checksum = "a1e6e8778706838f43f771d80d37787cb2fe06dafe89dd3aebaf6721b9eaec81" dependencies = [ "cc", "glob", From be76948ddc15896d9882bdd339d427a0ecfa018c Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 8 Mar 2021 13:52:01 +0700 Subject: [PATCH 41/88] Fixes compilation --- client/executor/wasmtime/src/imports.rs | 18 ++++++++++++------ .../executor/wasmtime/src/instance_wrapper.rs | 8 ++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/client/executor/wasmtime/src/imports.rs b/client/executor/wasmtime/src/imports.rs index 08cedd434e366..49400a51cdead 100644 --- a/client/executor/wasmtime/src/imports.rs +++ b/client/executor/wasmtime/src/imports.rs @@ -78,10 +78,10 @@ pub fn resolve_imports( /// Because we are not using this proposal we could safely unwrap the name. /// However, we opt for an error in order to avoid panics at all costs. fn import_name<'a, 'b: 'a>(import: &'a ImportType<'b>) -> Result<&'a str, WasmError> { - let name = import.name().ok_or_else(|| - WasmError::Other("The module linking proposal is not supported.".to_owned()) - )?; - Ok(name) + // let name = import.name().ok_or_else(|| + // WasmError::Other("The module linking proposal is not supported.".to_owned()) + // )?; + Ok(import.name()) } fn resolve_memory_import( @@ -277,12 +277,18 @@ fn wasmtime_func_sig(func: &dyn Function) -> wasmtime::FuncType { .args .iter() .cloned() - .map(into_wasmtime_val_type); + .map(into_wasmtime_val_type) + .collect::>() + .into_boxed_slice(); + let results = signature .return_value .iter() .cloned() - .map(into_wasmtime_val_type); + .map(into_wasmtime_val_type) + .collect::>() + .into_boxed_slice(); + wasmtime::FuncType::new(params, results) } diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index ff04ec42d76a7..dd437e83aa24b 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -126,8 +126,8 @@ impl EntryPoint { pub fn direct(func: wasmtime::Func) -> std::result::Result { use wasmtime::ValType; let entry_point = wasmtime::FuncType::new( - [ValType::I32, ValType::I32].iter().cloned(), - [ValType::I64].iter().cloned(), + Box::new([ValType::I32, ValType::I32]), + Box::new([ValType::I64]), ); if func.ty() == entry_point { Ok(Self { func, call_type: EntryPointType::Direct }) @@ -139,8 +139,8 @@ impl EntryPoint { pub fn wrapped(dispatcher: wasmtime::Func, func: u32) -> std::result::Result { use wasmtime::ValType; let entry_point = wasmtime::FuncType::new( - [ValType::I32, ValType::I32, ValType::I32].iter().cloned(), - [ValType::I64].iter().cloned(), + Box::new([ValType::I32, ValType::I32, ValType::I32]), + Box::new([ValType::I64]), ); if dispatcher.ty() == entry_point { Ok(Self { func: dispatcher, call_type: EntryPointType::Wrapped(func) }) From 1ae9d46a4a860ebf3b2f56468fe9f692ddb14ec4 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 9 Apr 2021 17:02:12 +0700 Subject: [PATCH 42/88] Refactors sandbox to use TLS for dispatch_thunk propagation to wasmer --- Cargo.lock | 246 ++++++++++++++++---------- client/executor/common/Cargo.toml | 6 +- client/executor/common/src/sandbox.rs | 43 +++-- client/executor/wasmi/src/lib.rs | 21 ++- client/executor/wasmtime/src/host.rs | 21 ++- 5 files changed, 223 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9fc536b23b7ab..3334030919e37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -950,16 +950,16 @@ name = "cranelift-bforest" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" dependencies = [ - "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-entity 0.65.0", ] [[package]] name = "cranelift-bforest" -version = "0.65.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" +checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0" dependencies = [ - "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.68.0", ] [[package]] @@ -968,36 +968,35 @@ version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" dependencies = [ "byteorder", - "cranelift-bforest 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-codegen-meta 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-codegen-shared 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-bforest 0.65.0", + "cranelift-codegen-meta 0.65.0", + "cranelift-codegen-shared 0.65.0", + "cranelift-entity 0.65.0", "gimli 0.21.0", "log", - "regalloc", + "regalloc 0.0.26", "serde", "smallvec 1.6.1", - "target-lexicon", + "target-lexicon 0.10.0", "thiserror", ] [[package]] name = "cranelift-codegen" -version = "0.65.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" +checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1" dependencies = [ "byteorder", - "cranelift-bforest 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen-meta 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen-shared 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gimli 0.21.0", + "cranelift-bforest 0.68.0", + "cranelift-codegen-meta 0.68.0", + "cranelift-codegen-shared 0.68.0", + "cranelift-entity 0.68.0", + "gimli 0.22.0", "log", - "regalloc", - "serde", + "regalloc 0.0.31", "smallvec 1.6.1", - "target-lexicon", + "target-lexicon 0.11.2", "thiserror", ] @@ -1006,18 +1005,18 @@ name = "cranelift-codegen-meta" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" dependencies = [ - "cranelift-codegen-shared 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen-shared 0.65.0", + "cranelift-entity 0.65.0", ] [[package]] name = "cranelift-codegen-meta" -version = "0.65.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" +checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7" dependencies = [ - "cranelift-codegen-shared 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen-shared 0.68.0", + "cranelift-entity 0.68.0", ] [[package]] @@ -1027,9 +1026,9 @@ source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71 [[package]] name = "cranelift-codegen-shared" -version = "0.65.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" +checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] name = "cranelift-entity" @@ -1041,9 +1040,9 @@ dependencies = [ [[package]] name = "cranelift-entity" -version = "0.65.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" +checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6" dependencies = [ "serde", ] @@ -1053,22 +1052,22 @@ name = "cranelift-frontend" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" dependencies = [ - "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen 0.65.0", "log", "smallvec 1.6.1", - "target-lexicon", + "target-lexicon 0.10.0", ] [[package]] name = "cranelift-frontend" -version = "0.65.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" +checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8" dependencies = [ - "cranelift-codegen 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.68.0", "log", "smallvec 1.6.1", - "target-lexicon", + "target-lexicon 0.11.2", ] [[package]] @@ -1076,9 +1075,9 @@ name = "cranelift-native" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" dependencies = [ - "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen 0.65.0", "raw-cpuid", - "target-lexicon", + "target-lexicon 0.10.0", ] [[package]] @@ -1086,13 +1085,13 @@ name = "cranelift-wasm" version = "0.65.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" dependencies = [ - "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-frontend 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen 0.65.0", + "cranelift-entity 0.65.0", + "cranelift-frontend 0.65.0", "log", "serde", "thiserror", - "wasmparser", + "wasmparser 0.57.0", ] [[package]] @@ -2356,6 +2355,17 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gimli" version = "0.23.0" @@ -3695,7 +3705,7 @@ version = "0.18.0" source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" dependencies = [ "capstone", - "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen 0.65.0", "derive_more", "dynasm 0.5.2", "dynasmrt 0.5.2", @@ -3704,7 +3714,7 @@ dependencies = [ "memoffset 0.5.6", "more-asserts", "thiserror", - "wasmparser", + "wasmparser 0.57.0", ] [[package]] @@ -4671,6 +4681,16 @@ dependencies = [ "indexmap", ] +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +dependencies = [ + "crc32fast", + "indexmap", +] + [[package]] name = "object" version = "0.23.0" @@ -6731,6 +6751,17 @@ dependencies = [ "smallvec 1.6.1", ] +[[package]] +name = "regalloc" +version = "0.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" +dependencies = [ + "log", + "rustc-hash", + "smallvec 1.6.1", +] + [[package]] name = "regex" version = "1.4.3" @@ -7501,7 +7532,7 @@ name = "sc-executor-wasmtime" version = "0.9.0" dependencies = [ "assert_matches", - "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen 0.65.0", "cranelift-wasm", "log", "parity-scale-codec", @@ -9776,6 +9807,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +[[package]] +name = "target-lexicon" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "422045212ea98508ae3d28025bc5aaa2bd4a9cdaecd442a08da2ee620ee9ea95" + [[package]] name = "tempfile" version = "3.2.0" @@ -10748,16 +10785,18 @@ dependencies = [ [[package]] name = "wasmer" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70cfae554988d904d64ca17ab0e7cd652ee5c8a0807094819c1ea93eb9d6866" dependencies = [ "cfg-if 0.1.10", "indexmap", "more-asserts", - "target-lexicon", + "target-lexicon 0.11.2", "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", + "wasmer-derive", "wasmer-engine", "wasmer-engine-jit", "wasmer-engine-native", @@ -10769,32 +10808,34 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b7732a9cab472bd921d5a0c422f45b3d03f62fa2c40a89e0770cef6d47e383e" dependencies = [ "enumset", - "raw-cpuid", "serde", "serde_bytes", "smallvec 1.6.1", - "target-lexicon", + "target-lexicon 0.11.2", "thiserror", "wasmer-types", "wasmer-vm", - "wasmparser", + "wasmparser 0.65.0", ] [[package]] name = "wasmer-compiler-cranelift" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48cb9395f094e1d81534f4c5e330ed4cdb424e8df870d29ad585620284f5fddb" dependencies = [ - "cranelift-codegen 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-frontend 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gimli 0.21.0", + "cranelift-codegen 0.68.0", + "cranelift-frontend 0.68.0", + "gimli 0.22.0", "more-asserts", "rayon", "serde", + "smallvec 1.6.1", "tracing", "wasmer-compiler", "wasmer-types", @@ -10803,8 +10844,9 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", "dynasm 1.0.1", @@ -10819,19 +10861,33 @@ dependencies = [ "wasmer-vm", ] +[[package]] +name = "wasmer-derive" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasmer-engine" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efe4667d6bd888f26ae8062a63a9379fa697415b4b4e380f33832e8418fd71b5" dependencies = [ "backtrace", "bincode", "lazy_static", + "memmap2", "more-asserts", "rustc-demangle", "serde", "serde_bytes", - "target-lexicon", + "target-lexicon 0.11.2", "thiserror", "wasmer-compiler", "wasmer-types", @@ -10840,8 +10896,9 @@ dependencies = [ [[package]] name = "wasmer-engine-jit" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26770be802888011b4a3072f2a282fc2faa68aa48c71b3db6252a3937a85f3da" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -10857,8 +10914,9 @@ dependencies = [ [[package]] name = "wasmer-engine-native" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bb4083a6c69f2cd4b000b82a80717f37c6cc2e536aee3a8ffe9af3edc276a8b" dependencies = [ "bincode", "cfg-if 0.1.10", @@ -10877,10 +10935,11 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf8e0c12b82ff81ebecd30d7e118be5fec871d6de885a90eeb105df0a769a7b" dependencies = [ - "object 0.19.0", + "object 0.22.0", "thiserror", "wasmer-compiler", "wasmer-types", @@ -10888,24 +10947,27 @@ dependencies = [ [[package]] name = "wasmer-types" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f4ac28c2951cd792c18332f03da523ed06b170f5cf6bb5b1bdd7e36c2a8218" dependencies = [ - "cranelift-entity 0.65.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.68.0", "serde", + "thiserror", ] [[package]] name = "wasmer-vm" -version = "1.0.0-alpha4" -source = "git+https://github.com/0x7CFE/wasmer?branch=frame-info-patch#97bfb86f8f95b447bb795d6f0e2ad5cca2f1b3f5" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7635ba0b6d2fd325f588d69a950ad9fa04dddbf6ad08b6b2a183146319bf6ae" dependencies = [ "backtrace", "cc", "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.5.6", + "memoffset 0.6.1", "more-asserts", "region", "serde", @@ -10944,6 +11006,12 @@ version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +[[package]] +name = "wasmparser" +version = "0.65.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" + [[package]] name = "wasmtime" version = "0.18.0" @@ -10958,8 +11026,8 @@ dependencies = [ "log", "region", "rustc-demangle", - "target-lexicon", - "wasmparser", + "target-lexicon 0.10.0", + "wasmparser 0.57.0", "wasmtime-environ", "wasmtime-jit", "wasmtime-profiling", @@ -10977,9 +11045,9 @@ dependencies = [ "gimli 0.21.0", "more-asserts", "object 0.19.0", - "target-lexicon", + "target-lexicon 0.10.0", "thiserror", - "wasmparser", + "wasmparser 0.57.0", "wasmtime-environ", ] @@ -10991,8 +11059,8 @@ dependencies = [ "anyhow", "base64 0.12.3", "bincode", - "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen 0.65.0", + "cranelift-entity 0.65.0", "cranelift-wasm", "directories 2.0.2", "errno", @@ -11007,7 +11075,7 @@ dependencies = [ "sha2 0.8.2", "thiserror", "toml", - "wasmparser", + "wasmparser 0.57.0", "winapi 0.3.9", "zstd", ] @@ -11019,18 +11087,18 @@ source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71 dependencies = [ "anyhow", "cfg-if 0.1.10", - "cranelift-codegen 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-entity 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", - "cranelift-frontend 0.65.0 (git+https://github.com/Vurich/wasmtime.git?branch=master)", + "cranelift-codegen 0.65.0", + "cranelift-entity 0.65.0", + "cranelift-frontend 0.65.0", "cranelift-native", "cranelift-wasm", "gimli 0.21.0", "log", "more-asserts", "region", - "target-lexicon", + "target-lexicon 0.10.0", "thiserror", - "wasmparser", + "wasmparser 0.57.0", "wasmtime-debug", "wasmtime-environ", "wasmtime-profiling", @@ -11051,7 +11119,7 @@ dependencies = [ "object 0.19.0", "scroll", "serde", - "target-lexicon", + "target-lexicon 0.10.0", "wasmtime-environ", "wasmtime-runtime", ] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index bc5c15c45c907..0d4ecc5fa5248 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -24,8 +24,10 @@ sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interf sp-serializer = { version = "3.0.0", path = "../../../primitives/serializer" } wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -wasmer = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } -wasmer-compiler-singlepass = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } +wasmer = "1.0" +wasmer-compiler-singlepass = "1.0" +# wasmer = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } +# wasmer-compiler-singlepass = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } #wasmer-engine-jit = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } #wasmer = "1.0.0-alpha3" diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 61bcbba796515..ebab7cc4f3d4d 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -22,7 +22,7 @@ //! a compiled execution engine. use crate::error::{Result, Error}; -use std::{cell::RefCell, collections::HashMap, convert::TryInto, rc::Rc, todo}; +use std::{cell::RefCell, collections::HashMap, convert::TryInto, rc::Rc, sync::{Arc, Mutex}, todo}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; @@ -649,6 +649,15 @@ pub trait SandboxCapabiliesHolder { fn with_sandbox_capabilities R>(f: F) -> R; } +/// Helper type to provide dispatch thunk to the inner context +pub trait DispatchThunkHolder { + /// Dispatch thunk for this particular context + type DispatchThunk; + + /// Wrapper that provides dispatch thunk in a limited context + fn with_dispatch_thunk R>(f: F) -> R; +} + /// Sandbox backend to use pub enum SandboxBackend { /// Wasm interpreter @@ -685,7 +694,7 @@ impl Memory { } struct WasmerBackend { - compiler: Singlepass, + // compiler: Singlepass, store: wasmer::Store, } @@ -706,8 +715,8 @@ impl BackendContext { BackendContext::Wasmer( WasmerBackend { - store: wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()), - compiler, + store: wasmer::Store::new(&wasmer::JIT::new(compiler).engine()), + // compiler, } ) } @@ -867,7 +876,7 @@ impl Store { /// normally created by `sp_sandbox::Instance` primitive. /// /// Returns uninitialized sandboxed module instance or an instantiation error. - pub fn instantiate<'a, FE, SCH>( + pub fn instantiate<'a, FE, SCH, DTH>( &mut self, dispatch_thunk: FR, wasm: &[u8], @@ -878,6 +887,7 @@ impl Store { FR: Clone + 'static, FE: SandboxCapabilities + 'a, SCH: SandboxCapabiliesHolder, + DTH: DispatchThunkHolder, { let memories = &mut self.memories; let backend_context = &self.backend_context; @@ -1090,8 +1100,9 @@ impl Store { let supervisor_func_index = guest_env.guest_to_supervisor_mapping .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - let dispatch_thunk = dispatch_thunk.clone(); - let function = wasmer::Function::new(&context.store, func_ty, move |params| { + let dispatch_thunk = Mutex::new(dispatch_thunk.clone()); + let function = wasmer::Function::new(&context.store, func_ty, move |params: &[wasmer::Val]| { + SCH::with_sandbox_capabilities(|supervisor_externals| { // Serialize arguments into a byte vector. let invoke_args_data = params @@ -1127,14 +1138,15 @@ impl Store { return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); } - let serialized_result = supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) - .map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; + let serialized_result = DTH::with_dispatch_thunk(|dispatch_thunk| { + supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + }).map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; // dispatch_thunk returns pointer to serialized arguments. // Unpack pointer and len of the serialized result data. @@ -1192,6 +1204,7 @@ impl Store { match error { wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, + wasmer::InstantiationError::HostEnvInitialization(_) => InstantiationError::EnvironmentDefinitionCorrupted, } })?; diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index df69ddb8a5754..f4e544301d026 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -247,7 +247,7 @@ impl Sandbox for FunctionExecutor { .instance(instance_id).map_err(|e| e.to_string())?; let result = EXECUTOR.set(self, || { - instance.invoke::<_, Holder>(export_name, &args, state) + instance.invoke::<_, CapsHolder>(export_name, &args, state) }); match result { @@ -301,7 +301,7 @@ impl Sandbox for FunctionExecutor { println!("Instantiating sandbox from wasmi"); let store = &mut *self.inner.sandbox_store.borrow_mut(); - let result = EXECUTOR.set(self, || store.instantiate::<_, Holder>( + let result = EXECUTOR.set(self, || store.instantiate::<_, CapsHolder, ThunkHolder>( dispatch_thunk, wasm, guest_env, @@ -336,11 +336,11 @@ impl Sandbox for FunctionExecutor { } } -struct Holder; +struct CapsHolder; scoped_tls::scoped_thread_local!(static EXECUTOR: FunctionExecutor); -impl sandbox::SandboxCapabiliesHolder for Holder { +impl sandbox::SandboxCapabiliesHolder for CapsHolder { type SupervisorFuncRef = wasmi::FuncRef; type SC = FunctionExecutor; @@ -350,6 +350,19 @@ impl sandbox::SandboxCapabiliesHolder for Holder { } } +struct ThunkHolder; + +scoped_tls::scoped_thread_local!(static DISPATCH_THUNK: wasmi::FuncRef); + +impl sandbox::DispatchThunkHolder for ThunkHolder { + type DispatchThunk = wasmi::FuncRef; + + fn with_dispatch_thunk R>(f: F) -> R { + assert!(DISPATCH_THUNK.is_set(), "dispatch thunk is not set"); + DISPATCH_THUNK.with(|thunk| f(&mut thunk.clone())) + } +} + /// Will be used on initialization of a module to resolve function and memory imports. struct Resolver<'a> { /// All the hot functions that we export for the WASM blob. diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 5acaaefdb08f9..630102c6d8934 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -335,7 +335,7 @@ impl Sandbox for HostState { .instance(instance_id) .map_err(|e| e.to_string())?; - let result = instance.invoke::<_, Holder>(export_name, &args, state); + let result = instance.invoke::<_, CapsHolder>(export_name, &args, state); match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -400,7 +400,7 @@ impl Sandbox for HostState { let store = &mut *self.inner.sandbox_store.borrow_mut(); let instance_idx_or_err_code = - match store.instantiate::<_, Holder>( + match store.instantiate::<_, CapsHolder, ThunkHolder>( dispatch_thunk, wasm, guest_env, @@ -429,9 +429,9 @@ impl Sandbox for HostState { } } -struct Holder; +struct CapsHolder; -impl SandboxCapabiliesHolder for Holder { +impl SandboxCapabiliesHolder for CapsHolder { type SupervisorFuncRef = SupervisorFuncRef; type SC = HostState; @@ -441,3 +441,16 @@ impl SandboxCapabiliesHolder for Holder { }) } } + +struct ThunkHolder; + +scoped_tls::scoped_thread_local!(static DISPATCH_THUNK: SupervisorFuncRef); + +impl sandbox::DispatchThunkHolder for ThunkHolder { + type DispatchThunk = SupervisorFuncRef; + + fn with_dispatch_thunk R>(f: F) -> R { + assert!(DISPATCH_THUNK.is_set(), "dispatch thunk is not set"); + DISPATCH_THUNK.with(|thunk| f(&mut thunk.clone())) + } +} From 4f1f9513950def8c44b9e1fc041bbfb27b22ee7d Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 13 Apr 2021 12:50:14 +0700 Subject: [PATCH 43/88] Pass dispatch thunk to the sandbox as a TLS --- client/executor/common/src/sandbox.rs | 41 ++++++++++++++------------- client/executor/wasmi/src/lib.rs | 12 ++++---- client/executor/wasmtime/src/host.rs | 18 ++++++------ 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index ebab7cc4f3d4d..221e92941155e 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -878,7 +878,7 @@ impl Store { /// Returns uninitialized sandboxed module instance or an instantiation error. pub fn instantiate<'a, FE, SCH, DTH>( &mut self, - dispatch_thunk: FR, + // dispatch_thunk: FR, wasm: &[u8], guest_env: GuestEnvironment, state: u32, @@ -898,13 +898,15 @@ impl Store { let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) .map_err(|_| InstantiationError::Instantiation)?; - let sandbox_instance = Rc::new(SandboxInstance { - // In general, it's not a very good idea to use `.not_started_instance()` for anything - // but for extracting memory and tables. But in this particular case, we are extracting - // for the purpose of running `start` function which should be ok. - backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), - dispatch_thunk, - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + let sandbox_instance = DTH::with_dispatch_thunk(|dispatch_thunk| { + Rc::new(SandboxInstance { + // In general, it's not a very good idea to use `.not_started_instance()` for anything + // but for extracting memory and tables. But in this particular case, we are extracting + // for the purpose of running `start` function which should be ok. + backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), + dispatch_thunk: dispatch_thunk.clone(), + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }) }); SCH::with_sandbox_capabilities( |supervisor_externals| { @@ -948,7 +950,7 @@ impl Store { let supervisor_func_index = guest_env.guest_to_supervisor_mapping .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - let dispatch_thunk = dispatch_thunk.clone(); + // let dispatch_thunk = dispatch_thunk.clone(); Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, move |_caller, params, result| { SCH::with_sandbox_capabilities(|supervisor_externals| { @@ -986,13 +988,15 @@ impl Store { return Err(wasmtime::Trap::new("Can't write invoke args into memory")); } - let serialized_result = supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) + let serialized_result = DTH::with_dispatch_thunk(|dispatch_thunk| { + supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + }) .map_err(|e| wasmtime::Trap::new(e.to_string()))?; // dispatch_thunk returns pointer to serialized arguments. @@ -1045,7 +1049,7 @@ impl Store { Rc::new(SandboxInstance { backend_instance: BackendInstance::Wasmtime(wasmtime_instance), - dispatch_thunk, + dispatch_thunk: DTH::with_dispatch_thunk(|dispatch_thunk| dispatch_thunk.clone()), guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, }) } @@ -1100,7 +1104,6 @@ impl Store { let supervisor_func_index = guest_env.guest_to_supervisor_mapping .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - let dispatch_thunk = Mutex::new(dispatch_thunk.clone()); let function = wasmer::Function::new(&context.store, func_ty, move |params: &[wasmer::Val]| { SCH::with_sandbox_capabilities(|supervisor_externals| { @@ -1211,7 +1214,7 @@ impl Store { println!("Creating SandboxInstance..."); Rc::new(SandboxInstance { backend_instance: BackendInstance::Wasmer(instance), - dispatch_thunk, + dispatch_thunk: DTH::with_dispatch_thunk(|dispatch_thunk| dispatch_thunk.clone()), guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, }) } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index f4e544301d026..e86553c830194 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -301,11 +301,13 @@ impl Sandbox for FunctionExecutor { println!("Instantiating sandbox from wasmi"); let store = &mut *self.inner.sandbox_store.borrow_mut(); - let result = EXECUTOR.set(self, || store.instantiate::<_, CapsHolder, ThunkHolder>( - dispatch_thunk, - wasm, - guest_env, - state + let result = EXECUTOR.set(self, || DISPATCH_THUNK.set(&dispatch_thunk, || { + store.instantiate::<_, CapsHolder, ThunkHolder>( + // dispatch_thunk, + wasm, + guest_env, + state, + )} )); let instance_idx_or_err_code: u32 = diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 630102c6d8934..6029840dc67d2 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -399,19 +399,21 @@ impl Sandbox for HostState { println!("Instantiating sandbox from host"); let store = &mut *self.inner.sandbox_store.borrow_mut(); - let instance_idx_or_err_code = - match store.instantiate::<_, CapsHolder, ThunkHolder>( - dispatch_thunk, + let result = DISPATCH_THUNK.set(&dispatch_thunk, || { + store.instantiate::<_, CapsHolder, ThunkHolder>( + // dispatch_thunk, wasm, guest_env, state ) .map(|i| i.register(store)) - { - Ok(instance_idx) => instance_idx, - Err(sandbox::InstantiationError::StartTrapped) => sandbox_primitives::ERR_EXECUTION, - Err(_) => sandbox_primitives::ERR_MODULE, - }; + }); + + let instance_idx_or_err_code = match result { + Ok(instance_idx) => instance_idx, + Err(sandbox::InstantiationError::StartTrapped) => sandbox_primitives::ERR_EXECUTION, + Err(_) => sandbox_primitives::ERR_MODULE, + }; Ok(instance_idx_or_err_code as u32) } From 3e20bb61797cff42284230c723a965c15322c05c Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 14 Apr 2021 13:09:30 +0700 Subject: [PATCH 44/88] Initialize dispatch thunk holder in `SandboxInstance` --- client/executor/common/src/sandbox.rs | 13 +++++++++---- client/executor/wasmi/src/lib.rs | 6 +++++- client/executor/wasmtime/src/host.rs | 6 +++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 221e92941155e..a79c2d31aca00 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -378,7 +378,7 @@ impl SandboxInstance { /// /// The `state` parameter can be used to provide custom data for /// these syscall implementations. - pub fn invoke<'a, FE, SCH>( + pub fn invoke<'a, FE, SCH, DTH>( &self, // function to call that is exported from the module @@ -395,7 +395,8 @@ impl SandboxInstance { ) -> std::result::Result, wasmi::Error> where FE: SandboxCapabilities + 'a, - SCH: SandboxCapabiliesHolder + SCH: SandboxCapabiliesHolder, + DTH: DispatchThunkHolder, { SCH::with_sandbox_capabilities( |supervisor_externals| { with_guest_externals( @@ -468,8 +469,7 @@ impl SandboxInstance { }) .collect(); - let wasmer_result = function - .call(&args) + let wasmer_result = DTH::initialize_thunk(&self.dispatch_thunk, || function.call(&args)) .map_err(|e| wasmi::Error::Function(e.to_string()))?; assert!(wasmer_result.len() < 2, "multiple return types are not supported yet"); @@ -654,6 +654,11 @@ pub trait DispatchThunkHolder { /// Dispatch thunk for this particular context type DispatchThunk; + /// Provide `DispatchThunk` for the runtime method call and execute the given function `f`. + /// + /// During the execution of the provided function `dispatch_thunk` will be callable. + fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R where F: FnOnce() -> R; + /// Wrapper that provides dispatch thunk in a limited context fn with_dispatch_thunk R>(f: F) -> R; } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index e86553c830194..f9a9148beeecd 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -247,7 +247,7 @@ impl Sandbox for FunctionExecutor { .instance(instance_id).map_err(|e| e.to_string())?; let result = EXECUTOR.set(self, || { - instance.invoke::<_, CapsHolder>(export_name, &args, state) + instance.invoke::<_, CapsHolder, ThunkHolder>(export_name, &args, state) }); match result { @@ -363,6 +363,10 @@ impl sandbox::DispatchThunkHolder for ThunkHolder { assert!(DISPATCH_THUNK.is_set(), "dispatch thunk is not set"); DISPATCH_THUNK.with(|thunk| f(&mut thunk.clone())) } + + fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R where F: FnOnce() -> R { + DISPATCH_THUNK.set(s, f) + } } /// Will be used on initialization of a module to resolve function and memory imports. diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 6029840dc67d2..e2a264b837af2 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -335,7 +335,7 @@ impl Sandbox for HostState { .instance(instance_id) .map_err(|e| e.to_string())?; - let result = instance.invoke::<_, CapsHolder>(export_name, &args, state); + let result = instance.invoke::<_, CapsHolder, ThunkHolder>(export_name, &args, state); match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -455,4 +455,8 @@ impl sandbox::DispatchThunkHolder for ThunkHolder { assert!(DISPATCH_THUNK.is_set(), "dispatch thunk is not set"); DISPATCH_THUNK.with(|thunk| f(&mut thunk.clone())) } + + fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R where F: FnOnce() -> R { + DISPATCH_THUNK.set(s, f) + } } From f1fdbd2a69a7147a299396e455f587b9b2cc40f0 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 3 May 2021 12:57:58 +0700 Subject: [PATCH 45/88] Comment out Wasmtime/Lightbeam sandbox backend --- client/executor/common/src/sandbox.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index a79c2d31aca00..591bb3d6389f4 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -346,7 +346,7 @@ where enum BackendInstance { Wasmi(wasmi::ModuleRef), - Wasmtime(wasmtime::Instance), + // Wasmtime(wasmtime::Instance), Wasmer(wasmer::Instance), } @@ -412,7 +412,7 @@ impl SandboxInstance { Ok(wasmi_result) } - BackendInstance::Wasmtime(wasmtime_instance) => { + /*BackendInstance::Wasmtime(wasmtime_instance) => { let wasmtime_function = wasmtime_instance .get_func(export_name) .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; @@ -448,7 +448,7 @@ impl SandboxInstance { }; Ok(wasmtime_result) - } + }*/ BackendInstance::Wasmer(wasmer_instance) => { let function = wasmer_instance @@ -510,7 +510,7 @@ impl SandboxInstance { Some(wasmi_global.into()) } - BackendInstance::Wasmtime(wasmtime_instance) => { + /*BackendInstance::Wasmtime(wasmtime_instance) => { let wasmtime_global = wasmtime_instance.get_global(name)?.get(); let wasmtime_value = match wasmtime_global { Val::I32(val) => Value::I32(val), @@ -521,7 +521,7 @@ impl SandboxInstance { }; Some(wasmtime_value) - } + }*/ BackendInstance::Wasmer(wasmer_instance) => { let global = wasmer_instance.exports.get_global(name).ok()?; @@ -669,7 +669,7 @@ pub enum SandboxBackend { Wasmi, /// Wasmtime environment - Wasmtime, + // Wasmtime, /// Wasmer environment Wasmer, @@ -705,7 +705,7 @@ struct WasmerBackend { enum BackendContext { Wasmi, - Wasmtime, + // Wasmtime, Wasmer(WasmerBackend), } @@ -713,7 +713,7 @@ impl BackendContext { pub fn new(backend: SandboxBackend) -> BackendContext { match backend { SandboxBackend::Wasmi => BackendContext::Wasmi, - SandboxBackend::Wasmtime => todo!(), + // SandboxBackend::Wasmtime => todo!(), SandboxBackend::Wasmer => { let compiler = Singlepass::default(); @@ -772,7 +772,7 @@ impl Store { ) } - BackendContext::Wasmtime => todo!(), + // BackendContext::Wasmtime => todo!(), }; let mem_idx = memories.len(); @@ -932,7 +932,7 @@ impl Store { sandbox_instance } - BackendContext::Wasmtime => { + /*BackendContext::Wasmtime => { let mut config = wasmtime::Config::new(); config.cranelift_opt_level(wasmtime::OptLevel::None); config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; @@ -1057,7 +1057,7 @@ impl Store { dispatch_thunk: DTH::with_dispatch_thunk(|dispatch_thunk| dispatch_thunk.clone()), guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, }) - } + }*/ BackendContext::Wasmer(context) => { // let compiler = Singlepass::default(); From 0063bf988bb09e27f883509663693624f1061270 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 6 May 2021 14:22:47 +0700 Subject: [PATCH 46/88] Revert wasmtime back to mainstream --- Cargo.lock | 541 +++++++++--------- client/executor/common/Cargo.toml | 2 +- client/executor/common/src/sandbox.rs | 2 +- client/executor/wasmtime/Cargo.toml | 12 +- client/executor/wasmtime/src/imports.rs | 20 +- .../executor/wasmtime/src/instance_wrapper.rs | 8 +- 6 files changed, 285 insertions(+), 300 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3334030919e37..9e69b80cff4a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -691,24 +691,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" -[[package]] -name = "capstone" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031ba51c39151a1d6336ec859646153187204b0147c7b3f6fe2de636f1b8dbb3" -dependencies = [ - "capstone-sys", -] - -[[package]] -name = "capstone-sys" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fae25eddcb80e24f98c35952c37a91ff7f8d0f60dbbdafb9763e8d5cc566b8d7" -dependencies = [ - "cc", -] - [[package]] name = "cargo-platform" version = "0.1.1" @@ -933,6 +915,16 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" +[[package]] +name = "cpp_demangle" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44919ecaf6f99e8e737bc239408931c9a01e9a6c74814fee8242dd2506b65390" +dependencies = [ + "cfg-if 1.0.0", + "glob", +] + [[package]] name = "cpuid-bool" version = "0.1.2" @@ -945,14 +937,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" -[[package]] -name = "cranelift-bforest" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" -dependencies = [ - "cranelift-entity 0.65.0", -] - [[package]] name = "cranelift-bforest" version = "0.68.0" @@ -963,22 +947,12 @@ dependencies = [ ] [[package]] -name = "cranelift-codegen" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +name = "cranelift-bforest" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcee7a5107071484772b89fdf37f0f460b7db75f476e43ea7a684fd942470bcf" dependencies = [ - "byteorder", - "cranelift-bforest 0.65.0", - "cranelift-codegen-meta 0.65.0", - "cranelift-codegen-shared 0.65.0", - "cranelift-entity 0.65.0", - "gimli 0.21.0", - "log", - "regalloc 0.0.26", - "serde", - "smallvec 1.6.1", - "target-lexicon 0.10.0", - "thiserror", + "cranelift-entity 0.71.0", ] [[package]] @@ -994,19 +968,30 @@ dependencies = [ "cranelift-entity 0.68.0", "gimli 0.22.0", "log", - "regalloc 0.0.31", + "regalloc", "smallvec 1.6.1", - "target-lexicon 0.11.2", + "target-lexicon", "thiserror", ] [[package]] -name = "cranelift-codegen-meta" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +name = "cranelift-codegen" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "654ab96f0f1cab71c0d323618a58360a492da2c341eb2c1f977fc195c664001b" dependencies = [ - "cranelift-codegen-shared 0.65.0", - "cranelift-entity 0.65.0", + "byteorder", + "cranelift-bforest 0.71.0", + "cranelift-codegen-meta 0.71.0", + "cranelift-codegen-shared 0.71.0", + "cranelift-entity 0.71.0", + "gimli 0.23.0", + "log", + "regalloc", + "serde", + "smallvec 1.6.1", + "target-lexicon", + "thiserror", ] [[package]] @@ -1020,9 +1005,14 @@ dependencies = [ ] [[package]] -name = "cranelift-codegen-shared" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +name = "cranelift-codegen-meta" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65994cfc5be9d5fd10c5fc30bcdddfa50c04bb79c91329287bff846434ff8f14" +dependencies = [ + "cranelift-codegen-shared 0.71.0", + "cranelift-entity 0.71.0", +] [[package]] name = "cranelift-codegen-shared" @@ -1031,9 +1021,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" [[package]] -name = "cranelift-entity" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +name = "cranelift-codegen-shared" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "889d720b688b8b7df5e4903f9b788c3c59396050f5548e516e58ccb7312463ab" dependencies = [ "serde", ] @@ -1048,14 +1039,12 @@ dependencies = [ ] [[package]] -name = "cranelift-frontend" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +name = "cranelift-entity" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a2e6884a363e42a9ba980193ea8603a4272f8a92bd8bbaf9f57a94dbea0ff96" dependencies = [ - "cranelift-codegen 0.65.0", - "log", - "smallvec 1.6.1", - "target-lexicon 0.10.0", + "serde", ] [[package]] @@ -1067,31 +1056,46 @@ dependencies = [ "cranelift-codegen 0.68.0", "log", "smallvec 1.6.1", - "target-lexicon 0.11.2", + "target-lexicon", +] + +[[package]] +name = "cranelift-frontend" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f41e2f9b57d2c030e249d0958f1cdc2c3cd46accf8c0438b3d1944e9153444" +dependencies = [ + "cranelift-codegen 0.71.0", + "log", + "smallvec 1.6.1", + "target-lexicon", ] [[package]] name = "cranelift-native" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aab70ba7575665375d31cbdea2462916ce58be887834e1b83c860b43b51af637" dependencies = [ - "cranelift-codegen 0.65.0", - "raw-cpuid", - "target-lexicon 0.10.0", + "cranelift-codegen 0.71.0", + "target-lexicon", ] [[package]] name = "cranelift-wasm" -version = "0.65.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fc3d2e70da6439adf97648dcdf81834363154f2907405345b6fbe7ca38918c" dependencies = [ - "cranelift-codegen 0.65.0", - "cranelift-entity 0.65.0", - "cranelift-frontend 0.65.0", + "cranelift-codegen 0.71.0", + "cranelift-entity 0.71.0", + "cranelift-frontend 0.71.0", + "itertools 0.10.0", "log", "serde", + "smallvec 1.6.1", "thiserror", - "wasmparser 0.57.0", + "wasmparser 0.76.0", ] [[package]] @@ -1409,17 +1413,6 @@ dependencies = [ "syn", ] -[[package]] -name = "derive_utils" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532b4c15dccee12c7044f1fcad956e98410860b22231e44a3b827464797ca7bf" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "difference" version = "2.0.0" @@ -1446,21 +1439,21 @@ dependencies = [ [[package]] name = "directories" -version = "2.0.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c" +checksum = "f8fed639d60b58d0f53498ab13d26f621fd77569cc6edb031f4cc36a2ad9da0f" dependencies = [ - "cfg-if 0.1.10", "dirs-sys", ] [[package]] -name = "directories" -version = "3.0.1" +name = "directories-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fed639d60b58d0f53498ab13d26f621fd77569cc6edb031f4cc36a2ad9da0f" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" dependencies = [ - "dirs-sys", + "cfg-if 1.0.0", + "dirs-sys-next", ] [[package]] @@ -1470,7 +1463,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ "libc", - "redox_users", + "redox_users 0.3.5", + "winapi 0.3.9", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users 0.4.0", "winapi 0.3.9", ] @@ -1523,21 +1527,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" -[[package]] -name = "dynasm" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a814e1edeb85dd2a3c6fc0d6bf76d02ca5695d438c70ecee3d90774f3259c5" -dependencies = [ - "bitflags", - "byteorder", - "lazy_static", - "owning_ref", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "dynasm" version = "1.0.1" @@ -1553,16 +1542,6 @@ dependencies = [ "syn", ] -[[package]] -name = "dynasmrt" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a393aaeb4441a48bcf47b5b6155971f82cc1eb77e22855403ccc0415ac8328d" -dependencies = [ - "byteorder", - "memmap", -] - [[package]] name = "dynasmrt" version = "1.0.1" @@ -1570,7 +1549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1dd4d1d5ca12258cef339a57a7643e8b233a42dea9bb849630ddd9dd7726aa9" dependencies = [ "byteorder", - "dynasm 1.0.1", + "dynasm", "memmap2", ] @@ -2346,9 +2325,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "fallible-iterator", "indexmap", @@ -2357,21 +2336,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" - [[package]] name = "glob" version = "0.3.0" @@ -2864,26 +2837,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" -[[package]] -name = "iter-enum" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad34f24d3b48ceffdff38af2df5ce1b7d1d9cc113e503d8e86fe8cdb889c871" -dependencies = [ - "derive_utils", - "quote", - "syn", -] - -[[package]] -name = "itertools" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.9.0" @@ -3699,24 +3652,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "lightbeam" -version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" -dependencies = [ - "capstone", - "cranelift-codegen 0.65.0", - "derive_more", - "dynasm 0.5.2", - "dynasmrt 0.5.2", - "iter-enum", - "itertools 0.8.2", - "memoffset 0.5.6", - "more-asserts", - "thiserror", - "wasmparser 0.57.0", -] - [[package]] name = "linked-hash-map" version = "0.5.4" @@ -4671,16 +4606,6 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" -dependencies = [ - "crc32fast", - "indexmap", -] - [[package]] name = "object" version = "0.22.0" @@ -4696,6 +4621,10 @@ name = "object" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" +dependencies = [ + "crc32fast", + "indexmap", +] [[package]] name = "once_cell" @@ -6434,6 +6363,15 @@ dependencies = [ "prost", ] +[[package]] +name = "psm" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a" +dependencies = [ + "cc", +] + [[package]] name = "pwasm-utils" version = "0.14.0" @@ -6643,17 +6581,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "raw-cpuid" -version = "7.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb71f708fe39b2c5e98076204c3cc094ee5a4c12c4cdb119a2b72dc34164f41" -dependencies = [ - "bitflags", - "cc", - "rustc_version", -] - [[package]] name = "rawpointer" version = "0.2.1" @@ -6720,6 +6647,16 @@ dependencies = [ "rust-argon2", ] +[[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom 0.2.2", + "redox_syscall 0.2.4", +] + [[package]] name = "ref-cast" version = "1.0.6" @@ -6740,17 +6677,6 @@ dependencies = [ "syn", ] -[[package]] -name = "regalloc" -version = "0.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" -dependencies = [ - "log", - "rustc-hash", - "smallvec 1.6.1", -] - [[package]] name = "regalloc" version = "0.0.31" @@ -6759,6 +6685,7 @@ checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", + "serde", "smallvec 1.6.1", ] @@ -7509,7 +7436,6 @@ dependencies = [ "wasmer", "wasmer-compiler-singlepass", "wasmi", - "wasmtime", ] [[package]] @@ -7532,8 +7458,6 @@ name = "sc-executor-wasmtime" version = "0.9.0" dependencies = [ "assert_matches", - "cranelift-codegen 0.65.0", - "cranelift-wasm", "log", "parity-scale-codec", "parity-wasm 0.41.0", @@ -7545,8 +7469,6 @@ dependencies = [ "sp-runtime-interface", "sp-wasm-interface", "wasmtime", - "wasmtime-environ", - "wasmtime-runtime", ] [[package]] @@ -7971,7 +7893,7 @@ name = "sc-service" version = "0.9.0" dependencies = [ "async-std", - "directories 3.0.1", + "directories", "exit-future", "futures 0.1.30", "futures 0.3.12", @@ -9801,12 +9723,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e" -[[package]] -name = "target-lexicon" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" - [[package]] name = "target-lexicon" version = "0.11.2" @@ -10792,7 +10708,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "more-asserts", - "target-lexicon 0.11.2", + "target-lexicon", "thiserror", "wasmer-compiler", "wasmer-compiler-cranelift", @@ -10816,7 +10732,7 @@ dependencies = [ "serde", "serde_bytes", "smallvec 1.6.1", - "target-lexicon 0.11.2", + "target-lexicon", "thiserror", "wasmer-types", "wasmer-vm", @@ -10849,8 +10765,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "426ae6ef0f606ca815510f3e2ef6f520e217514bfb7a664defe180b9a9e75d07" dependencies = [ "byteorder", - "dynasm 1.0.1", - "dynasmrt 1.0.1", + "dynasm", + "dynasmrt", "lazy_static", "more-asserts", "rayon", @@ -10887,7 +10803,7 @@ dependencies = [ "rustc-demangle", "serde", "serde_bytes", - "target-lexicon 0.11.2", + "target-lexicon", "thiserror", "wasmer-compiler", "wasmer-types", @@ -11002,33 +10918,40 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.57.0" +version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" +checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wasmparser" -version = "0.65.0" +version = "0.76.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" +checksum = "755a9a4afe3f6cccbbe6d7e965eef44cf260b001f93e547eba84255c1d0187d8" [[package]] name = "wasmtime" -version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "718cb52a9fdb7ab12471e9b9d051c9adfa6b5c504e0a1fea045e5eabc81eedd9" dependencies = [ "anyhow", "backtrace", - "cfg-if 0.1.10", - "itertools 0.9.0", - "lazy_static", + "bincode", + "cfg-if 1.0.0", + "cpp_demangle", + "indexmap", "libc", "log", + "paste 1.0.4", "region", "rustc-demangle", - "target-lexicon 0.10.0", - "wasmparser 0.57.0", + "serde", + "smallvec 1.6.1", + "target-lexicon", + "wasmparser 0.76.0", + "wasmtime-cache", "wasmtime-environ", + "wasmtime-fiber", "wasmtime-jit", "wasmtime-profiling", "wasmtime-runtime", @@ -11036,108 +10959,170 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "wasmtime-cache" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f984df56c4adeba91540f9052db9f7a8b3b00cfaac1a023bee50a972f588b0c" +dependencies = [ + "anyhow", + "base64 0.13.0", + "bincode", + "directories-next", + "errno", + "file-per-thread-logger", + "libc", + "log", + "serde", + "sha2 0.9.3", + "toml", + "winapi 0.3.9", + "zstd", +] + +[[package]] +name = "wasmtime-cranelift" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a05abbf94e03c2c8ee02254b1949320c4d45093de5d9d6ed4d9351d536075c9" +dependencies = [ + "cranelift-codegen 0.71.0", + "cranelift-entity 0.71.0", + "cranelift-frontend 0.71.0", + "cranelift-wasm", + "wasmparser 0.76.0", + "wasmtime-environ", +] + [[package]] name = "wasmtime-debug" -version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382eecd6281c6c1d1f3c904c3c143e671fc1a9573820cbfa777fba45ce2eda9c" dependencies = [ "anyhow", - "gimli 0.21.0", + "gimli 0.23.0", "more-asserts", - "object 0.19.0", - "target-lexicon 0.10.0", + "object 0.23.0", + "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser 0.76.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81011b2b833663d7e0ce34639459a0e301e000fc7331e0298b3a27c78d0cec60" dependencies = [ "anyhow", - "base64 0.12.3", - "bincode", - "cranelift-codegen 0.65.0", - "cranelift-entity 0.65.0", + "cfg-if 1.0.0", + "cranelift-codegen 0.71.0", + "cranelift-entity 0.71.0", "cranelift-wasm", - "directories 2.0.2", - "errno", - "file-per-thread-logger", + "gimli 0.23.0", "indexmap", - "libc", - "lightbeam", "log", "more-asserts", - "rayon", "serde", - "sha2 0.8.2", "thiserror", - "toml", - "wasmparser 0.57.0", + "wasmparser 0.76.0", +] + +[[package]] +name = "wasmtime-fiber" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92da32e31af2e3d828f485f5f24651ed4d3b7f03a46ea6555eae6940d1402cd" +dependencies = [ + "cc", + "libc", "winapi 0.3.9", - "zstd", ] [[package]] name = "wasmtime-jit" -version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b5f649623859a12d361fe4cc4793de44f7c3ff34c322c5714289787e89650bb" dependencies = [ + "addr2line", "anyhow", - "cfg-if 0.1.10", - "cranelift-codegen 0.65.0", - "cranelift-entity 0.65.0", - "cranelift-frontend 0.65.0", + "cfg-if 1.0.0", + "cranelift-codegen 0.71.0", + "cranelift-entity 0.71.0", + "cranelift-frontend 0.71.0", "cranelift-native", "cranelift-wasm", - "gimli 0.21.0", + "gimli 0.23.0", "log", "more-asserts", + "object 0.23.0", + "rayon", "region", - "target-lexicon 0.10.0", + "serde", + "target-lexicon", "thiserror", - "wasmparser 0.57.0", + "wasmparser 0.76.0", + "wasmtime-cranelift", "wasmtime-debug", "wasmtime-environ", + "wasmtime-obj", "wasmtime-profiling", "wasmtime-runtime", "winapi 0.3.9", ] +[[package]] +name = "wasmtime-obj" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2e99cd9858f57fd062e9351e07881cedfc8597928385e02a48d9333b9e15a1" +dependencies = [ + "anyhow", + "more-asserts", + "object 0.23.0", + "target-lexicon", + "wasmtime-debug", + "wasmtime-environ", +] + [[package]] name = "wasmtime-profiling" -version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46c0a590e49278ba7f79ef217af9db4ecc671b50042c185093e22d73524abb2" dependencies = [ "anyhow", - "cfg-if 0.1.10", - "gimli 0.21.0", + "cfg-if 1.0.0", + "gimli 0.23.0", "lazy_static", "libc", - "object 0.19.0", + "object 0.23.0", "scroll", "serde", - "target-lexicon 0.10.0", + "target-lexicon", "wasmtime-environ", "wasmtime-runtime", ] [[package]] name = "wasmtime-runtime" -version = "0.18.0" -source = "git+https://github.com/Vurich/wasmtime.git?branch=master#e0ea20baddf71f5cc025b5435e6fbbef6d39a698" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1438a09185fc7ca067caf1a80d7e5b398eefd4fb7630d94841448ade60feb3d0" dependencies = [ "backtrace", "cc", - "cfg-if 0.1.10", + "cfg-if 1.0.0", "indexmap", "lazy_static", "libc", "log", - "memoffset 0.5.6", + "memoffset 0.6.1", "more-asserts", + "psm", "region", "thiserror", "wasmtime-environ", @@ -11146,18 +11131,18 @@ dependencies = [ [[package]] name = "wast" -version = "32.0.0" +version = "35.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24a3ee360d01d60ed0a0f960ab76a6acce64348cdb0bf8699c2a866fad57c7c" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.33" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e8f7f34773fa6318e8897283abf7941c1f250faae4e1a52f82df09c3bad7cce" +checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" dependencies = [ "wast", ] @@ -11326,18 +11311,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.5.4+zstd.1.4.7" +version = "0.6.1+zstd.1.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69996ebdb1ba8b1517f61387a883857818a66c8a295f487b1ffd8fd9d2c82910" +checksum = "5de55e77f798f205d8561b8fe2ef57abfb6e0ff2abe7fd3c089e119cdb5631a3" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "2.0.6+zstd.1.4.7" +version = "3.0.1+zstd.1.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98aa931fb69ecee256d44589d19754e61851ae4769bf963b385119b1cc37a49e" +checksum = "1387cabcd938127b30ce78c4bf00b30387dddf704e3f0881dbc4ff62b5566f8c" dependencies = [ "libc", "zstd-sys", @@ -11345,12 +11330,10 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.4.18+zstd.1.4.7" +version = "1.4.20+zstd.1.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e6e8778706838f43f771d80d37787cb2fe06dafe89dd3aebaf6721b9eaec81" +checksum = "ebd5b733d7cf2d9447e2c3e76a5589b4f5e5ae065c22a2bc0b023cbc331b6c8e" dependencies = [ "cc", - "glob", - "itertools 0.9.0", "libc", ] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index 0d4ecc5fa5248..43edb3ac93b97 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -22,7 +22,7 @@ sp-core = { version = "3.0.0", path = "../../../primitives/core" } sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" } sp-serializer = { version = "3.0.0", path = "../../../primitives/serializer" } -wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +# wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } wasmer = "1.0" wasmer-compiler-singlepass = "1.0" diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 591bb3d6389f4..068a8702e31d8 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -29,7 +29,7 @@ use sp_core::sandbox as sandbox_primitives; use wasmi::{Externals, ImportResolver, MemoryDescriptor, MemoryInstance, MemoryRef, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages}; use sp_wasm_interface::Value; -use wasmtime::Val; +// use wasmtime::Val; // use crate::sandbox:: wasmtime::instance_wrapper::InstanceWrapper; diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 7c5a7177c8d2c..eb1548c24aefc 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -23,11 +23,13 @@ sp-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime- sp-core = { version = "3.0.0", path = "../../../primitives/core" } sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } pwasm-utils = "0.14.0" -wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master", features=["lightbeam"] } -wasmtime-runtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -wasmtime-environ = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -cranelift-wasm = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -cranelift-codegen = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } + +wasmtime = "0.24" +# wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master", features=["lightbeam"] } +# wasmtime-runtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +# wasmtime-environ = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +# cranelift-wasm = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } +# cranelift-codegen = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } [dev-dependencies] assert_matches = "1.3.0" diff --git a/client/executor/wasmtime/src/imports.rs b/client/executor/wasmtime/src/imports.rs index 49400a51cdead..8a2e9ec3dafb9 100644 --- a/client/executor/wasmtime/src/imports.rs +++ b/client/executor/wasmtime/src/imports.rs @@ -78,10 +78,10 @@ pub fn resolve_imports( /// Because we are not using this proposal we could safely unwrap the name. /// However, we opt for an error in order to avoid panics at all costs. fn import_name<'a, 'b: 'a>(import: &'a ImportType<'b>) -> Result<&'a str, WasmError> { - // let name = import.name().ok_or_else(|| - // WasmError::Other("The module linking proposal is not supported.".to_owned()) - // )?; - Ok(import.name()) + let name = import.name().ok_or_else(|| + WasmError::Other("The module linking proposal is not supported.".to_owned()) + )?; + Ok(name) } fn resolve_memory_import( @@ -277,17 +277,17 @@ fn wasmtime_func_sig(func: &dyn Function) -> wasmtime::FuncType { .args .iter() .cloned() - .map(into_wasmtime_val_type) - .collect::>() - .into_boxed_slice(); + .map(into_wasmtime_val_type); + // .collect::>() + // .into_boxed_slice(); let results = signature .return_value .iter() .cloned() - .map(into_wasmtime_val_type) - .collect::>() - .into_boxed_slice(); + .map(into_wasmtime_val_type); + // .collect::>() + // .into_boxed_slice(); wasmtime::FuncType::new(params, results) } diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index dd437e83aa24b..ff04ec42d76a7 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -126,8 +126,8 @@ impl EntryPoint { pub fn direct(func: wasmtime::Func) -> std::result::Result { use wasmtime::ValType; let entry_point = wasmtime::FuncType::new( - Box::new([ValType::I32, ValType::I32]), - Box::new([ValType::I64]), + [ValType::I32, ValType::I32].iter().cloned(), + [ValType::I64].iter().cloned(), ); if func.ty() == entry_point { Ok(Self { func, call_type: EntryPointType::Direct }) @@ -139,8 +139,8 @@ impl EntryPoint { pub fn wrapped(dispatcher: wasmtime::Func, func: u32) -> std::result::Result { use wasmtime::ValType; let entry_point = wasmtime::FuncType::new( - Box::new([ValType::I32, ValType::I32, ValType::I32]), - Box::new([ValType::I64]), + [ValType::I32, ValType::I32, ValType::I32].iter().cloned(), + [ValType::I64].iter().cloned(), ); if dispatcher.ty() == entry_point { Ok(Self { func: dispatcher, call_type: EntryPointType::Wrapped(func) }) From 5cda36eba1cefdf9230ef5eea9031da5002c900b Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 11 May 2021 13:57:56 +0700 Subject: [PATCH 47/88] Adds SandboxExecutionMethod enum for cli param --- client/cli/src/arg_enums.rs | 11 +++++++++++ client/cli/src/params/import_params.rs | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index aeb3eeacc6f2c..c62f02c645744 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -216,3 +216,14 @@ pub const DEFAULT_EXECUTION_BLOCK_CONSTRUCTION: ExecutionStrategy = ExecutionStr pub const DEFAULT_EXECUTION_OFFCHAIN_WORKER: ExecutionStrategy = ExecutionStrategy::Native; /// Default value for the `--execution-other` parameter. pub const DEFAULT_EXECUTION_OTHER: ExecutionStrategy = ExecutionStrategy::Native; + +arg_enum! { + /// How to execute wasm in a sandboxed environment + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SandboxExecutionMethod { + // Uses an interpreter. + Interpreted, + // Uses a compiled runtime. + Compiled, + } +} diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index 7409dbf79dc0f..1cb2bd5471acd 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use crate::arg_enums::{ - ExecutionStrategy, WasmExecutionMethod, DEFAULT_EXECUTION_BLOCK_CONSTRUCTION, + ExecutionStrategy, WasmExecutionMethod, SandboxExecutionMethod, DEFAULT_EXECUTION_BLOCK_CONSTRUCTION, DEFAULT_EXECUTION_IMPORT_BLOCK, DEFAULT_EXECUTION_IMPORT_BLOCK_VALIDATOR, DEFAULT_EXECUTION_OFFCHAIN_WORKER, DEFAULT_EXECUTION_OTHER, DEFAULT_EXECUTION_SYNCING, }; @@ -56,6 +56,16 @@ pub struct ImportParams { )] pub wasm_method: WasmExecutionMethod, + /// Method for executing Wasm in a sandbox environment + #[structopt( + long = "sandbox-execution", + value_name = "METHOD", + possible_values = &SandboxExecutionMethod::variants(), + case_insensitive = true, + default_value = "Interpreted" + )] + pub sandbox_method: SandboxExecutionMethod, + /// Specify the path where local WASM runtimes are stored. /// /// These runtimes will override on-chain runtimes when the version matches. From 84e3a8180877c20fe6ea7eb164571c14e0007f80 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 14 May 2021 13:26:54 +0700 Subject: [PATCH 48/88] Cleanup sandbox code --- client/executor/Cargo.toml | 2 +- client/executor/common/Cargo.toml | 9 - client/executor/common/src/sandbox.rs | 235 +++----------------------- 3 files changed, 21 insertions(+), 225 deletions(-) diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index c79a852c86d4d..e9f0fa14d8e7e 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -53,7 +53,7 @@ tracing-subscriber = "0.2.15" paste = "1.0" [features] -default = [ "std", "wasmtime" ] +default = [ "std" ] # This crate does not have `no_std` support, we just require this for tests std = [] wasm-extern-trace = [] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index c8d90ff586910..c03325ea0bacd 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -23,18 +23,9 @@ sp-core = { version = "3.0.0", path = "../../../primitives/core" } sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" } sp-serializer = { version = "3.0.0", path = "../../../primitives/serializer" } -# wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } wasmer = "1.0" wasmer-compiler-singlepass = "1.0" -# wasmer = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } -# wasmer-compiler-singlepass = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } -#wasmer-engine-jit = { git = "https://github.com/0x7CFE/wasmer", branch = "frame-info-patch" } - -#wasmer = "1.0.0-alpha3" -#wasmer-compiler-singlepass = "1.0.0-alpha3" -#wasmer-engine-jit = "1.0.0-alpha3" -#wasmer-runtime = "0.17" thiserror = "1.0.21" diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 068a8702e31d8..6d6c42fb62142 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -22,23 +22,13 @@ //! a compiled execution engine. use crate::error::{Result, Error}; -use std::{cell::RefCell, collections::HashMap, convert::TryInto, rc::Rc, sync::{Arc, Mutex}, todo}; +use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; -use wasmi::{Externals, ImportResolver, MemoryDescriptor, MemoryInstance, MemoryRef, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages}; - -use sp_wasm_interface::Value; -// use wasmtime::Val; - -// use crate::sandbox:: wasmtime::instance_wrapper::InstanceWrapper; - -// use wasmtime::{Store, Instance, Module, Memory, Table, Val, Func, Extern, Global}; - -use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; - -// use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; -use wasmer_compiler_singlepass::{Singlepass, SinglepassCompiler}; +use wasmi::{Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages}; +use sp_wasm_interface::{Value, FunctionContext, Pointer, WordSize}; +use wasmer_compiler_singlepass::Singlepass; /// Index of a function inside the supervisor. /// @@ -344,9 +334,12 @@ where f(&mut guest_externals) } +/// Module instance in terms of selected backend enum BackendInstance { + /// Wasmi module instance Wasmi(wasmi::ModuleRef), - // Wasmtime(wasmtime::Instance), + + /// Wasmer module instance Wasmer(wasmer::Instance), } @@ -387,9 +380,6 @@ impl SandboxInstance { // arguments passed to the function args: &[RuntimeValue], - // supervisor environment provided to the module - // supervisor_externals: &mut FE, - // arbitraty context data of the call state: u32, ) -> std::result::Result, wasmi::Error> @@ -412,44 +402,6 @@ impl SandboxInstance { Ok(wasmi_result) } - /*BackendInstance::Wasmtime(wasmtime_instance) => { - let wasmtime_function = wasmtime_instance - .get_func(export_name) - .ok_or(wasmi::Error::Function("wasmtime function failed".to_string()))?; - - let args: Vec = args - .iter() - .map(|v| match *v { - RuntimeValue::I32(val) => Val::I32(val), - RuntimeValue::I64(val) => Val::I64(val), - RuntimeValue::F32(val) => Val::F32(val.into()), - RuntimeValue::F64(val) => Val::F64(val.into()), - }) - .collect(); - - let wasmtime_result = wasmtime_function - .call(&args) - .map_err(|e| wasmi::Error::Function(e.to_string()))?; - - assert!(wasmtime_result.len() < 2, "multiple return types are not supported yet"); - - let wasmtime_result = if let Some(wasmtime_value) = wasmtime_result.first() { - let wasmtime_value = match *wasmtime_value { - Val::I32(val) => RuntimeValue::I32(val), - Val::I64(val) => RuntimeValue::I64(val), - Val::F32(val) => RuntimeValue::F32(val.into()), - Val::F64(val) => RuntimeValue::F64(val.into()), - _ => unreachable!(), - }; - - Some(wasmtime_value) - } else { - None - }; - - Ok(wasmtime_result) - }*/ - BackendInstance::Wasmer(wasmer_instance) => { let function = wasmer_instance .exports @@ -510,19 +462,6 @@ impl SandboxInstance { Some(wasmi_global.into()) } - /*BackendInstance::Wasmtime(wasmtime_instance) => { - let wasmtime_global = wasmtime_instance.get_global(name)?.get(); - let wasmtime_value = match wasmtime_global { - Val::I32(val) => Value::I32(val), - Val::I64(val) => Value::I64(val), - Val::F32(val) => Value::F32(val), - Val::F64(val) => Value::F64(val), - _ => None?, - }; - - Some(wasmtime_value) - }*/ - BackendInstance::Wasmer(wasmer_instance) => { let global = wasmer_instance.exports.get_global(name).ok()?; let wasmtime_value = match global.get() { @@ -668,17 +607,17 @@ pub enum SandboxBackend { /// Wasm interpreter Wasmi, - /// Wasmtime environment - // Wasmtime, - /// Wasmer environment Wasmer, } +/// Memory reference in terms of a selected backend #[derive(Clone, Debug)] pub enum Memory { + /// Wasmi memory reference Wasmi(MemoryRef), - // Wasmtime(todo), + + /// Wasmer memory refernce Wasmer(wasmer::Memory), } @@ -698,14 +637,17 @@ impl Memory { } } +/// Wasmer specific context struct WasmerBackend { - // compiler: Singlepass, store: wasmer::Store, } +/// Information specific to a particular execution backend enum BackendContext { + /// Wasmi specific context Wasmi, - // Wasmtime, + + /// Wasmer specific context Wasmer(WasmerBackend), } @@ -713,7 +655,6 @@ impl BackendContext { pub fn new(backend: SandboxBackend) -> BackendContext { match backend { SandboxBackend::Wasmi => BackendContext::Wasmi, - // SandboxBackend::Wasmtime => todo!(), SandboxBackend::Wasmer => { let compiler = Singlepass::default(); @@ -721,7 +662,6 @@ impl BackendContext { BackendContext::Wasmer( WasmerBackend { store: wasmer::Store::new(&wasmer::JIT::new(compiler).engine()), - // compiler, } ) } @@ -760,9 +700,6 @@ impl Store { let ty = wasmer::MemoryType::new(initial, maximum, false); println!("creating wasmer memory {:?}", ty); - // let bt = backtrace::Backtrace::new(); - // println!("{:?}", bt); - Memory::Wasmer( wasmer::Memory::new(&context.store, ty) .map_err(|r| { @@ -771,8 +708,6 @@ impl Store { })? ) } - - // BackendContext::Wasmtime => todo!(), }; let mem_idx = memories.len(); @@ -876,14 +811,15 @@ impl Store { /// Instantiate a guest module and return it's index in the store. /// /// The guest module's code is specified in `wasm`. Environment that will be available to - /// guest module is specified in `guest_env`, `dispatch_thunk` is used as function that + /// guest module is specified in `guest_env`. A dispatch thunk is used as function that /// handle calls from guests. `state` is an opaque pointer to caller's arbitrary context /// normally created by `sp_sandbox::Instance` primitive. /// + /// Note: Due to borrowing constraints dispatch thunk is now propagated using DTH + /// /// Returns uninitialized sandboxed module instance or an instantiation error. pub fn instantiate<'a, FE, SCH, DTH>( &mut self, - // dispatch_thunk: FR, wasm: &[u8], guest_env: GuestEnvironment, state: u32, @@ -894,7 +830,6 @@ impl Store { SCH: SandboxCapabiliesHolder, DTH: DispatchThunkHolder, { - let memories = &mut self.memories; let backend_context = &self.backend_context; let sandbox_instance = match backend_context { @@ -932,137 +867,7 @@ impl Store { sandbox_instance } - /*BackendContext::Wasmtime => { - let mut config = wasmtime::Config::new(); - config.cranelift_opt_level(wasmtime::OptLevel::None); - config.strategy(wasmtime::Strategy::Cranelift).map_err(|_| InstantiationError::ModuleDecoding)?; - - let wasmtime_engine = wasmtime::Engine::new(&config); - let wasmtime_store = wasmtime::Store::new(&wasmtime_engine); - let wasmtime_module = wasmtime::Module::new(&wasmtime_engine, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - - let module_imports: Vec<_> = wasmtime_module - .imports() - .filter_map(|import| { - if let wasmtime::ExternType::Func(func_ty) = import.ty() { - let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { - index - } else { - // Missing import - return None; - }; - - let supervisor_func_index = guest_env.guest_to_supervisor_mapping - .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); - - // let dispatch_thunk = dispatch_thunk.clone(); - Some(wasmtime::Extern::Func(wasmtime::Func::new(&wasmtime_store, func_ty, - move |_caller, params, result| { - SCH::with_sandbox_capabilities(|supervisor_externals| { - // Serialize arguments into a byte vector. - let invoke_args_data = params - .iter() - .map(|val| match val { - Val::I32(val) => Value::I32(*val), - Val::I64(val) => Value::I64(*val), - Val::F32(val) => Value::F32(*val), - Val::F64(val) => Value::F64(*val), - _ => unimplemented!() - }) - .collect::>() - .encode(); - - // Move serialized arguments inside the memory, invoke dispatch thunk and - // then free allocated memory. - let invoke_args_len = invoke_args_data.len() as WordSize; - let invoke_args_ptr = supervisor_externals - .allocate_memory(invoke_args_len) - .map_err(|_| wasmtime::Trap::new("Can't allocate memory in supervisor for the arguments"))?; - - let deallocate = |fe: &mut FE, ptr, fail_msg| { - fe - .deallocate_memory(ptr) - .map_err(|_| wasmtime::Trap::new(fail_msg)) - }; - - if supervisor_externals - .write_memory(invoke_args_ptr, &invoke_args_data) - .is_err() - { - deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; - return Err(wasmtime::Trap::new("Can't write invoke args into memory")); - } - - let serialized_result = DTH::with_dispatch_thunk(|dispatch_thunk| { - supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) - }) - .map_err(|e| wasmtime::Trap::new(e.to_string()))?; - - // dispatch_thunk returns pointer to serialized arguments. - // Unpack pointer and len of the serialized result data. - let (serialized_result_val_ptr, serialized_result_val_len) = { - // Cast to u64 to use zero-extension. - let v = serialized_result as u64; - let ptr = (v as u64 >> 32) as u32; - let len = (v & 0xFFFFFFFF) as u32; - (Pointer::new(ptr), len) - }; - - let serialized_result_val = supervisor_externals - .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmtime::Trap::new("Can't read the serialized result from dispatch thunk")); - - let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") - .and_then(|_| serialized_result_val) - .and_then(|serialized_result_val| { - deserialize_result(&serialized_result_val) - .map_err(|e| wasmtime::Trap::new(e.to_string())) - })?; - - if let Some(value) = deserialized_result { - result[0] = match value { - RuntimeValue::I32(val) => Val::I32(val), - RuntimeValue::I64(val) => Val::I64(val), - RuntimeValue::F32(val) => Val::F32(val.into()), - RuntimeValue::F64(val) => Val::F64(val.into()), - } - } - - Ok(()) - }) - } - ))) - } else { - None - } - }) - .collect(); - - let wasmtime_instance = wasmtime::Instance::new(&wasmtime_store, &wasmtime_module, &module_imports).map_err(|error| - if let Ok(_trap) = error.downcast::() { - InstantiationError::StartTrapped - } else { - InstantiationError::Instantiation - } - )?; - - Rc::new(SandboxInstance { - backend_instance: BackendInstance::Wasmtime(wasmtime_instance), - dispatch_thunk: DTH::with_dispatch_thunk(|dispatch_thunk| dispatch_thunk.clone()), - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }) - }*/ - BackendContext::Wasmer(context) => { - // let compiler = Singlepass::default(); - // let store = wasmer::Store::new(&wasmer::JIT::new(&compiler).engine()); - println!("Decoding module..."); let module = wasmer::Module::new(&context.store, wasm).map_err(|error| { println!("{:?}", error); From ef9b9784fd01b1139d8e85a97c28c87ad904a717 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 20 May 2021 12:54:03 +0700 Subject: [PATCH 49/88] Allow wasmi to access wasmer memory regions --- client/executor/wasmi/src/lib.rs | 64 ++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 7f0c91ff9d5cf..ae675828d8d86 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -18,12 +18,8 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. -use std::{str, cell::RefCell, sync::Arc, rc::Rc}; -use wasmi::{ - Module, ModuleInstance, MemoryInstance, MemoryRef, TableRef, ImportsBuilder, ModuleRef, - FuncInstance, memory_units::Pages, - RuntimeValue::{I32, I64, self}, -}; +use std::{borrow::BorrowMut, cell::RefCell, io::Bytes, ops::{Deref, Range}, rc::Rc, slice, str, sync::Arc}; +use wasmi::{FuncInstance, ImportsBuilder, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, RuntimeValue::{I32, I64, self}, TableRef, memory_units::{self, Pages}}; use codec::{Encode, Decode}; use sp_core::sandbox as sandbox_primitives; use log::{error, trace, debug}; @@ -136,6 +132,18 @@ impl FunctionContext for FunctionExecutor { } } +// TODO Move to executor common and deduplicate code +/// Construct a range from an offset to a data length after the offset. +/// Returns None if the end of the range would exceed some maximum offset. +pub fn checked_range(offset: usize, len: usize, max: usize) -> Option> { + let end = offset.checked_add(len)?; + if end <= max { + Some(offset..end) + } else { + None + } +} + impl Sandbox for FunctionExecutor { fn memory_get( &mut self, @@ -165,7 +173,27 @@ impl Sandbox for FunctionExecutor { } sandbox::Memory::Wasmer(sandboxed_memory) => { - todo!() + let len = buf_len as usize; + + let src_range = match checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let memory_size: memory_units::Bytes = self.inner.memory.current_size().into(); + let dst_range = match checked_range(buf_ptr.into(), len, memory_size.0) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + // This is safe because we construct slice from the same parts as the memory region itself + let src_buffer = unsafe { slice::from_raw_parts(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + + self.inner.memory.with_direct_access_mut(|dst_buffer| { + dst_buffer[dst_range].copy_from_slice(&src_buffer[src_range]); + }); + + Ok(sandbox_primitives::ERR_OK) } } @@ -199,7 +227,27 @@ impl Sandbox for FunctionExecutor { } sandbox::Memory::Wasmer(sandboxed_memory) => { - todo!() + let len = val_len as usize; + + let memory_size: memory_units::Bytes = self.inner.memory.current_size().into(); + let src_range = match checked_range(val_ptr.into(), len, memory_size.0) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let dst_range = match checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + // This is safe because we construct slice from the same parts as the memory region itself + let dest_buffer = unsafe { slice::from_raw_parts_mut(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + + self.inner.memory.with_direct_access(|src_buffer| { + dest_buffer[dst_range].copy_from_slice(&src_buffer[src_range]); + }); + + Ok(sandbox_primitives::ERR_OK) } } } From 24ca76514e638db113a04e88e9b668e0b4638714 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 20 May 2021 13:14:24 +0700 Subject: [PATCH 50/88] More cleanup --- client/executor/common/src/sandbox.rs | 2 ++ client/executor/wasmi/src/lib.rs | 11 +++++------ client/executor/wasmtime/Cargo.toml | 7 ------- client/executor/wasmtime/src/host.rs | 11 ++++++----- client/executor/wasmtime/src/imports.rs | 4 ---- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 6d6c42fb62142..a80d52ab9ea52 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -622,6 +622,7 @@ pub enum Memory { } impl Memory { + /// View as wasmi memory pub fn as_wasmi(&self) -> Option { match self { Memory::Wasmi(memory) => Some(memory.clone()), @@ -629,6 +630,7 @@ impl Memory { } } + /// View as wasmer memory pub fn as_wasmer(&self) -> Option { match self { Memory::Wasmer(memory) => Some(memory.clone()), diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index ae675828d8d86..011734a3ffba6 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -18,7 +18,7 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. -use std::{borrow::BorrowMut, cell::RefCell, io::Bytes, ops::{Deref, Range}, rc::Rc, slice, str, sync::Arc}; +use std::{cell::RefCell, ops::Range, rc::Rc, slice, str, sync::Arc}; use wasmi::{FuncInstance, ImportsBuilder, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, RuntimeValue::{I32, I64, self}, TableRef, memory_units::{self, Pages}}; use codec::{Encode, Decode}; use sp_core::sandbox as sandbox_primitives; @@ -33,8 +33,6 @@ use sc_executor_common::{ sandbox, }; -// use sc_executor_common::util::{DataSegmentsSnapshot, WasmModuleInfo}; -use sandbox::SandboxBackend; use sc_executor_common::runtime_blob::{RuntimeBlob, DataSegmentsSnapshot}; #[derive(Clone)] @@ -186,7 +184,8 @@ impl Sandbox for FunctionExecutor { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // This is safe because we construct slice from the same parts as the memory region itself + // This is safe because we construct slice from the same parts as the memory region itself. + // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. let src_buffer = unsafe { slice::from_raw_parts(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; self.inner.memory.with_direct_access_mut(|dst_buffer| { @@ -240,7 +239,8 @@ impl Sandbox for FunctionExecutor { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // This is safe because we construct slice from the same parts as the memory region itself + // This is safe because we construct slice from the same parts as the memory region itself. + // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. let dest_buffer = unsafe { slice::from_raw_parts_mut(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; self.inner.memory.with_direct_access(|src_buffer| { @@ -353,7 +353,6 @@ impl Sandbox for FunctionExecutor { let store = &mut *self.inner.sandbox_store.borrow_mut(); let result = EXECUTOR.set(self, || DISPATCH_THUNK.set(&dispatch_thunk, || { store.instantiate::<_, CapsHolder, ThunkHolder>( - // dispatch_thunk, wasm, guest_env, state, diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 1c4ad8f30515e..b9f2dd1a9d92f 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -25,12 +25,5 @@ sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } wasmtime = "0.24.0" pwasm-utils = "0.14.0" -#wasmtime = "0.24" -# wasmtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master", features=["lightbeam"] } -# wasmtime-runtime = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -# wasmtime-environ = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -# cranelift-wasm = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } -# cranelift-codegen = { git = "https://github.com/Vurich/wasmtime.git", branch="master" } - [dev-dependencies] assert_matches = "1.3.0" diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index e2a264b837af2..36ffaf1571317 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -22,7 +22,7 @@ use crate::instance_wrapper::InstanceWrapper; use crate::util; use core::slice; -use std::{cell::RefCell, rc::Rc, vec::Splice}; +use std::{cell::RefCell, rc::Rc}; use log::trace; use codec::{Encode, Decode}; use sp_allocator::FreeingBumpHeapAllocator; @@ -31,7 +31,7 @@ use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; use wasmtime::{Func, Val}; -use sandbox::{SandboxBackend, SandboxCapabiliesHolder}; +use sandbox::{SandboxCapabiliesHolder}; /// Wrapper type for pointer to a Wasm table entry. /// @@ -210,7 +210,8 @@ impl Sandbox for HostState { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // TODO Proof of safety + // This is safe because we construct slice from the same parts as the memory region itself. + // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. let source = unsafe { slice::from_raw_parts(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; self.inner.instance @@ -279,7 +280,8 @@ impl Sandbox for HostState { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // TODO Proof of safety + // This is safe because we construct slice from the same parts as the memory region itself. + // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. let dest = unsafe { slice::from_raw_parts_mut(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; self.inner.instance @@ -401,7 +403,6 @@ impl Sandbox for HostState { let store = &mut *self.inner.sandbox_store.borrow_mut(); let result = DISPATCH_THUNK.set(&dispatch_thunk, || { store.instantiate::<_, CapsHolder, ThunkHolder>( - // dispatch_thunk, wasm, guest_env, state diff --git a/client/executor/wasmtime/src/imports.rs b/client/executor/wasmtime/src/imports.rs index 24859b1782a82..49cf95fff6e33 100644 --- a/client/executor/wasmtime/src/imports.rs +++ b/client/executor/wasmtime/src/imports.rs @@ -278,16 +278,12 @@ fn wasmtime_func_sig(func: &dyn Function) -> wasmtime::FuncType { .iter() .cloned() .map(into_wasmtime_val_type); - // .collect::>() - // .into_boxed_slice(); let results = signature .return_value .iter() .cloned() .map(into_wasmtime_val_type); - // .collect::>() - // .into_boxed_slice(); wasmtime::FuncType::new(params, results) } From a01fc3e25d51d849fbd8a356a950fcc6881e0922 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 20 May 2021 15:31:58 +0700 Subject: [PATCH 51/88] Remove debug logging, replace asserts with runtime errors --- client/executor/common/src/sandbox.rs | 47 +++++++-------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index a80d52ab9ea52..84d7e625a7adb 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -406,10 +406,7 @@ impl SandboxInstance { let function = wasmer_instance .exports .get_function(export_name) - .map_err(|error| { - println!("{:?}", error); - wasmi::Error::Function("wasmer function failed".to_string()) - })?; + .map_err(|error| wasmi::Error::Function("wasmer function failed".to_string()))?; let args: Vec = args .iter() @@ -424,7 +421,9 @@ impl SandboxInstance { let wasmer_result = DTH::initialize_thunk(&self.dispatch_thunk, || function.call(&args)) .map_err(|e| wasmi::Error::Function(e.to_string()))?; - assert!(wasmer_result.len() < 2, "multiple return types are not supported yet"); + if wasmer_result.len() < 2 { + return Err(wasmi::Error::Function("multiple return types are not supported yet".to_owned())); + } let wasmer_result = if let Some(wasmer_value) = wasmer_result.first() { let wasmer_value = match *wasmer_value { @@ -690,8 +689,6 @@ impl Store { let memory = match &backend_context { BackendContext::Wasmi => { - println!("creating wasmi memory {}..{}", initial, maximum.map(|v| v.to_string()).unwrap_or("?".into())); - Memory::Wasmi(MemoryInstance::alloc( Pages(initial as usize), maximum.map(|m| Pages(m as usize)), @@ -700,14 +697,9 @@ impl Store { BackendContext::Wasmer(context) => { let ty = wasmer::MemoryType::new(initial, maximum, false); - println!("creating wasmer memory {:?}", ty); - Memory::Wasmer( wasmer::Memory::new(&context.store, ty) - .map_err(|r| { - println!("Error creating wasmer Memory: {}", r.to_string()); - Error::InvalidMemoryReference - })? + .map_err(|r| Error::InvalidMemoryReference)? ) } }; @@ -738,8 +730,7 @@ impl Store { pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { let memories = &mut self.memories; let backend_context = &self.backend_context; - dbg!(initial, maximum); - dbg!(Self::allocate_memory(memories, backend_context, initial, maximum).map(|(index, _)| index)) + Self::allocate_memory(memories, backend_context, initial, maximum).map(|(index, _)| index) } /// Returns `SandboxInstance` by `instance_idx`. @@ -870,32 +861,23 @@ impl Store { } BackendContext::Wasmer(context) => { - println!("Decoding module..."); let module = wasmer::Module::new(&context.store, wasm).map_err(|error| { - println!("{:?}", error); InstantiationError::ModuleDecoding })?; - println!("Module name is {}", module.name().unwrap_or("(unknown)")); - type Exports = HashMap; let mut exports_map = Exports::new(); + // Populate exports map with module imports for import in module .imports() .into_iter() { match import.ty() { - wasmer::ExternType::Global(global) => { - println!("Importing global '{}' :: '{}' {}", import.module(), import.name(), global.to_string()); - } - - wasmer::ExternType::Table(table) => { - println!("Importing table '{}' :: '{}' {}", import.module(), import.name(), table.to_string()); - } + // Nothing to do here + wasmer::ExternType::Global(_) | wasmer::ExternType::Table(_) => (), wasmer::ExternType::Memory(memory_type) => { - println!("Importing memory '{}' :: '{}' {}", import.module(), import.name(), memory_type.to_string()); let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); let memory = guest_env.imports.memory_by_name(import.module(), import.name()).ok_or(InstantiationError::ModuleDecoding)?; @@ -903,18 +885,16 @@ impl Store { } wasmer::ExternType::Function(func_ty) => { - println!("Importing function '{}' :: '{}' {}", import.module(), import.name(), func_ty.to_string()); - let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { index } else { - // Missing import - println!("Missing import '{}' :: '{}'", import.module(), import.name()); + // Missing import (should we abort here?) continue; }; let supervisor_func_index = guest_env.guest_to_supervisor_mapping - .func_by_guest_index(guest_func_index).expect("missing guest to host mapping"); + .func_by_guest_index(guest_func_index) + .ok_or(InstantiationError::ModuleDecoding)?; let function = wasmer::Function::new(&context.store, func_ty, move |params: &[wasmer::Val]| { @@ -1011,10 +991,8 @@ impl Store { import_object.register(module_name, exports); } - println!("Instantiating module..."); let instance = wasmer::Instance::new(&module, &import_object) .map_err(|error| { - println!("{:?}", error); match error { wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, @@ -1023,7 +1001,6 @@ impl Store { } })?; - println!("Creating SandboxInstance..."); Rc::new(SandboxInstance { backend_instance: BackendInstance::Wasmer(instance), dispatch_thunk: DTH::with_dispatch_thunk(|dispatch_thunk| dispatch_thunk.clone()), From e3cf7c73ea25427cda9a273f12b907ac03e6fd7f Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 25 May 2021 16:51:04 +0700 Subject: [PATCH 52/88] Revert "Adds SandboxExecutionMethod enum for cli param" This reverts commit 5cda36eba1cefdf9230ef5eea9031da5002c900b. --- client/cli/src/arg_enums.rs | 11 ----------- client/cli/src/params/import_params.rs | 12 +----------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/client/cli/src/arg_enums.rs b/client/cli/src/arg_enums.rs index 6ca20a00132d4..fb2f8fdbc21d8 100644 --- a/client/cli/src/arg_enums.rs +++ b/client/cli/src/arg_enums.rs @@ -244,14 +244,3 @@ pub const DEFAULT_EXECUTION_BLOCK_CONSTRUCTION: ExecutionStrategy = ExecutionStr pub const DEFAULT_EXECUTION_OFFCHAIN_WORKER: ExecutionStrategy = ExecutionStrategy::Native; /// Default value for the `--execution-other` parameter. pub const DEFAULT_EXECUTION_OTHER: ExecutionStrategy = ExecutionStrategy::Native; - -arg_enum! { - /// How to execute wasm in a sandboxed environment - #[derive(Debug, Clone, Copy, PartialEq, Eq)] - pub enum SandboxExecutionMethod { - // Uses an interpreter. - Interpreted, - // Uses a compiled runtime. - Compiled, - } -} diff --git a/client/cli/src/params/import_params.rs b/client/cli/src/params/import_params.rs index c099497c77a0b..a62ec98a97029 100644 --- a/client/cli/src/params/import_params.rs +++ b/client/cli/src/params/import_params.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use crate::arg_enums::{ - ExecutionStrategy, WasmExecutionMethod, SandboxExecutionMethod, DEFAULT_EXECUTION_BLOCK_CONSTRUCTION, + ExecutionStrategy, WasmExecutionMethod, DEFAULT_EXECUTION_BLOCK_CONSTRUCTION, DEFAULT_EXECUTION_IMPORT_BLOCK, DEFAULT_EXECUTION_IMPORT_BLOCK_VALIDATOR, DEFAULT_EXECUTION_OFFCHAIN_WORKER, DEFAULT_EXECUTION_OTHER, DEFAULT_EXECUTION_SYNCING, }; @@ -62,16 +62,6 @@ pub struct ImportParams { )] pub wasm_method: WasmExecutionMethod, - /// Method for executing Wasm in a sandbox environment - #[structopt( - long = "sandbox-execution", - value_name = "METHOD", - possible_values = &SandboxExecutionMethod::variants(), - case_insensitive = true, - default_value = "Interpreted" - )] - pub sandbox_method: SandboxExecutionMethod, - /// Specify the path where local WASM runtimes are stored. /// /// These runtimes will override on-chain runtimes when the version matches. From cc4c27e9ea9e87a7d479afd59966a23305e852f6 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 25 May 2021 16:57:39 +0700 Subject: [PATCH 53/88] Fixes warnings --- client/executor/common/src/sandbox.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 84d7e625a7adb..338d73b560458 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -406,7 +406,7 @@ impl SandboxInstance { let function = wasmer_instance .exports .get_function(export_name) - .map_err(|error| wasmi::Error::Function("wasmer function failed".to_string()))?; + .map_err(|error| wasmi::Error::Function(error.to_string()))?; let args: Vec = args .iter() @@ -419,7 +419,7 @@ impl SandboxInstance { .collect(); let wasmer_result = DTH::initialize_thunk(&self.dispatch_thunk, || function.call(&args)) - .map_err(|e| wasmi::Error::Function(e.to_string()))?; + .map_err(|error| wasmi::Error::Function(error.to_string()))?; if wasmer_result.len() < 2 { return Err(wasmi::Error::Function("multiple return types are not supported yet".to_owned())); @@ -699,7 +699,7 @@ impl Store { let ty = wasmer::MemoryType::new(initial, maximum, false); Memory::Wasmer( wasmer::Memory::new(&context.store, ty) - .map_err(|r| Error::InvalidMemoryReference)? + .map_err(|_| Error::InvalidMemoryReference)? ) } }; @@ -861,7 +861,7 @@ impl Store { } BackendContext::Wasmer(context) => { - let module = wasmer::Module::new(&context.store, wasm).map_err(|error| { + let module = wasmer::Module::new(&context.store, wasm).map_err(|_| { InstantiationError::ModuleDecoding })?; @@ -877,7 +877,7 @@ impl Store { // Nothing to do here wasmer::ExternType::Global(_) | wasmer::ExternType::Table(_) => (), - wasmer::ExternType::Memory(memory_type) => { + wasmer::ExternType::Memory(_) => { let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); let memory = guest_env.imports.memory_by_name(import.module(), import.name()).ok_or(InstantiationError::ModuleDecoding)?; From e246b62928128ac840429891c19181e310a2612f Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 25 May 2021 17:36:52 +0700 Subject: [PATCH 54/88] Fixes indentation and line width --- client/executor/common/src/sandbox.rs | 74 +++++++++++++++++++-------- client/executor/wasmi/src/lib.rs | 25 ++++++--- client/executor/wasmtime/src/host.rs | 20 +++++--- 3 files changed, 85 insertions(+), 34 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 338d73b560458..8746edaa2ebeb 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -18,15 +18,16 @@ //! This module implements sandboxing support in the runtime. //! -//! Sandboxing is baked by wasmi at the moment. In future, however, we would like to add/switch to -//! a compiled execution engine. +//! Sandboxing is baked by wasmi and wasmer, depending on the configuration. use crate::error::{Result, Error}; use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; - -use wasmi::{Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages}; +use wasmi::{ + Externals, ImportResolver, MemoryInstance, MemoryRef, Module, + ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages +}; use sp_wasm_interface::{Value, FunctionContext, Pointer, WordSize}; use wasmer_compiler_singlepass::Singlepass; @@ -246,9 +247,9 @@ impl<'a, FE: SandboxCapabilities + 'a> Externals for GuestExternals<'a, FE> { .func_by_guest_index(index) .expect( "`invoke_index` is called with indexes registered via `FuncInstance::alloc_host`; - `FuncInstance::alloc_host` is called with indexes that was obtained from `guest_to_supervisor_mapping`; - `func_by_guest_index` called with `index` can't return `None`; - qed" + `FuncInstance::alloc_host` is called with indexes that were obtained from `guest_to_supervisor_mapping`; + `func_by_guest_index` called with `index` can't return `None`; + qed" ); // Serialize arguments into a byte vector. @@ -422,7 +423,9 @@ impl SandboxInstance { .map_err(|error| wasmi::Error::Function(error.to_string()))?; if wasmer_result.len() < 2 { - return Err(wasmi::Error::Function("multiple return types are not supported yet".to_owned())); + return Err(wasmi::Error::Function( + "multiple return types are not supported yet".to_owned()) + ); } let wasmer_result = if let Some(wasmer_value) = wasmer_result.first() { @@ -681,7 +684,12 @@ pub struct Store { } impl Store { - fn allocate_memory(memories: &mut Vec>, backend_context: &BackendContext, initial: u32, maximum: u32) -> Result<(u32, Memory)> { + fn allocate_memory( + memories: &mut Vec>, + backend_context: &BackendContext, + initial: u32, + maximum: u32 + ) -> Result<(u32, Memory)> { let maximum = match maximum { sandbox_primitives::MEM_UNLIMITED => None, specified_limit => Some(specified_limit), @@ -878,14 +886,21 @@ impl Store { wasmer::ExternType::Global(_) | wasmer::ExternType::Table(_) => (), wasmer::ExternType::Memory(_) => { - let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); - let memory = guest_env.imports.memory_by_name(import.module(), import.name()).ok_or(InstantiationError::ModuleDecoding)?; + let exports = exports_map + .entry(import.module().to_string()) + .or_insert(wasmer::Exports::new()); + + let memory = guest_env.imports.memory_by_name( + import.module(), + import.name() + ).ok_or(InstantiationError::ModuleDecoding)?; exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); } wasmer::ExternType::Function(func_ty) => { - let guest_func_index = if let Some(index) = guest_env.imports.func_by_name(import.module(), import.name()) { + let guest_func_index = guest_env.imports.func_by_name(import.module(), import.name()); + let guest_func_index = if let Some(index) = guest_func_index { index } else { // Missing import (should we abort here?) @@ -896,8 +911,7 @@ impl Store { .func_by_guest_index(guest_func_index) .ok_or(InstantiationError::ModuleDecoding)?; - let function = wasmer::Function::new(&context.store, func_ty, move |params: &[wasmer::Val]| { - + let function = wasmer::Function::new(&context.store, func_ty, move |params| { SCH::with_sandbox_capabilities(|supervisor_externals| { // Serialize arguments into a byte vector. let invoke_args_data = params @@ -917,7 +931,9 @@ impl Store { let invoke_args_len = invoke_args_data.len() as WordSize; let invoke_args_ptr = supervisor_externals .allocate_memory(invoke_args_len) - .map_err(|_| wasmer::RuntimeError::new("Can't allocate memory in supervisor for the arguments"))?; + .map_err(|_| wasmer::RuntimeError::new( + "Can't allocate memory in supervisor for the arguments") + )?; let deallocate = |fe: &mut FE, ptr, fail_msg| { fe @@ -929,7 +945,12 @@ impl Store { .write_memory(invoke_args_ptr, &invoke_args_data) .is_err() { - deallocate(supervisor_externals, invoke_args_ptr, "Failed dealloction after failed write of invoke arguments")?; + deallocate( + supervisor_externals, + invoke_args_ptr, + "Failed dealloction after failed write of invoke arguments" + )?; + return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); } @@ -955,9 +976,15 @@ impl Store { let serialized_result_val = supervisor_externals .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmer::RuntimeError::new("Can't read the serialized result from dispatch thunk")); - - let deserialized_result = deallocate(supervisor_externals, serialized_result_val_ptr, "Can't deallocate memory for dispatch thunk's result") + .map_err(|_| wasmer::RuntimeError::new( + "Can't read the serialized result from dispatch thunk") + ); + + let deserialized_result = deallocate( + supervisor_externals, + serialized_result_val_ptr, + "Can't deallocate memory for dispatch thunk's result" + ) .and_then(|_| serialized_result_val) .and_then(|serialized_result_val| { deserialize_result(&serialized_result_val) @@ -979,7 +1006,10 @@ impl Store { }) }); - let exports = exports_map.entry(import.module().to_string()).or_insert(wasmer::Exports::new()); + let exports = exports_map + .entry(import.module().to_string()) + .or_insert(wasmer::Exports::new()); + exports.insert(import.name(), wasmer::Extern::Function(function)); } } @@ -997,7 +1027,9 @@ impl Store { match error { wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, - wasmer::InstantiationError::HostEnvInitialization(_) => InstantiationError::EnvironmentDefinitionCorrupted, + wasmer::InstantiationError::HostEnvInitialization(_) => { + InstantiationError::EnvironmentDefinitionCorrupted + } } })?; diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 99f1ac3450bc7..c0bfd8441b01d 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -19,7 +19,10 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. use std::{cell::RefCell, ops::Range, rc::Rc, slice, str, sync::Arc}; -use wasmi::{FuncInstance, ImportsBuilder, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, RuntimeValue::{I32, I64, self}, TableRef, memory_units::{self, Pages}}; +use wasmi::{ + FuncInstance, ImportsBuilder, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, + RuntimeValue::{I32, I64, self}, TableRef, memory_units::{self, Pages} +}; use codec::{Encode, Decode}; use sp_core::sandbox as sandbox_primitives; use log::{error, trace, debug}; @@ -184,9 +187,13 @@ impl Sandbox for FunctionExecutor { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // This is safe because we construct slice from the same parts as the memory region itself. - // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. - let src_buffer = unsafe { slice::from_raw_parts(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + // This is safe because we construct slice from the same parts as + // the memory region itself. Current implementation is single threaded, + // so we should not face any synchronization or aliasing issues. + let src_buffer = unsafe { slice::from_raw_parts( + sandboxed_memory.data_ptr(), + sandboxed_memory.data_size() as usize) + }; self.inner.memory.with_direct_access_mut(|dst_buffer| { dst_buffer[dst_range].copy_from_slice(&src_buffer[src_range]); @@ -239,9 +246,13 @@ impl Sandbox for FunctionExecutor { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // This is safe because we construct slice from the same parts as the memory region itself. - // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. - let dest_buffer = unsafe { slice::from_raw_parts_mut(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + // This is safe because we construct slice from the same parts as + // the memory region itself. Current implementation is single threaded, + // so we should not face any synchronization or aliasing issues. + let dest_buffer = unsafe { slice::from_raw_parts_mut( + sandboxed_memory.data_ptr(), + sandboxed_memory.data_size() as usize) + }; self.inner.memory.with_direct_access(|src_buffer| { dest_buffer[dst_range].copy_from_slice(&src_buffer[src_range]); diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 36ffaf1571317..767f17de5b783 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -210,9 +210,13 @@ impl Sandbox for HostState { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // This is safe because we construct slice from the same parts as the memory region itself. - // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. - let source = unsafe { slice::from_raw_parts(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + // This is safe because we construct slice from the same parts as + // the memory region itself. Current implementation is single threaded, + // so we should not face any synchronization or aliasing issues. + let source = unsafe { slice::from_raw_parts( + sandboxed_memory.data_ptr(), + sandboxed_memory.data_size() as usize) + }; self.inner.instance .write_memory_from( @@ -280,9 +284,13 @@ impl Sandbox for HostState { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - // This is safe because we construct slice from the same parts as the memory region itself. - // Current implementation is single threaded, so we should not face any synchronization or aliasing issues. - let dest = unsafe { slice::from_raw_parts_mut(sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; + // This is safe because we construct slice from the same parts as + // the memory region itself. Current implementation is single threaded, + // so we should not face any synchronization or aliasing issues. + let dest = unsafe { slice::from_raw_parts_mut( + sandboxed_memory.data_ptr(), + sandboxed_memory.data_size() as usize) + }; self.inner.instance .read_memory_into( From 4211ad7dbc0cf5c77bc22a7477c0735211632acf Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 1 Jun 2021 21:52:10 +0700 Subject: [PATCH 55/88] Fix return types condition --- client/executor/common/src/sandbox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 8746edaa2ebeb..953bec4024ddb 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -422,7 +422,7 @@ impl SandboxInstance { let wasmer_result = DTH::initialize_thunk(&self.dispatch_thunk, || function.call(&args)) .map_err(|error| wasmi::Error::Function(error.to_string()))?; - if wasmer_result.len() < 2 { + if wasmer_result.len() > 1 { return Err(wasmi::Error::Function( "multiple return types are not supported yet".to_owned()) ); From 6b420635bb8b80d0f469a47e2c776786701696d5 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 2 Jun 2021 22:38:23 +0700 Subject: [PATCH 56/88] Puts everything related under the `wasmer-sandbox` feature flag --- Cargo.lock | 10 ++++++---- client/executor/common/Cargo.toml | 8 ++++---- client/executor/common/src/sandbox.rs | 14 ++++++++++++-- client/executor/wasmi/src/lib.rs | 2 ++ client/executor/wasmtime/Cargo.toml | 3 +++ client/executor/wasmtime/src/host.rs | 12 ++++++++++-- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75295919c05cf..1641b17eca894 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "Inflector" version = "0.11.4" @@ -1564,9 +1566,9 @@ checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" [[package]] name = "dynasm" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7d1242462849390bb2ad38aeed769499f1afc7383affa2ab0c1baa894c0200" +checksum = "cdc2d9a5e44da60059bd38db2d05cbb478619541b8c79890547861ec1e3194f0" dependencies = [ "bitflags", "byteorder", @@ -1579,9 +1581,9 @@ dependencies = [ [[package]] name = "dynasmrt" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dd4d1d5ca12258cef339a57a7643e8b233a42dea9bb849630ddd9dd7726aa9" +checksum = "42276e3f205fe63887cca255aa9a65a63fb72764c30b9a6252a7c7e46994f689" dependencies = [ "byteorder", "dynasm", diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index 6a2814714ec5a..84c46ae99fc67 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -23,11 +23,11 @@ sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } sp-wasm-interface = { version = "3.0.0", path = "../../../primitives/wasm-interface" } sp-maybe-compressed-blob = { version = "3.0.0", path = "../../../primitives/maybe-compressed-blob" } sp-serializer = { version = "3.0.0", path = "../../../primitives/serializer" } - -wasmer = "1.0" -wasmer-compiler-singlepass = "1.0" - thiserror = "1.0.21" +wasmer = { version = "1.0", optional = true } +wasmer-compiler-singlepass = { version = "1.0", optional = true } + [features] default = [] +wasmer-sandbox = [ "wasmer", "wasmer-compiler-singlepass" ] diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 953bec4024ddb..de1bb7b6a8466 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -29,7 +29,6 @@ use wasmi::{ ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages }; use sp_wasm_interface::{Value, FunctionContext, Pointer, WordSize}; -use wasmer_compiler_singlepass::Singlepass; /// Index of a function inside the supervisor. /// @@ -341,6 +340,7 @@ enum BackendInstance { Wasmi(wasmi::ModuleRef), /// Wasmer module instance + #[cfg(feature = "wasmer-sandbox")] Wasmer(wasmer::Instance), } @@ -403,6 +403,7 @@ impl SandboxInstance { Ok(wasmi_result) } + #[cfg(feature = "wasmer-sandbox")] BackendInstance::Wasmer(wasmer_instance) => { let function = wasmer_instance .exports @@ -464,6 +465,7 @@ impl SandboxInstance { Some(wasmi_global.into()) } + #[cfg(feature = "wasmer-sandbox")] BackendInstance::Wasmer(wasmer_instance) => { let global = wasmer_instance.exports.get_global(name).ok()?; let wasmtime_value = match global.get() { @@ -610,6 +612,7 @@ pub enum SandboxBackend { Wasmi, /// Wasmer environment + #[cfg(feature = "wasmer-sandbox")] Wasmer, } @@ -620,6 +623,7 @@ pub enum Memory { Wasmi(MemoryRef), /// Wasmer memory refernce + #[cfg(feature = "wasmer-sandbox")] Wasmer(wasmer::Memory), } @@ -633,6 +637,7 @@ impl Memory { } /// View as wasmer memory + #[cfg(feature = "wasmer-sandbox")] pub fn as_wasmer(&self) -> Option { match self { Memory::Wasmer(memory) => Some(memory.clone()), @@ -642,6 +647,7 @@ impl Memory { } /// Wasmer specific context +#[cfg(feature = "wasmer-sandbox")] struct WasmerBackend { store: wasmer::Store, } @@ -652,6 +658,7 @@ enum BackendContext { Wasmi, /// Wasmer specific context + #[cfg(feature = "wasmer-sandbox")] Wasmer(WasmerBackend), } @@ -660,8 +667,9 @@ impl BackendContext { match backend { SandboxBackend::Wasmi => BackendContext::Wasmi, + #[cfg(feature = "wasmer-sandbox")] SandboxBackend::Wasmer => { - let compiler = Singlepass::default(); + let compiler = wasmer_compiler_singlepass::Singlepass::default(); BackendContext::Wasmer( WasmerBackend { @@ -703,6 +711,7 @@ impl Store { )?) } + #[cfg(feature = "wasmer-sandbox")] BackendContext::Wasmer(context) => { let ty = wasmer::MemoryType::new(initial, maximum, false); Memory::Wasmer( @@ -868,6 +877,7 @@ impl Store { sandbox_instance } + #[cfg(feature = "wasmer-sandbox")] BackendContext::Wasmer(context) => { let module = wasmer::Module::new(&context.store, wasm).map_err(|_| { InstantiationError::ModuleDecoding diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index c0bfd8441b01d..d7e6e743c98b3 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -173,6 +173,7 @@ impl Sandbox for FunctionExecutor { } } + #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { let len = buf_len as usize; @@ -232,6 +233,7 @@ impl Sandbox for FunctionExecutor { } } + #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { let len = val_len as usize; diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 4583c1ab82027..4ea5f69ff19e0 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -26,3 +26,6 @@ wasmtime = "0.24.0" [dev-dependencies] assert_matches = "1.3.0" + +[features] +wasmer-sandbox = [] diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 767f17de5b783..999de815a8d17 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -31,7 +31,7 @@ use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; use wasmtime::{Func, Val}; -use sandbox::{SandboxCapabiliesHolder}; +use sandbox::SandboxCapabiliesHolder; /// Wrapper type for pointer to a Wasm table entry. /// @@ -66,9 +66,15 @@ struct Inner { impl HostState { /// Constructs a new `HostState`. pub fn new(allocator: FreeingBumpHeapAllocator, instance: Rc) -> Self { + #[cfg(feature = "wasmer-sandbox")] + let backend = sandbox::SandboxBackend::Wasmer; + + #[cfg(not(feature = "wasmer-sandbox"))] + let backend = sandbox::SandboxBackend::Wasmi; + HostState { inner: Rc::new(Inner { - sandbox_store: RefCell::new(sandbox::Store::new(sandbox::SandboxBackend::Wasmer)), + sandbox_store: RefCell::new(sandbox::Store::new(backend)), allocator: RefCell::new(allocator), instance, }) @@ -196,6 +202,7 @@ impl Sandbox for HostState { }) }, + #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { let len = buf_len as usize; @@ -270,6 +277,7 @@ impl Sandbox for HostState { }) } + #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { let len = val_len as usize; let supervisor_mem_size = self.inner.instance.memory_size() as usize; From 7807a2b8071ef05b82a82b04a3c3efda2e4c4ef7 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 3 Jun 2021 16:44:28 +0700 Subject: [PATCH 57/88] Fixes warnings --- client/executor/common/src/sandbox.rs | 11 ++++++++++- client/executor/wasmi/Cargo.toml | 3 +++ client/executor/wasmi/src/lib.rs | 12 ++++++------ client/executor/wasmtime/src/host.rs | 5 ++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index de1bb7b6a8466..1cf3c91bc048d 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -28,7 +28,7 @@ use wasmi::{ Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages }; -use sp_wasm_interface::{Value, FunctionContext, Pointer, WordSize}; +use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; /// Index of a function inside the supervisor. /// @@ -86,6 +86,7 @@ struct Imports { memories_map: HashMap<(Vec, Vec), Memory>, } +#[cfg(feature = "wasmer-sandbox")] impl Imports { fn func_by_name(&self, module_name: &str, func_name: &str) -> Option { self.func_map.get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())).cloned() @@ -467,6 +468,8 @@ impl SandboxInstance { #[cfg(feature = "wasmer-sandbox")] BackendInstance::Wasmer(wasmer_instance) => { + use sp_wasm_interface::Value; + let global = wasmer_instance.exports.get_global(name).ok()?; let wasmtime_value = match global.get() { wasmer::Val::I32(val) => Value::I32(val), @@ -632,6 +635,8 @@ impl Memory { pub fn as_wasmi(&self) -> Option { match self { Memory::Wasmi(memory) => Some(memory.clone()), + + #[allow(unreachable_patterns)] _ => None, } } @@ -641,6 +646,8 @@ impl Memory { pub fn as_wasmer(&self) -> Option { match self { Memory::Wasmer(memory) => Some(memory.clone()), + + #[allow(unreachable_patterns)] _ => None, } } @@ -923,6 +930,8 @@ impl Store { let function = wasmer::Function::new(&context.store, func_ty, move |params| { SCH::with_sandbox_capabilities(|supervisor_externals| { + use sp_wasm_interface::Value; + // Serialize arguments into a byte vector. let invoke_args_data = params .iter() diff --git a/client/executor/wasmi/Cargo.toml b/client/executor/wasmi/Cargo.toml index 49f8eda39cce0..2cfb01b9b5c02 100644 --- a/client/executor/wasmi/Cargo.toml +++ b/client/executor/wasmi/Cargo.toml @@ -23,3 +23,6 @@ sp-runtime-interface = { version = "3.0.0", path = "../../../primitives/runtime- sp-core = { version = "3.0.0", path = "../../../primitives/core" } sp-allocator = { version = "3.0.0", path = "../../../primitives/allocator" } scoped-tls = "1.0" + +[features] +wasmer-sandbox = [] diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index d7e6e743c98b3..6e091692e9e2f 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -18,10 +18,10 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. -use std::{cell::RefCell, ops::Range, rc::Rc, slice, str, sync::Arc}; +use std::{cell::RefCell, ops::Range, rc::Rc, str, sync::Arc}; use wasmi::{ FuncInstance, ImportsBuilder, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, - RuntimeValue::{I32, I64, self}, TableRef, memory_units::{self, Pages} + RuntimeValue::{I32, I64, self}, TableRef, memory_units::Pages, }; use codec::{Encode, Decode}; use sp_core::sandbox as sandbox_primitives; @@ -182,7 +182,7 @@ impl Sandbox for FunctionExecutor { None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), }; - let memory_size: memory_units::Bytes = self.inner.memory.current_size().into(); + let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); let dst_range = match checked_range(buf_ptr.into(), len, memory_size.0) { Some(range) => range, None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), @@ -191,7 +191,7 @@ impl Sandbox for FunctionExecutor { // This is safe because we construct slice from the same parts as // the memory region itself. Current implementation is single threaded, // so we should not face any synchronization or aliasing issues. - let src_buffer = unsafe { slice::from_raw_parts( + let src_buffer = unsafe { core::slice::from_raw_parts( sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; @@ -237,7 +237,7 @@ impl Sandbox for FunctionExecutor { sandbox::Memory::Wasmer(sandboxed_memory) => { let len = val_len as usize; - let memory_size: memory_units::Bytes = self.inner.memory.current_size().into(); + let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); let src_range = match checked_range(val_ptr.into(), len, memory_size.0) { Some(range) => range, None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), @@ -251,7 +251,7 @@ impl Sandbox for FunctionExecutor { // This is safe because we construct slice from the same parts as // the memory region itself. Current implementation is single threaded, // so we should not face any synchronization or aliasing issues. - let dest_buffer = unsafe { slice::from_raw_parts_mut( + let dest_buffer = unsafe { core::slice::from_raw_parts_mut( sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 999de815a8d17..17aab1d303d3a 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -21,7 +21,6 @@ use crate::instance_wrapper::InstanceWrapper; use crate::util; -use core::slice; use std::{cell::RefCell, rc::Rc}; use log::trace; use codec::{Encode, Decode}; @@ -220,7 +219,7 @@ impl Sandbox for HostState { // This is safe because we construct slice from the same parts as // the memory region itself. Current implementation is single threaded, // so we should not face any synchronization or aliasing issues. - let source = unsafe { slice::from_raw_parts( + let source = unsafe { core::slice::from_raw_parts( sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; @@ -295,7 +294,7 @@ impl Sandbox for HostState { // This is safe because we construct slice from the same parts as // the memory region itself. Current implementation is single threaded, // so we should not face any synchronization or aliasing issues. - let dest = unsafe { slice::from_raw_parts_mut( + let dest = unsafe { core::slice::from_raw_parts_mut( sandboxed_memory.data_ptr(), sandboxed_memory.data_size() as usize) }; From 8c8c2c83327336a18aaf2f4333aeab7d5cede97f Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 8 Jun 2021 16:04:18 +0700 Subject: [PATCH 58/88] Address grumbles --- client/executor/common/src/sandbox.rs | 18 ++++++++---------- client/executor/wasmi/src/lib.rs | 6 ++---- client/executor/wasmtime/src/host.rs | 6 ++---- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 1cf3c91bc048d..e5d2fa0eecbce 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -52,7 +52,7 @@ struct GuestFuncIndex(usize); /// This struct holds a mapping from guest index space to supervisor. struct GuestToSupervisorFunctionMapping { /// Position of elements in this vector are interpreted - /// as indices of guest functions and are mappeed to + /// as indices of guest functions and are mapped to /// corresponding supervisor function indices. funcs: Vec, } @@ -207,7 +207,7 @@ pub struct GuestExternals<'a, FE: SandboxCapabilities + 'a> { /// Instance of sandboxed module to be dispatched sandbox_instance: &'a SandboxInstance, - /// Opaque pointer to outer context, see the `instantiate` function + /// External state passed to guest environment, see the `instantiate` function state: u32, } @@ -387,7 +387,7 @@ impl SandboxInstance { ) -> std::result::Result, wasmi::Error> where FE: SandboxCapabilities + 'a, - SCH: SandboxCapabiliesHolder, + SCH: SandboxCapabilitiesHolder, DTH: DispatchThunkHolder, { SCH::with_sandbox_capabilities( |supervisor_externals| { @@ -584,7 +584,7 @@ impl UnregisteredInstance { } /// Helper type to provide sandbox capabilities to the inner context -pub trait SandboxCapabiliesHolder { +pub trait SandboxCapabilitiesHolder { /// Supervisor function reference type SupervisorFuncRef; @@ -636,8 +636,8 @@ impl Memory { match self { Memory::Wasmi(memory) => Some(memory.clone()), - #[allow(unreachable_patterns)] - _ => None, + #[cfg(feature = "wasmer-sandbox")] + Memory::Wasmer(_) => None, } } @@ -646,9 +646,7 @@ impl Memory { pub fn as_wasmer(&self) -> Option { match self { Memory::Wasmer(memory) => Some(memory.clone()), - - #[allow(unreachable_patterns)] - _ => None, + Memory::Wasmi(_) => None, } } } @@ -844,7 +842,7 @@ impl Store { where FR: Clone + 'static, FE: SandboxCapabilities + 'a, - SCH: SandboxCapabiliesHolder, + SCH: SandboxCapabilitiesHolder, DTH: DispatchThunkHolder, { let backend_context = &self.backend_context; diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 6e091692e9e2f..672f33d93f851 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -361,8 +361,6 @@ impl Sandbox for FunctionExecutor { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; - println!("Instantiating sandbox from wasmi"); - let store = &mut *self.inner.sandbox_store.borrow_mut(); let result = EXECUTOR.set(self, || DISPATCH_THUNK.set(&dispatch_thunk, || { store.instantiate::<_, CapsHolder, ThunkHolder>( @@ -404,7 +402,7 @@ struct CapsHolder; scoped_tls::scoped_thread_local!(static EXECUTOR: FunctionExecutor); -impl sandbox::SandboxCapabiliesHolder for CapsHolder { +impl sandbox::SandboxCapabilitiesHolder for CapsHolder { type SupervisorFuncRef = wasmi::FuncRef; type SC = FunctionExecutor; @@ -855,7 +853,7 @@ pub struct WasmiInstance { missing_functions: Arc>, } -// This is safe because `WasmiInstance` does not leak any references to `self.inner.memory` and `self.instance` +// This is safe because `WasmiInstance` does not leak any references to `self.memory` and `self.instance` unsafe impl Send for WasmiInstance {} impl WasmInstance for WasmiInstance { diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 17aab1d303d3a..51b9f3f2a3314 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -30,7 +30,7 @@ use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; use wasmtime::{Func, Val}; -use sandbox::SandboxCapabiliesHolder; +use sandbox::SandboxCapabilitiesHolder; /// Wrapper type for pointer to a Wasm table entry. /// @@ -413,8 +413,6 @@ impl Sandbox for HostState { Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; - println!("Instantiating sandbox from host"); - let store = &mut *self.inner.sandbox_store.borrow_mut(); let result = DISPATCH_THUNK.set(&dispatch_thunk, || { store.instantiate::<_, CapsHolder, ThunkHolder>( @@ -449,7 +447,7 @@ impl Sandbox for HostState { struct CapsHolder; -impl SandboxCapabiliesHolder for CapsHolder { +impl SandboxCapabilitiesHolder for CapsHolder { type SupervisorFuncRef = SupervisorFuncRef; type SC = HostState; From 3d3c827a5cac2bbde6ebfbd4eacff3fcd63c0e3e Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 16 Jun 2021 17:30:32 +0700 Subject: [PATCH 59/88] Split instantiate per backend --- client/executor/common/src/sandbox.rs | 436 ++++++++++++++------------ 1 file changed, 232 insertions(+), 204 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index e5d2fa0eecbce..169321917f36b 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -823,6 +823,231 @@ impl Store { instance_idx as u32 } + fn instantiate_wasmi<'a, FE, SCH, DTH>( + wasm: &[u8], + guest_env: GuestEnvironment, + state: u32 + ) -> std::result::Result>, InstantiationError> + where + FR: Clone + 'static, + FE: SandboxCapabilities + 'a, + SCH: SandboxCapabilitiesHolder, + DTH: DispatchThunkHolder, + { + let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) + .map_err(|_| InstantiationError::Instantiation)?; + + let sandbox_instance = DTH::with_dispatch_thunk(|dispatch_thunk| { + Rc::new(SandboxInstance { + // In general, it's not a very good idea to use `.not_started_instance()` for anything + // but for extracting memory and tables. But in this particular case, we are extracting + // for the purpose of running `start` function which should be ok. + backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), + dispatch_thunk: dispatch_thunk.clone(), + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }) + }); + + SCH::with_sandbox_capabilities( |supervisor_externals| { + with_guest_externals( + supervisor_externals, + &sandbox_instance, + state, + |guest_externals| { + wasmi_instance + .run_start(guest_externals) + .map_err(|_| InstantiationError::StartTrapped) + + // Note: no need to run start on wasmtime instance, since it's done automatically + }, + ) + })?; + + Ok(sandbox_instance) + } + + #[cfg(feature = "wasmer-sandbox")] + fn instantiate_wasmer<'a, FE, SCH, DTH>( + context: &WasmerBackend, + wasm: &[u8], + guest_env: GuestEnvironment, + state: u32 + ) -> std::result::Result>, InstantiationError> + where + FR: Clone + 'static, + FE: SandboxCapabilities + 'a, + SCH: SandboxCapabilitiesHolder, + DTH: DispatchThunkHolder, + { + let module = wasmer::Module::new(&context.store, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + + type Exports = HashMap; + let mut exports_map = Exports::new(); + + for import in module.imports().into_iter() { + match import.ty() { + // Nothing to do here + wasmer::ExternType::Global(_) | wasmer::ExternType::Table(_) => (), + + wasmer::ExternType::Memory(_) => { + let exports = exports_map + .entry(import.module().to_string()) + .or_insert(wasmer::Exports::new()); + + let memory = guest_env.imports.memory_by_name( + import.module(), + import.name() + ).ok_or(InstantiationError::ModuleDecoding)?; + + exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); + } + + wasmer::ExternType::Function(func_ty) => { + let guest_func_index = guest_env.imports.func_by_name(import.module(), import.name()); + + let guest_func_index = if let Some(index) = guest_func_index { + index + } else { + // Missing import (should we abort here?) + continue; + }; + + let supervisor_func_index = guest_env.guest_to_supervisor_mapping + .func_by_guest_index(guest_func_index) + .ok_or(InstantiationError::ModuleDecoding)?; + + let function = wasmer::Function::new(&context.store, func_ty, move |params| { + SCH::with_sandbox_capabilities(|supervisor_externals| { + use sp_wasm_interface::Value; + + // Serialize arguments into a byte vector. + let invoke_args_data = params + .iter() + .map(|val| match val { + wasmer::Val::I32(val) => Value::I32(*val), + wasmer::Val::I64(val) => Value::I64(*val), + wasmer::Val::F32(val) => Value::F32(f32::to_bits(*val)), + wasmer::Val::F64(val) => Value::F64(f64::to_bits(*val)), + _ => unimplemented!() + }) + .collect::>() + .encode(); + + // Move serialized arguments inside the memory, invoke dispatch thunk and + // then free allocated memory. + let invoke_args_len = invoke_args_data.len() as WordSize; + let invoke_args_ptr = supervisor_externals + .allocate_memory(invoke_args_len) + .map_err(|_| wasmer::RuntimeError::new( + "Can't allocate memory in supervisor for the arguments") + )?; + + let deallocate = |fe: &mut FE, ptr, fail_msg| { + fe + .deallocate_memory(ptr) + .map_err(|_| wasmer::RuntimeError::new(fail_msg)) + }; + + if supervisor_externals + .write_memory(invoke_args_ptr, &invoke_args_data) + .is_err() + { + deallocate( + supervisor_externals, + invoke_args_ptr, + "Failed dealloction after failed write of invoke arguments" + )?; + + return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); + } + + // Perform the actuall call + let serialized_result = DTH::with_dispatch_thunk(|dispatch_thunk| { + supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + }).map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; + + // dispatch_thunk returns pointer to serialized arguments. + // Unpack pointer and len of the serialized result data. + let (serialized_result_val_ptr, serialized_result_val_len) = { + // Cast to u64 to use zero-extension. + let v = serialized_result as u64; + let ptr = (v as u64 >> 32) as u32; + let len = (v & 0xFFFFFFFF) as u32; + (Pointer::new(ptr), len) + }; + + let serialized_result_val = supervisor_externals + .read_memory(serialized_result_val_ptr, serialized_result_val_len) + .map_err(|_| wasmer::RuntimeError::new( + "Can't read the serialized result from dispatch thunk") + ); + + let deserialized_result = deallocate( + supervisor_externals, + serialized_result_val_ptr, + "Can't deallocate memory for dispatch thunk's result" + ) + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmer::RuntimeError::new(e.to_string())) + })?; + + if let Some(value) = deserialized_result { + Ok(vec![ + match value { + RuntimeValue::I32(val) => wasmer::Val::I32(val), + RuntimeValue::I64(val) => wasmer::Val::I64(val), + RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), + RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), + } + ]) + } else { + Ok(vec![]) + } + }) + }); + + let exports = exports_map + .entry(import.module().to_string()) + .or_insert(wasmer::Exports::new()); + + exports.insert(import.name(), wasmer::Extern::Function(function)); + } + } + } + + let mut import_object = wasmer::ImportObject::new(); + for (module_name, exports) in exports_map.into_iter() { + import_object.register(module_name, exports); + } + + let instance = wasmer::Instance::new(&module, &import_object) + .map_err(|error| { + match error { + wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, + wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, + wasmer::InstantiationError::HostEnvInitialization(_) => { + InstantiationError::EnvironmentDefinitionCorrupted + } + } + })?; + + Ok(Rc::new(SandboxInstance { + backend_instance: BackendInstance::Wasmer(instance), + dispatch_thunk: DTH::with_dispatch_thunk(|dispatch_thunk| dispatch_thunk.clone()), + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + })) + } + + /// Instantiate a guest module and return it's index in the store. /// /// The guest module's code is specified in `wasm`. Environment that will be available to @@ -848,213 +1073,16 @@ impl Store { let backend_context = &self.backend_context; let sandbox_instance = match backend_context { - BackendContext::Wasmi => { - let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; - let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) - .map_err(|_| InstantiationError::Instantiation)?; - - let sandbox_instance = DTH::with_dispatch_thunk(|dispatch_thunk| { - Rc::new(SandboxInstance { - // In general, it's not a very good idea to use `.not_started_instance()` for anything - // but for extracting memory and tables. But in this particular case, we are extracting - // for the purpose of running `start` function which should be ok. - backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), - dispatch_thunk: dispatch_thunk.clone(), - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }) - }); - - SCH::with_sandbox_capabilities( |supervisor_externals| { - with_guest_externals( - supervisor_externals, - &sandbox_instance, - state, - |guest_externals| { - wasmi_instance - .run_start(guest_externals) - .map_err(|_| InstantiationError::StartTrapped) - - // Note: no need to run start on wasmtime instance, since it's done automatically - }, - ) - })?; - - sandbox_instance - } + BackendContext::Wasmi => Self::instantiate_wasmi::(wasm, guest_env, state)?, #[cfg(feature = "wasmer-sandbox")] BackendContext::Wasmer(context) => { - let module = wasmer::Module::new(&context.store, wasm).map_err(|_| { - InstantiationError::ModuleDecoding - })?; - - type Exports = HashMap; - let mut exports_map = Exports::new(); - - // Populate exports map with module imports - for import in module - .imports() - .into_iter() - { - match import.ty() { - // Nothing to do here - wasmer::ExternType::Global(_) | wasmer::ExternType::Table(_) => (), - - wasmer::ExternType::Memory(_) => { - let exports = exports_map - .entry(import.module().to_string()) - .or_insert(wasmer::Exports::new()); - - let memory = guest_env.imports.memory_by_name( - import.module(), - import.name() - ).ok_or(InstantiationError::ModuleDecoding)?; - - exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); - } - - wasmer::ExternType::Function(func_ty) => { - let guest_func_index = guest_env.imports.func_by_name(import.module(), import.name()); - let guest_func_index = if let Some(index) = guest_func_index { - index - } else { - // Missing import (should we abort here?) - continue; - }; - - let supervisor_func_index = guest_env.guest_to_supervisor_mapping - .func_by_guest_index(guest_func_index) - .ok_or(InstantiationError::ModuleDecoding)?; - - let function = wasmer::Function::new(&context.store, func_ty, move |params| { - SCH::with_sandbox_capabilities(|supervisor_externals| { - use sp_wasm_interface::Value; - - // Serialize arguments into a byte vector. - let invoke_args_data = params - .iter() - .map(|val| match val { - wasmer::Val::I32(val) => Value::I32(*val), - wasmer::Val::I64(val) => Value::I64(*val), - wasmer::Val::F32(val) => Value::F32(f32::to_bits(*val)), - wasmer::Val::F64(val) => Value::F64(f64::to_bits(*val)), - _ => unimplemented!() - }) - .collect::>() - .encode(); - - // Move serialized arguments inside the memory, invoke dispatch thunk and - // then free allocated memory. - let invoke_args_len = invoke_args_data.len() as WordSize; - let invoke_args_ptr = supervisor_externals - .allocate_memory(invoke_args_len) - .map_err(|_| wasmer::RuntimeError::new( - "Can't allocate memory in supervisor for the arguments") - )?; - - let deallocate = |fe: &mut FE, ptr, fail_msg| { - fe - .deallocate_memory(ptr) - .map_err(|_| wasmer::RuntimeError::new(fail_msg)) - }; - - if supervisor_externals - .write_memory(invoke_args_ptr, &invoke_args_data) - .is_err() - { - deallocate( - supervisor_externals, - invoke_args_ptr, - "Failed dealloction after failed write of invoke arguments" - )?; - - return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); - } - - let serialized_result = DTH::with_dispatch_thunk(|dispatch_thunk| { - supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) - }).map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; - - // dispatch_thunk returns pointer to serialized arguments. - // Unpack pointer and len of the serialized result data. - let (serialized_result_val_ptr, serialized_result_val_len) = { - // Cast to u64 to use zero-extension. - let v = serialized_result as u64; - let ptr = (v as u64 >> 32) as u32; - let len = (v & 0xFFFFFFFF) as u32; - (Pointer::new(ptr), len) - }; - - let serialized_result_val = supervisor_externals - .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmer::RuntimeError::new( - "Can't read the serialized result from dispatch thunk") - ); - - let deserialized_result = deallocate( - supervisor_externals, - serialized_result_val_ptr, - "Can't deallocate memory for dispatch thunk's result" - ) - .and_then(|_| serialized_result_val) - .and_then(|serialized_result_val| { - deserialize_result(&serialized_result_val) - .map_err(|e| wasmer::RuntimeError::new(e.to_string())) - })?; - - if let Some(value) = deserialized_result { - Ok(vec![ - match value { - RuntimeValue::I32(val) => wasmer::Val::I32(val), - RuntimeValue::I64(val) => wasmer::Val::I64(val), - RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), - RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), - } - ]) - } else { - Ok(vec![]) - } - }) - }); - - let exports = exports_map - .entry(import.module().to_string()) - .or_insert(wasmer::Exports::new()); - - exports.insert(import.name(), wasmer::Extern::Function(function)); - } - } - } - - let mut import_object = wasmer::ImportObject::new(); - - for (module_name, exports) in exports_map.into_iter() { - import_object.register(module_name, exports); - } - - let instance = wasmer::Instance::new(&module, &import_object) - .map_err(|error| { - - match error { - wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, - wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, - wasmer::InstantiationError::HostEnvInitialization(_) => { - InstantiationError::EnvironmentDefinitionCorrupted - } - } - })?; - - Rc::new(SandboxInstance { - backend_instance: BackendInstance::Wasmer(instance), - dispatch_thunk: DTH::with_dispatch_thunk(|dispatch_thunk| dispatch_thunk.clone()), - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }) + Self::instantiate_wasmer::( + context, + wasm, + guest_env, + state + )? } }; From facfa6c2147f4af73efe01bfba85a331a53fcb7d Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 16 Jun 2021 17:56:57 +0700 Subject: [PATCH 60/88] More splits --- client/executor/common/src/sandbox.rs | 280 ++++++++++++++------------ 1 file changed, 151 insertions(+), 129 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 169321917f36b..a0ea05dc52243 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -817,6 +817,50 @@ impl Store { } } + /// Instantiate a guest module and return it's index in the store. + /// + /// The guest module's code is specified in `wasm`. Environment that will be available to + /// guest module is specified in `guest_env`. A dispatch thunk is used as function that + /// handle calls from guests. `state` is an opaque pointer to caller's arbitrary context + /// normally created by `sp_sandbox::Instance` primitive. + /// + /// Note: Due to borrowing constraints dispatch thunk is now propagated using DTH + /// + /// Returns uninitialized sandboxed module instance or an instantiation error. + pub fn instantiate<'a, FE, SCH, DTH>( + &mut self, + wasm: &[u8], + guest_env: GuestEnvironment, + state: u32, + ) -> std::result::Result, InstantiationError> + where + FR: Clone + 'static, + FE: SandboxCapabilities + 'a, + SCH: SandboxCapabilitiesHolder, + DTH: DispatchThunkHolder, + { + let backend_context = &self.backend_context; + + let sandbox_instance = match backend_context { + BackendContext::Wasmi => Self::instantiate_wasmi::(wasm, guest_env, state)?, + + #[cfg(feature = "wasmer-sandbox")] + BackendContext::Wasmer(context) => { + Self::instantiate_wasmer::( + context, + wasm, + guest_env, + state + )? + } + }; + + Ok(UnregisteredInstance { sandbox_instance }) + } +} + +// Private routines +impl Store { fn register_sandbox_instance(&mut self, sandbox_instance: Rc>) -> u32 { let instance_idx = self.instances.len(); self.instances.push(Some(sandbox_instance)); @@ -917,103 +961,12 @@ impl Store { .func_by_guest_index(guest_func_index) .ok_or(InstantiationError::ModuleDecoding)?; - let function = wasmer::Function::new(&context.store, func_ty, move |params| { - SCH::with_sandbox_capabilities(|supervisor_externals| { - use sp_wasm_interface::Value; - - // Serialize arguments into a byte vector. - let invoke_args_data = params - .iter() - .map(|val| match val { - wasmer::Val::I32(val) => Value::I32(*val), - wasmer::Val::I64(val) => Value::I64(*val), - wasmer::Val::F32(val) => Value::F32(f32::to_bits(*val)), - wasmer::Val::F64(val) => Value::F64(f64::to_bits(*val)), - _ => unimplemented!() - }) - .collect::>() - .encode(); - - // Move serialized arguments inside the memory, invoke dispatch thunk and - // then free allocated memory. - let invoke_args_len = invoke_args_data.len() as WordSize; - let invoke_args_ptr = supervisor_externals - .allocate_memory(invoke_args_len) - .map_err(|_| wasmer::RuntimeError::new( - "Can't allocate memory in supervisor for the arguments") - )?; - - let deallocate = |fe: &mut FE, ptr, fail_msg| { - fe - .deallocate_memory(ptr) - .map_err(|_| wasmer::RuntimeError::new(fail_msg)) - }; - - if supervisor_externals - .write_memory(invoke_args_ptr, &invoke_args_data) - .is_err() - { - deallocate( - supervisor_externals, - invoke_args_ptr, - "Failed dealloction after failed write of invoke arguments" - )?; - - return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); - } - - // Perform the actuall call - let serialized_result = DTH::with_dispatch_thunk(|dispatch_thunk| { - supervisor_externals.invoke( - &dispatch_thunk, - invoke_args_ptr, - invoke_args_len, - state, - supervisor_func_index, - ) - }).map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; - - // dispatch_thunk returns pointer to serialized arguments. - // Unpack pointer and len of the serialized result data. - let (serialized_result_val_ptr, serialized_result_val_len) = { - // Cast to u64 to use zero-extension. - let v = serialized_result as u64; - let ptr = (v as u64 >> 32) as u32; - let len = (v & 0xFFFFFFFF) as u32; - (Pointer::new(ptr), len) - }; - - let serialized_result_val = supervisor_externals - .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmer::RuntimeError::new( - "Can't read the serialized result from dispatch thunk") - ); - - let deserialized_result = deallocate( - supervisor_externals, - serialized_result_val_ptr, - "Can't deallocate memory for dispatch thunk's result" - ) - .and_then(|_| serialized_result_val) - .and_then(|serialized_result_val| { - deserialize_result(&serialized_result_val) - .map_err(|e| wasmer::RuntimeError::new(e.to_string())) - })?; - - if let Some(value) = deserialized_result { - Ok(vec![ - match value { - RuntimeValue::I32(val) => wasmer::Val::I32(val), - RuntimeValue::I64(val) => wasmer::Val::I64(val), - RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), - RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), - } - ]) - } else { - Ok(vec![]) - } - }) - }); + let function = Self::wasmer_dispatch_function::( + supervisor_func_index, + &context.store, + func_ty, + state + ); let exports = exports_map .entry(import.module().to_string()) @@ -1047,46 +1000,115 @@ impl Store { })) } - - /// Instantiate a guest module and return it's index in the store. - /// - /// The guest module's code is specified in `wasm`. Environment that will be available to - /// guest module is specified in `guest_env`. A dispatch thunk is used as function that - /// handle calls from guests. `state` is an opaque pointer to caller's arbitrary context - /// normally created by `sp_sandbox::Instance` primitive. - /// - /// Note: Due to borrowing constraints dispatch thunk is now propagated using DTH - /// - /// Returns uninitialized sandboxed module instance or an instantiation error. - pub fn instantiate<'a, FE, SCH, DTH>( - &mut self, - wasm: &[u8], - guest_env: GuestEnvironment, - state: u32, - ) -> std::result::Result, InstantiationError> + #[cfg(feature = "wasmer-sandbox")] + fn wasmer_dispatch_function<'a, FE, SCH, DTH>( + supervisor_func_index: SupervisorFuncIndex, + store: &wasmer::Store, + func_ty: &wasmer::FunctionType, + state: u32 + ) -> wasmer::Function where FR: Clone + 'static, FE: SandboxCapabilities + 'a, SCH: SandboxCapabilitiesHolder, DTH: DispatchThunkHolder, { - let backend_context = &self.backend_context; + wasmer::Function::new(store, func_ty, move |params| { + SCH::with_sandbox_capabilities(|supervisor_externals| { + use sp_wasm_interface::Value; - let sandbox_instance = match backend_context { - BackendContext::Wasmi => Self::instantiate_wasmi::(wasm, guest_env, state)?, + // Serialize arguments into a byte vector. + let invoke_args_data = params + .iter() + .map(|val| match val { + wasmer::Val::I32(val) => Value::I32(*val), + wasmer::Val::I64(val) => Value::I64(*val), + wasmer::Val::F32(val) => Value::F32(f32::to_bits(*val)), + wasmer::Val::F64(val) => Value::F64(f64::to_bits(*val)), + _ => unimplemented!() + }) + .collect::>() + .encode(); + + // Move serialized arguments inside the memory, invoke dispatch thunk and + // then free allocated memory. + let invoke_args_len = invoke_args_data.len() as WordSize; + let invoke_args_ptr = supervisor_externals + .allocate_memory(invoke_args_len) + .map_err(|_| wasmer::RuntimeError::new( + "Can't allocate memory in supervisor for the arguments") + )?; + + let deallocate = |fe: &mut FE, ptr, fail_msg| { + fe + .deallocate_memory(ptr) + .map_err(|_| wasmer::RuntimeError::new(fail_msg)) + }; - #[cfg(feature = "wasmer-sandbox")] - BackendContext::Wasmer(context) => { - Self::instantiate_wasmer::( - context, - wasm, - guest_env, - state - )? - } - }; + if supervisor_externals + .write_memory(invoke_args_ptr, &invoke_args_data) + .is_err() + { + deallocate( + supervisor_externals, + invoke_args_ptr, + "Failed dealloction after failed write of invoke arguments" + )?; + + return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); + } - Ok(UnregisteredInstance { sandbox_instance }) - } + // Perform the actuall call + let serialized_result = DTH::with_dispatch_thunk(|dispatch_thunk| { + supervisor_externals.invoke( + &dispatch_thunk, + invoke_args_ptr, + invoke_args_len, + state, + supervisor_func_index, + ) + }).map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; + + // dispatch_thunk returns pointer to serialized arguments. + // Unpack pointer and len of the serialized result data. + let (serialized_result_val_ptr, serialized_result_val_len) = { + // Cast to u64 to use zero-extension. + let v = serialized_result as u64; + let ptr = (v as u64 >> 32) as u32; + let len = (v & 0xFFFFFFFF) as u32; + (Pointer::new(ptr), len) + }; + + let serialized_result_val = supervisor_externals + .read_memory(serialized_result_val_ptr, serialized_result_val_len) + .map_err(|_| wasmer::RuntimeError::new( + "Can't read the serialized result from dispatch thunk") + ); + let deserialized_result = deallocate( + supervisor_externals, + serialized_result_val_ptr, + "Can't deallocate memory for dispatch thunk's result" + ) + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmer::RuntimeError::new(e.to_string())) + })?; + + if let Some(value) = deserialized_result { + Ok(vec![ + match value { + RuntimeValue::I32(val) => wasmer::Val::I32(val), + RuntimeValue::I64(val) => wasmer::Val::I64(val), + RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), + RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), + } + ]) + } else { + Ok(vec![]) + } + }) + }) + } } From e0a5a25a5df1ab805af7162a8dfdf2cef363adee Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 18 Jun 2021 16:55:49 +0700 Subject: [PATCH 61/88] Refacmemory allocation --- client/executor/common/src/sandbox.rs | 50 +++++++++++---------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index a0ea05dc52243..14205322e4f61 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -697,12 +697,25 @@ pub struct Store { } impl Store { - fn allocate_memory( - memories: &mut Vec>, - backend_context: &BackendContext, - initial: u32, - maximum: u32 - ) -> Result<(u32, Memory)> { + /// Create a new empty sandbox store. + pub fn new(backend: SandboxBackend) -> Self { + Store { + instances: Vec::new(), + memories: Vec::new(), + backend_context: BackendContext::new(backend), + } + } + + /// Create a new memory instance and return it's index. + /// + /// # Errors + /// + /// Returns `Err` if the memory couldn't be created. + /// Typically happens if `initial` is more than `maximum`. + pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { + let memories = &mut self.memories; + let backend_context = &self.backend_context; + let maximum = match maximum { sandbox_primitives::MEM_UNLIMITED => None, specified_limit => Some(specified_limit), @@ -729,30 +742,7 @@ impl Store { let mem_idx = memories.len(); memories.push(Some(memory.clone())); - Ok((mem_idx as u32, memory)) - } -} - -impl Store { - /// Create a new empty sandbox store. - pub fn new(backend: SandboxBackend) -> Self { - Store { - instances: Vec::new(), - memories: Vec::new(), - backend_context: BackendContext::new(backend), - } - } - - /// Create a new memory instance and return it's index. - /// - /// # Errors - /// - /// Returns `Err` if the memory couldn't be created. - /// Typically happens if `initial` is more than `maximum`. - pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result { - let memories = &mut self.memories; - let backend_context = &self.backend_context; - Self::allocate_memory(memories, backend_context, initial, maximum).map(|(index, _)| index) + Ok(mem_idx as u32) } /// Returns `SandboxInstance` by `instance_idx`. From 84f309353fa6327ca015eb457c9c19812f264e6a Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 18 Jun 2021 17:17:45 +0700 Subject: [PATCH 62/88] Nitpicks --- client/executor/common/src/sandbox.rs | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 14205322e4f61..1bb68c49482e4 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -86,7 +86,6 @@ struct Imports { memories_map: HashMap<(Vec, Vec), Memory>, } -#[cfg(feature = "wasmer-sandbox")] impl Imports { fn func_by_name(&self, module_name: &str, func_name: &str) -> Option { self.func_map.get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())).cloned() @@ -104,16 +103,14 @@ impl ImportResolver for Imports { field_name: &str, signature: &::wasmi::Signature, ) -> std::result::Result { - let key = ( - module_name.as_bytes().to_owned(), - field_name.as_bytes().to_owned(), - ); - let idx = *self.func_map.get(&key).ok_or_else(|| { - wasmi::Error::Instantiation(format!( - "Export {}:{} not found", - module_name, field_name - )) - })?; + let idx = self.func_by_name(module_name, field_name) + .ok_or_else(|| { + wasmi::Error::Instantiation(format!( + "Export {}:{} not found", + module_name, field_name + )) + })?; + Ok(wasmi::FuncInstance::alloc_host(signature.clone(), idx.0)) } @@ -123,20 +120,23 @@ impl ImportResolver for Imports { field_name: &str, _memory_type: &::wasmi::MemoryDescriptor, ) -> std::result::Result { - let key = ( - module_name.as_bytes().to_vec(), - field_name.as_bytes().to_vec(), - ); - let mem = self.memories_map - .get(&key) - .and_then(|m| m.as_wasmi()) + let mem = self.memory_by_name(module_name, field_name) .ok_or_else(|| { wasmi::Error::Instantiation(format!( "Export {}:{} not found", module_name, field_name )) + })?; + + let mem = mem.as_wasmi() + .ok_or_else(|| { + wasmi::Error::Instantiation(format!( + "Unsupported non-wasmi export {}:{}", + module_name, field_name + )) })? .clone(); + Ok(mem) } @@ -390,7 +390,7 @@ impl SandboxInstance { SCH: SandboxCapabilitiesHolder, DTH: DispatchThunkHolder, { - SCH::with_sandbox_capabilities( |supervisor_externals| { + SCH::with_sandbox_capabilities(|supervisor_externals| { with_guest_externals( supervisor_externals, self, @@ -883,7 +883,7 @@ impl Store { }) }); - SCH::with_sandbox_capabilities( |supervisor_externals| { + SCH::with_sandbox_capabilities(|supervisor_externals| { with_guest_externals( supervisor_externals, &sandbox_instance, From d3b86a052a259a7011f07add6fc784073f487e1d Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 23 Jun 2021 14:58:36 +0700 Subject: [PATCH 63/88] Attempt to wrap wasmer memory in protoco enforcing type --- client/executor/common/src/sandbox.rs | 38 ++++++++--- client/executor/common/src/util.rs | 87 +++++++++++++++++++++++++ client/executor/wasmi/src/lib.rs | 92 ++++++++++++--------------- client/executor/wasmtime/src/host.rs | 88 +++++++++++-------------- 4 files changed, 193 insertions(+), 112 deletions(-) create mode 100644 client/executor/common/src/util.rs diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 1bb68c49482e4..41ce6e5544362 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -18,18 +18,21 @@ //! This module implements sandboxing support in the runtime. //! -//! Sandboxing is baked by wasmi and wasmer, depending on the configuration. +//! Sandboxing is backed by wasmi and wasmer, depending on the configuration. use crate::error::{Result, Error}; use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; use wasmi::{ - Externals, ImportResolver, MemoryInstance, MemoryRef, Module, + Externals, ImportResolver, MemoryInstance, MemoryRef as WasmiMemoryRef, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages }; use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; +#[cfg(feature = "wasmer-sandbox")] +use crate::util::wasmer::MemoryRef as WasmerMemoryRef; + /// Index of a function inside the supervisor. /// /// This is a typically an index in the default table of the supervisor, however @@ -119,7 +122,7 @@ impl ImportResolver for Imports { module_name: &str, field_name: &str, _memory_type: &::wasmi::MemoryDescriptor, - ) -> std::result::Result { + ) -> std::result::Result { let mem = self.memory_by_name(module_name, field_name) .ok_or_else(|| { wasmi::Error::Instantiation(format!( @@ -623,16 +626,16 @@ pub enum SandboxBackend { #[derive(Clone, Debug)] pub enum Memory { /// Wasmi memory reference - Wasmi(MemoryRef), + Wasmi(WasmiMemoryRef), /// Wasmer memory refernce #[cfg(feature = "wasmer-sandbox")] - Wasmer(wasmer::Memory), + Wasmer(WasmerMemoryRef), } impl Memory { /// View as wasmi memory - pub fn as_wasmi(&self) -> Option { + pub fn as_wasmi(&self) -> Option { match self { Memory::Wasmi(memory) => Some(memory.clone()), @@ -643,7 +646,7 @@ impl Memory { /// View as wasmer memory #[cfg(feature = "wasmer-sandbox")] - pub fn as_wasmer(&self) -> Option { + pub fn as_wasmer(&self) -> Option { match self { Memory::Wasmer(memory) => Some(memory.clone()), Memory::Wasmi(_) => None, @@ -733,8 +736,10 @@ impl Store { BackendContext::Wasmer(context) => { let ty = wasmer::MemoryType::new(initial, maximum, false); Memory::Wasmer( - wasmer::Memory::new(&context.store, ty) - .map_err(|_| Error::InvalidMemoryReference)? + WasmerMemoryRef::new( + wasmer::Memory::new(&context.store, ty) + .map_err(|_| Error::InvalidMemoryReference)? + ) ) } }; @@ -934,7 +939,20 @@ impl Store { import.name() ).ok_or(InstantiationError::ModuleDecoding)?; - exports.insert(import.name(), wasmer::Extern::Memory(memory.as_wasmer().unwrap())); + let mut wasmer_memory_ref = memory.as_wasmer().expect( + "memory is created by wasmer; \ + exported by the same module and backend; \ + thus the operation can't fail; \ + qed" + ); + + // This is safe since we're only instantiating the module and populating + // the export table, so no memory access can happen at this time. + // All subsequent memory accesses should happen through the wrapper, + // that enforces the memory access protocol. + let wasmer_memory = unsafe { wasmer_memory_ref.clone_inner() }; + + exports.insert(import.name(), wasmer::Extern::Memory(wasmer_memory)); } wasmer::ExternType::Function(func_ty) => { diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs new file mode 100644 index 0000000000000..0aac0a76135bf --- /dev/null +++ b/client/executor/common/src/util.rs @@ -0,0 +1,87 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2021 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Utilities used by all backends + +/// Routines specific to Wasmer runtime. Since sandbox can be invoked from both +/// wasmi and wasmtime runtime executors, we need to have a way to deal with sanbox +/// backends right from the start. +#[cfg(feature = "wasmer-sandbox")] +pub mod wasmer { + use std::{cell::RefCell, rc::Rc}; + + /// In order to enforce memory access protocol to the backend memory we wrap it + /// with a `RefCell` and provide a scoped access. + #[derive(Debug, Clone)] + pub struct MemoryRef { + buffer: Rc>, + } + + impl MemoryRef { + /// Take ownership of the memory region and return a wrapper object + pub fn new(memory: wasmer::Memory) -> Self { + Self { + buffer: Rc::new(RefCell::new(memory)) + } + } + + /// Provides direct access to the underlying memory buffer. + /// + /// # Panics + /// + /// Any call that requires write access to memory made within + /// the closure will panic. + pub fn with_direct_access R>(&self, f: F) -> R { + let buf = self.buffer.borrow(); + let slice = unsafe { core::slice::from_raw_parts(buf.data_ptr(), buf.data_size() as usize) }; + + f(slice) + } + + /// Provides direct mutable access to the underlying memory buffer. + /// + /// # Panics + /// + /// Any calls that requires either read or write access to memory + /// made within the closure will panic. Proceed with caution. + pub fn with_direct_access_mut R>(&self, f: F) -> R { + let buf = self.buffer.borrow_mut(); + let slice = unsafe { core::slice::from_raw_parts_mut(buf.data_ptr(), buf.data_size() as usize) }; + + f(slice) + } + + /// Clone the underlying memory object + /// + /// # Safety + /// + /// The sole purpose of `MemoryRef` is to protect the memory from uncontrolled + /// access. By returning memory object "as is" we bypass all checks. + /// + /// Intended to use only during module initialization. + /// + /// # Panics + /// + /// Will panic if `MemoryRef` is currently in use. + pub unsafe fn clone_inner(&mut self) -> wasmer::Memory { + // We take exclusive lock to ensure that we're the only one here + self.buffer.borrow_mut().clone() + } + } + +} diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 672f33d93f851..f61dca287dc23 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -175,32 +175,26 @@ impl Sandbox for FunctionExecutor { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - let len = buf_len as usize; - - let src_range = match checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); - let dst_range = match checked_range(buf_ptr.into(), len, memory_size.0) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - // This is safe because we construct slice from the same parts as - // the memory region itself. Current implementation is single threaded, - // so we should not face any synchronization or aliasing issues. - let src_buffer = unsafe { core::slice::from_raw_parts( - sandboxed_memory.data_ptr(), - sandboxed_memory.data_size() as usize) - }; - - self.inner.memory.with_direct_access_mut(|dst_buffer| { - dst_buffer[dst_range].copy_from_slice(&src_buffer[src_range]); - }); - - Ok(sandbox_primitives::ERR_OK) + sandboxed_memory.with_direct_access(|sandboxed_memory| { + let len = buf_len as usize; + + let src_range = match checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); + let dst_range = match checked_range(buf_ptr.into(), len, memory_size.0) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + self.inner.memory.with_direct_access_mut(|dst_buffer| { + dst_buffer[dst_range].copy_from_slice(&sandboxed_memory[src_range]); + }); + + Ok(sandbox_primitives::ERR_OK) + }) } } @@ -235,32 +229,26 @@ impl Sandbox for FunctionExecutor { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - let len = val_len as usize; - - let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); - let src_range = match checked_range(val_ptr.into(), len, memory_size.0) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - let dst_range = match checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - // This is safe because we construct slice from the same parts as - // the memory region itself. Current implementation is single threaded, - // so we should not face any synchronization or aliasing issues. - let dest_buffer = unsafe { core::slice::from_raw_parts_mut( - sandboxed_memory.data_ptr(), - sandboxed_memory.data_size() as usize) - }; - - self.inner.memory.with_direct_access(|src_buffer| { - dest_buffer[dst_range].copy_from_slice(&src_buffer[src_range]); - }); - - Ok(sandbox_primitives::ERR_OK) + sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { + let len = val_len as usize; + + let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); + let src_range = match checked_range(val_ptr.into(), len, memory_size.0) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + let dst_range = match checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; + + self.inner.memory.with_direct_access(|src_buffer| { + sandboxed_memory[dst_range].copy_from_slice(&src_buffer[src_range]); + }); + + Ok(sandbox_primitives::ERR_OK) + }) } } } diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 51b9f3f2a3314..47f8608068671 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -203,35 +203,29 @@ impl Sandbox for HostState { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - let len = buf_len as usize; - - let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + sandboxed_memory.with_direct_access(|sandboxed_memory| { + let len = buf_len as usize; - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; - // This is safe because we construct slice from the same parts as - // the memory region itself. Current implementation is single threaded, - // so we should not face any synchronization or aliasing issues. - let source = unsafe { core::slice::from_raw_parts( - sandboxed_memory.data_ptr(), - sandboxed_memory.data_size() as usize) - }; + let supervisor_mem_size = self.inner.instance.memory_size() as usize; + let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; - self.inner.instance - .write_memory_from( - Pointer::new(dst_range.start as u32), - &source[src_range], - ) - .expect("ranges are checked above; write can't fail; qed"); + self.inner.instance + .write_memory_from( + Pointer::new(dst_range.start as u32), + &sandboxed_memory[src_range], + ) + .expect("ranges are checked above; write can't fail; qed"); - Ok(sandbox_primitives::ERR_OK) + Ok(sandbox_primitives::ERR_OK) + }) } } } @@ -278,35 +272,29 @@ impl Sandbox for HostState { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - let len = val_len as usize; - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - - let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { + let len = val_len as usize; + let supervisor_mem_size = self.inner.instance.memory_size() as usize; - let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.data_size() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; - // This is safe because we construct slice from the same parts as - // the memory region itself. Current implementation is single threaded, - // so we should not face any synchronization or aliasing issues. - let dest = unsafe { core::slice::from_raw_parts_mut( - sandboxed_memory.data_ptr(), - sandboxed_memory.data_size() as usize) - }; + let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + Some(range) => range, + None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + }; - self.inner.instance - .read_memory_into( - Pointer::new(src_range.start as u32), - &mut dest[dst_range], - ) - .expect("ranges are checked above; read can't fail; qed"); + self.inner.instance + .read_memory_into( + Pointer::new(src_range.start as u32), + &mut sandboxed_memory[dst_range], + ) + .expect("ranges are checked above; read can't fail; qed"); - Ok(sandbox_primitives::ERR_OK) + Ok(sandbox_primitives::ERR_OK) + }) } } } From c8506506784cd904b3141402c25b9043bd5035c5 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 23 Jun 2021 14:59:18 +0700 Subject: [PATCH 64/88] Revert renaming --- client/executor/wasmtime/src/instance_wrapper.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index a142df9527898..6dd78912d91aa 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -109,8 +109,8 @@ impl EntryPoint { /// This struct is a handy wrapper around a wasmtime `Instance` that provides substrate specific /// routines. pub struct InstanceWrapper { - /// Instantiated WebAssembly module instance: Instance, + // The memory instance of the `instance`. // // It is important to make sure that we don't make any copies of this to make it easier to proof @@ -336,15 +336,15 @@ impl InstanceWrapper { /// Write data to a slice of memory. /// /// Returns an error if the write would go out of the memory bounds. - pub fn write_memory_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { + pub fn write_memory_from(&self, dest_addr: Pointer, data: &[u8]) -> Result<()> { unsafe { // This should be safe since we don't grow up memory while caching this reference and // we give up the reference before returning from this function. let memory = self.memory_as_slice_mut(); - let range = util::checked_range(dest_addr.into(), source.len(), memory.len()) + let range = util::checked_range(dest_addr.into(), data.len(), memory.len()) .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; - &mut memory[range].copy_from_slice(source); + &mut memory[range].copy_from_slice(data); Ok(()) } } From 76a8bd829dcbe3aae2575f022f679a6d2b7ab88c Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 29 Jun 2021 14:29:00 +0700 Subject: [PATCH 65/88] WIP wasm buffer proxy API --- client/executor/common/src/error.rs | 10 ++ client/executor/common/src/lib.rs | 1 + client/executor/common/src/util.rs | 131 ++++++++++++++++-- client/executor/wasmi/src/lib.rs | 91 ++++++------ client/executor/wasmtime/src/host.rs | 89 ++++++------ .../executor/wasmtime/src/instance_wrapper.rs | 11 +- client/executor/wasmtime/src/util.rs | 13 -- 7 files changed, 230 insertions(+), 116 deletions(-) diff --git a/client/executor/common/src/error.rs b/client/executor/common/src/error.rs index 96329d1680301..b6e3a982340a2 100644 --- a/client/executor/common/src/error.rs +++ b/client/executor/common/src/error.rs @@ -150,3 +150,13 @@ pub enum WasmError { } impl std::error::Error for WasmError {} + +/// Possible transfer errors +#[derive(Debug, derive_more::Display)] +pub enum TransferError { + /// Source memory is too small to contain all of the requested data + SourceTooSmall, + + /// Destination memory is too small to fit all of the transferred data + DestTooSmall, +} diff --git a/client/executor/common/src/lib.rs b/client/executor/common/src/lib.rs index 25e06314aba39..f129b06c772bf 100644 --- a/client/executor/common/src/lib.rs +++ b/client/executor/common/src/lib.rs @@ -25,3 +25,4 @@ pub mod error; pub mod sandbox; pub mod wasm_runtime; pub mod runtime_blob; +pub mod util; diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs index 0aac0a76135bf..75db775e082cb 100644 --- a/client/executor/common/src/util.rs +++ b/client/executor/common/src/util.rs @@ -18,20 +18,129 @@ //! Utilities used by all backends +use std::ops::Range; +use wasmi::MemoryRef; +use crate::error::TransferError; + +/// Construct a range from an offset to a data length after the offset. +/// Returns None if the end of the range would exceed some maximum offset. +pub fn checked_range(offset: usize, len: usize, max: usize) -> Option> { + let end = offset.checked_add(len)?; + if end <= max { + Some(offset..end) + } else { + None + } +} + +pub unsafe trait BufferProvider { + /// Provide scoped read-only access to the underlying buffer + fn scoped_access R>(&self, f: F) -> R; +} + +unsafe impl<'a> BufferProvider for MemoryRef { + fn scoped_access R>(&self, f: F) -> R { + self.with_direct_access(f) + } +} + +struct WasmiBufferProxyMut { + memory: MemoryRef, +} + +impl WasmiBufferProxyMut { + pub fn transfer(&mut self, source: impl BufferProvider, source_offset: usize, dest_offset: usize, len: usize) -> Result<(), TransferError> { + source.scoped_access(|source| { + self.memory.with_direct_access_mut(|dest| { + let src_range = checked_range(source_offset, len, source.len()).ok_or(TransferError::SourceTooSmall)?; + let dst_range = checked_range(dest_offset, len, dest.len()).ok_or(TransferError::DestTooSmall)?; + + dest[dst_range].copy_from_slice(&source[src_range]); + + Ok(()) + }) + }) + } +} + /// Routines specific to Wasmer runtime. Since sandbox can be invoked from both /// wasmi and wasmtime runtime executors, we need to have a way to deal with sanbox /// backends right from the start. #[cfg(feature = "wasmer-sandbox")] pub mod wasmer { - use std::{cell::RefCell, rc::Rc}; + use std::{cell::{Ref, RefCell, RefMut}, rc::Rc}; + use crate::{error::TransferError, util::checked_range}; + use super::BufferProvider; - /// In order to enforce memory access protocol to the backend memory we wrap it - /// with a `RefCell` and provide a scoped access. + /// In order to enforce memory access protocol to the backend memory + /// we wrap it with `RefCell` and provide a scoped access. #[derive(Debug, Clone)] pub struct MemoryRef { buffer: Rc>, } + /// Represents a scoped right to read the associated memory + pub struct BufferProxy<'a> { + guard: Ref<'a, wasmer::Memory>, + } + + impl<'a> BufferProxy<'a> { + /// Accept the ownership and created proxy object + pub fn new(guard: Ref<'a, wasmer::Memory>) -> Self { + Self { + guard, + } + } + } + + /// Represents a scoped right to access the associated memory + pub struct BufferProxyMut<'a> { + guard: RefMut<'a, wasmer::Memory>, + } + + impl<'a> BufferProxyMut<'a> { + /// Accept the ownership and created proxy object + pub fn new(guard: RefMut<'a, wasmer::Memory>) -> Self { + Self { + guard, + } + } + + /// Copy the data between buffers at a specified location + pub fn transfer(&mut self, source: impl BufferProvider, source_offset: usize, dest_offset: usize, len: usize) -> Result<(), TransferError> { + source.scoped_access(|source| { + // This is safe because we construct the slice from the same parts as + // the memory region itself. We hold the lock to both of memory buffers, + // so we shouldn't have issues even if we'd try to borrow the memory twice. + let dest = unsafe { + let memory = &* self.guard; + core::slice::from_raw_parts_mut(memory.data_ptr(), memory.data_size() as usize) + }; + + let src_range = checked_range(source_offset, len, source.len()).ok_or(TransferError::SourceTooSmall)?; + let dst_range = checked_range(dest_offset, len, dest.len()).ok_or(TransferError::DestTooSmall)?; + + dest[dst_range].copy_from_slice(&source[src_range]); + + Ok(()) + }) + } + } + + unsafe impl<'a> BufferProvider for BufferProxy<'a> { + fn scoped_access R>(&self, f: F) -> R { + // This is safe because we construct the slice from the same parts as + // the memory region itself. We hold the lock to both of memory buffers, + // so we shouldn't have issues even if we'd try to borrow the memory twice. + let buffer = unsafe { + let memory = &* self.guard; + core::slice::from_raw_parts(memory.data_ptr(), memory.data_size() as usize) + }; + + f(buffer) + } + } + impl MemoryRef { /// Take ownership of the memory region and return a wrapper object pub fn new(memory: wasmer::Memory) -> Self { @@ -46,11 +155,9 @@ pub mod wasmer { /// /// Any call that requires write access to memory made within /// the closure will panic. - pub fn with_direct_access R>(&self, f: F) -> R { + pub fn with_direct_access R>(&self, f: F) -> R { let buf = self.buffer.borrow(); - let slice = unsafe { core::slice::from_raw_parts(buf.data_ptr(), buf.data_size() as usize) }; - - f(slice) + f(&BufferProxy::new(buf)) } /// Provides direct mutable access to the underlying memory buffer. @@ -59,11 +166,9 @@ pub mod wasmer { /// /// Any calls that requires either read or write access to memory /// made within the closure will panic. Proceed with caution. - pub fn with_direct_access_mut R>(&self, f: F) -> R { + pub fn with_direct_access_mut R>(&self, f: F) -> R { let buf = self.buffer.borrow_mut(); - let slice = unsafe { core::slice::from_raw_parts_mut(buf.data_ptr(), buf.data_size() as usize) }; - - f(slice) + f(&BufferProxyMut::new(buf)) } /// Clone the underlying memory object @@ -71,12 +176,12 @@ pub mod wasmer { /// # Safety /// /// The sole purpose of `MemoryRef` is to protect the memory from uncontrolled - /// access. By returning memory object "as is" we bypass all checks. + /// access. By returning the memory object "as is" we bypass all of the checks. /// /// Intended to use only during module initialization. /// /// # Panics - /// + /// /// Will panic if `MemoryRef` is currently in use. pub unsafe fn clone_inner(&mut self) -> wasmer::Memory { // We take exclusive lock to ensure that we're the only one here diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index f61dca287dc23..8d82f549f5b50 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -18,7 +18,7 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. -use std::{cell::RefCell, ops::Range, rc::Rc, str, sync::Arc}; +use std::{cell::{Ref, RefCell}, ops::Range, rc::Rc, str, sync::Arc}; use wasmi::{ FuncInstance, ImportsBuilder, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, RuntimeValue::{I32, I64, self}, TableRef, memory_units::Pages, @@ -30,10 +30,11 @@ use sp_wasm_interface::{ FunctionContext, Pointer, WordSize, Sandbox, MemoryId, Result as WResult, Function, }; use sp_runtime_interface::unpack_ptr_and_len; -use sc_executor_common::wasm_runtime::{WasmModule, WasmInstance, InvokeMethod}; +use sc_executor_common::{util::BufferProvider, wasm_runtime::{WasmModule, WasmInstance, InvokeMethod}}; use sc_executor_common::{ error::{Error, WasmError}, sandbox, + util, }; use sc_executor_common::runtime_blob::{RuntimeBlob, DataSegmentsSnapshot}; @@ -133,18 +134,6 @@ impl FunctionContext for FunctionExecutor { } } -// TODO Move to executor common and deduplicate code -/// Construct a range from an offset to a data length after the offset. -/// Returns None if the end of the range would exceed some maximum offset. -pub fn checked_range(offset: usize, len: usize, max: usize) -> Option> { - let end = offset.checked_add(len)?; - if end <= max { - Some(offset..end) - } else { - None - } -} - impl Sandbox for FunctionExecutor { fn memory_get( &mut self, @@ -175,25 +164,33 @@ impl Sandbox for FunctionExecutor { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.with_direct_access(|sandboxed_memory| { - let len = buf_len as usize; + sandboxed_memory.with_direct_access(|source_proxy| { + dest_proxy + .transfer(source_proxy, val_ptr.into(), offset as usize, val_len as usize) + .map_err(|e| e.to_string()) + .map(|_| sandbox_primitives::ERR_OK) - let src_range = match checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); - let dst_range = match checked_range(buf_ptr.into(), len, memory_size.0) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + // todo!() - self.inner.memory.with_direct_access_mut(|dst_buffer| { - dst_buffer[dst_range].copy_from_slice(&sandboxed_memory[src_range]); - }); + // let len = buf_len as usize; - Ok(sandbox_primitives::ERR_OK) + // let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + + // let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); + // let dst_range = match util::checked_range(buf_ptr.into(), len, memory_size.0) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + + // self.inner.memory.with_direct_access_mut(|dst_buffer| { + // dst_buffer[dst_range].copy_from_slice(&sandboxed_memory[src_range]); + // }); + + // Ok(sandbox_primitives::ERR_OK) }) } } @@ -229,25 +226,31 @@ impl Sandbox for FunctionExecutor { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { - let len = val_len as usize; + sandboxed_memory.with_direct_access_mut(|dest_proxy| { - let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); - let src_range = match checked_range(val_ptr.into(), len, memory_size.0) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + dest_proxy + .transfer(self.inner.memory, val_ptr.into(), offset as usize, val_len as usize) + .map_err(|e| e.to_string()) + .map(|_| sandbox_primitives::ERR_OK) - let dst_range = match checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + // let len = val_len as usize; - self.inner.memory.with_direct_access(|src_buffer| { - sandboxed_memory[dst_range].copy_from_slice(&src_buffer[src_range]); - }); + // let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); + // let src_range = match util::checked_range(val_ptr.into(), len, memory_size.0) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; - Ok(sandbox_primitives::ERR_OK) + // let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + + // self.inner.memory.with_direct_access(|src_buffer| { + // sandboxed_memory[dst_range].copy_from_slice(&src_buffer[src_range]); + // }); + + // Ok(sandbox_primitives::ERR_OK) }) } } diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 47f8608068671..ffbc7a89c904c 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -20,12 +20,11 @@ //! required for execution of host. use crate::instance_wrapper::InstanceWrapper; -use crate::util; use std::{cell::RefCell, rc::Rc}; use log::trace; use codec::{Encode, Decode}; use sp_allocator::FreeingBumpHeapAllocator; -use sc_executor_common::error::Result; +use sc_executor_common::{error::Result, util}; use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex}; use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; @@ -204,27 +203,29 @@ impl Sandbox for HostState { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { sandboxed_memory.with_direct_access(|sandboxed_memory| { - let len = buf_len as usize; + todo!() - let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + // let len = buf_len as usize; - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; + // let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; - self.inner.instance - .write_memory_from( - Pointer::new(dst_range.start as u32), - &sandboxed_memory[src_range], - ) - .expect("ranges are checked above; write can't fail; qed"); + // let supervisor_mem_size = self.inner.instance.memory_size() as usize; + // let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; - Ok(sandbox_primitives::ERR_OK) + // self.inner.instance + // .write_memory_from( + // Pointer::new(dst_range.start as u32), + // &sandboxed_memory[src_range], + // ) + // .expect("ranges are checked above; write can't fail; qed"); + + // Ok(sandbox_primitives::ERR_OK) }) } } @@ -272,28 +273,34 @@ impl Sandbox for HostState { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { - let len = val_len as usize; - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - - let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - self.inner.instance - .read_memory_into( - Pointer::new(src_range.start as u32), - &mut sandboxed_memory[dst_range], - ) - .expect("ranges are checked above; read can't fail; qed"); - - Ok(sandbox_primitives::ERR_OK) + sandboxed_memory.with_direct_access_mut(|dest_proxy| { + + dest_proxy + .transfer(source, val_ptr.into(), offset as usize, val_len as usize) + .map_err(|e| e.to_string()) + .map(|_| sandbox_primitives::ERR_OK) + + // let len = val_len as usize; + // let supervisor_mem_size = self.inner.instance.memory_size() as usize; + + // let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + + // let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { + // Some(range) => range, + // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + // }; + + // self.inner.instance + // .read_memory_into( + // Pointer::new(src_range.start as u32), + // &mut sandboxed_memory[dst_range], + // ) + // .expect("ranges are checked above; read can't fail; qed"); + + // Ok(sandbox_primitives::ERR_OK) }) } } diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index 6dd78912d91aa..e7c0c028ccd32 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -19,7 +19,7 @@ //! Defines data and logic needed for interaction with an WebAssembly instance of a substrate //! runtime module. -use crate::util; +use crate::util::{from_wasmtime_val, into_wasmtime_val}; use crate::imports::Imports; use std::{slice, marker}; @@ -27,6 +27,7 @@ use sc_executor_common::{ error::{Error, Result}, runtime_blob, wasm_runtime::InvokeMethod, + util::checked_range, }; use sp_wasm_interface::{Pointer, WordSize, Value}; use wasmtime::{Instance, Module, Memory, Table, Val, Func, Extern, Global, Store}; @@ -326,7 +327,7 @@ impl InstanceWrapper { // we give up the reference before returning from this function. let memory = self.memory_as_slice(); - let range = util::checked_range(source_addr.into(), dest.len(), memory.len()) + let range = checked_range(source_addr.into(), dest.len(), memory.len()) .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; dest.copy_from_slice(&memory[range]); Ok(()) @@ -342,7 +343,7 @@ impl InstanceWrapper { // we give up the reference before returning from this function. let memory = self.memory_as_slice_mut(); - let range = util::checked_range(dest_addr.into(), data.len(), memory.len()) + let range = checked_range(dest_addr.into(), data.len(), memory.len()) .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; &mut memory[range].copy_from_slice(data); Ok(()) @@ -431,11 +432,11 @@ impl runtime_blob::InstanceGlobals for InstanceWrapper { } fn get_global_value(&self, global: &Self::Global) -> Value { - util::from_wasmtime_val(global.get()) + from_wasmtime_val(global.get()) } fn set_global_value(&self, global: &Self::Global, value: Value) { - global.set(util::into_wasmtime_val(value)).expect( + global.set(into_wasmtime_val(value)).expect( "the value is guaranteed to be of the same value; the global is guaranteed to be mutable; qed", ); } diff --git a/client/executor/wasmtime/src/util.rs b/client/executor/wasmtime/src/util.rs index c294f66b5017f..33b3a8106efb9 100644 --- a/client/executor/wasmtime/src/util.rs +++ b/client/executor/wasmtime/src/util.rs @@ -16,21 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::ops::Range; - use sp_wasm_interface::Value; -/// Construct a range from an offset to a data length after the offset. -/// Returns None if the end of the range would exceed some maximum offset. -pub fn checked_range(offset: usize, len: usize, max: usize) -> Option> { - let end = offset.checked_add(len)?; - if end <= max { - Some(offset..end) - } else { - None - } -} - /// Converts a [`wasmtime::Val`] into a substrate runtime interface [`Value`]. /// /// Panics if the given value doesn't have a corresponding variant in `Value`. From d2002caa6561556bd5fe59a7b41f36a917715882 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 1 Jul 2021 17:05:13 +0700 Subject: [PATCH 66/88] Reimplement util::wasmer::MemoryRef to use buffers instead of memory slices --- client/executor/common/src/util.rs | 190 +++++++++++---------------- client/executor/wasmi/src/lib.rs | 65 ++------- client/executor/wasmtime/src/host.rs | 72 +++------- 3 files changed, 111 insertions(+), 216 deletions(-) diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs index 75db775e082cb..eb8601c2a4a76 100644 --- a/client/executor/common/src/util.rs +++ b/client/executor/common/src/util.rs @@ -19,8 +19,6 @@ //! Utilities used by all backends use std::ops::Range; -use wasmi::MemoryRef; -use crate::error::TransferError; /// Construct a range from an offset to a data length after the offset. /// Returns None if the end of the range would exceed some maximum offset. @@ -33,142 +31,110 @@ pub fn checked_range(offset: usize, len: usize, max: usize) -> Option R>(&self, f: F) -> R; -} - -unsafe impl<'a> BufferProvider for MemoryRef { - fn scoped_access R>(&self, f: F) -> R { - self.with_direct_access(f) - } -} - -struct WasmiBufferProxyMut { - memory: MemoryRef, -} - -impl WasmiBufferProxyMut { - pub fn transfer(&mut self, source: impl BufferProvider, source_offset: usize, dest_offset: usize, len: usize) -> Result<(), TransferError> { - source.scoped_access(|source| { - self.memory.with_direct_access_mut(|dest| { - let src_range = checked_range(source_offset, len, source.len()).ok_or(TransferError::SourceTooSmall)?; - let dst_range = checked_range(dest_offset, len, dest.len()).ok_or(TransferError::DestTooSmall)?; - - dest[dst_range].copy_from_slice(&source[src_range]); - - Ok(()) - }) - }) - } -} - -/// Routines specific to Wasmer runtime. Since sandbox can be invoked from both +// Routines specific to Wasmer runtime. Since sandbox can be invoked from both /// wasmi and wasmtime runtime executors, we need to have a way to deal with sanbox /// backends right from the start. #[cfg(feature = "wasmer-sandbox")] pub mod wasmer { - use std::{cell::{Ref, RefCell, RefMut}, rc::Rc}; - use crate::{error::TransferError, util::checked_range}; - use super::BufferProvider; - - /// In order to enforce memory access protocol to the backend memory - /// we wrap it with `RefCell` and provide a scoped access. + use std::{cell::{RefCell}, rc::Rc}; + use error::Result; + use sp_wasm_interface::Pointer; + use crate::{error::{self, Error}, util::checked_range}; + use std::convert::TryInto; + + /// In order to enforce memory access protocol to the backend memory + /// we wrap it with `RefCell` and encapsulate all memory operations. #[derive(Debug, Clone)] pub struct MemoryRef { buffer: Rc>, } - /// Represents a scoped right to read the associated memory - pub struct BufferProxy<'a> { - guard: Ref<'a, wasmer::Memory>, - } - - impl<'a> BufferProxy<'a> { - /// Accept the ownership and created proxy object - pub fn new(guard: Ref<'a, wasmer::Memory>) -> Self { + impl MemoryRef { + /// Take ownership of the memory region and return a wrapper object + pub fn new(memory: wasmer::Memory) -> Self { Self { - guard, + buffer: Rc::new(RefCell::new(memory)) } } - } - /// Represents a scoped right to access the associated memory - pub struct BufferProxyMut<'a> { - guard: RefMut<'a, wasmer::Memory>, - } + /// Returns linear memory of the wasm instance as a slice. + /// + /// # Safety + /// + /// Wasmer doesn't provide comprehensive documentation about the exact behavior of the data + /// pointer. If a dynamic style heap is used the base pointer of the heap can change. Since + /// growing, we cannot guarantee the lifetime of the returned slice reference. + unsafe fn memory_as_slice(memory: &wasmer::Memory) -> &[u8] { + let ptr = memory.data_ptr() as *const _; + let len: usize = memory + .data_size() + .try_into() + .expect("data size should fit into usize"); + + if len == 0 { + &[] + } else { + core::slice::from_raw_parts(ptr, len) + } + } - impl<'a> BufferProxyMut<'a> { - /// Accept the ownership and created proxy object - pub fn new(guard: RefMut<'a, wasmer::Memory>) -> Self { - Self { - guard, + /// Returns linear memory of the wasm instance as a slice. + /// + /// # Safety + /// + /// See `[memory_as_slice]`. In addition to those requirements, since a mutable reference is + /// returned it must be ensured that only one mutable and no shared references to memory exists + /// at the same time. + unsafe fn memory_as_slice_mut(memory: &wasmer::Memory) -> &mut [u8] { + let ptr = memory.data_ptr(); + let len: usize = memory + .data_size() + .try_into() + .expect("data size should fit into usize"); + + if len == 0 { + &mut [] + } else { + core::slice::from_raw_parts_mut(ptr, len) } } - /// Copy the data between buffers at a specified location - pub fn transfer(&mut self, source: impl BufferProvider, source_offset: usize, dest_offset: usize, len: usize) -> Result<(), TransferError> { - source.scoped_access(|source| { - // This is safe because we construct the slice from the same parts as - // the memory region itself. We hold the lock to both of memory buffers, - // so we shouldn't have issues even if we'd try to borrow the memory twice. - let dest = unsafe { - let memory = &* self.guard; - core::slice::from_raw_parts_mut(memory.data_ptr(), memory.data_size() as usize) - }; + /// Read data from a slice of memory into a destination buffer. + /// + /// Returns an error if the read would go out of the memory bounds. + pub fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { + unsafe { + let memory = self.buffer.borrow(); - let src_range = checked_range(source_offset, len, source.len()).ok_or(TransferError::SourceTooSmall)?; - let dst_range = checked_range(dest_offset, len, dest.len()).ok_or(TransferError::DestTooSmall)?; + // This should be safe since we don't grow up memory while caching this reference and + // we give up the reference before returning from this function. + let source = Self::memory_as_slice(&memory); - dest[dst_range].copy_from_slice(&source[src_range]); + let range = checked_range(source_addr.into(), destination.len(), source.len()) + .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; + destination.copy_from_slice(&source[range]); Ok(()) - }) - } - } - - unsafe impl<'a> BufferProvider for BufferProxy<'a> { - fn scoped_access R>(&self, f: F) -> R { - // This is safe because we construct the slice from the same parts as - // the memory region itself. We hold the lock to both of memory buffers, - // so we shouldn't have issues even if we'd try to borrow the memory twice. - let buffer = unsafe { - let memory = &* self.guard; - core::slice::from_raw_parts(memory.data_ptr(), memory.data_size() as usize) - }; - - f(buffer) - } - } - - impl MemoryRef { - /// Take ownership of the memory region and return a wrapper object - pub fn new(memory: wasmer::Memory) -> Self { - Self { - buffer: Rc::new(RefCell::new(memory)) } } - /// Provides direct access to the underlying memory buffer. + /// Write data to a slice of memory. /// - /// # Panics - /// - /// Any call that requires write access to memory made within - /// the closure will panic. - pub fn with_direct_access R>(&self, f: F) -> R { - let buf = self.buffer.borrow(); - f(&BufferProxy::new(buf)) - } + /// Returns an error if the write would go out of the memory bounds. + pub fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { + unsafe { + let memory = self.buffer.borrow_mut(); - /// Provides direct mutable access to the underlying memory buffer. - /// - /// # Panics - /// - /// Any calls that requires either read or write access to memory - /// made within the closure will panic. Proceed with caution. - pub fn with_direct_access_mut R>(&self, f: F) -> R { - let buf = self.buffer.borrow_mut(); - f(&BufferProxyMut::new(buf)) + // This should be safe since we don't grow up memory while caching this reference and + // we give up the reference before returning from this function. + let destination = Self::memory_as_slice_mut(&memory); + + let range = checked_range(dest_addr.into(), source.len(), destination.len()) + .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; + + &mut destination[range].copy_from_slice(source); + Ok(()) + } } /// Clone the underlying memory object diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 8d82f549f5b50..4bf20c783e25f 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -30,11 +30,10 @@ use sp_wasm_interface::{ FunctionContext, Pointer, WordSize, Sandbox, MemoryId, Result as WResult, Function, }; use sp_runtime_interface::unpack_ptr_and_len; -use sc_executor_common::{util::BufferProvider, wasm_runtime::{WasmModule, WasmInstance, InvokeMethod}}; +use sc_executor_common::{wasm_runtime::{WasmModule, WasmInstance, InvokeMethod}}; use sc_executor_common::{ error::{Error, WasmError}, sandbox, - util, }; use sc_executor_common::runtime_blob::{RuntimeBlob, DataSegmentsSnapshot}; @@ -164,34 +163,19 @@ impl Sandbox for FunctionExecutor { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.with_direct_access(|source_proxy| { - dest_proxy - .transfer(source_proxy, val_ptr.into(), offset as usize, val_len as usize) - .map_err(|e| e.to_string()) - .map(|_| sandbox_primitives::ERR_OK) + let len = buf_len as usize; + let mut buffer = vec![0; len]; + if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } - // todo!() - - // let len = buf_len as usize; - - // let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - - // let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); - // let dst_range = match util::checked_range(buf_ptr.into(), len, memory_size.0) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - - // self.inner.memory.with_direct_access_mut(|dst_buffer| { - // dst_buffer[dst_range].copy_from_slice(&sandboxed_memory[src_range]); - // }); + todo!(); + // if let Err(_) = self.inner.instance.write_memory_from(buf_ptr, &buffer) { + // return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + // } - // Ok(sandbox_primitives::ERR_OK) - }) + // Ok(sandbox_primitives::ERR_OK) } } @@ -226,32 +210,7 @@ impl Sandbox for FunctionExecutor { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.with_direct_access_mut(|dest_proxy| { - - dest_proxy - .transfer(self.inner.memory, val_ptr.into(), offset as usize, val_len as usize) - .map_err(|e| e.to_string()) - .map(|_| sandbox_primitives::ERR_OK) - - // let len = val_len as usize; - - // let memory_size: wasmi::memory_units::Bytes = self.inner.memory.current_size().into(); - // let src_range = match util::checked_range(val_ptr.into(), len, memory_size.0) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - - // let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - - // self.inner.memory.with_direct_access(|src_buffer| { - // sandboxed_memory[dst_range].copy_from_slice(&src_buffer[src_range]); - // }); - - // Ok(sandbox_primitives::ERR_OK) - }) + todo!() } } } diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index ffbc7a89c904c..324a5c4c17357 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -202,31 +202,18 @@ impl Sandbox for HostState { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.with_direct_access(|sandboxed_memory| { - todo!() - - // let len = buf_len as usize; - - // let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; + let len = buf_len as usize; + let mut buffer = vec![0; len]; - // let supervisor_mem_size = self.inner.instance.memory_size() as usize; - // let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; + if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } - // self.inner.instance - // .write_memory_from( - // Pointer::new(dst_range.start as u32), - // &sandboxed_memory[src_range], - // ) - // .expect("ranges are checked above; write can't fail; qed"); + if let Err(_) = self.inner.instance.write_memory_from(buf_ptr, &buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } - // Ok(sandbox_primitives::ERR_OK) - }) + Ok(sandbox_primitives::ERR_OK) } } } @@ -273,35 +260,18 @@ impl Sandbox for HostState { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.with_direct_access_mut(|dest_proxy| { - - dest_proxy - .transfer(source, val_ptr.into(), offset as usize, val_len as usize) - .map_err(|e| e.to_string()) - .map(|_| sandbox_primitives::ERR_OK) - - // let len = val_len as usize; - // let supervisor_mem_size = self.inner.instance.memory_size() as usize; - - // let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - - // let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len() as usize) { - // Some(range) => range, - // None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - // }; - - // self.inner.instance - // .read_memory_into( - // Pointer::new(src_range.start as u32), - // &mut sandboxed_memory[dst_range], - // ) - // .expect("ranges are checked above; read can't fail; qed"); - - // Ok(sandbox_primitives::ERR_OK) - }) + let len = val_len as usize; + let mut buffer = vec![0; len]; + + if let Err(_) = self.inner.instance.read_memory_into(val_ptr, &mut buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } + + if let Err(_) = sandboxed_memory.write_from(Pointer::new(offset as u32), &buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } + + Ok(sandbox_primitives::ERR_OK) } } } From ea86458f101782aef6d3ce6d2c7aa881acdb0d62 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Fri, 2 Jul 2021 13:58:11 +0700 Subject: [PATCH 67/88] Adds WasmiMemoryWrapper and MemoryTransfer trait --- client/executor/common/src/util.rs | 92 ++++++++++++++++++++-------- client/executor/wasmi/src/lib.rs | 2 +- client/executor/wasmtime/src/host.rs | 1 + 3 files changed, 68 insertions(+), 27 deletions(-) diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs index eb8601c2a4a76..40c8d6d0d2b1e 100644 --- a/client/executor/common/src/util.rs +++ b/client/executor/common/src/util.rs @@ -19,6 +19,8 @@ //! Utilities used by all backends use std::ops::Range; +use sp_wasm_interface::Pointer; +use crate::error::{Result, Error}; /// Construct a range from an offset to a data length after the offset. /// Returns None if the end of the range would exceed some maximum offset. @@ -31,6 +33,49 @@ pub fn checked_range(offset: usize, len: usize, max: usize) -> Option, destination: &mut [u8]) -> Result<()>; + + /// Write data to a slice of memory. + /// + /// Returns an error if the write would go out of the memory bounds. + fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()>; +} + +struct WasmiMemoryWrapper(wasmi::MemoryRef); + +impl WasmiMemoryWrapper { + /// Take ownership of the memory region and return a wrapper object + pub fn new(memory: wasmi::MemoryRef) -> Self { + Self(memory) + } +} + +impl MemoryTransfer for WasmiMemoryWrapper { + fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { + self.0.with_direct_access(|source| { + let range = checked_range(source_addr.into(), destination.len(), source.len()) + .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; + + destination.copy_from_slice(&source[range]); + Ok(()) + }) + } + + fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { + self.0.with_direct_access_mut(|destination| { + let range = checked_range(dest_addr.into(), source.len(), destination.len()) + .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; + + &mut destination[range].copy_from_slice(source); + Ok(()) + }) + } +} + // Routines specific to Wasmer runtime. Since sandbox can be invoked from both /// wasmi and wasmtime runtime executors, we need to have a way to deal with sanbox /// backends right from the start. @@ -99,10 +144,26 @@ pub mod wasmer { } } - /// Read data from a slice of memory into a destination buffer. + /// Clone the underlying memory object + /// + /// # Safety + /// + /// The sole purpose of `MemoryRef` is to protect the memory from uncontrolled + /// access. By returning the memory object "as is" we bypass all of the checks. /// - /// Returns an error if the read would go out of the memory bounds. - pub fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { + /// Intended to use only during module initialization. + /// + /// # Panics + /// + /// Will panic if `MemoryRef` is currently in use. + pub unsafe fn clone_inner(&mut self) -> wasmer::Memory { + // We take exclusive lock to ensure that we're the only one here + self.buffer.borrow_mut().clone() + } + } + + impl super::MemoryTransfer for MemoryRef { + fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { unsafe { let memory = self.buffer.borrow(); @@ -118,10 +179,7 @@ pub mod wasmer { } } - /// Write data to a slice of memory. - /// - /// Returns an error if the write would go out of the memory bounds. - pub fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { + fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { unsafe { let memory = self.buffer.borrow_mut(); @@ -135,24 +193,6 @@ pub mod wasmer { &mut destination[range].copy_from_slice(source); Ok(()) } - } - - /// Clone the underlying memory object - /// - /// # Safety - /// - /// The sole purpose of `MemoryRef` is to protect the memory from uncontrolled - /// access. By returning the memory object "as is" we bypass all of the checks. - /// - /// Intended to use only during module initialization. - /// - /// # Panics - /// - /// Will panic if `MemoryRef` is currently in use. - pub unsafe fn clone_inner(&mut self) -> wasmer::Memory { - // We take exclusive lock to ensure that we're the only one here - self.buffer.borrow_mut().clone() - } + } } - } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 4bf20c783e25f..103fbe38e1279 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -30,7 +30,7 @@ use sp_wasm_interface::{ FunctionContext, Pointer, WordSize, Sandbox, MemoryId, Result as WResult, Function, }; use sp_runtime_interface::unpack_ptr_and_len; -use sc_executor_common::{wasm_runtime::{WasmModule, WasmInstance, InvokeMethod}}; +use sc_executor_common::{util::MemoryTransfer, wasm_runtime::{WasmModule, WasmInstance, InvokeMethod}}; use sc_executor_common::{ error::{Error, WasmError}, sandbox, diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 324a5c4c17357..215a9f2fbf0e6 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -23,6 +23,7 @@ use crate::instance_wrapper::InstanceWrapper; use std::{cell::RefCell, rc::Rc}; use log::trace; use codec::{Encode, Decode}; +use sc_executor_common::util::MemoryTransfer; use sp_allocator::FreeingBumpHeapAllocator; use sc_executor_common::{error::Result, util}; use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex}; From 33e607341af3c03af497810676b0cd9a85dd2f63 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 6 Jul 2021 11:52:27 +0700 Subject: [PATCH 68/88] Refactor naming --- client/executor/common/src/sandbox.rs | 39 ++++++++----- client/executor/common/src/util.rs | 79 +++++++++++++++++---------- client/executor/wasmtime/src/host.rs | 2 + 3 files changed, 77 insertions(+), 43 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 41ce6e5544362..5be4d91d56639 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -25,13 +25,14 @@ use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; use wasmi::{ - Externals, ImportResolver, MemoryInstance, MemoryRef as WasmiMemoryRef, Module, + Externals, ImportResolver, MemoryInstance, Module, ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages }; use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; #[cfg(feature = "wasmer-sandbox")] -use crate::util::wasmer::MemoryRef as WasmerMemoryRef; +use crate::util::wasmer::MemoryWrapper as WasmerMemoryWrapper; +use crate::util::wasmi::MemoryWrapper as WasmiMemoryWrapper; /// Index of a function inside the supervisor. /// @@ -122,7 +123,7 @@ impl ImportResolver for Imports { module_name: &str, field_name: &str, _memory_type: &::wasmi::MemoryDescriptor, - ) -> std::result::Result { + ) -> std::result::Result { let mem = self.memory_by_name(module_name, field_name) .ok_or_else(|| { wasmi::Error::Instantiation(format!( @@ -131,14 +132,18 @@ impl ImportResolver for Imports { )) })?; - let mem = mem.as_wasmi() + let wrapper = mem + .as_wasmi() .ok_or_else(|| { wasmi::Error::Instantiation(format!( "Unsupported non-wasmi export {}:{}", module_name, field_name )) - })? - .clone(); + })?; + + // Here we use inner memory reference only to resolve + // the imports wthout accessing the memory contents. + let mem = unsafe { wrapper.clone_inner() }; Ok(mem) } @@ -626,16 +631,16 @@ pub enum SandboxBackend { #[derive(Clone, Debug)] pub enum Memory { /// Wasmi memory reference - Wasmi(WasmiMemoryRef), + Wasmi(WasmiMemoryWrapper), /// Wasmer memory refernce #[cfg(feature = "wasmer-sandbox")] - Wasmer(WasmerMemoryRef), + Wasmer(WasmerMemoryWrapper), } impl Memory { /// View as wasmi memory - pub fn as_wasmi(&self) -> Option { + pub fn as_wasmi(&self) -> Option { match self { Memory::Wasmi(memory) => Some(memory.clone()), @@ -646,7 +651,7 @@ impl Memory { /// View as wasmer memory #[cfg(feature = "wasmer-sandbox")] - pub fn as_wasmer(&self) -> Option { + pub fn as_wasmer(&self) -> Option { match self { Memory::Wasmer(memory) => Some(memory.clone()), Memory::Wasmi(_) => None, @@ -726,17 +731,21 @@ impl Store { let memory = match &backend_context { BackendContext::Wasmi => { - Memory::Wasmi(MemoryInstance::alloc( - Pages(initial as usize), - maximum.map(|m| Pages(m as usize)), - )?) + Memory::Wasmi( + WasmiMemoryWrapper::new( + MemoryInstance::alloc( + Pages(initial as usize), + maximum.map(|m| Pages(m as usize)), + )? + ) + ) } #[cfg(feature = "wasmer-sandbox")] BackendContext::Wasmer(context) => { let ty = wasmer::MemoryType::new(initial, maximum, false); Memory::Wasmer( - WasmerMemoryRef::new( + WasmerMemoryWrapper::new( wasmer::Memory::new(&context.store, ty) .map_err(|_| Error::InvalidMemoryReference)? ) diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs index 40c8d6d0d2b1e..4ced26efa5d6d 100644 --- a/client/executor/common/src/util.rs +++ b/client/executor/common/src/util.rs @@ -33,6 +33,7 @@ pub fn checked_range(offset: usize, len: usize, max: usize) -> Option, source: &[u8]) -> Result<()>; } -struct WasmiMemoryWrapper(wasmi::MemoryRef); +/// Safe wrapper over wasmi memory reference +pub mod wasmi { + use super::*; -impl WasmiMemoryWrapper { - /// Take ownership of the memory region and return a wrapper object - pub fn new(memory: wasmi::MemoryRef) -> Self { - Self(memory) - } -} + /// Wasmi provides direct access to its memory using slices. + /// + /// This wrapper limits the scope where the slice can be taken to + #[derive(Debug, Clone)] + pub struct MemoryWrapper(::wasmi::MemoryRef); -impl MemoryTransfer for WasmiMemoryWrapper { - fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { - self.0.with_direct_access(|source| { - let range = checked_range(source_addr.into(), destination.len(), source.len()) - .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; + impl MemoryWrapper { + /// Take ownership of the memory region and return a wrapper object + pub fn new(memory: ::wasmi::MemoryRef) -> Self { + Self(memory) + } - destination.copy_from_slice(&source[range]); - Ok(()) - }) + /// Clone the underlying memory object + /// + /// # Safety + /// + /// The sole purpose of `MemoryRef` is to protect the memory from uncontrolled + /// access. By returning the memory object "as is" we bypass all of the checks. + /// + /// Intended to use only during module initialization. + /// + pub unsafe fn clone_inner(&self) -> ::wasmi::MemoryRef { + self.0.clone() + } } - fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { - self.0.with_direct_access_mut(|destination| { - let range = checked_range(dest_addr.into(), source.len(), destination.len()) - .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; + impl super::MemoryTransfer for MemoryWrapper { + fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { + self.0.with_direct_access(|source| { + let range = checked_range(source_addr.into(), destination.len(), source.len()) + .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; + + destination.copy_from_slice(&source[range]); + Ok(()) + }) + } - &mut destination[range].copy_from_slice(source); - Ok(()) - }) + fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { + self.0.with_direct_access_mut(|destination| { + let range = checked_range(dest_addr.into(), source.len(), destination.len()) + .ok_or_else(|| Error::Other("memory write is out of bounds".into()))?; + + &mut destination[range].copy_from_slice(source); + Ok(()) + }) + } } } @@ -81,20 +104,20 @@ impl MemoryTransfer for WasmiMemoryWrapper { /// backends right from the start. #[cfg(feature = "wasmer-sandbox")] pub mod wasmer { - use std::{cell::{RefCell}, rc::Rc}; - use error::Result; use sp_wasm_interface::Pointer; - use crate::{error::{self, Error}, util::checked_range}; + use crate::error::{Result, Error}; + use super::checked_range; + use std::{cell::RefCell, rc::Rc}; use std::convert::TryInto; /// In order to enforce memory access protocol to the backend memory /// we wrap it with `RefCell` and encapsulate all memory operations. #[derive(Debug, Clone)] - pub struct MemoryRef { + pub struct MemoryWrapper { buffer: Rc>, } - impl MemoryRef { + impl MemoryWrapper { /// Take ownership of the memory region and return a wrapper object pub fn new(memory: wasmer::Memory) -> Self { Self { @@ -162,7 +185,7 @@ pub mod wasmer { } } - impl super::MemoryTransfer for MemoryRef { + impl super::MemoryTransfer for MemoryWrapper { fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { unsafe { let memory = self.buffer.borrow(); diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 215a9f2fbf0e6..4a68b0649abcc 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -261,6 +261,8 @@ impl Sandbox for HostState { #[cfg(feature = "wasmer-sandbox")] sandbox::Memory::Wasmer(sandboxed_memory) => { + // TODO check len vs supervisor_mem_size + let len = val_len as usize; let mut buffer = vec![0; len]; From e098dcad9025d6b609154776be796c284aeccebd Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 6 Jul 2021 12:20:01 +0700 Subject: [PATCH 69/88] Perform all memory transfers using MemoryTransfer --- client/executor/common/src/sandbox.rs | 30 +++++++- client/executor/wasmi/src/lib.rs | 63 +++++----------- client/executor/wasmtime/src/host.rs | 100 +++++--------------------- 3 files changed, 66 insertions(+), 127 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 5be4d91d56639..ef4d0a6450ec9 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -20,7 +20,7 @@ //! //! Sandboxing is backed by wasmi and wasmer, depending on the configuration. -use crate::error::{Result, Error}; +use crate::{error::{Result, Error}, util}; use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; @@ -659,6 +659,34 @@ impl Memory { } } +impl util::MemoryTransfer for Memory { + fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { + match self { + Memory::Wasmi(sandboxed_memory) => { + sandboxed_memory.read_into(source_addr, destination) + }, + + #[cfg(feature = "wasmer-sandbox")] + Memory::Wasmer(sandboxed_memory) => { + sandboxed_memory.read_into(source_addr, destination) + }, + } + } + + fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { + match self { + Memory::Wasmi(sandboxed_memory) => { + sandboxed_memory.write_from(dest_addr, source) + }, + + #[cfg(feature = "wasmer-sandbox")] + Memory::Wasmer(sandboxed_memory) => { + sandboxed_memory.write_from(dest_addr, source) + }, + } + } +} + /// Wasmer specific context #[cfg(feature = "wasmer-sandbox")] struct WasmerBackend { diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 103fbe38e1279..a0bf6da685522 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -147,38 +147,18 @@ impl Sandbox for FunctionExecutor { .borrow() .memory(memory_id).map_err(|e| e.to_string())?; - match sandboxed_memory { - sandbox::Memory::Wasmi(sandboxed_memory) => { - match MemoryInstance::transfer( - &sandboxed_memory, - offset as usize, - &self.inner.memory, - buf_ptr.into(), - buf_len as usize, - ) { - Ok(()) => Ok(sandbox_primitives::ERR_OK), - Err(_) => Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - } - } + let len = buf_len as usize; + let mut buffer = vec![0; len]; - #[cfg(feature = "wasmer-sandbox")] - sandbox::Memory::Wasmer(sandboxed_memory) => { - let len = buf_len as usize; - let mut buffer = vec![0; len]; - - if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } - - todo!(); - // if let Err(_) = self.inner.instance.write_memory_from(buf_ptr, &buffer) { - // return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - // } + if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } - // Ok(sandbox_primitives::ERR_OK) - } + if let Err(_) = self.inner.memory.set(buf_ptr.into(), &buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) } + Ok(sandbox_primitives::ERR_OK) } fn memory_set( @@ -194,25 +174,18 @@ impl Sandbox for FunctionExecutor { .borrow() .memory(memory_id).map_err(|e| e.to_string())?; - match sandboxed_memory { - sandbox::Memory::Wasmi(sandboxed_memory) => { - match MemoryInstance::transfer( - &self.inner.memory, - val_ptr.into(), - &sandboxed_memory, - offset as usize, - val_len as usize, - ) { - Ok(()) => Ok(sandbox_primitives::ERR_OK), - Err(_) => Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - } - } + let len = val_len as usize; + let mut buffer = vec![0; len]; - #[cfg(feature = "wasmer-sandbox")] - sandbox::Memory::Wasmer(sandboxed_memory) => { - todo!() - } + if let Err(_) = self.inner.memory.get_into(val_ptr.into(), &mut buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) } + + if let Err(_) = sandboxed_memory.write_from(Pointer::new(offset as u32), &buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } + + Ok(sandbox_primitives::ERR_OK) } fn memory_teardown(&mut self, memory_id: MemoryId) -> WResult<()> { diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 4a68b0649abcc..0153653c53473 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -174,49 +174,18 @@ impl Sandbox for HostState { .memory(memory_id) .map_err(|e| e.to_string())?; - match sandboxed_memory { - sandbox::Memory::Wasmi(sandboxed_memory) => { - sandboxed_memory.with_direct_access(|sandboxed_memory| { - let len = buf_len as usize; - - let src_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - let dst_range = match util::checked_range(buf_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - self.inner.instance - .write_memory_from( - Pointer::new(dst_range.start as u32), - &sandboxed_memory[src_range], - ) - .expect("ranges are checked above; write can't fail; qed"); + let len = buf_len as usize; + let mut buffer = vec![0; len]; - Ok(sandbox_primitives::ERR_OK) - }) - }, - - #[cfg(feature = "wasmer-sandbox")] - sandbox::Memory::Wasmer(sandboxed_memory) => { - let len = buf_len as usize; - let mut buffer = vec![0; len]; - - if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } - - if let Err(_) = self.inner.instance.write_memory_from(buf_ptr, &buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } + if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } - Ok(sandbox_primitives::ERR_OK) - } + if let Err(_) = self.inner.instance.write_memory_from(buf_ptr, &buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) } + + Ok(sandbox_primitives::ERR_OK) } fn memory_set( @@ -232,51 +201,20 @@ impl Sandbox for HostState { .memory(memory_id) .map_err(|e| e.to_string())?; - match sandboxed_memory { - sandbox::Memory::Wasmi(sandboxed_memory) => { - sandboxed_memory.with_direct_access_mut(|sandboxed_memory| { - let len = val_len as usize; - let supervisor_mem_size = self.inner.instance.memory_size() as usize; - - let src_range = match util::checked_range(val_ptr.into(), len, supervisor_mem_size) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - let dst_range = match util::checked_range(offset as usize, len, sandboxed_memory.len()) { - Some(range) => range, - None => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), - }; - - self.inner.instance - .read_memory_into( - Pointer::new(src_range.start as u32), - &mut sandboxed_memory[dst_range], - ) - .expect("ranges are checked above; read can't fail; qed"); + // TODO check len vs supervisor_mem_size - Ok(sandbox_primitives::ERR_OK) - }) - } - - #[cfg(feature = "wasmer-sandbox")] - sandbox::Memory::Wasmer(sandboxed_memory) => { - // TODO check len vs supervisor_mem_size - - let len = val_len as usize; - let mut buffer = vec![0; len]; - - if let Err(_) = self.inner.instance.read_memory_into(val_ptr, &mut buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } + let len = val_len as usize; + let mut buffer = vec![0; len]; - if let Err(_) = sandboxed_memory.write_from(Pointer::new(offset as u32), &buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } + if let Err(_) = self.inner.instance.read_memory_into(val_ptr, &mut buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) + } - Ok(sandbox_primitives::ERR_OK) - } + if let Err(_) = sandboxed_memory.write_from(Pointer::new(offset as u32), &buffer) { + return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) } + + Ok(sandbox_primitives::ERR_OK) } fn memory_teardown(&mut self, memory_id: MemoryId) -> sp_wasm_interface::Result<()> { From 314b6aa97d974633040e7a0d476be1d719a2a7b0 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 6 Jul 2021 17:41:08 +0700 Subject: [PATCH 70/88] Adds allocating `read` --- client/executor/common/src/sandbox.rs | 15 ++++++++- client/executor/common/src/util.rs | 33 ++++++++++++++++++- client/executor/wasmi/src/lib.rs | 16 ++++----- client/executor/wasmtime/src/host.rs | 18 +++++----- .../executor/wasmtime/src/instance_wrapper.rs | 13 ++++++++ 5 files changed, 75 insertions(+), 20 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index ef4d0a6450ec9..9480e91f247b6 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -660,7 +660,20 @@ impl Memory { } impl util::MemoryTransfer for Memory { - fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { + fn read(&self, source_addr: Pointer, size: usize) -> Result> { + match self { + Memory::Wasmi(sandboxed_memory) => { + sandboxed_memory.read(source_addr, size) + }, + + #[cfg(feature = "wasmer-sandbox")] + Memory::Wasmer(sandboxed_memory) => { + sandboxed_memory.read(source_addr, size) + }, + } + } + + fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { match self { Memory::Wasmi(sandboxed_memory) => { sandboxed_memory.read_into(source_addr, destination) diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs index 4ced26efa5d6d..9e8e90ab58ca1 100644 --- a/client/executor/common/src/util.rs +++ b/client/executor/common/src/util.rs @@ -35,6 +35,11 @@ pub fn checked_range(offset: usize, len: usize, max: usize) -> Option, size: usize) -> Result>; + /// Read data from a slice of memory into a destination buffer. /// /// Returns an error if the read would go out of the memory bounds. @@ -77,6 +82,15 @@ pub mod wasmi { } impl super::MemoryTransfer for MemoryWrapper { + fn read(&self, source_addr: Pointer, size: usize) -> Result> { + self.0.with_direct_access(|source| { + let range = checked_range(source_addr.into(), size, source.len()) + .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; + + Ok(Vec::from(&source[range])) + }) + } + fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { self.0.with_direct_access(|source| { let range = checked_range(source_addr.into(), destination.len(), source.len()) @@ -186,6 +200,23 @@ pub mod wasmer { } impl super::MemoryTransfer for MemoryWrapper { + fn read(&self, source_addr: Pointer, size: usize) -> Result> { + let memory = self.buffer.borrow(); + + let data_size = memory + .data_size() + .try_into() + .expect("data size does not fit"); + + let range = checked_range(source_addr.into(), size, data_size) + .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; + + let mut buffer = vec![0; range.len()]; + self.read_into(source_addr, &mut buffer)?; + + Ok(buffer) + } + fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { unsafe { let memory = self.buffer.borrow(); @@ -216,6 +247,6 @@ pub mod wasmer { &mut destination[range].copy_from_slice(source); Ok(()) } - } + } } } diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index a0bf6da685522..22719d48e5123 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -148,11 +148,11 @@ impl Sandbox for FunctionExecutor { .memory(memory_id).map_err(|e| e.to_string())?; let len = buf_len as usize; - let mut buffer = vec![0; len]; - if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } + let buffer = match sandboxed_memory.read(Pointer::new(offset as u32), len) { + Err(_) => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + Ok(buffer) => buffer, + }; if let Err(_) = self.inner.memory.set(buf_ptr.into(), &buffer) { return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) @@ -175,11 +175,11 @@ impl Sandbox for FunctionExecutor { .memory(memory_id).map_err(|e| e.to_string())?; let len = val_len as usize; - let mut buffer = vec![0; len]; - if let Err(_) = self.inner.memory.get_into(val_ptr.into(), &mut buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } + let buffer = match self.inner.memory.get(val_ptr.into(), len) { + Err(_) => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + Ok(buffer) => buffer, + }; if let Err(_) = sandboxed_memory.write_from(Pointer::new(offset as u32), &buffer) { return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 0153653c53473..e18cfe05a44aa 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -175,11 +175,11 @@ impl Sandbox for HostState { .map_err(|e| e.to_string())?; let len = buf_len as usize; - let mut buffer = vec![0; len]; - if let Err(_) = sandboxed_memory.read_into(Pointer::new(offset as u32), &mut buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } + let buffer = match sandboxed_memory.read(Pointer::new(offset as u32), len) { + Err(_) => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + Ok(buffer) => buffer, + }; if let Err(_) = self.inner.instance.write_memory_from(buf_ptr, &buffer) { return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) @@ -201,14 +201,12 @@ impl Sandbox for HostState { .memory(memory_id) .map_err(|e| e.to_string())?; - // TODO check len vs supervisor_mem_size - let len = val_len as usize; - let mut buffer = vec![0; len]; - if let Err(_) = self.inner.instance.read_memory_into(val_ptr, &mut buffer) { - return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) - } + let buffer = match self.inner.instance.read_memory(val_ptr, len) { + Err(_) => return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS), + Ok(buffer) => buffer, + }; if let Err(_) = sandboxed_memory.write_from(Pointer::new(offset as u32), &buffer) { return Ok(sandbox_primitives::ERR_OUT_OF_BOUNDS) diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index e7c0c028ccd32..4832cffc57615 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -318,6 +318,19 @@ fn get_table(instance: &Instance) -> Option
{ /// Functions realted to memory. impl InstanceWrapper { + /// Read data from a slice of memory into a newly allocated buffer. + /// + /// Returns an error if the read would go out of the memory bounds. + pub fn read_memory(&self, source_addr: Pointer, size: usize) -> Result> { + let range = checked_range(source_addr.into(), size, self.memory.data_size()) + .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; + + let mut buffer = vec![0; range.len()]; + self.read_memory_into(source_addr, &mut buffer)?; + + Ok(buffer) + } + /// Read data from a slice of memory into a destination buffer. /// /// Returns an error if the read would go out of the memory bounds. From 32423fb354f541c2ecda25a009b83c619c42ba0f Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Jul 2021 09:01:19 +0700 Subject: [PATCH 71/88] Adds comments --- client/executor/wasmi/src/lib.rs | 8 ++++++++ client/executor/wasmtime/src/host.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 22719d48e5123..75b6403fe1a60 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -321,6 +321,10 @@ impl Sandbox for FunctionExecutor { } } +/// Wasmi specific implementation of `SandboxCapabilitiesHolder` that provides +/// sandbox with a scoped thread local access to a function executor. +/// This is a way to calm down the borrow checker since host function closures +/// require exclusive access to it. struct CapsHolder; scoped_tls::scoped_thread_local!(static EXECUTOR: FunctionExecutor); @@ -335,6 +339,10 @@ impl sandbox::SandboxCapabilitiesHolder for CapsHolder { } } +/// Wasmi specific implementation of `DispatchThunkHolder` that provides +/// sandbox with a scoped thread local access to a dispatch thunk. +/// This is a way to calm down the borrow checker since host function closures +/// require exclusive access to it. struct ThunkHolder; scoped_tls::scoped_thread_local!(static DISPATCH_THUNK: wasmi::FuncRef); diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index e18cfe05a44aa..b3846d917cd14 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -349,6 +349,10 @@ impl Sandbox for HostState { } } +/// Wasmtime specific implementation of `SandboxCapabilitiesHolder` that provides +/// sandbox with a scoped thread local access to a function executor. +/// This is a way to calm down the borrow checker since host function closures +/// require exclusive access to it. struct CapsHolder; impl SandboxCapabilitiesHolder for CapsHolder { @@ -362,6 +366,10 @@ impl SandboxCapabilitiesHolder for CapsHolder { } } +/// Wasmtime specific implementation of `DispatchThunkHolder` that provides +/// sandbox with a scoped thread local access to a dispatch thunk. +/// This is a way to calm down the borrow checker since host function closures +/// require exclusive access to it. struct ThunkHolder; scoped_tls::scoped_thread_local!(static DISPATCH_THUNK: SupervisorFuncRef); From 72ba8dc69c437c329504191663b1976f37890a59 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Jul 2021 16:58:10 +0700 Subject: [PATCH 72/88] Removes unused imports --- client/executor/wasmi/src/lib.rs | 2 +- client/executor/wasmtime/src/host.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 75b6403fe1a60..c14f95f566d61 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -18,7 +18,7 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. -use std::{cell::{Ref, RefCell}, ops::Range, rc::Rc, str, sync::Arc}; +use std::{cell::RefCell, rc::Rc, str, sync::Arc}; use wasmi::{ FuncInstance, ImportsBuilder, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, RuntimeValue::{I32, I64, self}, TableRef, memory_units::Pages, diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index b3846d917cd14..e631363df1188 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -25,7 +25,7 @@ use log::trace; use codec::{Encode, Decode}; use sc_executor_common::util::MemoryTransfer; use sp_allocator::FreeingBumpHeapAllocator; -use sc_executor_common::{error::Result, util}; +use sc_executor_common::error::Result; use sc_executor_common::sandbox::{self, SandboxCapabilities, SupervisorFuncIndex}; use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; From e27bba20eb1f9044f8dc9e3b9a1c1fec28f0484e Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 7 Jul 2021 22:07:15 +0700 Subject: [PATCH 73/88] Removes now unused function --- client/executor/wasmtime/src/instance_wrapper.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index baaacb987f027..98589de64cab4 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -250,11 +250,6 @@ impl InstanceWrapper { self.table.as_ref() } - /// Returns the byte size of the linear memory instance attached to this instance. - pub fn memory_size(&self) -> u32 { - self.memory.data_size() as u32 - } - /// Reads `__heap_base: i32` global variable and returns it. /// /// If it doesn't exist, not a global or of not i32 type returns an error. From 2d7ba8a2111f1a9bd7c91057b344ecbb367ca142 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 8 Jul 2021 15:09:54 +0700 Subject: [PATCH 74/88] Pulls Cargo.lock from origin/master --- Cargo.lock | 1389 +++++++++++++++++++++++++++------------------------- 1 file changed, 711 insertions(+), 678 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c605e51144a5..28883ed7c6c3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,18 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.15.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" +dependencies = [ + "gimli 0.23.0", +] + +[[package]] +name = "addr2line" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" dependencies = [ "gimli 0.24.0", ] @@ -27,12 +36,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" - [[package]] name = "aead" version = "0.3.2" @@ -63,7 +66,7 @@ dependencies = [ "aes", "block-cipher", "ghash", - "subtle 2.2.2", + "subtle 2.4.0", ] [[package]] @@ -106,9 +109,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.10" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] @@ -133,9 +136,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.41" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" [[package]] name = "approx" @@ -148,9 +151,9 @@ dependencies = [ [[package]] name = "arbitrary" -version = "1.0.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237430fd6ed3740afe94eefcc278ae21e050285be882804e0d6e8695f0c94691" +checksum = "698b65a961a9d730fb45b6b0327e20207810c9f61ee421b082b27ba003f49e2b" [[package]] name = "arrayref" @@ -169,15 +172,15 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd" +checksum = "5a2f58b0bb10c380af2b26e57212856b8c9a59e0925b4c20f4a174a49734eaf7" [[package]] name = "asn1_der" @@ -187,10 +190,11 @@ checksum = "9d6e24d2cce90c53b948c46271bfb053e4bdc2db9b5d3f65e20f8cf28a1b7fc3" [[package]] name = "assert_cmd" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da" +checksum = "f2475b58cd94eb4f70159f4fd8844ba3b807532fe3131b3373fae060bbe30396" dependencies = [ + "bstr", "doc-comment", "predicates", "predicates-core", @@ -200,9 +204,9 @@ dependencies = [ [[package]] name = "assert_matches" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-attributes" @@ -227,16 +231,16 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.4.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +checksum = "eb877970c7b440ead138f6321a3b5395d6061183af779340b65e20c0fede9146" dependencies = [ "async-task", "concurrent-queue", "fastrand", "futures-lite", "once_cell", - "slab", + "vec-arena", ] [[package]] @@ -257,28 +261,29 @@ dependencies = [ [[package]] name = "async-io" -version = "1.6.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +checksum = "9315f8f07556761c3e48fec2e6b276004acf426e6dc068b2c2251854d65ee0fd" dependencies = [ "concurrent-queue", + "fastrand", "futures-lite", "libc", "log", + "nb-connect", "once_cell", "parking", "polling", - "slab", - "socket2 0.4.0", + "vec-arena", "waker-fn", "winapi 0.3.9", ] [[package]] name = "async-lock" -version = "2.4.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +checksum = "1996609732bde4a9988bc42125f55f2af5f3c36370e27c778d5191a4a1b63bfb" dependencies = [ "event-listener", ] @@ -294,16 +299,15 @@ dependencies = [ [[package]] name = "async-process" -version = "1.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f38756dd9ac84671c428afbf7c9f7495feff9ec5b0710f17100098e5b354ac" +checksum = "ef37b86e2fa961bae5a4d212708ea0154f904ce31d1a4a7f47e1bbc33a0c040b" dependencies = [ "async-io", "blocking", "cfg-if 1.0.0", "event-listener", "futures-lite", - "libc", "once_cell", "signal-hook", "winapi 0.3.9", @@ -321,7 +325,7 @@ dependencies = [ "async-io", "async-lock", "async-process", - "crossbeam-utils 0.8.5", + "crossbeam-utils 0.8.3", "futures-channel", "futures-core", "futures-io", @@ -332,7 +336,7 @@ dependencies = [ "memchr", "num_cpus", "once_cell", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.6", "pin-utils", "slab", "wasm-bindgen-futures", @@ -340,9 +344,9 @@ dependencies = [ [[package]] name = "async-std-resolver" -version = "0.20.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed4e2c3da14d8ad45acb1e3191db7a918e9505b6f155b218e70a7c9a1a48c638" +checksum = "f665c56111e244fe38e7708ee10948a4356ad6a548997c21f5a63a0f4e0edc4d" dependencies = [ "async-std", "async-trait", @@ -360,9 +364,9 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-trait" -version = "0.1.50" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" +checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf" dependencies = [ "proc-macro2", "quote", @@ -379,7 +383,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.6", ] [[package]] @@ -392,7 +396,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.6", ] [[package]] @@ -423,22 +427,21 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.59" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ - "addr2line", - "cc", + "addr2line 0.14.1", "cfg-if 1.0.0", "libc", - "miniz_oxide 0.4.4", - "object 0.24.0", + "miniz_oxide", + "object 0.23.0", "rustc-demangle", ] @@ -477,10 +480,11 @@ dependencies = [ [[package]] name = "bincode" -version = "1.3.3" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +checksum = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" dependencies = [ + "byteorder", "serde", ] @@ -511,9 +515,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bitvec" -version = "0.20.4" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +checksum = "1f682656975d3a682daff957be4ddeb65d6ad656737cd821f2d00685ae466af1" dependencies = [ "funty", "radium", @@ -544,34 +548,34 @@ dependencies = [ [[package]] name = "blake2b_simd" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ "arrayref", - "arrayvec 0.5.1", + "arrayvec 0.5.2", "constant_time_eq", ] [[package]] name = "blake2s_simd" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9e07352b829279624ceb7c64adb4f585dacdb81d35cafae81139ccd617cf44" +checksum = "9e461a7034e85b211a4acb57ee2e6730b32912b06c08cc242243c39fc21ae6a2" dependencies = [ "arrayref", - "arrayvec 0.5.1", + "arrayvec 0.5.2", "constant_time_eq", ] [[package]] name = "blake3" -version = "0.3.8" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" +checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" dependencies = [ "arrayref", - "arrayvec 0.5.1", + "arrayvec 0.5.2", "cc", "cfg-if 0.1.10", "constant_time_eq", @@ -588,7 +592,7 @@ dependencies = [ "block-padding 0.1.5", "byte-tools", "byteorder", - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] @@ -647,9 +651,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" dependencies = [ "lazy_static", "memchr", @@ -668,9 +672,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.2.1" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byte-slice-cast" @@ -686,9 +690,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "bytes" @@ -703,9 +707,9 @@ dependencies = [ [[package]] name = "bytes" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" [[package]] name = "bytes" @@ -762,9 +766,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.68" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" dependencies = [ "jobserver", ] @@ -884,9 +888,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.33.0" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "ansi_term 0.11.0", "atty", @@ -931,12 +935,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "core-foundation" version = "0.7.0" @@ -980,13 +978,10 @@ dependencies = [ ] [[package]] -name = "cpufeatures" -version = "0.1.5" +name = "cpuid-bool" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" -dependencies = [ - "libc", -] +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "cpuid-bool" @@ -1145,7 +1140,7 @@ dependencies = [ "cranelift-codegen 0.74.0", "cranelift-entity 0.74.0", "cranelift-frontend 0.74.0", - "itertools 0.10.1", + "itertools 0.10.0", "log", "serde", "smallvec 1.6.1", @@ -1155,11 +1150,11 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] @@ -1173,7 +1168,7 @@ dependencies = [ "clap", "criterion-plot", "csv", - "itertools 0.10.1", + "itertools 0.10.0", "lazy_static", "num-traits", "oorandom", @@ -1200,12 +1195,12 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.5", + "crossbeam-utils 0.8.3", ] [[package]] @@ -1226,8 +1221,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch 0.9.5", - "crossbeam-utils 0.8.5", + "crossbeam-epoch 0.9.3", + "crossbeam-utils 0.8.3", ] [[package]] @@ -1241,31 +1236,32 @@ dependencies = [ "crossbeam-utils 0.7.2", "lazy_static", "maybe-uninit", - "memoffset 0.5.4", + "memoffset 0.5.6", "scopeguard", ] [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.5", + "crossbeam-utils 0.8.3", "lazy_static", - "memoffset 0.6.4", + "memoffset 0.6.1", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" dependencies = [ "cfg-if 0.1.10", "crossbeam-utils 0.7.2", + "maybe-uninit", ] [[package]] @@ -1281,10 +1277,11 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.5" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" dependencies = [ + "autocfg", "cfg-if 1.0.0", "lazy_static", ] @@ -1301,7 +1298,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", "subtle 1.0.0", ] @@ -1312,14 +1309,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.4", - "subtle 2.2.2", + "subtle 2.4.0", ] [[package]] name = "csv" -version = "1.1.3" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" dependencies = [ "bstr", "csv-core", @@ -1348,9 +1345,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.13" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c5e5ac752e18207b12e16b10631ae5f7f68f8805f335f9b817ead83d9ffce1" +checksum = "e8f45d9ad417bcef4817d614a501ab55cdd96a6fdb24f49aab89a54acfd66b19" dependencies = [ "quote", "syn", @@ -1369,27 +1366,27 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "2.0.0" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" +checksum = "434e1720189a637d44fe464f4df1e6eb900b4835255b14354497c78af37d9bb8" dependencies = [ "byteorder", "digest 0.8.1", "rand_core 0.5.1", - "subtle 2.2.2", + "subtle 2.4.0", "zeroize", ] [[package]] name = "curve25519-dalek" -version = "3.1.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", - "subtle 2.2.2", + "subtle 2.4.0", "zeroize", ] @@ -1436,9 +1433,9 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" [[package]] name = "data-encoding-macro" -version = "0.1.12" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" +checksum = "0a94feec3d2ba66c0b6621bca8bc6f68415b1e5c69af3586fdd0af9fd9f29b17" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -1446,9 +1443,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.10" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" +checksum = "f0f83e699727abca3c56e187945f303389590305ab2f0185ea445aa66e8d5f2a" dependencies = [ "data-encoding", "syn", @@ -1456,11 +1453,10 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.14" +version = "0.99.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc7b9cef1e351660e5443924e4f43ab25fbbed3e9a5f052df3677deb4d6b320" +checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ - "convert_case", "proc-macro2", "quote", "syn", @@ -1484,7 +1480,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.3", + "generic-array 0.12.4", ] [[package]] @@ -1498,9 +1494,9 @@ dependencies = [ [[package]] name = "directories" -version = "3.0.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69600ff1703123957937708eb27f7a564e48885c537782722ed0ba3189ce1d7" +checksum = "f8fed639d60b58d0f53498ab13d26f621fd77569cc6edb031f4cc36a2ad9da0f" dependencies = [ "dirs-sys", ] @@ -1517,12 +1513,12 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ "libc", - "redox_users", + "redox_users 0.3.5", "winapi 0.3.9", ] @@ -1533,7 +1529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", - "redox_users", + "redox_users 0.4.0", "winapi 0.3.9", ] @@ -1620,9 +1616,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.1.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" +checksum = "37c66a534cbb46ab4ea03477eae19d5c22c01da8258030280b7bd9d8433fb6ef" dependencies = [ "signature", ] @@ -1633,11 +1629,11 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.1.0", + "curve25519-dalek 3.0.2", "ed25519", "rand 0.7.3", "serde", - "sha2 0.9.5", + "sha2 0.9.3", "zeroize", ] @@ -1661,18 +1657,18 @@ dependencies = [ [[package]] name = "enumflags2" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a80e524ebf194285b57e5e7944018721c7fffc673253f5183f7accd88a2a3b0c" +checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ed9afacaea0301eefb738c9deea725e6d53938004597cdc518a8cf9a7aa2f03" +checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" dependencies = [ "proc-macro2", "quote", @@ -1700,19 +1696,6 @@ dependencies = [ "syn", ] -[[package]] -name = "env_logger" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -dependencies = [ - "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - [[package]] name = "env_logger" version = "0.7.1" @@ -1728,9 +1711,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.8.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" dependencies = [ "atty", "humantime 2.1.0", @@ -1747,18 +1730,18 @@ checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" [[package]] name = "erased-serde" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88b6d1705e16a4d62e05ea61cc0496c2bd190f4fa8e5c1f11ce747be6bcf3d1" +checksum = "0465971a8cc1fa2455c8465aaa377131e1f1cf4983280f474a13e68793aa770c" dependencies = [ "serde", ] [[package]] name = "errno" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480f641ccf0faf324e20c1d3e53d81b7484c698b42ea677f6907ae4db195371" +checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" dependencies = [ "errno-dragonfly", "libc", @@ -1792,9 +1775,9 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" dependencies = [ "backtrace", "failure_derive", @@ -1802,9 +1785,9 @@ dependencies = [ [[package]] name = "failure_derive" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", @@ -1826,9 +1809,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.4.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b705829d1e87f762c2df6da140b26af5839e1033aa84aa5f56bb688e4e1bdb" +checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3" dependencies = [ "instant", ] @@ -1844,11 +1827,11 @@ dependencies = [ [[package]] name = "file-per-thread-logger" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8505b75b31ef7285168dd237c4a7db3c1f3e0927e7d314e670bc98e854272fe9" +checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126" dependencies = [ - "env_logger 0.6.2", + "env_logger 0.7.1", "log", ] @@ -1865,7 +1848,7 @@ dependencies = [ "num-traits", "parity-scale-codec", "parking_lot 0.11.1", - "rand 0.8.4", + "rand 0.8.3", ] [[package]] @@ -1875,7 +1858,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" dependencies = [ "byteorder", - "rand 0.8.4", + "rand 0.8.3", "rustc-hex", "static_assertions", ] @@ -1888,15 +1871,15 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" [[package]] name = "flate2" -version = "1.0.14" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "crc32fast", "libc", "libz-sys", - "miniz_oxide 0.3.6", + "miniz_oxide", ] [[package]] @@ -1912,6 +1895,16 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding 2.1.0", +] + [[package]] name = "frame-benchmarking" version = "3.1.0" @@ -1922,7 +1915,7 @@ dependencies = [ "linregress", "log", "parity-scale-codec", - "paste 1.0.5", + "paste 1.0.4", "serde", "sp-api", "sp-io", @@ -2010,7 +2003,7 @@ dependencies = [ "once_cell", "parity-scale-codec", "parity-util-mem", - "paste 1.0.5", + "paste 1.0.4", "pretty_assertions 0.6.1", "serde", "smallvec 1.6.1", @@ -2152,9 +2145,9 @@ dependencies = [ [[package]] name = "fs_extra" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" [[package]] name = "fuchsia-cprng" @@ -2186,9 +2179,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.1.29" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" @@ -2227,7 +2220,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" dependencies = [ - "futures 0.1.29", + "futures 0.1.31", "num_cpus", ] @@ -2251,16 +2244,16 @@ checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" [[package]] name = "futures-lite" -version = "1.12.0" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +checksum = "b4481d0cd0de1d204a4fa55e7d45f07b1d958abcb06714b3446438e2eff695fb" dependencies = [ "fastrand", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.6", "waker-fn", ] @@ -2323,7 +2316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" dependencies = [ "autocfg", - "futures 0.1.29", + "futures 0.1.31", "futures-channel", "futures-core", "futures-io", @@ -2331,7 +2324,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.6", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -2346,9 +2339,9 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] @@ -2365,11 +2358,12 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", + "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", "wasm-bindgen", @@ -2409,6 +2403,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + [[package]] name = "gimli" version = "0.24.0" @@ -2428,9 +2428,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "globset" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" +checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" dependencies = [ "aho-corasick", "bstr", @@ -2461,7 +2461,7 @@ dependencies = [ "byteorder", "bytes 0.4.12", "fnv", - "futures 0.1.29", + "futures 0.1.31", "http 0.1.21", "indexmap", "log", @@ -2472,21 +2472,22 @@ dependencies = [ [[package]] name = "h2" -version = "0.2.4" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377038bf3c89d18d6ca1431e7a5027194fbd724ca10592b9487ede5e8e144f42" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" dependencies = [ - "bytes 0.5.4", + "bytes 0.5.6", "fnv", "futures-core", "futures-sink", "futures-util", - "http 0.2.1", + "http 0.2.3", "indexmap", - "log", "slab", "tokio 0.2.25", "tokio-util", + "tracing", + "tracing-futures", ] [[package]] @@ -2497,14 +2498,14 @@ checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "handlebars" -version = "3.5.5" +version = "3.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3" +checksum = "cdb0867bbc5a3da37a753e78021d5fcf8a4db00e18dd2dd90fd36e24190e162d" dependencies = [ "log", "pest", "pest_derive", - "quick-error 2.0.1", + "quick-error 2.0.0", "serde", "serde_json", ] @@ -2544,33 +2545,33 @@ dependencies = [ [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.10" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] [[package]] name = "hex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76505e26b6ca3bbdbbb360b68472abbb80998c5fa5dc43672eca34f28258e138" +checksum = "5af1f635ef1bc545d78392b136bfe1c9809e029023c84a3638a864a10b8819c8" [[package]] name = "hex_fmt" @@ -2605,7 +2606,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" dependencies = [ "digest 0.8.1", - "generic-array 0.12.3", + "generic-array 0.12.4", "hmac 0.7.1", ] @@ -2644,11 +2645,11 @@ dependencies = [ [[package]] name = "http" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" dependencies = [ - "bytes 0.5.4", + "bytes 1.0.1", "fnv", "itoa", ] @@ -2660,7 +2661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "http 0.1.21", "tokio-buf", ] @@ -2671,8 +2672,8 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ - "bytes 0.5.4", - "http 0.2.1", + "bytes 0.5.6", + "http 0.2.3", ] [[package]] @@ -2682,15 +2683,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" dependencies = [ "bytes 1.0.1", - "http 0.2.1", - "pin-project-lite 0.2.7", + "http 0.2.3", + "pin-project-lite 0.2.6", ] [[package]] name = "httparse" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" [[package]] name = "httpdate" @@ -2715,12 +2716,12 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.12.35" +version = "0.12.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" +checksum = "5c843caf6296fc1f93444735205af9ed4e109a539005abb2564ae1d6fad34c52" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "futures-cpupool", "h2 0.1.26", "http 0.1.21", @@ -2749,17 +2750,17 @@ version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" dependencies = [ - "bytes 0.5.4", + "bytes 0.5.6", "futures-channel", "futures-core", "futures-util", - "h2 0.2.4", - "http 0.2.1", + "h2 0.2.7", + "http 0.2.3", "http-body 0.3.1", "httparse", "httpdate", "itoa", - "pin-project 1.0.7", + "pin-project 1.0.5", "socket2 0.3.19", "tokio 0.2.25", "tower-service", @@ -2777,13 +2778,13 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "http 0.2.1", + "http 0.2.3", "http-body 0.4.2", "httparse", "httpdate", "itoa", - "pin-project 1.0.7", - "tokio 1.8.1", + "pin-project 1.0.5", + "tokio 1.6.0", "tower-service", "tracing", "want 0.3.0", @@ -2795,7 +2796,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37743cc83e8ee85eacfce90f2f4102030d9ff0a95244098d781e9bee4a90abb6" dependencies = [ - "bytes 0.5.4", + "bytes 0.5.6", "ct-logs", "futures-util", "hyper 0.13.10", @@ -2826,9 +2827,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" dependencies = [ "matches", "unicode-bidi", @@ -2858,9 +2859,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "0.2.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8ab7f67bad3240049cb24fb9cb0b4c2c6af4c245840917fbbdededeee91179" +checksum = "6a6d52908d4ea4ab2bc22474ba149bf1011c8e2c3ebc1ff593ae28ac44f494b6" dependencies = [ "async-io", "futures 0.3.15", @@ -2903,12 +2904,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.7.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown 0.9.1", "serde", ] @@ -2926,9 +2927,12 @@ dependencies = [ [[package]] name = "integer-sqrt" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] [[package]] name = "intervalier" @@ -2984,18 +2988,18 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jobserver" @@ -3022,8 +3026,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "489b9c612e60c766f751ab40fcb43cbb55a1e10bb44a9b4307ed510ca598cbd7" dependencies = [ "failure", - "futures 0.1.29", - "hyper 0.12.35", + "futures 0.1.31", + "hyper 0.12.36", "jsonrpc-core", "jsonrpc-pubsub", "log", @@ -3038,7 +3042,7 @@ version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0745a6379e3edc893c84ec203589790774e4247420033e71a76d3ab4687991fa" dependencies = [ - "futures 0.1.29", + "futures 0.1.31", "log", "serde", "serde_derive", @@ -3060,7 +3064,7 @@ version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99a847f9ec7bb52149b2786a17c9cb260d6effc6b8eeb8c16b343a487a7563a3" dependencies = [ - "proc-macro-crate 0.1.4", + "proc-macro-crate 0.1.5", "proc-macro2", "quote", "syn", @@ -3072,7 +3076,7 @@ version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb5c4513b7b542f42da107942b7b759f27120b5cc894729f88254b28dff44b7" dependencies = [ - "hyper 0.12.35", + "hyper 0.12.36", "jsonrpc-core", "jsonrpc-server-utils", "log", @@ -3180,7 +3184,7 @@ dependencies = [ "futures 0.3.15", "jsonrpsee-types", "log", - "pin-project 1.0.7", + "pin-project 1.0.5", "rustls 0.19.1", "rustls-native-certs 0.5.0", "serde", @@ -3190,7 +3194,7 @@ dependencies = [ "tokio 0.2.25", "tokio-rustls 0.15.0", "tokio-util", - "url 2.1.1", + "url 2.2.1", ] [[package]] @@ -3201,13 +3205,13 @@ checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" [[package]] name = "keccak-hasher" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3468207deea1359a0e921591ae9b4c928733d94eb9d6a2eeda994cfd59f42cf8" +checksum = "711adba9940a039f4374fc5724c0a5eaca84a2d558cce62256bfe26f0dbef05e" dependencies = [ "hash-db", "hash256-std-hasher", - "tiny-keccak 1.5.0", + "tiny-keccak", ] [[package]] @@ -3276,9 +3280,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "leb128" @@ -3288,9 +3292,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.97" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" +checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" [[package]] name = "libloading" @@ -3362,16 +3366,16 @@ dependencies = [ "libp2p-yamux", "parity-multiaddr", "parking_lot 0.11.1", - "pin-project 1.0.7", + "pin-project 1.0.5", "smallvec 1.6.1", "wasm-timer", ] [[package]] name = "libp2p-core" -version = "0.28.3" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "554d3e7e9e65f939d66b75fd6a4c67f258fe250da61b91f46c545fc4a89b51d9" +checksum = "71dd51b562e14846e65bad00e5808d0644376e6588668c490d3c48e1dfeb4a9a" dependencies = [ "asn1_der", "bs58", @@ -3387,13 +3391,13 @@ dependencies = [ "multistream-select", "parity-multiaddr", "parking_lot 0.11.1", - "pin-project 1.0.7", + "pin-project 1.0.5", "prost", "prost-build", "rand 0.7.3", "ring", "rw-stream-sink", - "sha2 0.9.5", + "sha2 0.9.3", "smallvec 1.6.1", "thiserror", "unsigned-varint 0.7.0", @@ -3446,9 +3450,9 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.30.1" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7b0c8506a6ec3344b9e706d7c7a6dba826f8ede735cfe13dde12a8c263c4af9" +checksum = "73cb9a89a301afde1e588c73f7e9131e12a5388725f290a9047b878862db1b53" dependencies = [ "asynchronous-codec 0.6.0", "base64 0.13.0", @@ -3464,7 +3468,7 @@ dependencies = [ "prost-build", "rand 0.7.3", "regex", - "sha2 0.9.5", + "sha2 0.9.3", "smallvec 1.6.1", "unsigned-varint 0.7.0", "wasm-timer", @@ -3492,7 +3496,7 @@ version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07312ebe5ee4fd2404447a0609814574df55c65d4e20838b957bbd34907d820" dependencies = [ - "arrayvec 0.5.1", + "arrayvec 0.5.2", "asynchronous-codec 0.6.0", "bytes 1.0.1", "either", @@ -3504,7 +3508,7 @@ dependencies = [ "prost", "prost-build", "rand 0.7.3", - "sha2 0.9.5", + "sha2 0.9.3", "smallvec 1.6.1", "uint", "unsigned-varint 0.7.0", @@ -3514,9 +3518,9 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.30.2" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4efa70c1c3d2d91237f8546e27aeb85e287d62c066a7b4f3ea6a696d43ced714" +checksum = "c221897b3fd7f215de7ecfec215c5eba598e5b61c605b5f8b56fe8a4fb507724" dependencies = [ "async-io", "data-encoding", @@ -3527,7 +3531,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "rand 0.8.4", + "rand 0.8.3", "smallvec 1.6.1", "socket2 0.4.0", "void", @@ -3558,7 +3562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36db0f0db3b0433f5b9463f1c0cd9eadc0a3734a9170439ce501ff99733a88bd" dependencies = [ "bytes 1.0.1", - "curve25519-dalek 3.1.0", + "curve25519-dalek 3.0.2", "futures 0.3.15", "lazy_static", "libp2p-core", @@ -3566,7 +3570,7 @@ dependencies = [ "prost", "prost-build", "rand 0.7.3", - "sha2 0.9.5", + "sha2 0.9.3", "snow", "static_assertions", "x25519-dalek", @@ -3613,7 +3617,7 @@ checksum = "6ce3374f3b28162db9d3442c9347c4f14cb01e8290052615c7d341d40eae0599" dependencies = [ "futures 0.3.15", "log", - "pin-project 1.0.7", + "pin-project 1.0.5", "rand 0.7.3", "salsa20", "sha3", @@ -3632,7 +3636,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "pin-project 1.0.7", + "pin-project 1.0.5", "prost", "prost-build", "rand 0.7.3", @@ -3719,9 +3723,9 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.28.2" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d413e4cf9b8e5dfbcd2a60d3dc5a3391308bdb463684093d4f67137b7113de" +checksum = "cef45d61e43c313531b5e903e4e8415212ff6338e0c54c47da5b9b412b5760de" dependencies = [ "futures 0.3.15", "js-sys", @@ -3745,7 +3749,7 @@ dependencies = [ "quicksink", "rw-stream-sink", "soketto 0.4.2", - "url 2.1.1", + "url 2.2.1", "webpki-roots", ] @@ -3785,34 +3789,33 @@ dependencies = [ "digest 0.8.1", "hmac-drbg", "rand 0.7.3", - "sha2 0.8.1", - "subtle 2.2.2", + "sha2 0.8.2", + "subtle 2.4.0", "typenum", ] [[package]] name = "libz-sys" -version = "1.0.25" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" +checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" dependencies = [ "cc", - "libc", "pkg-config", "vcpkg", ] [[package]] name = "linked-hash-map" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linked_hash_set" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7c91c4c7bbeb4f2f7c4e5be11e6a05bd6830bc37249c47ce1ad86ad453ff9c" +checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" dependencies = [ "linked-hash-map", ] @@ -3829,11 +3832,20 @@ dependencies = [ [[package]] name = "lite-json" -version = "0.1.0" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa835713bb12ba5204013497da16caf2dd2eee25ca829d0efaa054fb38c4ddd" +checksum = "0460d985423a026b4d9b828a7c6eed1bcf606f476322f3f9b507529686a61715" dependencies = [ - "paste 0.1.10", + "lite-parser", +] + +[[package]] +name = "lite-parser" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c50092e40e0ccd1bf2015a10333fde0502ff95b832b0895dc1ca0d7ac6c52f6" +dependencies = [ + "paste 0.1.18", ] [[package]] @@ -3847,9 +3859,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" dependencies = [ "scopeguard", ] @@ -3935,9 +3947,9 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" -version = "2.3.3" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memmap" @@ -3951,27 +3963,27 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.2.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723e3ebdcdc5c023db1df315364573789f8857c11b631a2fdfad7c00f5c046b4" +checksum = "04e3e85b970d650e2ae6d70592474087051c11c54da7f7b4949725c5735fbcc6" dependencies = [ "libc", ] [[package]] name = "memoffset" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" dependencies = [ "autocfg", ] [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" dependencies = [ "autocfg", ] @@ -3995,9 +4007,9 @@ checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" [[package]] name = "merlin" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" dependencies = [ "byteorder", "keccak", @@ -4007,33 +4019,24 @@ dependencies = [ [[package]] name = "minicbor" -version = "0.8.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51aa5bb0ca22415daca596a227b507f880ad1b2318a87fa9325312a5d285ca0d" +checksum = "ea79ce4ab9f445ec6b71833a2290ac0a29c9dde0fa7cae4c481eecae021d9bd9" dependencies = [ "minicbor-derive", ] [[package]] name = "minicbor-derive" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2b9e8883d58e34b18facd16c4564a77ea50fce028ad3d0ee6753440e37acc8" +checksum = "19ce18b5423c573a13e80cb3046ea0af6379ef725dc3af4886bdb8f4e5093068" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "miniz_oxide" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" -dependencies = [ - "adler32", -] - [[package]] name = "miniz_oxide" version = "0.4.4" @@ -4083,15 +4086,15 @@ checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" dependencies = [ "log", "mio", - "miow 0.3.7", + "miow 0.3.6", "winapi 0.3.9", ] [[package]] name = "mio-uds" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" dependencies = [ "iovec", "libc", @@ -4112,10 +4115,11 @@ dependencies = [ [[package]] name = "miow" -version = "0.3.7" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ + "socket2 0.3.19", "winapi 0.3.9", ] @@ -4148,18 +4152,18 @@ dependencies = [ "digest 0.9.0", "generic-array 0.14.4", "multihash-derive", - "sha2 0.9.5", + "sha2 0.9.3", "sha3", "unsigned-varint 0.5.1", ] [[package]] name = "multihash-derive" -version = "0.7.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99" +checksum = "85ee3c48cb9d9b275ad967a0e96715badc13c6029adb92f34fa17b9ff28fd81f" dependencies = [ - "proc-macro-crate 1.0.0", + "proc-macro-crate 0.1.5", "proc-macro-error", "proc-macro2", "quote", @@ -4169,9 +4173,9 @@ dependencies = [ [[package]] name = "multimap" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8883adfde9756c1d30b0f519c9b8c502a94b41ac62f696453c37c7fc0a958ce" +checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" [[package]] name = "multistream-select" @@ -4182,7 +4186,7 @@ dependencies = [ "bytes 1.0.1", "futures 0.3.15", "log", - "pin-project 1.0.7", + "pin-project 1.0.5", "smallvec 1.6.1", "unsigned-varint 0.7.0", ] @@ -4199,7 +4203,7 @@ dependencies = [ "num-complex", "num-rational 0.4.0", "num-traits", - "rand 0.8.4", + "rand 0.8.3", "rand_distr", "simba", "typenum", @@ -4225,6 +4229,16 @@ dependencies = [ "rand 0.3.23", ] +[[package]] +name = "nb-connect" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670361df1bc2399ee1ff50406a0d422587dd3bb0da596e1978fe8e05dabddf4f" +dependencies = [ + "libc", + "socket2 0.3.19", +] + [[package]] name = "net2" version = "0.2.37" @@ -4487,8 +4501,8 @@ dependencies = [ name = "node-rpc-client" version = "2.0.0" dependencies = [ - "futures 0.1.29", - "hyper 0.12.35", + "futures 0.1.31", + "hyper 0.12.36", "jsonrpc-core-client", "log", "node-primitives", @@ -4706,9 +4720,9 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "5.1.1" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" dependencies = [ "memchr", "version_check", @@ -4736,9 +4750,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.42" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ "autocfg", "num-traits", @@ -4797,6 +4811,12 @@ dependencies = [ "indexmap", ] +[[package]] +name = "object" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" + [[package]] name = "object" version = "0.24.0" @@ -4809,18 +4829,18 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" dependencies = [ "parking_lot 0.11.1", ] [[package]] name = "oorandom" -version = "11.1.0" +version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "opaque-debug" @@ -5034,11 +5054,11 @@ dependencies = [ "pallet-randomness-collective-flip", "pallet-timestamp", "parity-scale-codec", - "paste 1.0.5", + "paste 1.0.4", "pretty_assertions 0.7.2", "pwasm-utils", - "rand 0.8.4", - "rand_pcg 0.3.1", + "rand 0.8.3", + "rand_pcg 0.3.0", "serde", "smallvec 1.6.1", "sp-core", @@ -5134,7 +5154,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "parking_lot 0.11.1", - "paste 1.0.5", + "paste 1.0.4", "rand 0.7.3", "sp-arithmetic", "sp-core", @@ -5361,7 +5381,7 @@ name = "pallet-mmr" version = "3.0.0" dependencies = [ "ckb-merkle-mountain-range", - "env_logger 0.8.4", + "env_logger 0.8.3", "frame-benchmarking", "frame-support", "frame-system", @@ -5646,7 +5666,7 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "parking_lot 0.11.1", - "paste 1.0.5", + "paste 1.0.4", "rand_chacha 0.2.2", "serde", "sp-application-crypto", @@ -5887,7 +5907,7 @@ dependencies = [ "log", "memmap2", "parking_lot 0.11.1", - "rand 0.8.4", + "rand 0.8.3", ] [[package]] @@ -5905,7 +5925,7 @@ dependencies = [ "serde", "static_assertions", "unsigned-varint 0.7.0", - "url 2.1.1", + "url 2.2.1", ] [[package]] @@ -5914,7 +5934,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8975095a2a03bbbdc70a74ab11a4f76a6d0b84680d87c68d722531b0ac28e8a9" dependencies = [ - "arrayvec 0.7.1", + "arrayvec 0.7.0", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", @@ -5947,11 +5967,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e57fea504fea33f9fbb5f49f378359030e7e026a6ab849bb9e8f0787376f1bf" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "libc", "log", "mio-named-pipes", - "miow 0.3.7", + "miow 0.3.6", "rand 0.7.3", "tokio 0.1.22", "tokio-named-pipes", @@ -6016,7 +6036,7 @@ dependencies = [ "rand 0.7.3", "sha-1 0.8.2", "slab", - "url 2.1.1", + "url 2.2.1", ] [[package]] @@ -6043,7 +6063,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ "lock_api 0.3.4", - "parking_lot_core 0.7.1", + "parking_lot_core 0.7.2", ] [[package]] @@ -6053,7 +6073,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", - "lock_api 0.4.4", + "lock_api 0.4.2", "parking_lot_core 0.8.3", ] @@ -6066,22 +6086,22 @@ dependencies = [ "cfg-if 0.1.10", "cloudabi", "libc", - "redox_syscall 0.1.56", + "redox_syscall 0.1.57", "rustc_version", - "smallvec 0.6.13", + "smallvec 0.6.14", "winapi 0.3.9", ] [[package]] name = "parking_lot_core" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e136c1904604defe99ce5fd71a28d473fa60a12255d511aa78a9ddf11237aeb" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ "cfg-if 0.1.10", "cloudabi", "libc", - "redox_syscall 0.1.56", + "redox_syscall 0.1.57", "smallvec 1.6.1", "winapi 0.3.9", ] @@ -6095,16 +6115,16 @@ dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.2.9", + "redox_syscall 0.2.5", "smallvec 1.6.1", "winapi 0.3.9", ] [[package]] name = "paste" -version = "0.1.10" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4fb1930692d1b6a9cfabdde3d06ea0a7d186518e2f4d67660d8970e2fa647a" +checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" dependencies = [ "paste-impl", "proc-macro-hack", @@ -6112,20 +6132,17 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1" [[package]] name = "paste-impl" -version = "0.1.10" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62486e111e571b1e93b710b61e8f493c0013be39629b714cb166bdb06aa5a8a" +checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" dependencies = [ "proc-macro-hack", - "proc-macro2", - "quote", - "syn", ] [[package]] @@ -6216,9 +6233,9 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c127eea4a29ec6c85d153c59dc1213f33ec74cead30fe4730aecc88cc1fd92" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" dependencies = [ "fixedbitset", "indexmap", @@ -6226,27 +6243,27 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.8" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" dependencies = [ - "pin-project-internal 0.4.8", + "pin-project-internal 0.4.27", ] [[package]] name = "pin-project" -version = "1.0.7" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" +checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63" dependencies = [ - "pin-project-internal 1.0.7", + "pin-project-internal 1.0.5", ] [[package]] name = "pin-project-internal" -version = "0.4.8" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" +checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ "proc-macro2", "quote", @@ -6255,9 +6272,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "1.0.7" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" +checksum = "758669ae3558c6f74bd2a18b41f7ac0b5a195aea6639d6a9b5e5d1ad5ba24c0b" dependencies = [ "proc-macro2", "quote", @@ -6266,15 +6283,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.4" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] name = "pin-utils" @@ -6284,9 +6301,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "platforms" @@ -6309,29 +6326,29 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" dependencies = [ "plotters-backend", ] [[package]] name = "polling" -version = "2.1.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25" +checksum = "a2a7bc6b2a29e632e45451c941832803a18cce6781db04de8a04696cdca8bde4" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "libc", "log", - "wepoll-ffi", + "wepoll-sys", "winapi 0.3.9", ] @@ -6341,7 +6358,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b7456bc1ad2d4cf82b3a016be4c2ac48daf11bf990c1603ebd447fe6f30fca8" dependencies = [ - "cpuid-bool", + "cpuid-bool 0.2.0", "universal-hash", ] @@ -6351,7 +6368,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" dependencies = [ - "cpuid-bool", + "cpuid-bool 0.2.0", "opaque-debug 0.3.0", "universal-hash", ] @@ -6364,9 +6381,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "predicates" -version = "1.0.4" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030" +checksum = "eeb433456c1a57cc93554dea3ce40b4c19c4057e41c55d4a0f3d84ea71c325aa" dependencies = [ "difference", "predicates-core", @@ -6374,15 +6391,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" [[package]] name = "predicates-tree" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2" dependencies = [ "predicates-core", "treeline", @@ -6414,9 +6431,9 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" +checksum = "e90f6931e6b3051e208a449c342246cb7c786ef300789b95619f46f1dd75d9b0" dependencies = [ "fixed-hash", "impl-codec", @@ -6426,9 +6443,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ "toml", ] @@ -6475,15 +6492,15 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] @@ -6555,9 +6572,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.13" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21ff0279b4a85e576b97e4a21d13e437ebcd56612706cde5d3f0d5c9399490c0" +checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a" dependencies = [ "cc", ] @@ -6581,9 +6598,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick-error" -version = "2.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" +checksum = "3ac73b1112776fc109b2e61909bc46c7e1bf0d7f690ffb1676553acce16d5cda" [[package]] name = "quickcheck" @@ -6591,9 +6608,9 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ - "env_logger 0.8.4", + "env_logger 0.8.3", "log", - "rand 0.8.4", + "rand 0.8.3", ] [[package]] @@ -6604,7 +6621,7 @@ checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858" dependencies = [ "futures-core", "futures-sink", - "pin-project-lite 0.1.4", + "pin-project-lite 0.1.12", ] [[package]] @@ -6651,7 +6668,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.14", + "getrandom 0.1.16", "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", @@ -6661,14 +6678,14 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", - "rand_hc 0.3.1", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", ] [[package]] @@ -6683,12 +6700,12 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core 0.6.2", ] [[package]] @@ -6712,14 +6729,14 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.14", + "getrandom 0.1.16", ] [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ "getrandom 0.2.3", ] @@ -6731,7 +6748,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "051b398806e42b9cd04ad9ec8f81e355d0a382c543ac6672c62f5a5b452ef142" dependencies = [ "num-traits", - "rand 0.8.4", + "rand 0.8.3", ] [[package]] @@ -6745,11 +6762,11 @@ dependencies = [ [[package]] name = "rand_hc" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core 0.6.3", + "rand_core 0.6.2", ] [[package]] @@ -6763,11 +6780,11 @@ dependencies = [ [[package]] name = "rand_pcg" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" +checksum = "7de198537002b913568a3847e53535ace266f93526caf5c360ec41d72c5787f0" dependencies = [ - "rand_core 0.6.3", + "rand_core 0.6.2", ] [[package]] @@ -6778,9 +6795,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.5.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ "autocfg", "crossbeam-deque 0.8.0", @@ -6790,13 +6807,13 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" dependencies = [ "crossbeam-channel", "crossbeam-deque 0.8.0", - "crossbeam-utils 0.8.5", + "crossbeam-utils 0.8.3", "lazy_static", "num_cpus", ] @@ -6812,19 +6829,30 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +dependencies = [ + "getrandom 0.1.16", + "redox_syscall 0.1.57", + "rust-argon2", +] + [[package]] name = "redox_users" version = "0.4.0" @@ -6832,7 +6860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ "getrandom 0.2.3", - "redox_syscall 0.2.9", + "redox_syscall 0.2.5", ] [[package]] @@ -6869,13 +6897,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.6" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", "regex-syntax", + "thread_local", ] [[package]] @@ -6890,9 +6919,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "region" @@ -6910,7 +6939,7 @@ dependencies = [ name = "remote-externalities" version = "0.9.0" dependencies = [ - "env_logger 0.8.4", + "env_logger 0.8.3", "frame-support", "hex", "jsonrpsee-proc-macros", @@ -6928,9 +6957,9 @@ dependencies = [ [[package]] name = "remove_dir_all" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ "winapi 0.3.9", ] @@ -6953,13 +6982,13 @@ checksum = "e9c17925a9027d298a4603d286befe3f9dc0e8ed02523141914eb628798d6e5b" [[package]] name = "ring" -version = "0.16.12" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba5a8ec64ee89a76c98c549af81ff14813df09c3e6dc4766c3856da48597a0c" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", - "lazy_static", "libc", + "once_cell", "spin", "untrusted", "web-sys", @@ -6986,11 +7015,23 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rust-argon2" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" +dependencies = [ + "base64 0.13.0", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils 0.8.3", +] + [[package]] name = "rustc-demangle" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" [[package]] name = "rustc-hash" @@ -7060,25 +7101,20 @@ dependencies = [ "openssl-probe", "rustls 0.19.1", "schannel", - "security-framework 2.3.1", + "security-framework 2.3.0", ] [[package]] name = "rustversion" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" [[package]] name = "ruzstd" -version = "0.2.4" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cada0ef59efa6a5f4dc5e491f93d9f31e3fc7758df421ff1de8a706338e1100" +checksum = "3d425143485a37727c7a46e689bbe3b883a00f42b4a52c4ac0f44855c1009b00" dependencies = [ "byteorder", "twox-hash", @@ -7091,15 +7127,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" dependencies = [ "futures 0.3.15", - "pin-project 0.4.8", + "pin-project 0.4.27", "static_assertions", ] [[package]] name = "ryu" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "safe-mix" @@ -7614,7 +7650,7 @@ dependencies = [ "parity-scale-codec", "parity-wasm 0.42.2", "parking_lot 0.11.1", - "paste 1.0.5", + "paste 1.0.4", "regex", "sc-executor-common", "sc-executor-wasmi", @@ -7715,7 +7751,7 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.11.1", - "pin-project 1.0.7", + "pin-project 1.0.5", "rand 0.7.3", "sc-block-builder", "sc-client-api", @@ -7790,7 +7826,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.11.1", "prost", - "rand 0.8.4", + "rand 0.8.3", "sc-block-builder", "sc-client-api", "sc-finality-grandpa", @@ -7837,7 +7873,7 @@ dependencies = [ "sp-application-crypto", "sp-core", "sp-keystore", - "subtle 2.2.2", + "subtle 2.4.0", "tempfile", ] @@ -7888,7 +7924,7 @@ dependencies = [ "nohash-hasher", "parity-scale-codec", "parking_lot 0.11.1", - "pin-project 1.0.7", + "pin-project 1.0.5", "prost", "prost-build", "quickcheck", @@ -7971,7 +8007,7 @@ dependencies = [ name = "sc-offchain" version = "3.0.0" dependencies = [ - "bytes 0.5.4", + "bytes 0.5.6", "fnv", "futures 0.3.15", "futures-timer 3.0.2", @@ -8029,7 +8065,7 @@ name = "sc-rpc" version = "3.0.0" dependencies = [ "assert_matches", - "futures 0.1.29", + "futures 0.1.31", "futures 0.3.15", "hash-db", "jsonrpc-core", @@ -8095,7 +8131,7 @@ dependencies = [ name = "sc-rpc-server" version = "3.0.0" dependencies = [ - "futures 0.1.29", + "futures 0.1.31", "jsonrpc-core", "jsonrpc-http-server", "jsonrpc-ipc-server", @@ -8129,7 +8165,7 @@ dependencies = [ "async-trait", "directories", "exit-future", - "futures 0.1.29", + "futures 0.1.31", "futures 0.3.15", "futures-timer 3.0.2", "hash-db", @@ -8140,7 +8176,7 @@ dependencies = [ "parity-scale-codec", "parity-util-mem", "parking_lot 0.11.1", - "pin-project 1.0.7", + "pin-project 1.0.5", "rand 0.7.3", "sc-block-builder", "sc-chain-spec", @@ -8198,7 +8234,7 @@ name = "sc-service-test" version = "2.0.0" dependencies = [ "fdlimit", - "futures 0.1.29", + "futures 0.1.31", "futures 0.3.15", "hex-literal", "log", @@ -8271,7 +8307,7 @@ dependencies = [ "libp2p", "log", "parking_lot 0.11.1", - "pin-project 1.0.7", + "pin-project 1.0.5", "rand 0.7.3", "serde", "serde_json", @@ -8385,9 +8421,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039c25b130bd8c1321ee2d7de7fde2659fa9c2744e4bb29711cfc852ea53cd19" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", "winapi 0.3.9", @@ -8400,14 +8436,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" dependencies = [ "arrayref", - "arrayvec 0.5.1", - "curve25519-dalek 2.0.0", - "getrandom 0.1.14", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.2", + "getrandom 0.1.16", "merlin", "rand 0.7.3", "rand_core 0.5.1", - "sha2 0.8.1", - "subtle 2.2.2", + "sha2 0.8.2", + "subtle 2.4.0", "zeroize", ] @@ -8457,9 +8493,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.3.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" +checksum = "b239a3d5db51252f6f48f42172c65317f37202f4a21021bf5f9d40a408f4592c" dependencies = [ "bitflags", "core-foundation 0.9.1", @@ -8539,9 +8575,9 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.126" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" dependencies = [ "serde_derive", ] @@ -8567,9 +8603,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "1800f7693e94e186f5e25a28291ae1570da908aff7d97a095dec1e56ff99069b" dependencies = [ "proc-macro2", "quote", @@ -8601,22 +8637,22 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.9.6" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16" +checksum = "dfebf75d25bd900fd1e7d11501efab59bc846dbc76196839663e6637bba9f25f" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures", + "cpuid-bool 0.1.2", "digest 0.9.0", "opaque-debug 0.3.0", ] [[package]] name = "sha2" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", @@ -8626,13 +8662,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.5" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures", + "cpuid-bool 0.1.2", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -8666,9 +8702,9 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" [[package]] name = "signal-hook" -version = "0.3.9" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "470c5a6397076fae0094aaf06a08e6ba6f37acb77d3b1b91ea92b4d6c8650c39" +checksum = "8a7f3f92a1da3d6b1d32245d0cbcbbab0cfc45996d8df619c42bccfa6d2bbb5f" dependencies = [ "libc", "signal-hook-registry", @@ -8676,18 +8712,18 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ "libc", ] [[package]] name = "signature" -version = "1.3.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19772be3c4dd2ceaacf03cb41d5885f2a02c4d8804884918e3a258480803335" +checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" [[package]] name = "simba" @@ -8698,7 +8734,7 @@ dependencies = [ "approx", "num-complex", "num-traits", - "paste 1.0.5", + "paste 1.0.4", ] [[package]] @@ -8709,18 +8745,18 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "slog" -version = "2.5.2" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" +checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" dependencies = [ "erased-serde", ] [[package]] name = "smallvec" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" dependencies = [ "maybe-uninit", ] @@ -8744,8 +8780,8 @@ dependencies = [ "rand_core 0.5.1", "ring", "rustc_version", - "sha2 0.9.5", - "subtle 2.2.2", + "sha2 0.9.3", + "subtle 2.4.0", "x25519-dalek", ] @@ -8777,13 +8813,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5c71ed3d54db0a699f4948e1bb3e45b450fa31fe602621dee6680361d569c88" dependencies = [ "base64 0.12.3", - "bytes 0.5.4", + "bytes 0.5.6", "flate2", "futures 0.3.15", "httparse", "log", "rand 0.7.3", - "sha-1 0.9.6", + "sha-1 0.9.4", ] [[package]] @@ -8797,8 +8833,8 @@ dependencies = [ "futures 0.3.15", "httparse", "log", - "rand 0.8.4", - "sha-1 0.9.6", + "rand 0.8.3", + "sha-1 0.9.4", ] [[package]] @@ -9080,7 +9116,7 @@ dependencies = [ "secrecy", "serde", "serde_json", - "sha2 0.9.5", + "sha2 0.9.3", "sp-debug-derive", "sp-externalities", "sp-runtime-interface", @@ -9090,7 +9126,7 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", - "tiny-keccak 2.0.2", + "tiny-keccak", "twox-hash", "wasmi", "zeroize", @@ -9294,7 +9330,7 @@ dependencies = [ "log", "parity-scale-codec", "parity-util-mem", - "paste 1.0.5", + "paste 1.0.4", "rand 0.7.3", "serde", "serde_json", @@ -9625,9 +9661,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "stable_deref_trait" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "static_assertions" @@ -9645,7 +9681,7 @@ dependencies = [ "lazy_static", "nalgebra", "num-traits", - "rand 0.8.4", + "rand 0.8.3", ] [[package]] @@ -9681,9 +9717,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "structopt" -version = "0.3.22" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b041cdcb67226aca307e6e7be44c8806423d83e018bd662360a93dabce4d71" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" dependencies = [ "clap", "lazy_static", @@ -9692,9 +9728,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.15" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7813934aecf5f51a54775e00068c237de98489463968231a51746bbbc03f9c10" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" dependencies = [ "heck", "proc-macro-error", @@ -9741,7 +9777,7 @@ dependencies = [ "hmac 0.7.1", "pbkdf2 0.3.0", "schnorrkel", - "sha2 0.8.1", + "sha2 0.8.2", "zeroize", ] @@ -9751,7 +9787,7 @@ version = "0.9.0" dependencies = [ "chrono", "console_error_panic_hook", - "futures 0.1.29", + "futures 0.1.31", "futures 0.3.15", "futures-timer 3.0.2", "getrandom 0.2.3", @@ -9848,7 +9884,7 @@ name = "substrate-test-client" version = "2.0.1" dependencies = [ "async-trait", - "futures 0.1.29", + "futures 0.1.31", "futures 0.3.15", "hash-db", "hex", @@ -10002,15 +10038,15 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" [[package]] name = "subtle" -version = "2.2.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.73" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" dependencies = [ "proc-macro2", "quote", @@ -10055,23 +10091,23 @@ checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834" [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "rand 0.7.3", - "redox_syscall 0.1.56", + "rand 0.8.3", + "redox_syscall 0.2.5", "remove_dir_all", "winapi 0.3.9", ] [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] @@ -10161,18 +10197,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.26" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.26" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ "proc-macro2", "quote", @@ -10181,18 +10217,18 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "threadpool" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" dependencies = [ "num_cpus", ] @@ -10220,21 +10256,12 @@ dependencies = [ "pbkdf2 0.4.0", "rand 0.7.3", "rustc-hash", - "sha2 0.9.5", + "sha2 0.9.3", "thiserror", "unicode-normalization", "zeroize", ] -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -10256,9 +10283,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.2.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" dependencies = [ "tinyvec_macros", ] @@ -10276,7 +10303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "mio", "num_cpus", "tokio-codec", @@ -10299,7 +10326,7 @@ version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ - "bytes 0.5.4", + "bytes 0.5.6", "fnv", "futures-core", "iovec", @@ -10310,7 +10337,7 @@ dependencies = [ "mio-named-pipes", "mio-uds", "num_cpus", - "pin-project-lite 0.1.4", + "pin-project-lite 0.1.12", "signal-hook-registry", "slab", "tokio-macros", @@ -10319,12 +10346,12 @@ dependencies = [ [[package]] name = "tokio" -version = "1.8.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c8b05dc14c75ea83d63dd391100353789f5f24b8b3866542a5e85c8be8e985" +checksum = "bd3076b5c8cc18138b8f8814895c11eb4de37114a5d127bafdc5e55798ceef37" dependencies = [ "autocfg", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.6", ] [[package]] @@ -10335,7 +10362,7 @@ checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" dependencies = [ "bytes 0.4.12", "either", - "futures 0.1.29", + "futures 0.1.31", ] [[package]] @@ -10345,7 +10372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "tokio-io", ] @@ -10355,7 +10382,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" dependencies = [ - "futures 0.1.29", + "futures 0.1.31", "tokio-executor", ] @@ -10366,7 +10393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.31", ] [[package]] @@ -10375,7 +10402,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" dependencies = [ - "futures 0.1.29", + "futures 0.1.31", "tokio-io", "tokio-threadpool", ] @@ -10387,7 +10414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "log", ] @@ -10409,7 +10436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d282d483052288b2308ba5ee795f5673b159c9bdf63c385a05609da782a5eae" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "mio", "mio-named-pipes", "tokio 0.1.22", @@ -10422,7 +10449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.31", "lazy_static", "log", "mio", @@ -10464,7 +10491,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" dependencies = [ - "futures 0.1.29", + "futures 0.1.31", ] [[package]] @@ -10474,7 +10501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" dependencies = [ "fnv", - "futures 0.1.29", + "futures 0.1.31", ] [[package]] @@ -10484,7 +10511,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "iovec", "mio", "tokio-io", @@ -10500,7 +10527,7 @@ dependencies = [ "crossbeam-deque 0.7.3", "crossbeam-queue", "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.31", "lazy_static", "log", "num_cpus", @@ -10515,7 +10542,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" dependencies = [ "crossbeam-utils 0.7.2", - "futures 0.1.29", + "futures 0.1.31", "slab", "tokio-executor", ] @@ -10527,7 +10554,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "log", "mio", "tokio-codec", @@ -10537,12 +10564,12 @@ dependencies = [ [[package]] name = "tokio-uds" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798" +checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" dependencies = [ "bytes 0.4.12", - "futures 0.1.29", + "futures 0.1.31", "iovec", "libc", "log", @@ -10559,39 +10586,39 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes 0.5.4", + "bytes 0.5.6", "futures-core", "futures-io", "futures-sink", "log", - "pin-project-lite 0.1.4", + "pin-project-lite 0.1.12", "tokio 0.2.25", ] [[package]] name = "toml" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.26" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite 0.2.7", + "pin-project-lite 0.2.6", "tracing-attributes", "tracing-core", ] @@ -10609,9 +10636,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.18" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" dependencies = [ "lazy_static", ] @@ -10622,7 +10649,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" dependencies = [ - "pin-project 1.0.7", + "pin-project 1.0.5", "tracing", ] @@ -10649,9 +10676,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.19" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab69019741fca4d98be3c62d2b75254528b5432233fd8a4d2739fec20278de48" +checksum = "aa5553bf0883ba7c9cbe493b085c29926bd41b66afc31ff72cf17ff4fb60dcd5" dependencies = [ "ansi_term 0.12.1", "chrono", @@ -10725,9 +10752,9 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.20.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0d7f5db438199a6e2609debe3f69f808d074e0a2888ee0bccb45fe234d03f4" +checksum = "8d57e219ba600dd96c2f6d82eb79645068e14edbc5c7e27514af40436b88150c" dependencies = [ "async-trait", "cfg-if 1.0.0", @@ -10736,22 +10763,22 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna 0.2.0", + "idna 0.2.2", "ipnet", "lazy_static", "log", - "rand 0.8.4", + "rand 0.8.3", "smallvec 1.6.1", "thiserror", "tinyvec", - "url 2.1.1", + "url 2.2.1", ] [[package]] name = "trust-dns-resolver" -version = "0.20.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ad17b608a64bd0735e67bde16b0636f8aa8591f831a25d18443ed00a699770" +checksum = "b0437eea3a6da51acc1e946545ff53d5b8fb2611ff1c3bed58522dde100536ae" dependencies = [ "cfg-if 1.0.0", "futures-util", @@ -10768,9 +10795,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" @@ -10837,9 +10864,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "uint" -version = "0.9.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" +checksum = "e11fe9a9348741cf134085ad57c249508345fe16411b3d7fb4ff2da2f1d6382e" dependencies = [ "byteorder", "crunchy", @@ -10867,30 +10894,30 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "universal-hash" @@ -10899,7 +10926,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" dependencies = [ "generic-array 0.14.4", - "subtle 2.2.2", + "subtle 2.4.0", ] [[package]] @@ -10934,9 +10961,9 @@ dependencies = [ [[package]] name = "untrusted" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" @@ -10951,42 +10978,48 @@ dependencies = [ [[package]] name = "url" -version = "2.1.1" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" dependencies = [ - "idna 0.2.0", + "form_urlencoded", + "idna 0.2.2", "matches", "percent-encoding 2.1.0", ] [[package]] name = "value-bag" -version = "1.0.0-alpha.7" +version = "1.0.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd320e1520f94261153e96f7534476ad869c14022aee1e59af7c778075d840ae" +checksum = "6b676010e055c99033117c2343b33a40a30b91fecd6c49055ac9cd2d6c305ab1" dependencies = [ "ctor", - "version_check", ] [[package]] name = "vcpkg" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" + +[[package]] +name = "vec-arena" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d" [[package]] name = "vec_map" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] name = "void" @@ -11026,7 +11059,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" dependencies = [ - "futures 0.1.29", + "futures 0.1.31", "log", "try-lock", ] @@ -11082,9 +11115,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.23" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b8b767af23de6ac18bf2168b690bed2902743ddf0fb39252e36f9e2bfc63ea" +checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -11123,9 +11156,9 @@ checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" [[package]] name = "wasm-bindgen-test" -version = "0.3.23" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e972e914de63aa53bd84865e54f5c761bd274d48e5be3a6329a662c0386aa67a" +checksum = "f0d4da138503a4cf86801b94d95781ee3619faa8feca830569cc6b54997b8b5c" dependencies = [ "console_error_panic_hook", "js-sys", @@ -11137,9 +11170,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.23" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6153a8f9bf24588e9f25c87223414fff124049f68d3a442a0f0eab4768a8b6" +checksum = "c3199c33f06500c731d5544664c24d0c2b742b98debc6b1c6f0c6d6e8fb7c19b" dependencies = [ "proc-macro2", "quote", @@ -11355,7 +11388,7 @@ dependencies = [ "cfg-if 0.1.10", "indexmap", "libc", - "memoffset 0.6.4", + "memoffset 0.6.1", "more-asserts", "region", "serde", @@ -11416,7 +11449,7 @@ dependencies = [ "lazy_static", "libc", "log", - "paste 1.0.5", + "paste 1.0.4", "psm", "region", "rustc-demangle", @@ -11447,7 +11480,7 @@ dependencies = [ "libc", "log", "serde", - "sha2 0.9.5", + "sha2 0.9.3", "toml", "winapi 0.3.9", "zstd", @@ -11509,7 +11542,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d4539ea734422b7c868107e2187d7746d8affbcaa71916d72639f53757ad707" dependencies = [ - "addr2line", + "addr2line 0.15.1", "anyhow", "cfg-if 1.0.0", "cranelift-codegen 0.74.0", @@ -11581,9 +11614,9 @@ dependencies = [ "libc", "log", "mach", - "memoffset 0.6.4", + "memoffset 0.6.1", "more-asserts", - "rand 0.8.4", + "rand 0.8.3", "region", "thiserror", "wasmtime-environ", @@ -11592,27 +11625,27 @@ dependencies = [ [[package]] name = "wast" -version = "13.0.0" +version = "35.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b20abd8b4a26f7e0d4dd5e357e90a3d555ec190e94472c9b2b27c5b9777f9ae" +checksum = "db5ae96da18bb5926341516fd409b5a8ce4e4714da7f0a1063d3b20ac9f9a1e1" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.14" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51a615830ee3e7200b505c441fec09aac2f114deae69df52f215cb828ba112c4" +checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.50" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", @@ -11620,9 +11653,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ "ring", "untrusted", @@ -11630,30 +11663,30 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.21.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376" dependencies = [ "webpki", ] [[package]] -name = "wepoll-ffi" -version = "0.1.2" +name = "wepoll-sys" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +checksum = "0fcb14dea929042224824779fbc82d9fab8d2e6d3cbc0ac404de8edf489e77ff" dependencies = [ "cc", ] [[package]] name = "which" -version = "4.1.0" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" dependencies = [ - "either", "libc", + "thiserror", ] [[package]] @@ -11692,9 +11725,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi 0.3.9", ] @@ -11732,11 +11765,11 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" [[package]] name = "x25519-dalek" -version = "1.1.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +checksum = "bc614d95359fd7afc321b66d2107ede58b246b844cf5d8a0adcca413e439f088" dependencies = [ - "curve25519-dalek 3.1.0", + "curve25519-dalek 3.0.2", "rand_core 0.5.1", "zeroize", ] @@ -11751,24 +11784,24 @@ dependencies = [ "log", "nohash-hasher", "parking_lot 0.11.1", - "rand 0.8.4", + "rand 0.8.3", "static_assertions", ] [[package]] name = "zeroize" -version = "1.3.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" +checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" dependencies = [ "proc-macro2", "quote", From a808ec730dfa25fa5eb2a491fe20f3ae759bee49 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 8 Jul 2021 19:02:50 +0700 Subject: [PATCH 75/88] Fix rustdoc --- client/executor/wasmtime/src/instance_wrapper.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index 98589de64cab4..42949fc36071c 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -326,7 +326,7 @@ impl InstanceWrapper { Ok(buffer) } - /// Read data from a slice of memory into a destination buffer. + /// Read data from the instance memory into a slice. /// /// Returns an error if the read would go out of the memory bounds. pub fn read_memory_into(&self, source_addr: Pointer, dest: &mut [u8]) -> Result<()> { @@ -342,7 +342,7 @@ impl InstanceWrapper { } } - /// Write data to a slice of memory. + /// Write data to the instance memory from a slice. /// /// Returns an error if the write would go out of the memory bounds. pub fn write_memory_from(&self, dest_addr: Pointer, data: &[u8]) -> Result<()> { From e3b98ea8541127425467ab0254bea619b81d5edf Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 12 Jul 2021 15:51:40 +0700 Subject: [PATCH 76/88] Removes unused `TransferError` --- client/executor/common/src/error.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/client/executor/common/src/error.rs b/client/executor/common/src/error.rs index d0599cfe83f17..6ad4802e57a8b 100644 --- a/client/executor/common/src/error.rs +++ b/client/executor/common/src/error.rs @@ -150,13 +150,3 @@ pub enum WasmError { } impl std::error::Error for WasmError {} - -/// Possible transfer errors -#[derive(Debug, derive_more::Display)] -pub enum TransferError { - /// Source memory is too small to contain all of the requested data - SourceTooSmall, - - /// Destination memory is too small to fit all of the transferred data - DestTooSmall, -} From 61f30df43c508dde1d449b15f4b1c0457cf32d40 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Thu, 15 Jul 2021 17:38:02 +0700 Subject: [PATCH 77/88] Update Cargo.lock --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bfaceda87e1c1..402848f80aef3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1610,7 +1610,7 @@ dependencies = [ "bitflags", "byteorder", "lazy_static", - "proc-macro-error", + "proc-macro-error 1.0.4", "proc-macro2", "quote", "syn", @@ -11332,7 +11332,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b86dcd2c3efdb8390728a2b56f762db07789aaa5aa872a9dc776ba3a7912ed" dependencies = [ - "proc-macro-error", + "proc-macro-error 1.0.4", "proc-macro2", "quote", "syn", From 3b9fed02575cf8930a2fa32667fe5a29315a2802 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 26 Jul 2021 15:18:31 +0700 Subject: [PATCH 78/88] Removes unused import --- client/executor/wasmtime/src/host.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 146fd1a52d0ea..fd6826542aa4c 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -19,7 +19,7 @@ //! This module defines `HostState` and `HostContext` structs which provide logic and state //! required for execution of host. -use crate::{instance_wrapper::InstanceWrapper, util}; +use crate::instance_wrapper::InstanceWrapper; use codec::{Decode, Encode}; use log::trace; use sc_allocator::FreeingBumpHeapAllocator; From 33caef7df8d3e85e55197216f780878526ff5195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 9 Aug 2021 08:50:25 +0200 Subject: [PATCH 79/88] cargo fmt --- client/executor/common/src/lib.rs | 2 +- client/executor/common/src/sandbox.rs | 399 ++++++++---------- client/executor/common/src/util.rs | 32 +- client/executor/wasmi/src/lib.rs | 121 +++--- client/executor/wasmtime/src/host.rs | 48 +-- client/executor/wasmtime/src/imports.rs | 14 +- .../executor/wasmtime/src/instance_wrapper.rs | 8 +- client/executor/wasmtime/src/state_holder.rs | 2 +- 8 files changed, 276 insertions(+), 350 deletions(-) diff --git a/client/executor/common/src/lib.rs b/client/executor/common/src/lib.rs index 86ecb405690ba..99b927e062038 100644 --- a/client/executor/common/src/lib.rs +++ b/client/executor/common/src/lib.rs @@ -24,5 +24,5 @@ pub mod error; pub mod runtime_blob; pub mod sandbox; -pub mod wasm_runtime; pub mod util; +pub mod wasm_runtime; diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 00f69e79492ae..f98bdcd1be9c6 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -20,14 +20,17 @@ //! //! Sandboxing is backed by wasmi and wasmer, depending on the configuration. -use crate::{error::{Result, Error}, util}; +use crate::{ + error::{Error, Result}, + util, +}; use codec::{Decode, Encode}; use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, Pointer, WordSize}; use std::{collections::HashMap, rc::Rc}; use wasmi::{ - memory_units::Pages, Externals, ImportResolver, MemoryInstance, Module, - ModuleInstance, RuntimeArgs, RuntimeValue, Trap, TrapKind, + memory_units::Pages, Externals, ImportResolver, MemoryInstance, Module, ModuleInstance, + RuntimeArgs, RuntimeValue, Trap, TrapKind, }; #[cfg(feature = "wasmer-sandbox")] @@ -92,11 +95,15 @@ struct Imports { impl Imports { fn func_by_name(&self, module_name: &str, func_name: &str) -> Option { - self.func_map.get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())).cloned() + self.func_map + .get(&(module_name.as_bytes().to_owned(), func_name.as_bytes().to_owned())) + .cloned() } fn memory_by_name(&self, module_name: &str, memory_name: &str) -> Option { - self.memories_map.get(&(module_name.as_bytes().to_owned(), memory_name.as_bytes().to_owned())).cloned() + self.memories_map + .get(&(module_name.as_bytes().to_owned(), memory_name.as_bytes().to_owned())) + .cloned() } } @@ -107,13 +114,9 @@ impl ImportResolver for Imports { field_name: &str, signature: &::wasmi::Signature, ) -> std::result::Result { - let idx = self.func_by_name(module_name, field_name) - .ok_or_else(|| { - wasmi::Error::Instantiation(format!( - "Export {}:{} not found", - module_name, field_name - )) - })?; + let idx = self.func_by_name(module_name, field_name).ok_or_else(|| { + wasmi::Error::Instantiation(format!("Export {}:{} not found", module_name, field_name)) + })?; Ok(wasmi::FuncInstance::alloc_host(signature.clone(), idx.0)) } @@ -124,22 +127,16 @@ impl ImportResolver for Imports { field_name: &str, _memory_type: &::wasmi::MemoryDescriptor, ) -> std::result::Result { - let mem = self.memory_by_name(module_name, field_name) - .ok_or_else(|| { - wasmi::Error::Instantiation(format!( - "Export {}:{} not found", - module_name, field_name - )) - })?; + let mem = self.memory_by_name(module_name, field_name).ok_or_else(|| { + wasmi::Error::Instantiation(format!("Export {}:{} not found", module_name, field_name)) + })?; - let wrapper = mem - .as_wasmi() - .ok_or_else(|| { - wasmi::Error::Instantiation(format!( - "Unsupported non-wasmi export {}:{}", - module_name, field_name - )) - })?; + let wrapper = mem.as_wasmi().ok_or_else(|| { + wasmi::Error::Instantiation(format!( + "Unsupported non-wasmi export {}:{}", + module_name, field_name + )) + })?; // Here we use inner memory reference only to resolve // the imports wthout accessing the memory contents. @@ -401,64 +398,60 @@ impl SandboxInstance { DTH: DispatchThunkHolder, { SCH::with_sandbox_capabilities(|supervisor_externals| { - with_guest_externals( - supervisor_externals, - self, - state, - |guest_externals| { - match &self.backend_instance { - BackendInstance::Wasmi(wasmi_instance) => { - let wasmi_result = wasmi_instance - .invoke_export(export_name, args, guest_externals)?; - - Ok(wasmi_result) - } + with_guest_externals(supervisor_externals, self, state, |guest_externals| { + match &self.backend_instance { + BackendInstance::Wasmi(wasmi_instance) => { + let wasmi_result = + wasmi_instance.invoke_export(export_name, args, guest_externals)?; - #[cfg(feature = "wasmer-sandbox")] - BackendInstance::Wasmer(wasmer_instance) => { - let function = wasmer_instance - .exports - .get_function(export_name) - .map_err(|error| wasmi::Error::Function(error.to_string()))?; + Ok(wasmi_result) + }, - let args: Vec = args - .iter() - .map(|v| match *v { - RuntimeValue::I32(val) => wasmer::Val::I32(val), - RuntimeValue::I64(val) => wasmer::Val::I64(val), - RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), - RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), - }) - .collect(); - - let wasmer_result = DTH::initialize_thunk(&self.dispatch_thunk, || function.call(&args)) + #[cfg(feature = "wasmer-sandbox")] + BackendInstance::Wasmer(wasmer_instance) => { + let function = wasmer_instance + .exports + .get_function(export_name) + .map_err(|error| wasmi::Error::Function(error.to_string()))?; + + let args: Vec = args + .iter() + .map(|v| match *v { + RuntimeValue::I32(val) => wasmer::Val::I32(val), + RuntimeValue::I64(val) => wasmer::Val::I64(val), + RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), + RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), + }) + .collect(); + + let wasmer_result = + DTH::initialize_thunk(&self.dispatch_thunk, || function.call(&args)) .map_err(|error| wasmi::Error::Function(error.to_string()))?; - if wasmer_result.len() > 1 { - return Err(wasmi::Error::Function( - "multiple return types are not supported yet".to_owned()) - ); - } - - let wasmer_result = if let Some(wasmer_value) = wasmer_result.first() { - let wasmer_value = match *wasmer_value { - wasmer::Val::I32(val) => RuntimeValue::I32(val), - wasmer::Val::I64(val) => RuntimeValue::I64(val), - wasmer::Val::F32(val) => RuntimeValue::F32(val.into()), - wasmer::Val::F64(val) => RuntimeValue::F64(val.into()), - _ => unreachable!(), - }; - - Some(wasmer_value) - } else { - None + if wasmer_result.len() > 1 { + return Err(wasmi::Error::Function( + "multiple return types are not supported yet".to_owned(), + )) + } + + let wasmer_result = if let Some(wasmer_value) = wasmer_result.first() { + let wasmer_value = match *wasmer_value { + wasmer::Val::I32(val) => RuntimeValue::I32(val), + wasmer::Val::I64(val) => RuntimeValue::I64(val), + wasmer::Val::F32(val) => RuntimeValue::F32(val.into()), + wasmer::Val::F64(val) => RuntimeValue::F64(val.into()), + _ => unreachable!(), }; - Ok(wasmer_result) - } - } - }, - ) + Some(wasmer_value) + } else { + None + }; + + Ok(wasmer_result) + }, + } + }) }) } @@ -468,13 +461,10 @@ impl SandboxInstance { pub fn get_global_val(&self, name: &str) -> Option { match &self.backend_instance { BackendInstance::Wasmi(wasmi_instance) => { - let wasmi_global = wasmi_instance - .export_by_name(name)? - .as_global()? - .get(); + let wasmi_global = wasmi_instance.export_by_name(name)?.as_global()?.get(); Some(wasmi_global.into()) - } + }, #[cfg(feature = "wasmer-sandbox")] BackendInstance::Wasmer(wasmer_instance) => { @@ -490,7 +480,7 @@ impl SandboxInstance { }; Some(wasmtime_value) - } + }, } } } @@ -605,7 +595,9 @@ pub trait DispatchThunkHolder { /// Provide `DispatchThunk` for the runtime method call and execute the given function `f`. /// /// During the execution of the provided function `dispatch_thunk` will be callable. - fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R where F: FnOnce() -> R; + fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R + where + F: FnOnce() -> R; /// Wrapper that provides dispatch thunk in a limited context fn with_dispatch_thunk R>(f: F) -> R; @@ -656,40 +648,28 @@ impl Memory { impl util::MemoryTransfer for Memory { fn read(&self, source_addr: Pointer, size: usize) -> Result> { match self { - Memory::Wasmi(sandboxed_memory) => { - sandboxed_memory.read(source_addr, size) - }, + Memory::Wasmi(sandboxed_memory) => sandboxed_memory.read(source_addr, size), #[cfg(feature = "wasmer-sandbox")] - Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.read(source_addr, size) - }, + Memory::Wasmer(sandboxed_memory) => sandboxed_memory.read(source_addr, size), } } fn read_into(&self, source_addr: Pointer, destination: &mut [u8]) -> Result<()> { match self { - Memory::Wasmi(sandboxed_memory) => { - sandboxed_memory.read_into(source_addr, destination) - }, + Memory::Wasmi(sandboxed_memory) => sandboxed_memory.read_into(source_addr, destination), #[cfg(feature = "wasmer-sandbox")] - Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.read_into(source_addr, destination) - }, + Memory::Wasmer(sandboxed_memory) => sandboxed_memory.read_into(source_addr, destination), } } fn write_from(&self, dest_addr: Pointer, source: &[u8]) -> Result<()> { match self { - Memory::Wasmi(sandboxed_memory) => { - sandboxed_memory.write_from(dest_addr, source) - }, + Memory::Wasmi(sandboxed_memory) => sandboxed_memory.write_from(dest_addr, source), #[cfg(feature = "wasmer-sandbox")] - Memory::Wasmer(sandboxed_memory) => { - sandboxed_memory.write_from(dest_addr, source) - }, + Memory::Wasmer(sandboxed_memory) => sandboxed_memory.write_from(dest_addr, source), } } } @@ -719,12 +699,10 @@ impl BackendContext { SandboxBackend::Wasmer => { let compiler = wasmer_compiler_singlepass::Singlepass::default(); - BackendContext::Wasmer( - WasmerBackend { - store: wasmer::Store::new(&wasmer::JIT::new(compiler).engine()), - } - ) - } + BackendContext::Wasmer(WasmerBackend { + store: wasmer::Store::new(&wasmer::JIT::new(compiler).engine()), + }) + }, } } } @@ -765,27 +743,19 @@ impl Store { }; let memory = match &backend_context { - BackendContext::Wasmi => { - Memory::Wasmi( - WasmiMemoryWrapper::new( - MemoryInstance::alloc( - Pages(initial as usize), - maximum.map(|m| Pages(m as usize)), - )? - ) - ) - } + BackendContext::Wasmi => Memory::Wasmi(WasmiMemoryWrapper::new(MemoryInstance::alloc( + Pages(initial as usize), + maximum.map(|m| Pages(m as usize)), + )?)), #[cfg(feature = "wasmer-sandbox")] BackendContext::Wasmer(context) => { let ty = wasmer::MemoryType::new(initial, maximum, false); - Memory::Wasmer( - WasmerMemoryWrapper::new( - wasmer::Memory::new(&context.store, ty) - .map_err(|_| Error::InvalidMemoryReference)? - ) - ) - } + Memory::Wasmer(WasmerMemoryWrapper::new( + wasmer::Memory::new(&context.store, ty) + .map_err(|_| Error::InvalidMemoryReference)?, + )) + }, }; let mem_idx = memories.len(); @@ -881,17 +851,12 @@ impl Store { let backend_context = &self.backend_context; let sandbox_instance = match backend_context { - BackendContext::Wasmi => Self::instantiate_wasmi::(wasm, guest_env, state)?, + BackendContext::Wasmi => + Self::instantiate_wasmi::(wasm, guest_env, state)?, #[cfg(feature = "wasmer-sandbox")] - BackendContext::Wasmer(context) => { - Self::instantiate_wasmer::( - context, - wasm, - guest_env, - state - )? - } + BackendContext::Wasmer(context) => + Self::instantiate_wasmer::(context, wasm, guest_env, state)?, }; Ok(UnregisteredInstance { sandbox_instance }) @@ -909,7 +874,7 @@ impl Store { fn instantiate_wasmi<'a, FE, SCH, DTH>( wasm: &[u8], guest_env: GuestEnvironment, - state: u32 + state: u32, ) -> std::result::Result>, InstantiationError> where FR: Clone + 'static, @@ -917,35 +882,38 @@ impl Store { SCH: SandboxCapabilitiesHolder, DTH: DispatchThunkHolder, { - let wasmi_module = Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + let wasmi_module = + Module::from_buffer(wasm).map_err(|_| InstantiationError::ModuleDecoding)?; let wasmi_instance = ModuleInstance::new(&wasmi_module, &guest_env.imports) .map_err(|_| InstantiationError::Instantiation)?; let sandbox_instance = DTH::with_dispatch_thunk(|dispatch_thunk| { - Rc::new(SandboxInstance { - // In general, it's not a very good idea to use `.not_started_instance()` for anything - // but for extracting memory and tables. But in this particular case, we are extracting - // for the purpose of running `start` function which should be ok. - backend_instance: BackendInstance::Wasmi(wasmi_instance.not_started_instance().clone()), - dispatch_thunk: dispatch_thunk.clone(), - guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, - }) - }); + Rc::new(SandboxInstance { + // In general, it's not a very good idea to use `.not_started_instance()` for anything + // but for extracting memory and tables. But in this particular case, we are extracting + // for the purpose of running `start` function which should be ok. + backend_instance: BackendInstance::Wasmi( + wasmi_instance.not_started_instance().clone(), + ), + dispatch_thunk: dispatch_thunk.clone(), + guest_to_supervisor_mapping: guest_env.guest_to_supervisor_mapping, + }) + }); - SCH::with_sandbox_capabilities(|supervisor_externals| { - with_guest_externals( - supervisor_externals, - &sandbox_instance, - state, - |guest_externals| { - wasmi_instance - .run_start(guest_externals) - .map_err(|_| InstantiationError::StartTrapped) - - // Note: no need to run start on wasmtime instance, since it's done automatically - }, - ) - })?; + SCH::with_sandbox_capabilities(|supervisor_externals| { + with_guest_externals( + supervisor_externals, + &sandbox_instance, + state, + |guest_externals| { + wasmi_instance + .run_start(guest_externals) + .map_err(|_| InstantiationError::StartTrapped) + + // Note: no need to run start on wasmtime instance, since it's done automatically + }, + ) + })?; Ok(sandbox_instance) } @@ -955,7 +923,7 @@ impl Store { context: &WasmerBackend, wasm: &[u8], guest_env: GuestEnvironment, - state: u32 + state: u32, ) -> std::result::Result>, InstantiationError> where FR: Clone + 'static, @@ -963,7 +931,8 @@ impl Store { SCH: SandboxCapabilitiesHolder, DTH: DispatchThunkHolder, { - let module = wasmer::Module::new(&context.store, wasm).map_err(|_| InstantiationError::ModuleDecoding)?; + let module = wasmer::Module::new(&context.store, wasm) + .map_err(|_| InstantiationError::ModuleDecoding)?; type Exports = HashMap; let mut exports_map = Exports::new(); @@ -978,16 +947,16 @@ impl Store { .entry(import.module().to_string()) .or_insert(wasmer::Exports::new()); - let memory = guest_env.imports.memory_by_name( - import.module(), - import.name() - ).ok_or(InstantiationError::ModuleDecoding)?; + let memory = guest_env + .imports + .memory_by_name(import.module(), import.name()) + .ok_or(InstantiationError::ModuleDecoding)?; let mut wasmer_memory_ref = memory.as_wasmer().expect( "memory is created by wasmer; \ exported by the same module and backend; \ thus the operation can't fail; \ - qed" + qed", ); // This is safe since we're only instantiating the module and populating @@ -997,19 +966,21 @@ impl Store { let wasmer_memory = unsafe { wasmer_memory_ref.clone_inner() }; exports.insert(import.name(), wasmer::Extern::Memory(wasmer_memory)); - } + }, wasmer::ExternType::Function(func_ty) => { - let guest_func_index = guest_env.imports.func_by_name(import.module(), import.name()); + let guest_func_index = + guest_env.imports.func_by_name(import.module(), import.name()); let guest_func_index = if let Some(index) = guest_func_index { index } else { // Missing import (should we abort here?) - continue; + continue }; - let supervisor_func_index = guest_env.guest_to_supervisor_mapping + let supervisor_func_index = guest_env + .guest_to_supervisor_mapping .func_by_guest_index(guest_func_index) .ok_or(InstantiationError::ModuleDecoding)?; @@ -1017,7 +988,7 @@ impl Store { supervisor_func_index, &context.store, func_ty, - state + state, ); let exports = exports_map @@ -1025,7 +996,7 @@ impl Store { .or_insert(wasmer::Exports::new()); exports.insert(import.name(), wasmer::Extern::Function(function)); - } + }, } } @@ -1034,15 +1005,12 @@ impl Store { import_object.register(module_name, exports); } - let instance = wasmer::Instance::new(&module, &import_object) - .map_err(|error| { - match error { - wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, - wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, - wasmer::InstantiationError::HostEnvInitialization(_) => { - InstantiationError::EnvironmentDefinitionCorrupted - } - } + let instance = + wasmer::Instance::new(&module, &import_object).map_err(|error| match error { + wasmer::InstantiationError::Link(_) => InstantiationError::Instantiation, + wasmer::InstantiationError::Start(_) => InstantiationError::StartTrapped, + wasmer::InstantiationError::HostEnvInitialization(_) => + InstantiationError::EnvironmentDefinitionCorrupted, })?; Ok(Rc::new(SandboxInstance { @@ -1057,7 +1025,7 @@ impl Store { supervisor_func_index: SupervisorFuncIndex, store: &wasmer::Store, func_ty: &wasmer::FunctionType, - state: u32 + state: u32, ) -> wasmer::Function where FR: Clone + 'static, @@ -1077,7 +1045,7 @@ impl Store { wasmer::Val::I64(val) => Value::I64(*val), wasmer::Val::F32(val) => Value::F32(f32::to_bits(*val)), wasmer::Val::F64(val) => Value::F64(f64::to_bits(*val)), - _ => unimplemented!() + _ => unimplemented!(), }) .collect::>() .encode(); @@ -1085,29 +1053,25 @@ impl Store { // Move serialized arguments inside the memory, invoke dispatch thunk and // then free allocated memory. let invoke_args_len = invoke_args_data.len() as WordSize; - let invoke_args_ptr = supervisor_externals - .allocate_memory(invoke_args_len) - .map_err(|_| wasmer::RuntimeError::new( - "Can't allocate memory in supervisor for the arguments") - )?; + let invoke_args_ptr = + supervisor_externals.allocate_memory(invoke_args_len).map_err(|_| { + wasmer::RuntimeError::new( + "Can't allocate memory in supervisor for the arguments", + ) + })?; let deallocate = |fe: &mut FE, ptr, fail_msg| { - fe - .deallocate_memory(ptr) - .map_err(|_| wasmer::RuntimeError::new(fail_msg)) + fe.deallocate_memory(ptr).map_err(|_| wasmer::RuntimeError::new(fail_msg)) }; - if supervisor_externals - .write_memory(invoke_args_ptr, &invoke_args_data) - .is_err() - { + if supervisor_externals.write_memory(invoke_args_ptr, &invoke_args_data).is_err() { deallocate( supervisor_externals, invoke_args_ptr, - "Failed dealloction after failed write of invoke arguments" + "Failed dealloction after failed write of invoke arguments", )?; - return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")); + return Err(wasmer::RuntimeError::new("Can't write invoke args into memory")) } // Perform the actuall call @@ -1119,7 +1083,8 @@ impl Store { state, supervisor_func_index, ) - }).map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; + }) + .map_err(|e| wasmer::RuntimeError::new(e.to_string()))?; // dispatch_thunk returns pointer to serialized arguments. // Unpack pointer and len of the serialized result data. @@ -1133,30 +1098,30 @@ impl Store { let serialized_result_val = supervisor_externals .read_memory(serialized_result_val_ptr, serialized_result_val_len) - .map_err(|_| wasmer::RuntimeError::new( - "Can't read the serialized result from dispatch thunk") - ); + .map_err(|_| { + wasmer::RuntimeError::new( + "Can't read the serialized result from dispatch thunk", + ) + }); let deserialized_result = deallocate( supervisor_externals, serialized_result_val_ptr, - "Can't deallocate memory for dispatch thunk's result" + "Can't deallocate memory for dispatch thunk's result", ) - .and_then(|_| serialized_result_val) - .and_then(|serialized_result_val| { - deserialize_result(&serialized_result_val) - .map_err(|e| wasmer::RuntimeError::new(e.to_string())) - })?; + .and_then(|_| serialized_result_val) + .and_then(|serialized_result_val| { + deserialize_result(&serialized_result_val) + .map_err(|e| wasmer::RuntimeError::new(e.to_string())) + })?; if let Some(value) = deserialized_result { - Ok(vec![ - match value { - RuntimeValue::I32(val) => wasmer::Val::I32(val), - RuntimeValue::I64(val) => wasmer::Val::I64(val), - RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), - RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), - } - ]) + Ok(vec![match value { + RuntimeValue::I32(val) => wasmer::Val::I32(val), + RuntimeValue::I64(val) => wasmer::Val::I64(val), + RuntimeValue::F32(val) => wasmer::Val::F32(val.into()), + RuntimeValue::F64(val) => wasmer::Val::F64(val.into()), + }]) } else { Ok(vec![]) } diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs index 9e8e90ab58ca1..f7be5da44edab 100644 --- a/client/executor/common/src/util.rs +++ b/client/executor/common/src/util.rs @@ -18,9 +18,9 @@ //! Utilities used by all backends -use std::ops::Range; +use crate::error::{Error, Result}; use sp_wasm_interface::Pointer; -use crate::error::{Result, Error}; +use std::ops::Range; /// Construct a range from an offset to a data length after the offset. /// Returns None if the end of the range would exceed some maximum offset. @@ -118,11 +118,10 @@ pub mod wasmi { /// backends right from the start. #[cfg(feature = "wasmer-sandbox")] pub mod wasmer { - use sp_wasm_interface::Pointer; - use crate::error::{Result, Error}; use super::checked_range; - use std::{cell::RefCell, rc::Rc}; - use std::convert::TryInto; + use crate::error::{Error, Result}; + use sp_wasm_interface::Pointer; + use std::{cell::RefCell, convert::TryInto, rc::Rc}; /// In order to enforce memory access protocol to the backend memory /// we wrap it with `RefCell` and encapsulate all memory operations. @@ -134,9 +133,7 @@ pub mod wasmer { impl MemoryWrapper { /// Take ownership of the memory region and return a wrapper object pub fn new(memory: wasmer::Memory) -> Self { - Self { - buffer: Rc::new(RefCell::new(memory)) - } + Self { buffer: Rc::new(RefCell::new(memory)) } } /// Returns linear memory of the wasm instance as a slice. @@ -148,10 +145,8 @@ pub mod wasmer { /// growing, we cannot guarantee the lifetime of the returned slice reference. unsafe fn memory_as_slice(memory: &wasmer::Memory) -> &[u8] { let ptr = memory.data_ptr() as *const _; - let len: usize = memory - .data_size() - .try_into() - .expect("data size should fit into usize"); + let len: usize = + memory.data_size().try_into().expect("data size should fit into usize"); if len == 0 { &[] @@ -169,10 +164,8 @@ pub mod wasmer { /// at the same time. unsafe fn memory_as_slice_mut(memory: &wasmer::Memory) -> &mut [u8] { let ptr = memory.data_ptr(); - let len: usize = memory - .data_size() - .try_into() - .expect("data size should fit into usize"); + let len: usize = + memory.data_size().try_into().expect("data size should fit into usize"); if len == 0 { &mut [] @@ -203,10 +196,7 @@ pub mod wasmer { fn read(&self, source_addr: Pointer, size: usize) -> Result> { let memory = self.buffer.borrow(); - let data_size = memory - .data_size() - .try_into() - .expect("data size does not fit"); + let data_size = memory.data_size().try_into().expect("data size does not fit"); let range = checked_range(source_addr.into(), size, data_size) .ok_or_else(|| Error::Other("memory read is out of bounds".into()))?; diff --git a/client/executor/wasmi/src/lib.rs b/client/executor/wasmi/src/lib.rs index 74b2c30add145..ebb36b5e72731 100644 --- a/client/executor/wasmi/src/lib.rs +++ b/client/executor/wasmi/src/lib.rs @@ -18,15 +18,14 @@ //! This crate provides an implementation of `WasmModule` that is baked by wasmi. - use codec::{Decode, Encode}; use log::{debug, error, trace}; use sc_executor_common::{ error::{Error, WasmError}, runtime_blob::{DataSegmentsSnapshot, RuntimeBlob}, sandbox, - wasm_runtime::{InvokeMethod, WasmInstance, WasmModule}, util::MemoryTransfer, + wasm_runtime::{InvokeMethod, WasmInstance, WasmModule}, }; use sp_core::sandbox as sandbox_primitives; use sp_runtime_interface::unpack_ptr_and_len; @@ -74,7 +73,7 @@ impl FunctionExecutor { host_functions, allow_missing_func_imports, missing_functions, - }) + }), }) } } @@ -119,16 +118,16 @@ impl FunctionContext for FunctionExecutor { fn allocate_memory(&mut self, size: WordSize) -> WResult> { let heap = &mut self.inner.heap.borrow_mut(); - self.inner.memory.with_direct_access_mut(|mem| { - heap.allocate(mem, size).map_err(|e| e.to_string()) - }) + self.inner + .memory + .with_direct_access_mut(|mem| heap.allocate(mem, size).map_err(|e| e.to_string())) } fn deallocate_memory(&mut self, ptr: Pointer) -> WResult<()> { let heap = &mut self.inner.heap.borrow_mut(); - self.inner.memory.with_direct_access_mut(|mem| { - heap.deallocate(mem, ptr).map_err(|e| e.to_string()) - }) + self.inner + .memory + .with_direct_access_mut(|mem| heap.deallocate(mem, ptr).map_err(|e| e.to_string())) } fn sandbox(&mut self) -> &mut dyn Sandbox { @@ -144,11 +143,8 @@ impl Sandbox for FunctionExecutor { buf_ptr: Pointer, buf_len: WordSize, ) -> WResult { - let sandboxed_memory = self - .inner - .sandbox_store - .borrow() - .memory(memory_id).map_err(|e| e.to_string())?; + let sandboxed_memory = + self.inner.sandbox_store.borrow().memory(memory_id).map_err(|e| e.to_string())?; let len = buf_len as usize; @@ -171,11 +167,8 @@ impl Sandbox for FunctionExecutor { val_ptr: Pointer, val_len: WordSize, ) -> WResult { - let sandboxed_memory = self - .inner - .sandbox_store - .borrow() - .memory(memory_id).map_err(|e| e.to_string())?; + let sandboxed_memory = + self.inner.sandbox_store.borrow().memory(memory_id).map_err(|e| e.to_string())?; let len = val_len as usize; @@ -192,23 +185,19 @@ impl Sandbox for FunctionExecutor { } fn memory_teardown(&mut self, memory_id: MemoryId) -> WResult<()> { - self - .inner + self.inner .sandbox_store .borrow_mut() - .memory_teardown(memory_id).map_err(|e| e.to_string()) + .memory_teardown(memory_id) + .map_err(|e| e.to_string()) } - fn memory_new( - &mut self, - initial: u32, - maximum: u32, - ) -> WResult { - self - .inner + fn memory_new(&mut self, initial: u32, maximum: u32) -> WResult { + self.inner .sandbox_store .borrow_mut() - .new_memory(initial, maximum).map_err(|e| e.to_string()) + .new_memory(initial, maximum) + .map_err(|e| e.to_string()) } fn invoke( @@ -233,11 +222,11 @@ impl Sandbox for FunctionExecutor { .inner .sandbox_store .borrow() - .instance(instance_id).map_err(|e| e.to_string())?; + .instance(instance_id) + .map_err(|e| e.to_string())?; - let result = EXECUTOR.set(self, || { - instance.invoke::<_, CapsHolder, ThunkHolder>(export_name, &args, state) - }); + let result = EXECUTOR + .set(self, || instance.invoke::<_, CapsHolder, ThunkHolder>(export_name, &args, state)); match result { Ok(None) => Ok(sandbox_primitives::ERR_OK), @@ -256,11 +245,11 @@ impl Sandbox for FunctionExecutor { } fn instance_teardown(&mut self, instance_id: u32) -> WResult<()> { - self - .inner + self.inner .sandbox_store .borrow_mut() - .instance_teardown(instance_id).map_err(|e| e.to_string()) + .instance_teardown(instance_id) + .map_err(|e| e.to_string()) } fn instance_new( @@ -272,7 +261,10 @@ impl Sandbox for FunctionExecutor { ) -> WResult { // Extract a dispatch thunk from instance's table by the specified index. let dispatch_thunk = { - let table = self.inner.table.as_ref() + let table = self + .inner + .table + .as_ref() .ok_or_else(|| "Runtime doesn't have a table; sandbox is unavailable")?; table .get(dispatch_thunk_id) @@ -281,30 +273,25 @@ impl Sandbox for FunctionExecutor { }; let guest_env = match sandbox::GuestEnvironment::decode( - &*self.inner.sandbox_store.borrow(), - raw_env_def + &*self.inner.sandbox_store.borrow(), + raw_env_def, ) { Ok(guest_env) => guest_env, Err(_) => return Ok(sandbox_primitives::ERR_MODULE as u32), }; let store = &mut *self.inner.sandbox_store.borrow_mut(); - let result = EXECUTOR.set(self, || DISPATCH_THUNK.set(&dispatch_thunk, || { - store.instantiate::<_, CapsHolder, ThunkHolder>( - wasm, - guest_env, - state, - )} - )); - - let instance_idx_or_err_code: u32 = - match result - .map(|i| i.register(store)) - { - Ok(instance_idx) => instance_idx, - Err(sandbox::InstantiationError::StartTrapped) => sandbox_primitives::ERR_EXECUTION, - Err(_) => sandbox_primitives::ERR_MODULE, - }; + let result = EXECUTOR.set(self, || { + DISPATCH_THUNK.set(&dispatch_thunk, || { + store.instantiate::<_, CapsHolder, ThunkHolder>(wasm, guest_env, state) + }) + }); + + let instance_idx_or_err_code: u32 = match result.map(|i| i.register(store)) { + Ok(instance_idx) => instance_idx, + Err(sandbox::InstantiationError::StartTrapped) => sandbox_primitives::ERR_EXECUTION, + Err(_) => sandbox_primitives::ERR_MODULE, + }; Ok(instance_idx_or_err_code as u32) } @@ -314,8 +301,7 @@ impl Sandbox for FunctionExecutor { instance_idx: u32, name: &str, ) -> WResult> { - self - .inner + self.inner .sandbox_store .borrow() .instance(instance_idx) @@ -358,9 +344,12 @@ impl sandbox::DispatchThunkHolder for ThunkHolder { DISPATCH_THUNK.with(|thunk| f(&mut thunk.clone())) } - fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R where F: FnOnce() -> R { + fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R + where + F: FnOnce() -> R, + { DISPATCH_THUNK.set(s, f) - } + } } /// Will be used on initialization of a module to resolve function and memory imports. @@ -482,18 +471,20 @@ impl wasmi::Externals for FunctionExecutor { let mut args = args.as_ref().iter().copied().map(Into::into); if let Some(function) = self.inner.host_functions.clone().get(index) { - function.execute(self, &mut args) + function + .execute(self, &mut args) .map_err(|msg| Error::FunctionExecution(function.name().to_string(), msg)) .map_err(wasmi::Trap::from) .map(|v| v.map(Into::into)) - } else if self.inner.allow_missing_func_imports - && index >= self.inner.host_functions.len() - && index < self.inner.host_functions.len() + self.inner.missing_functions.len() + } else if self.inner.allow_missing_func_imports && + index >= self.inner.host_functions.len() && + index < self.inner.host_functions.len() + self.inner.missing_functions.len() { Err(Error::from(format!( "Function `{}` is only a stub. Calling a stub is not allowed.", self.inner.missing_functions[index - self.inner.host_functions.len()], - )).into()) + )) + .into()) } else { Err(Error::from(format!("Could not find host function with index: {}", index)).into()) } diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index fd6826542aa4c..8750bfd0fbce9 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -22,6 +22,7 @@ use crate::instance_wrapper::InstanceWrapper; use codec::{Decode, Encode}; use log::trace; +use sandbox::SandboxCapabilitiesHolder; use sc_allocator::FreeingBumpHeapAllocator; use sc_executor_common::{ error::Result, @@ -32,7 +33,6 @@ use sp_core::sandbox as sandbox_primitives; use sp_wasm_interface::{FunctionContext, MemoryId, Pointer, Sandbox, WordSize}; use std::{cell::RefCell, rc::Rc}; use wasmtime::{Func, Val}; -use sandbox::SandboxCapabilitiesHolder; /// Wrapper type for pointer to a Wasm table entry. /// @@ -78,7 +78,7 @@ impl HostState { sandbox_store: RefCell::new(sandbox::Store::new(backend)), allocator: RefCell::new(allocator), instance, - }) + }), } } } @@ -129,17 +129,11 @@ impl sp_wasm_interface::FunctionContext for HostState { address: Pointer, dest: &mut [u8], ) -> sp_wasm_interface::Result<()> { - self.inner - .instance - .read_memory_into(address, dest) - .map_err(|e| e.to_string()) + self.inner.instance.read_memory_into(address, dest).map_err(|e| e.to_string()) } fn write_memory(&mut self, address: Pointer, data: &[u8]) -> sp_wasm_interface::Result<()> { - self.inner - .instance - .write_memory_from(address, data) - .map_err(|e| e.to_string()) + self.inner.instance.write_memory_from(address, data).map_err(|e| e.to_string()) } fn allocate_memory(&mut self, size: WordSize) -> sp_wasm_interface::Result> { @@ -169,12 +163,8 @@ impl Sandbox for HostState { buf_ptr: Pointer, buf_len: WordSize, ) -> sp_wasm_interface::Result { - let sandboxed_memory = self - .inner - .sandbox_store - .borrow() - .memory(memory_id) - .map_err(|e| e.to_string())?; + let sandboxed_memory = + self.inner.sandbox_store.borrow().memory(memory_id).map_err(|e| e.to_string())?; let len = buf_len as usize; @@ -197,11 +187,8 @@ impl Sandbox for HostState { val_ptr: Pointer, val_len: WordSize, ) -> sp_wasm_interface::Result { - let sandboxed_memory = self.inner - .sandbox_store - .borrow() - .memory(memory_id) - .map_err(|e| e.to_string())?; + let sandboxed_memory = + self.inner.sandbox_store.borrow().memory(memory_id).map_err(|e| e.to_string())?; let len = val_len as usize; @@ -321,11 +308,8 @@ impl Sandbox for HostState { let store = &mut *self.inner.sandbox_store.borrow_mut(); let result = DISPATCH_THUNK.set(&dispatch_thunk, || { - store.instantiate::<_, CapsHolder, ThunkHolder>( - wasm, - guest_env, - state - ) + store + .instantiate::<_, CapsHolder, ThunkHolder>(wasm, guest_env, state) .map(|i| i.register(store)) }); @@ -343,7 +327,8 @@ impl Sandbox for HostState { instance_idx: u32, name: &str, ) -> sp_wasm_interface::Result> { - self.inner.sandbox_store + self.inner + .sandbox_store .borrow() .instance(instance_idx) .map(|i| i.get_global_val(name)) @@ -362,9 +347,7 @@ impl SandboxCapabilitiesHolder for CapsHolder { type SC = HostState; fn with_sandbox_capabilities R>(f: F) -> R { - crate::state_holder::with_context(|ctx| { - f(&mut ctx.expect("wasmtime executor is not set")) - }) + crate::state_holder::with_context(|ctx| f(&mut ctx.expect("wasmtime executor is not set"))) } } @@ -384,7 +367,10 @@ impl sandbox::DispatchThunkHolder for ThunkHolder { DISPATCH_THUNK.with(|thunk| f(&mut thunk.clone())) } - fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R where F: FnOnce() -> R { + fn initialize_thunk(s: &Self::DispatchThunk, f: F) -> R + where + F: FnOnce() -> R, + { DISPATCH_THUNK.set(s, f) } } diff --git a/client/executor/wasmtime/src/imports.rs b/client/executor/wasmtime/src/imports.rs index b51fdb8b9dc8d..b27fb944bc030 100644 --- a/client/executor/wasmtime/src/imports.rs +++ b/client/executor/wasmtime/src/imports.rs @@ -254,17 +254,9 @@ impl MissingHostFuncHandler { fn wasmtime_func_sig(func: &dyn Function) -> wasmtime::FuncType { let signature = func.signature(); - let params = signature - .args - .iter() - .cloned() - .map(into_wasmtime_val_type); - - let results = signature - .return_value - .iter() - .cloned() - .map(into_wasmtime_val_type); + let params = signature.args.iter().cloned().map(into_wasmtime_val_type); + + let results = signature.return_value.iter().cloned().map(into_wasmtime_val_type); wasmtime::FuncType::new(params, results) } diff --git a/client/executor/wasmtime/src/instance_wrapper.rs b/client/executor/wasmtime/src/instance_wrapper.rs index e063d91bcbbb2..5d7a2bdce1c9c 100644 --- a/client/executor/wasmtime/src/instance_wrapper.rs +++ b/client/executor/wasmtime/src/instance_wrapper.rs @@ -19,14 +19,16 @@ //! Defines data and logic needed for interaction with an WebAssembly instance of a substrate //! runtime module. -use crate::util::{from_wasmtime_val, into_wasmtime_val}; -use crate::imports::Imports; +use crate::{ + imports::Imports, + util::{from_wasmtime_val, into_wasmtime_val}, +}; use sc_executor_common::{ error::{Error, Result}, runtime_blob, - wasm_runtime::InvokeMethod, util::checked_range, + wasm_runtime::InvokeMethod, }; use sp_wasm_interface::{Pointer, Value, WordSize}; use std::{marker, slice}; diff --git a/client/executor/wasmtime/src/state_holder.rs b/client/executor/wasmtime/src/state_holder.rs index 94dd8e8c26d69..45bddc841bde6 100644 --- a/client/executor/wasmtime/src/state_holder.rs +++ b/client/executor/wasmtime/src/state_holder.rs @@ -39,7 +39,7 @@ where F: FnOnce(Option) -> R, { if !HOST_STATE.is_set() { - return f(None); + return f(None) } HOST_STATE.with(|state| f(Some(state.clone()))) } From fc5fec144a79a2f67a8f060f6b46181a54ca045c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 9 Aug 2021 10:03:56 +0200 Subject: [PATCH 80/88] Fix feature dependency graph * Feature should flow from the top level crate * We should not assume a specific workspace structure * sc-executor-wasmi does not use the feature * sc-executor-wasmtime should not know about the feature --- client/executor/Cargo.toml | 3 +++ client/executor/common/Cargo.toml | 5 ++++- client/executor/common/src/sandbox.rs | 8 +++++++- client/executor/wasmi/Cargo.toml | 3 --- client/executor/wasmtime/Cargo.toml | 3 --- client/executor/wasmtime/src/host.rs | 13 ++++--------- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index a96163f200df8..e4892409ab23c 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -64,3 +64,6 @@ wasmtime = [ wasmi-errno = [ "wasmi/errno" ] +wasmer-sandbox = [ + "sc-executor-common/wasmer-sandbox", +] diff --git a/client/executor/common/Cargo.toml b/client/executor/common/Cargo.toml index af0b4b696cdfc..402df438f6452 100644 --- a/client/executor/common/Cargo.toml +++ b/client/executor/common/Cargo.toml @@ -30,4 +30,7 @@ wasmer-compiler-singlepass = { version = "1.0", optional = true } [features] default = [] -wasmer-sandbox = [ "wasmer", "wasmer-compiler-singlepass" ] +wasmer-sandbox = [ + "wasmer", + "wasmer-compiler-singlepass", +] diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index f98bdcd1be9c6..62214342875c7 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -611,6 +611,9 @@ pub enum SandboxBackend { /// Wasmer environment #[cfg(feature = "wasmer-sandbox")] Wasmer, + + /// Use wasmer backend if available. Fall back to wasmi otherwise. + TryWasmer, } /// Memory reference in terms of a selected backend @@ -695,8 +698,11 @@ impl BackendContext { match backend { SandboxBackend::Wasmi => BackendContext::Wasmi, + #[cfg(not(feature = "wasmer-sandbox"))] + SandboxBackend::TryWasmer => BackendContext::Wasmi, + #[cfg(feature = "wasmer-sandbox")] - SandboxBackend::Wasmer => { + SandboxBackend::Wasmer | SandboxBackend::TryWasmer => { let compiler = wasmer_compiler_singlepass::Singlepass::default(); BackendContext::Wasmer(WasmerBackend { diff --git a/client/executor/wasmi/Cargo.toml b/client/executor/wasmi/Cargo.toml index 8bf22f127b965..324b2bdd0baeb 100644 --- a/client/executor/wasmi/Cargo.toml +++ b/client/executor/wasmi/Cargo.toml @@ -23,6 +23,3 @@ sp-wasm-interface = { version = "4.0.0-dev", path = "../../../primitives/wasm-in sp-runtime-interface = { version = "4.0.0-dev", path = "../../../primitives/runtime-interface" } sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" } scoped-tls = "1.0" - -[features] -wasmer-sandbox = [] diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index ddb4ab7ab63c6..e2736cd375a38 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -32,6 +32,3 @@ assert_matches = "1.3.0" sc-runtime-test = { version = "2.0.0", path = "../runtime-test" } sp-io = { version = "4.0.0-dev", path = "../../../primitives/io" } wat = "1.0" - -[features] -wasmer-sandbox = [] diff --git a/client/executor/wasmtime/src/host.rs b/client/executor/wasmtime/src/host.rs index 8750bfd0fbce9..12e5ab0023efb 100644 --- a/client/executor/wasmtime/src/host.rs +++ b/client/executor/wasmtime/src/host.rs @@ -22,11 +22,10 @@ use crate::instance_wrapper::InstanceWrapper; use codec::{Decode, Encode}; use log::trace; -use sandbox::SandboxCapabilitiesHolder; use sc_allocator::FreeingBumpHeapAllocator; use sc_executor_common::{ error::Result, - sandbox::{self, SandboxCapabilities, SupervisorFuncIndex}, + sandbox::{self, SandboxCapabilities, SandboxCapabilitiesHolder, SupervisorFuncIndex}, util::MemoryTransfer, }; use sp_core::sandbox as sandbox_primitives; @@ -67,15 +66,11 @@ struct Inner { impl HostState { /// Constructs a new `HostState`. pub fn new(allocator: FreeingBumpHeapAllocator, instance: Rc) -> Self { - #[cfg(feature = "wasmer-sandbox")] - let backend = sandbox::SandboxBackend::Wasmer; - - #[cfg(not(feature = "wasmer-sandbox"))] - let backend = sandbox::SandboxBackend::Wasmi; - HostState { inner: Rc::new(Inner { - sandbox_store: RefCell::new(sandbox::Store::new(backend)), + sandbox_store: RefCell::new(sandbox::Store::new( + sandbox::SandboxBackend::TryWasmer, + )), allocator: RefCell::new(allocator), instance, }), From ae6cf2a0c7b568675870738e0aad634945ec4042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 9 Aug 2021 11:08:41 +0200 Subject: [PATCH 81/88] Fix doc typo --- client/executor/common/src/sandbox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 62214342875c7..75ac1d960860f 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -139,7 +139,7 @@ impl ImportResolver for Imports { })?; // Here we use inner memory reference only to resolve - // the imports wthout accessing the memory contents. + // the imports without accessing the memory contents. let mem = unsafe { wrapper.clone_inner() }; Ok(mem) From a1b77a97c1252d2f76bd80d320652d4d7c05a951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 9 Aug 2021 11:09:30 +0200 Subject: [PATCH 82/88] Enable wasmer-sandbox by default (for now) It will be removed before merge. It is so that the benchbot uses the wasmer sandbox. --- client/executor/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index e4892409ab23c..3554f09943dc4 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -54,7 +54,7 @@ paste = "1.0" regex = "1" [features] -default = [ "std" ] +default = [ "std", "wasmer-sandbox" ] # This crate does not have `no_std` support, we just require this for tests std = [] wasm-extern-trace = [] From d713590ba45387c4204b2ad97c8bd6f6ebabda4e Mon Sep 17 00:00:00 2001 From: Parity Benchmarking Bot Date: Mon, 9 Aug 2021 12:07:41 +0000 Subject: [PATCH 83/88] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/contracts/src/weights.rs | 1230 ++++++++++++++++---------------- 1 file changed, 613 insertions(+), 617 deletions(-) diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index cffdb6ca9f006..1cba71db46939 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-08-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-08-09, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -155,46 +155,46 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize() -> Weight { - (3_175_000 as Weight) + (3_323_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn on_initialize_per_trie_key(k: u32, ) -> Weight { (0 as Weight) // Standard Error: 3_000 - .saturating_add((2_201_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((2_350_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (66_035_000 as Weight) - // Standard Error: 6_000 - .saturating_add((38_159_000 as Weight).saturating_mul(q as Weight)) + (158_387_000 as Weight) + // Standard Error: 39_000 + .saturating_add((39_461_000 as Weight).saturating_mul(q as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Contracts PristineCode (r:1 w:0) // Storage: Contracts CodeStorage (r:0 w:1) fn instrument(c: u32, ) -> Weight { - (35_007_000 as Weight) + (33_203_000 as Weight) // Standard Error: 110_000 - .saturating_add((75_739_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((76_504_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:0) fn code_load(c: u32, ) -> Weight { - (6_238_000 as Weight) + (6_741_000 as Weight) // Standard Error: 0 - .saturating_add((1_671_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((1_669_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:1) fn code_refcount(c: u32, ) -> Weight { - (10_080_000 as Weight) - // Standard Error: 0 + (10_937_000 as Weight) + // Standard Error: 1_000 .saturating_add((2_694_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -206,11 +206,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (182_161_000 as Weight) - // Standard Error: 115_000 - .saturating_add((113_515_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 7_000 - .saturating_add((2_314_000 as Weight).saturating_mul(s as Weight)) + (558_616_000 as Weight) + // Standard Error: 294_000 + .saturating_add((381_602_000 as Weight).saturating_mul(c as Weight)) + // Standard Error: 19_000 + .saturating_add((2_309_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -220,9 +220,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn instantiate(s: u32, ) -> Weight { - (183_914_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_224_000 as Weight).saturating_mul(s as Weight)) + (276_361_000 as Weight) + // Standard Error: 3_000 + .saturating_add((2_296_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -231,7 +231,7 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn call() -> Weight { - (166_507_000 as Weight) + (275_359_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -305,9 +305,9 @@ impl WeightInfo for SubstrateWeight { // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743aeb9db1dfeed3a7b47b] (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743abdc9db5edf43ffcb0d] (r:1 w:0) fn claim_surcharge(c: u32, ) -> Weight { - (126_115_000 as Weight) - // Standard Error: 2_000 - .saturating_add((2_829_000 as Weight).saturating_mul(c as Weight)) + (135_558_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_860_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -316,9 +316,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_caller(r: u32, ) -> Weight { - (134_110_000 as Weight) - // Standard Error: 130_000 - .saturating_add((230_337_000 as Weight).saturating_mul(r as Weight)) + (270_209_000 as Weight) + // Standard Error: 700_000 + .saturating_add((363_114_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -327,9 +327,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_address(r: u32, ) -> Weight { - (131_212_000 as Weight) - // Standard Error: 116_000 - .saturating_add((230_568_000 as Weight).saturating_mul(r as Weight)) + (342_353_000 as Weight) + // Standard Error: 466_000 + .saturating_add((359_040_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -338,9 +338,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas_left(r: u32, ) -> Weight { - (135_149_000 as Weight) - // Standard Error: 149_000 - .saturating_add((224_830_000 as Weight).saturating_mul(r as Weight)) + (309_341_000 as Weight) + // Standard Error: 523_000 + .saturating_add((355_882_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -349,9 +349,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_balance(r: u32, ) -> Weight { - (148_463_000 as Weight) - // Standard Error: 246_000 - .saturating_add((480_930_000 as Weight).saturating_mul(r as Weight)) + (395_512_000 as Weight) + // Standard Error: 736_000 + .saturating_add((617_968_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -360,9 +360,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_value_transferred(r: u32, ) -> Weight { - (137_790_000 as Weight) - // Standard Error: 152_000 - .saturating_add((224_961_000 as Weight).saturating_mul(r as Weight)) + (350_418_000 as Weight) + // Standard Error: 427_000 + .saturating_add((351_889_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -371,9 +371,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_minimum_balance(r: u32, ) -> Weight { - (134_238_000 as Weight) - // Standard Error: 135_000 - .saturating_add((224_433_000 as Weight).saturating_mul(r as Weight)) + (316_760_000 as Weight) + // Standard Error: 638_000 + .saturating_add((354_662_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -382,9 +382,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_tombstone_deposit(r: u32, ) -> Weight { - (135_053_000 as Weight) - // Standard Error: 147_000 - .saturating_add((223_955_000 as Weight).saturating_mul(r as Weight)) + (336_168_000 as Weight) + // Standard Error: 807_000 + .saturating_add((353_711_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -393,9 +393,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_rent_allowance(r: u32, ) -> Weight { - (138_522_000 as Weight) - // Standard Error: 145_000 - .saturating_add((223_459_000 as Weight).saturating_mul(r as Weight)) + (332_985_000 as Weight) + // Standard Error: 1_350_000 + .saturating_add((354_808_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -404,9 +404,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_block_number(r: u32, ) -> Weight { - (133_568_000 as Weight) - // Standard Error: 143_000 - .saturating_add((224_792_000 as Weight).saturating_mul(r as Weight)) + (340_298_000 as Weight) + // Standard Error: 377_000 + .saturating_add((355_811_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -415,9 +415,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_now(r: u32, ) -> Weight { - (134_786_000 as Weight) - // Standard Error: 130_000 - .saturating_add((224_331_000 as Weight).saturating_mul(r as Weight)) + (345_811_000 as Weight) + // Standard Error: 391_000 + .saturating_add((352_175_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -427,9 +427,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) fn seal_weight_to_fee(r: u32, ) -> Weight { - (147_402_000 as Weight) - // Standard Error: 233_000 - .saturating_add((439_237_000 as Weight).saturating_mul(r as Weight)) + (350_136_000 as Weight) + // Standard Error: 605_000 + .saturating_add((553_639_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -438,9 +438,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas(r: u32, ) -> Weight { - (115_711_000 as Weight) - // Standard Error: 88_000 - .saturating_add((113_467_000 as Weight).saturating_mul(r as Weight)) + (313_206_000 as Weight) + // Standard Error: 446_000 + .saturating_add((194_676_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -448,10 +448,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:1 w:0) // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) - fn seal_input(r: u32, ) -> Weight { - (123_004_000 as Weight) - // Standard Error: 78_000 - .saturating_add((6_674_000 as Weight).saturating_mul(r as Weight)) + fn seal_input(_r: u32, ) -> Weight { + (266_886_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -460,9 +458,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_input_per_kb(n: u32, ) -> Weight { - (131_611_000 as Weight) - // Standard Error: 0 - .saturating_add((1_035_000 as Weight).saturating_mul(n as Weight)) + (280_666_000 as Weight) + // Standard Error: 2_000 + .saturating_add((1_091_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -471,9 +469,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return(r: u32, ) -> Weight { - (118_327_000 as Weight) - // Standard Error: 84_000 - .saturating_add((4_274_000 as Weight).saturating_mul(r as Weight)) + (246_709_000 as Weight) + // Standard Error: 3_895_000 + .saturating_add((39_082_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -482,9 +480,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return_per_kb(n: u32, ) -> Weight { - (126_129_000 as Weight) - // Standard Error: 0 - .saturating_add((495_000 as Weight).saturating_mul(n as Weight)) + (288_633_000 as Weight) + // Standard Error: 2_000 + .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -494,9 +492,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts DeletionQueue (r:1 w:1) fn seal_terminate(r: u32, ) -> Weight { - (123_759_000 as Weight) - // Standard Error: 115_000 - .saturating_add((89_730_000 as Weight).saturating_mul(r as Weight)) + (258_057_000 as Weight) + // Standard Error: 1_614_000 + .saturating_add((139_230_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -508,9 +506,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743af3fd4cc2fc8d170b6d] (r:1 w:0) fn seal_restore_to(r: u32, ) -> Weight { - (151_364_000 as Weight) - // Standard Error: 263_000 - .saturating_add((99_367_000 as Weight).saturating_mul(r as Weight)) + (311_627_000 as Weight) + // Standard Error: 1_602_000 + .saturating_add((133_583_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -518,9 +516,9 @@ impl WeightInfo for SubstrateWeight { } // Storage: Skipped Metadata (r:0 w:0) fn seal_restore_to_per_delta(d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_919_000 - .saturating_add((2_415_482_000 as Weight).saturating_mul(d as Weight)) + (293_186_000 as Weight) + // Standard Error: 1_931_000 + .saturating_add((2_475_203_000 as Weight).saturating_mul(d as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(d as Weight))) .saturating_add(T::DbWeight::get().writes(7 as Weight)) @@ -532,9 +530,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) fn seal_random(r: u32, ) -> Weight { - (137_660_000 as Weight) - // Standard Error: 204_000 - .saturating_add((563_042_000 as Weight).saturating_mul(r as Weight)) + (367_617_000 as Weight) + // Standard Error: 706_000 + .saturating_add((728_941_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -543,9 +541,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_deposit_event(r: u32, ) -> Weight { - (137_087_000 as Weight) - // Standard Error: 413_000 - .saturating_add((835_499_000 as Weight).saturating_mul(r as Weight)) + (378_232_000 as Weight) + // Standard Error: 810_000 + .saturating_add((983_125_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -555,11 +553,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: System EventTopics (r:100 w:100) fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (1_117_515_000 as Weight) - // Standard Error: 2_167_000 - .saturating_add((494_145_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 427_000 - .saturating_add((150_093_000 as Weight).saturating_mul(n as Weight)) + (1_528_485_000 as Weight) + // Standard Error: 3_632_000 + .saturating_add((542_754_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 715_000 + .saturating_add((158_018_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(t as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -570,9 +568,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_set_rent_allowance(r: u32, ) -> Weight { - (132_070_000 as Weight) - // Standard Error: 129_000 - .saturating_add((155_669_000 as Weight).saturating_mul(r as Weight)) + (308_772_000 as Weight) + // Standard Error: 445_000 + .saturating_add((263_979_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -581,17 +579,17 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_debug_message(r: u32, ) -> Weight { - (126_971_000 as Weight) - // Standard Error: 90_000 - .saturating_add((122_445_000 as Weight).saturating_mul(r as Weight)) + (288_794_000 as Weight) + // Standard Error: 531_000 + .saturating_add((222_581_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_set_storage(r: u32, ) -> Weight { - (125_746_000 as Weight) - // Standard Error: 610_000 - .saturating_add((501_265_000 as Weight).saturating_mul(r as Weight)) + (396_150_000 as Weight) + // Standard Error: 705_000 + .saturating_add((625_327_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -603,17 +601,17 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:1) fn seal_set_storage_per_kb(n: u32, ) -> Weight { - (563_219_000 as Weight) - // Standard Error: 219_000 - .saturating_add((41_578_000 as Weight).saturating_mul(n as Weight)) + (903_526_000 as Weight) + // Standard Error: 699_000 + .saturating_add((46_708_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_clear_storage(r: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_727_000 - .saturating_add((1_001_461_000 as Weight).saturating_mul(r as Weight)) + (174_034_000 as Weight) + // Standard Error: 1_770_000 + .saturating_add((1_140_377_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -621,9 +619,9 @@ impl WeightInfo for SubstrateWeight { } // Storage: Skipped Metadata (r:0 w:0) fn seal_get_storage(r: u32, ) -> Weight { - (9_115_000 as Weight) - // Standard Error: 784_000 - .saturating_add((660_533_000 as Weight).saturating_mul(r as Weight)) + (254_586_000 as Weight) + // Standard Error: 613_000 + .saturating_add((841_011_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -634,9 +632,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:0) fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (563_175_000 as Weight) - // Standard Error: 206_000 - .saturating_add((89_626_000 as Weight).saturating_mul(n as Weight)) + (928_899_000 as Weight) + // Standard Error: 801_000 + .saturating_add((96_065_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -645,9 +643,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_transfer(r: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_750_000 - .saturating_add((4_820_493_000 as Weight).saturating_mul(r as Weight)) + (268_870_000 as Weight) + // Standard Error: 1_651_000 + .saturating_add((5_223_725_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -659,8 +657,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) fn seal_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 6_692_000 - .saturating_add((11_477_937_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 24_770_000 + .saturating_add((19_541_686_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((200 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -671,13 +669,13 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:101 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_call_per_transfer_input_output_kb(t: u32, i: u32, o: u32, ) -> Weight { - (11_238_437_000 as Weight) - // Standard Error: 81_620_000 - .saturating_add((3_700_413_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 29_000 - .saturating_add((32_106_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 31_000 - .saturating_add((54_386_000 as Weight).saturating_mul(o as Weight)) + (28_665_061_000 as Weight) + // Standard Error: 289_240_000 + .saturating_add((3_479_153_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 103_000 + .saturating_add((39_897_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 110_000 + .saturating_add((66_181_000 as Weight).saturating_mul(o as Weight)) .saturating_add(T::DbWeight::get().reads(205 as Weight)) .saturating_add(T::DbWeight::get().writes(101 as Weight)) .saturating_add(T::DbWeight::get().writes((101 as Weight).saturating_mul(t as Weight))) @@ -689,8 +687,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 35_258_000 - .saturating_add((20_674_357_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 38_420_000 + .saturating_add((30_459_849_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((300 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) @@ -702,13 +700,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate_per_input_output_salt_kb(i: u32, o: u32, s: u32, ) -> Weight { - (14_725_288_000 as Weight) - // Standard Error: 53_000 - .saturating_add((33_848_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 53_000 - .saturating_add((57_054_000 as Weight).saturating_mul(o as Weight)) - // Standard Error: 53_000 - .saturating_add((180_033_000 as Weight).saturating_mul(s as Weight)) + (21_687_643_000 as Weight) + // Standard Error: 131_000 + .saturating_add((45_430_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 131_000 + .saturating_add((72_656_000 as Weight).saturating_mul(o as Weight)) + // Standard Error: 131_000 + .saturating_add((197_556_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(206 as Weight)) .saturating_add(T::DbWeight::get().writes(204 as Weight)) } @@ -717,9 +715,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256(r: u32, ) -> Weight { - (131_974_000 as Weight) - // Standard Error: 125_000 - .saturating_add((220_711_000 as Weight).saturating_mul(r as Weight)) + (329_994_000 as Weight) + // Standard Error: 469_000 + .saturating_add((324_178_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -728,9 +726,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (367_148_000 as Weight) - // Standard Error: 12_000 - .saturating_add((462_143_000 as Weight).saturating_mul(n as Weight)) + (687_111_000 as Weight) + // Standard Error: 37_000 + .saturating_add((472_129_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -739,9 +737,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256(r: u32, ) -> Weight { - (134_585_000 as Weight) - // Standard Error: 131_000 - .saturating_add((227_264_000 as Weight).saturating_mul(r as Weight)) + (298_723_000 as Weight) + // Standard Error: 463_000 + .saturating_add((336_842_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -750,9 +748,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (325_319_000 as Weight) - // Standard Error: 12_000 - .saturating_add((313_033_000 as Weight).saturating_mul(n as Weight)) + (628_474_000 as Weight) + // Standard Error: 30_000 + .saturating_add((320_036_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -761,9 +759,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256(r: u32, ) -> Weight { - (135_347_000 as Weight) - // Standard Error: 150_000 - .saturating_add((199_764_000 as Weight).saturating_mul(r as Weight)) + (281_202_000 as Weight) + // Standard Error: 557_000 + .saturating_add((308_068_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -772,9 +770,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (424_473_000 as Weight) - // Standard Error: 13_000 - .saturating_add((130_936_000 as Weight).saturating_mul(n as Weight)) + (749_425_000 as Weight) + // Standard Error: 27_000 + .saturating_add((136_471_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -783,9 +781,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128(r: u32, ) -> Weight { - (128_776_000 as Weight) - // Standard Error: 118_000 - .saturating_add((203_125_000 as Weight).saturating_mul(r as Weight)) + (343_669_000 as Weight) + // Standard Error: 761_000 + .saturating_add((312_147_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -794,266 +792,266 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (445_726_000 as Weight) - // Standard Error: 14_000 - .saturating_add((130_931_000 as Weight).saturating_mul(n as Weight)) + (714_529_000 as Weight) + // Standard Error: 25_000 + .saturating_add((136_454_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn instr_i64const(r: u32, ) -> Weight { - (22_161_000 as Weight) - // Standard Error: 36_000 - .saturating_add((3_329_000 as Weight).saturating_mul(r as Weight)) + (5_749_000 as Weight) + // Standard Error: 41_000 + .saturating_add((399_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64load(r: u32, ) -> Weight { - (24_430_000 as Weight) - // Standard Error: 65_000 - .saturating_add((159_566_000 as Weight).saturating_mul(r as Weight)) + (9_666_000 as Weight) + // Standard Error: 83_000 + .saturating_add((134_313_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64store(r: u32, ) -> Weight { - (24_443_000 as Weight) - // Standard Error: 62_000 - .saturating_add((232_854_000 as Weight).saturating_mul(r as Weight)) + (10_188_000 as Weight) + // Standard Error: 167_000 + .saturating_add((207_638_000 as Weight).saturating_mul(r as Weight)) } fn instr_select(r: u32, ) -> Weight { - (22_158_000 as Weight) - // Standard Error: 34_000 - .saturating_add((12_112_000 as Weight).saturating_mul(r as Weight)) + (5_735_000 as Weight) + // Standard Error: 44_000 + .saturating_add((5_642_000 as Weight).saturating_mul(r as Weight)) } fn instr_if(r: u32, ) -> Weight { - (22_178_000 as Weight) - // Standard Error: 23_000 - .saturating_add((11_374_000 as Weight).saturating_mul(r as Weight)) + (5_727_000 as Weight) + // Standard Error: 39_000 + .saturating_add((5_688_000 as Weight).saturating_mul(r as Weight)) } fn instr_br(r: u32, ) -> Weight { - (22_157_000 as Weight) - // Standard Error: 41_000 - .saturating_add((5_826_000 as Weight).saturating_mul(r as Weight)) + (5_701_000 as Weight) + // Standard Error: 14_000 + .saturating_add((3_601_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_if(r: u32, ) -> Weight { - (22_182_000 as Weight) - // Standard Error: 34_000 - .saturating_add((13_647_000 as Weight).saturating_mul(r as Weight)) + (5_775_000 as Weight) + // Standard Error: 36_000 + .saturating_add((5_045_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table(r: u32, ) -> Weight { - (22_083_000 as Weight) - // Standard Error: 44_000 - .saturating_add((14_901_000 as Weight).saturating_mul(r as Weight)) + (5_649_000 as Weight) + // Standard Error: 42_000 + .saturating_add((12_551_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table_per_entry(e: u32, ) -> Weight { - (32_689_000 as Weight) - // Standard Error: 1_000 - .saturating_add((154_000 as Weight).saturating_mul(e as Weight)) + (18_118_000 as Weight) + // Standard Error: 0 + .saturating_add((90_000 as Weight).saturating_mul(e as Weight)) } fn instr_call(r: u32, ) -> Weight { - (22_313_000 as Weight) - // Standard Error: 383_000 - .saturating_add((89_804_000 as Weight).saturating_mul(r as Weight)) + (6_359_000 as Weight) + // Standard Error: 68_000 + .saturating_add((20_800_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect(r: u32, ) -> Weight { - (29_939_000 as Weight) - // Standard Error: 230_000 - .saturating_add((185_309_000 as Weight).saturating_mul(r as Weight)) + (7_708_000 as Weight) + // Standard Error: 143_000 + .saturating_add((20_016_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (221_596_000 as Weight) - // Standard Error: 3_000 - .saturating_add((4_045_000 as Weight).saturating_mul(p as Weight)) + (16_341_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_777_000 as Weight).saturating_mul(p as Weight)) } fn instr_local_get(r: u32, ) -> Weight { - (22_171_000 as Weight) - // Standard Error: 28_000 - .saturating_add((3_362_000 as Weight).saturating_mul(r as Weight)) + (5_888_000 as Weight) + // Standard Error: 37_000 + .saturating_add((425_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_set(r: u32, ) -> Weight { - (22_182_000 as Weight) - // Standard Error: 31_000 - .saturating_add((3_801_000 as Weight).saturating_mul(r as Weight)) + (6_081_000 as Weight) + // Standard Error: 98_000 + .saturating_add((556_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_tee(r: u32, ) -> Weight { - (22_200_000 as Weight) - // Standard Error: 27_000 - .saturating_add((5_080_000 as Weight).saturating_mul(r as Weight)) + (5_950_000 as Weight) + // Standard Error: 117_000 + .saturating_add((1_339_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_get(r: u32, ) -> Weight { - (25_255_000 as Weight) - // Standard Error: 41_000 - .saturating_add((8_875_000 as Weight).saturating_mul(r as Weight)) + (17_229_000 as Weight) + // Standard Error: 28_000 + .saturating_add((580_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_set(r: u32, ) -> Weight { - (25_145_000 as Weight) - // Standard Error: 37_000 - .saturating_add((9_556_000 as Weight).saturating_mul(r as Weight)) + (17_064_000 as Weight) + // Standard Error: 49_000 + .saturating_add((1_131_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_current(r: u32, ) -> Weight { - (24_435_000 as Weight) - // Standard Error: 49_000 - .saturating_add((4_204_000 as Weight).saturating_mul(r as Weight)) + (9_947_000 as Weight) + // Standard Error: 40_000 + .saturating_add((14_603_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_grow(r: u32, ) -> Weight { - (23_158_000 as Weight) - // Standard Error: 5_969_000 - .saturating_add((2_339_630_000 as Weight).saturating_mul(r as Weight)) + (9_976_000 as Weight) + // Standard Error: 54_000 + .saturating_add((6_458_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64clz(r: u32, ) -> Weight { - (21_984_000 as Weight) - // Standard Error: 25_000 - .saturating_add((5_421_000 as Weight).saturating_mul(r as Weight)) + (5_794_000 as Weight) + // Standard Error: 34_000 + .saturating_add((4_712_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ctz(r: u32, ) -> Weight { - (22_069_000 as Weight) - // Standard Error: 26_000 - .saturating_add((5_187_000 as Weight).saturating_mul(r as Weight)) + (5_755_000 as Weight) + // Standard Error: 33_000 + .saturating_add((4_638_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64popcnt(r: u32, ) -> Weight { - (22_042_000 as Weight) - // Standard Error: 28_000 - .saturating_add((6_116_000 as Weight).saturating_mul(r as Weight)) + (5_957_000 as Weight) + // Standard Error: 101_000 + .saturating_add((1_278_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eqz(r: u32, ) -> Weight { - (22_018_000 as Weight) - // Standard Error: 34_000 - .saturating_add((5_130_000 as Weight).saturating_mul(r as Weight)) + (5_780_000 as Weight) + // Standard Error: 36_000 + .saturating_add((2_257_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendsi32(r: u32, ) -> Weight { - (21_933_000 as Weight) - // Standard Error: 29_000 - .saturating_add((5_005_000 as Weight).saturating_mul(r as Weight)) + (5_733_000 as Weight) + // Standard Error: 107_000 + .saturating_add((1_527_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendui32(r: u32, ) -> Weight { - (22_066_000 as Weight) - // Standard Error: 34_000 - .saturating_add((4_877_000 as Weight).saturating_mul(r as Weight)) + (5_860_000 as Weight) + // Standard Error: 36_000 + .saturating_add((1_610_000 as Weight).saturating_mul(r as Weight)) } fn instr_i32wrapi64(r: u32, ) -> Weight { - (22_003_000 as Weight) + (5_765_000 as Weight) // Standard Error: 25_000 - .saturating_add((5_018_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_429_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eq(r: u32, ) -> Weight { - (22_130_000 as Weight) - // Standard Error: 35_000 - .saturating_add((7_071_000 as Weight).saturating_mul(r as Weight)) + (5_734_000 as Weight) + // Standard Error: 36_000 + .saturating_add((2_506_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ne(r: u32, ) -> Weight { - (22_112_000 as Weight) - // Standard Error: 24_000 - .saturating_add((7_056_000 as Weight).saturating_mul(r as Weight)) + (5_746_000 as Weight) + // Standard Error: 29_000 + .saturating_add((2_345_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64lts(r: u32, ) -> Weight { - (22_114_000 as Weight) + (5_763_000 as Weight) // Standard Error: 27_000 - .saturating_add((6_974_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((2_347_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ltu(r: u32, ) -> Weight { - (22_111_000 as Weight) - // Standard Error: 32_000 - .saturating_add((7_183_000 as Weight).saturating_mul(r as Weight)) + (5_689_000 as Weight) + // Standard Error: 42_000 + .saturating_add((2_583_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gts(r: u32, ) -> Weight { - (22_148_000 as Weight) - // Standard Error: 28_000 - .saturating_add((7_044_000 as Weight).saturating_mul(r as Weight)) + (6_062_000 as Weight) + // Standard Error: 59_000 + .saturating_add((2_066_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gtu(r: u32, ) -> Weight { - (22_158_000 as Weight) - // Standard Error: 33_000 - .saturating_add((7_116_000 as Weight).saturating_mul(r as Weight)) + (5_717_000 as Weight) + // Standard Error: 31_000 + .saturating_add((2_425_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64les(r: u32, ) -> Weight { - (22_194_000 as Weight) - // Standard Error: 31_000 - .saturating_add((7_039_000 as Weight).saturating_mul(r as Weight)) + (5_868_000 as Weight) + // Standard Error: 41_000 + .saturating_add((2_089_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64leu(r: u32, ) -> Weight { - (22_219_000 as Weight) - // Standard Error: 23_000 - .saturating_add((7_076_000 as Weight).saturating_mul(r as Weight)) + (6_130_000 as Weight) + // Standard Error: 86_000 + .saturating_add((1_922_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ges(r: u32, ) -> Weight { - (22_170_000 as Weight) - // Standard Error: 50_000 - .saturating_add((7_122_000 as Weight).saturating_mul(r as Weight)) + (5_719_000 as Weight) + // Standard Error: 41_000 + .saturating_add((2_393_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64geu(r: u32, ) -> Weight { - (22_113_000 as Weight) - // Standard Error: 27_000 - .saturating_add((7_069_000 as Weight).saturating_mul(r as Weight)) + (5_751_000 as Weight) + // Standard Error: 42_000 + .saturating_add((2_554_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64add(r: u32, ) -> Weight { - (22_090_000 as Weight) - // Standard Error: 29_000 - .saturating_add((6_956_000 as Weight).saturating_mul(r as Weight)) + (5_698_000 as Weight) + // Standard Error: 22_000 + .saturating_add((2_259_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64sub(r: u32, ) -> Weight { - (22_006_000 as Weight) - // Standard Error: 30_000 - .saturating_add((7_094_000 as Weight).saturating_mul(r as Weight)) + (5_905_000 as Weight) + // Standard Error: 50_000 + .saturating_add((1_311_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64mul(r: u32, ) -> Weight { - (22_111_000 as Weight) - // Standard Error: 29_000 - .saturating_add((6_825_000 as Weight).saturating_mul(r as Weight)) + (5_667_000 as Weight) + // Standard Error: 33_000 + .saturating_add((2_465_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divs(r: u32, ) -> Weight { - (22_041_000 as Weight) - // Standard Error: 29_000 - .saturating_add((13_164_000 as Weight).saturating_mul(r as Weight)) + (5_664_000 as Weight) + // Standard Error: 31_000 + .saturating_add((8_475_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divu(r: u32, ) -> Weight { - (21_989_000 as Weight) - // Standard Error: 28_000 - .saturating_add((12_808_000 as Weight).saturating_mul(r as Weight)) + (6_258_000 as Weight) + // Standard Error: 124_000 + .saturating_add((6_918_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rems(r: u32, ) -> Weight { - (22_045_000 as Weight) - // Standard Error: 39_000 - .saturating_add((13_387_000 as Weight).saturating_mul(r as Weight)) + (5_717_000 as Weight) + // Standard Error: 49_000 + .saturating_add((13_956_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64remu(r: u32, ) -> Weight { - (22_075_000 as Weight) - // Standard Error: 40_000 - .saturating_add((12_791_000 as Weight).saturating_mul(r as Weight)) + (5_713_000 as Weight) + // Standard Error: 14_000 + .saturating_add((7_458_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64and(r: u32, ) -> Weight { - (22_044_000 as Weight) - // Standard Error: 32_000 - .saturating_add((7_090_000 as Weight).saturating_mul(r as Weight)) + (5_751_000 as Weight) + // Standard Error: 28_000 + .saturating_add((2_310_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64or(r: u32, ) -> Weight { - (22_133_000 as Weight) - // Standard Error: 40_000 - .saturating_add((6_967_000 as Weight).saturating_mul(r as Weight)) + (5_806_000 as Weight) + // Standard Error: 38_000 + .saturating_add((2_032_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64xor(r: u32, ) -> Weight { - (22_069_000 as Weight) + (5_877_000 as Weight) // Standard Error: 41_000 - .saturating_add((7_026_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((2_036_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shl(r: u32, ) -> Weight { - (22_165_000 as Weight) - // Standard Error: 44_000 - .saturating_add((7_440_000 as Weight).saturating_mul(r as Weight)) + (5_789_000 as Weight) + // Standard Error: 25_000 + .saturating_add((1_984_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shrs(r: u32, ) -> Weight { - (22_063_000 as Weight) - // Standard Error: 34_000 - .saturating_add((7_309_000 as Weight).saturating_mul(r as Weight)) + (5_885_000 as Weight) + // Standard Error: 23_000 + .saturating_add((1_905_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shru(r: u32, ) -> Weight { - (22_086_000 as Weight) - // Standard Error: 36_000 - .saturating_add((7_188_000 as Weight).saturating_mul(r as Weight)) + (5_865_000 as Weight) + // Standard Error: 22_000 + .saturating_add((1_967_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotl(r: u32, ) -> Weight { - (22_109_000 as Weight) - // Standard Error: 45_000 - .saturating_add((7_169_000 as Weight).saturating_mul(r as Weight)) + (5_696_000 as Weight) + // Standard Error: 37_000 + .saturating_add((2_107_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotr(r: u32, ) -> Weight { - (22_076_000 as Weight) - // Standard Error: 28_000 - .saturating_add((7_070_000 as Weight).saturating_mul(r as Weight)) + (5_914_000 as Weight) + // Standard Error: 56_000 + .saturating_add((885_000 as Weight).saturating_mul(r as Weight)) } } @@ -1061,46 +1059,46 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize() -> Weight { - (3_175_000 as Weight) + (3_323_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn on_initialize_per_trie_key(k: u32, ) -> Weight { (0 as Weight) // Standard Error: 3_000 - .saturating_add((2_201_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((2_350_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (66_035_000 as Weight) - // Standard Error: 6_000 - .saturating_add((38_159_000 as Weight).saturating_mul(q as Weight)) + (158_387_000 as Weight) + // Standard Error: 39_000 + .saturating_add((39_461_000 as Weight).saturating_mul(q as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Contracts PristineCode (r:1 w:0) // Storage: Contracts CodeStorage (r:0 w:1) fn instrument(c: u32, ) -> Weight { - (35_007_000 as Weight) + (33_203_000 as Weight) // Standard Error: 110_000 - .saturating_add((75_739_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((76_504_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:0) fn code_load(c: u32, ) -> Weight { - (6_238_000 as Weight) + (6_741_000 as Weight) // Standard Error: 0 - .saturating_add((1_671_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((1_669_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:1) fn code_refcount(c: u32, ) -> Weight { - (10_080_000 as Weight) - // Standard Error: 0 + (10_937_000 as Weight) + // Standard Error: 1_000 .saturating_add((2_694_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1112,11 +1110,11 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (182_161_000 as Weight) - // Standard Error: 115_000 - .saturating_add((113_515_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 7_000 - .saturating_add((2_314_000 as Weight).saturating_mul(s as Weight)) + (558_616_000 as Weight) + // Standard Error: 294_000 + .saturating_add((381_602_000 as Weight).saturating_mul(c as Weight)) + // Standard Error: 19_000 + .saturating_add((2_309_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -1126,9 +1124,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn instantiate(s: u32, ) -> Weight { - (183_914_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_224_000 as Weight).saturating_mul(s as Weight)) + (276_361_000 as Weight) + // Standard Error: 3_000 + .saturating_add((2_296_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -1137,7 +1135,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn call() -> Weight { - (166_507_000 as Weight) + (275_359_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } @@ -1211,9 +1209,9 @@ impl WeightInfo for () { // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743aeb9db1dfeed3a7b47b] (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743abdc9db5edf43ffcb0d] (r:1 w:0) fn claim_surcharge(c: u32, ) -> Weight { - (126_115_000 as Weight) - // Standard Error: 2_000 - .saturating_add((2_829_000 as Weight).saturating_mul(c as Weight)) + (135_558_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_860_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -1222,9 +1220,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_caller(r: u32, ) -> Weight { - (134_110_000 as Weight) - // Standard Error: 130_000 - .saturating_add((230_337_000 as Weight).saturating_mul(r as Weight)) + (270_209_000 as Weight) + // Standard Error: 700_000 + .saturating_add((363_114_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1233,9 +1231,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_address(r: u32, ) -> Weight { - (131_212_000 as Weight) - // Standard Error: 116_000 - .saturating_add((230_568_000 as Weight).saturating_mul(r as Weight)) + (342_353_000 as Weight) + // Standard Error: 466_000 + .saturating_add((359_040_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1244,9 +1242,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas_left(r: u32, ) -> Weight { - (135_149_000 as Weight) - // Standard Error: 149_000 - .saturating_add((224_830_000 as Weight).saturating_mul(r as Weight)) + (309_341_000 as Weight) + // Standard Error: 523_000 + .saturating_add((355_882_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1255,9 +1253,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_balance(r: u32, ) -> Weight { - (148_463_000 as Weight) - // Standard Error: 246_000 - .saturating_add((480_930_000 as Weight).saturating_mul(r as Weight)) + (395_512_000 as Weight) + // Standard Error: 736_000 + .saturating_add((617_968_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1266,9 +1264,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_value_transferred(r: u32, ) -> Weight { - (137_790_000 as Weight) - // Standard Error: 152_000 - .saturating_add((224_961_000 as Weight).saturating_mul(r as Weight)) + (350_418_000 as Weight) + // Standard Error: 427_000 + .saturating_add((351_889_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1277,9 +1275,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_minimum_balance(r: u32, ) -> Weight { - (134_238_000 as Weight) - // Standard Error: 135_000 - .saturating_add((224_433_000 as Weight).saturating_mul(r as Weight)) + (316_760_000 as Weight) + // Standard Error: 638_000 + .saturating_add((354_662_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1288,9 +1286,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_tombstone_deposit(r: u32, ) -> Weight { - (135_053_000 as Weight) - // Standard Error: 147_000 - .saturating_add((223_955_000 as Weight).saturating_mul(r as Weight)) + (336_168_000 as Weight) + // Standard Error: 807_000 + .saturating_add((353_711_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1299,9 +1297,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_rent_allowance(r: u32, ) -> Weight { - (138_522_000 as Weight) - // Standard Error: 145_000 - .saturating_add((223_459_000 as Weight).saturating_mul(r as Weight)) + (332_985_000 as Weight) + // Standard Error: 1_350_000 + .saturating_add((354_808_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1310,9 +1308,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_block_number(r: u32, ) -> Weight { - (133_568_000 as Weight) - // Standard Error: 143_000 - .saturating_add((224_792_000 as Weight).saturating_mul(r as Weight)) + (340_298_000 as Weight) + // Standard Error: 377_000 + .saturating_add((355_811_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1321,9 +1319,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_now(r: u32, ) -> Weight { - (134_786_000 as Weight) - // Standard Error: 130_000 - .saturating_add((224_331_000 as Weight).saturating_mul(r as Weight)) + (345_811_000 as Weight) + // Standard Error: 391_000 + .saturating_add((352_175_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1333,9 +1331,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) fn seal_weight_to_fee(r: u32, ) -> Weight { - (147_402_000 as Weight) - // Standard Error: 233_000 - .saturating_add((439_237_000 as Weight).saturating_mul(r as Weight)) + (350_136_000 as Weight) + // Standard Error: 605_000 + .saturating_add((553_639_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1344,9 +1342,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas(r: u32, ) -> Weight { - (115_711_000 as Weight) - // Standard Error: 88_000 - .saturating_add((113_467_000 as Weight).saturating_mul(r as Weight)) + (313_206_000 as Weight) + // Standard Error: 446_000 + .saturating_add((194_676_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1354,10 +1352,8 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:1 w:0) // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) - fn seal_input(r: u32, ) -> Weight { - (123_004_000 as Weight) - // Standard Error: 78_000 - .saturating_add((6_674_000 as Weight).saturating_mul(r as Weight)) + fn seal_input(_r: u32, ) -> Weight { + (266_886_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1366,9 +1362,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_input_per_kb(n: u32, ) -> Weight { - (131_611_000 as Weight) - // Standard Error: 0 - .saturating_add((1_035_000 as Weight).saturating_mul(n as Weight)) + (280_666_000 as Weight) + // Standard Error: 2_000 + .saturating_add((1_091_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1377,9 +1373,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return(r: u32, ) -> Weight { - (118_327_000 as Weight) - // Standard Error: 84_000 - .saturating_add((4_274_000 as Weight).saturating_mul(r as Weight)) + (246_709_000 as Weight) + // Standard Error: 3_895_000 + .saturating_add((39_082_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1388,9 +1384,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return_per_kb(n: u32, ) -> Weight { - (126_129_000 as Weight) - // Standard Error: 0 - .saturating_add((495_000 as Weight).saturating_mul(n as Weight)) + (288_633_000 as Weight) + // Standard Error: 2_000 + .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1400,9 +1396,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts DeletionQueue (r:1 w:1) fn seal_terminate(r: u32, ) -> Weight { - (123_759_000 as Weight) - // Standard Error: 115_000 - .saturating_add((89_730_000 as Weight).saturating_mul(r as Weight)) + (258_057_000 as Weight) + // Standard Error: 1_614_000 + .saturating_add((139_230_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1414,9 +1410,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743af3fd4cc2fc8d170b6d] (r:1 w:0) fn seal_restore_to(r: u32, ) -> Weight { - (151_364_000 as Weight) - // Standard Error: 263_000 - .saturating_add((99_367_000 as Weight).saturating_mul(r as Weight)) + (311_627_000 as Weight) + // Standard Error: 1_602_000 + .saturating_add((133_583_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1424,9 +1420,9 @@ impl WeightInfo for () { } // Storage: Skipped Metadata (r:0 w:0) fn seal_restore_to_per_delta(d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_919_000 - .saturating_add((2_415_482_000 as Weight).saturating_mul(d as Weight)) + (293_186_000 as Weight) + // Standard Error: 1_931_000 + .saturating_add((2_475_203_000 as Weight).saturating_mul(d as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(d as Weight))) .saturating_add(RocksDbWeight::get().writes(7 as Weight)) @@ -1438,9 +1434,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) fn seal_random(r: u32, ) -> Weight { - (137_660_000 as Weight) - // Standard Error: 204_000 - .saturating_add((563_042_000 as Weight).saturating_mul(r as Weight)) + (367_617_000 as Weight) + // Standard Error: 706_000 + .saturating_add((728_941_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1449,9 +1445,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_deposit_event(r: u32, ) -> Weight { - (137_087_000 as Weight) - // Standard Error: 413_000 - .saturating_add((835_499_000 as Weight).saturating_mul(r as Weight)) + (378_232_000 as Weight) + // Standard Error: 810_000 + .saturating_add((983_125_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1461,11 +1457,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: System EventTopics (r:100 w:100) fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (1_117_515_000 as Weight) - // Standard Error: 2_167_000 - .saturating_add((494_145_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 427_000 - .saturating_add((150_093_000 as Weight).saturating_mul(n as Weight)) + (1_528_485_000 as Weight) + // Standard Error: 3_632_000 + .saturating_add((542_754_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 715_000 + .saturating_add((158_018_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(t as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1476,9 +1472,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_set_rent_allowance(r: u32, ) -> Weight { - (132_070_000 as Weight) - // Standard Error: 129_000 - .saturating_add((155_669_000 as Weight).saturating_mul(r as Weight)) + (308_772_000 as Weight) + // Standard Error: 445_000 + .saturating_add((263_979_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1487,17 +1483,17 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_debug_message(r: u32, ) -> Weight { - (126_971_000 as Weight) - // Standard Error: 90_000 - .saturating_add((122_445_000 as Weight).saturating_mul(r as Weight)) + (288_794_000 as Weight) + // Standard Error: 531_000 + .saturating_add((222_581_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_set_storage(r: u32, ) -> Weight { - (125_746_000 as Weight) - // Standard Error: 610_000 - .saturating_add((501_265_000 as Weight).saturating_mul(r as Weight)) + (396_150_000 as Weight) + // Standard Error: 705_000 + .saturating_add((625_327_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1509,17 +1505,17 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:1) fn seal_set_storage_per_kb(n: u32, ) -> Weight { - (563_219_000 as Weight) - // Standard Error: 219_000 - .saturating_add((41_578_000 as Weight).saturating_mul(n as Weight)) + (903_526_000 as Weight) + // Standard Error: 699_000 + .saturating_add((46_708_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_clear_storage(r: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_727_000 - .saturating_add((1_001_461_000 as Weight).saturating_mul(r as Weight)) + (174_034_000 as Weight) + // Standard Error: 1_770_000 + .saturating_add((1_140_377_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1527,9 +1523,9 @@ impl WeightInfo for () { } // Storage: Skipped Metadata (r:0 w:0) fn seal_get_storage(r: u32, ) -> Weight { - (9_115_000 as Weight) - // Standard Error: 784_000 - .saturating_add((660_533_000 as Weight).saturating_mul(r as Weight)) + (254_586_000 as Weight) + // Standard Error: 613_000 + .saturating_add((841_011_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1540,9 +1536,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:0) fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (563_175_000 as Weight) - // Standard Error: 206_000 - .saturating_add((89_626_000 as Weight).saturating_mul(n as Weight)) + (928_899_000 as Weight) + // Standard Error: 801_000 + .saturating_add((96_065_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1551,9 +1547,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_transfer(r: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_750_000 - .saturating_add((4_820_493_000 as Weight).saturating_mul(r as Weight)) + (268_870_000 as Weight) + // Standard Error: 1_651_000 + .saturating_add((5_223_725_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) @@ -1565,8 +1561,8 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) fn seal_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 6_692_000 - .saturating_add((11_477_937_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 24_770_000 + .saturating_add((19_541_686_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((200 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1577,13 +1573,13 @@ impl WeightInfo for () { // Storage: System Account (r:101 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_call_per_transfer_input_output_kb(t: u32, i: u32, o: u32, ) -> Weight { - (11_238_437_000 as Weight) - // Standard Error: 81_620_000 - .saturating_add((3_700_413_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 29_000 - .saturating_add((32_106_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 31_000 - .saturating_add((54_386_000 as Weight).saturating_mul(o as Weight)) + (28_665_061_000 as Weight) + // Standard Error: 289_240_000 + .saturating_add((3_479_153_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 103_000 + .saturating_add((39_897_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 110_000 + .saturating_add((66_181_000 as Weight).saturating_mul(o as Weight)) .saturating_add(RocksDbWeight::get().reads(205 as Weight)) .saturating_add(RocksDbWeight::get().writes(101 as Weight)) .saturating_add(RocksDbWeight::get().writes((101 as Weight).saturating_mul(t as Weight))) @@ -1595,8 +1591,8 @@ impl WeightInfo for () { // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 35_258_000 - .saturating_add((20_674_357_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 38_420_000 + .saturating_add((30_459_849_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((300 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) @@ -1608,13 +1604,13 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate_per_input_output_salt_kb(i: u32, o: u32, s: u32, ) -> Weight { - (14_725_288_000 as Weight) - // Standard Error: 53_000 - .saturating_add((33_848_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 53_000 - .saturating_add((57_054_000 as Weight).saturating_mul(o as Weight)) - // Standard Error: 53_000 - .saturating_add((180_033_000 as Weight).saturating_mul(s as Weight)) + (21_687_643_000 as Weight) + // Standard Error: 131_000 + .saturating_add((45_430_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 131_000 + .saturating_add((72_656_000 as Weight).saturating_mul(o as Weight)) + // Standard Error: 131_000 + .saturating_add((197_556_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(206 as Weight)) .saturating_add(RocksDbWeight::get().writes(204 as Weight)) } @@ -1623,9 +1619,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256(r: u32, ) -> Weight { - (131_974_000 as Weight) - // Standard Error: 125_000 - .saturating_add((220_711_000 as Weight).saturating_mul(r as Weight)) + (329_994_000 as Weight) + // Standard Error: 469_000 + .saturating_add((324_178_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1634,9 +1630,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (367_148_000 as Weight) - // Standard Error: 12_000 - .saturating_add((462_143_000 as Weight).saturating_mul(n as Weight)) + (687_111_000 as Weight) + // Standard Error: 37_000 + .saturating_add((472_129_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1645,9 +1641,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256(r: u32, ) -> Weight { - (134_585_000 as Weight) - // Standard Error: 131_000 - .saturating_add((227_264_000 as Weight).saturating_mul(r as Weight)) + (298_723_000 as Weight) + // Standard Error: 463_000 + .saturating_add((336_842_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1656,9 +1652,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (325_319_000 as Weight) - // Standard Error: 12_000 - .saturating_add((313_033_000 as Weight).saturating_mul(n as Weight)) + (628_474_000 as Weight) + // Standard Error: 30_000 + .saturating_add((320_036_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1667,9 +1663,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256(r: u32, ) -> Weight { - (135_347_000 as Weight) - // Standard Error: 150_000 - .saturating_add((199_764_000 as Weight).saturating_mul(r as Weight)) + (281_202_000 as Weight) + // Standard Error: 557_000 + .saturating_add((308_068_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1678,9 +1674,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (424_473_000 as Weight) - // Standard Error: 13_000 - .saturating_add((130_936_000 as Weight).saturating_mul(n as Weight)) + (749_425_000 as Weight) + // Standard Error: 27_000 + .saturating_add((136_471_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1689,9 +1685,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128(r: u32, ) -> Weight { - (128_776_000 as Weight) - // Standard Error: 118_000 - .saturating_add((203_125_000 as Weight).saturating_mul(r as Weight)) + (343_669_000 as Weight) + // Standard Error: 761_000 + .saturating_add((312_147_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1700,265 +1696,265 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (445_726_000 as Weight) - // Standard Error: 14_000 - .saturating_add((130_931_000 as Weight).saturating_mul(n as Weight)) + (714_529_000 as Weight) + // Standard Error: 25_000 + .saturating_add((136_454_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn instr_i64const(r: u32, ) -> Weight { - (22_161_000 as Weight) - // Standard Error: 36_000 - .saturating_add((3_329_000 as Weight).saturating_mul(r as Weight)) + (5_749_000 as Weight) + // Standard Error: 41_000 + .saturating_add((399_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64load(r: u32, ) -> Weight { - (24_430_000 as Weight) - // Standard Error: 65_000 - .saturating_add((159_566_000 as Weight).saturating_mul(r as Weight)) + (9_666_000 as Weight) + // Standard Error: 83_000 + .saturating_add((134_313_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64store(r: u32, ) -> Weight { - (24_443_000 as Weight) - // Standard Error: 62_000 - .saturating_add((232_854_000 as Weight).saturating_mul(r as Weight)) + (10_188_000 as Weight) + // Standard Error: 167_000 + .saturating_add((207_638_000 as Weight).saturating_mul(r as Weight)) } fn instr_select(r: u32, ) -> Weight { - (22_158_000 as Weight) - // Standard Error: 34_000 - .saturating_add((12_112_000 as Weight).saturating_mul(r as Weight)) + (5_735_000 as Weight) + // Standard Error: 44_000 + .saturating_add((5_642_000 as Weight).saturating_mul(r as Weight)) } fn instr_if(r: u32, ) -> Weight { - (22_178_000 as Weight) - // Standard Error: 23_000 - .saturating_add((11_374_000 as Weight).saturating_mul(r as Weight)) + (5_727_000 as Weight) + // Standard Error: 39_000 + .saturating_add((5_688_000 as Weight).saturating_mul(r as Weight)) } fn instr_br(r: u32, ) -> Weight { - (22_157_000 as Weight) - // Standard Error: 41_000 - .saturating_add((5_826_000 as Weight).saturating_mul(r as Weight)) + (5_701_000 as Weight) + // Standard Error: 14_000 + .saturating_add((3_601_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_if(r: u32, ) -> Weight { - (22_182_000 as Weight) - // Standard Error: 34_000 - .saturating_add((13_647_000 as Weight).saturating_mul(r as Weight)) + (5_775_000 as Weight) + // Standard Error: 36_000 + .saturating_add((5_045_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table(r: u32, ) -> Weight { - (22_083_000 as Weight) - // Standard Error: 44_000 - .saturating_add((14_901_000 as Weight).saturating_mul(r as Weight)) + (5_649_000 as Weight) + // Standard Error: 42_000 + .saturating_add((12_551_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table_per_entry(e: u32, ) -> Weight { - (32_689_000 as Weight) - // Standard Error: 1_000 - .saturating_add((154_000 as Weight).saturating_mul(e as Weight)) + (18_118_000 as Weight) + // Standard Error: 0 + .saturating_add((90_000 as Weight).saturating_mul(e as Weight)) } fn instr_call(r: u32, ) -> Weight { - (22_313_000 as Weight) - // Standard Error: 383_000 - .saturating_add((89_804_000 as Weight).saturating_mul(r as Weight)) + (6_359_000 as Weight) + // Standard Error: 68_000 + .saturating_add((20_800_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect(r: u32, ) -> Weight { - (29_939_000 as Weight) - // Standard Error: 230_000 - .saturating_add((185_309_000 as Weight).saturating_mul(r as Weight)) + (7_708_000 as Weight) + // Standard Error: 143_000 + .saturating_add((20_016_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (221_596_000 as Weight) - // Standard Error: 3_000 - .saturating_add((4_045_000 as Weight).saturating_mul(p as Weight)) + (16_341_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_777_000 as Weight).saturating_mul(p as Weight)) } fn instr_local_get(r: u32, ) -> Weight { - (22_171_000 as Weight) - // Standard Error: 28_000 - .saturating_add((3_362_000 as Weight).saturating_mul(r as Weight)) + (5_888_000 as Weight) + // Standard Error: 37_000 + .saturating_add((425_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_set(r: u32, ) -> Weight { - (22_182_000 as Weight) - // Standard Error: 31_000 - .saturating_add((3_801_000 as Weight).saturating_mul(r as Weight)) + (6_081_000 as Weight) + // Standard Error: 98_000 + .saturating_add((556_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_tee(r: u32, ) -> Weight { - (22_200_000 as Weight) - // Standard Error: 27_000 - .saturating_add((5_080_000 as Weight).saturating_mul(r as Weight)) + (5_950_000 as Weight) + // Standard Error: 117_000 + .saturating_add((1_339_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_get(r: u32, ) -> Weight { - (25_255_000 as Weight) - // Standard Error: 41_000 - .saturating_add((8_875_000 as Weight).saturating_mul(r as Weight)) + (17_229_000 as Weight) + // Standard Error: 28_000 + .saturating_add((580_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_set(r: u32, ) -> Weight { - (25_145_000 as Weight) - // Standard Error: 37_000 - .saturating_add((9_556_000 as Weight).saturating_mul(r as Weight)) + (17_064_000 as Weight) + // Standard Error: 49_000 + .saturating_add((1_131_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_current(r: u32, ) -> Weight { - (24_435_000 as Weight) - // Standard Error: 49_000 - .saturating_add((4_204_000 as Weight).saturating_mul(r as Weight)) + (9_947_000 as Weight) + // Standard Error: 40_000 + .saturating_add((14_603_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_grow(r: u32, ) -> Weight { - (23_158_000 as Weight) - // Standard Error: 5_969_000 - .saturating_add((2_339_630_000 as Weight).saturating_mul(r as Weight)) + (9_976_000 as Weight) + // Standard Error: 54_000 + .saturating_add((6_458_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64clz(r: u32, ) -> Weight { - (21_984_000 as Weight) - // Standard Error: 25_000 - .saturating_add((5_421_000 as Weight).saturating_mul(r as Weight)) + (5_794_000 as Weight) + // Standard Error: 34_000 + .saturating_add((4_712_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ctz(r: u32, ) -> Weight { - (22_069_000 as Weight) - // Standard Error: 26_000 - .saturating_add((5_187_000 as Weight).saturating_mul(r as Weight)) + (5_755_000 as Weight) + // Standard Error: 33_000 + .saturating_add((4_638_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64popcnt(r: u32, ) -> Weight { - (22_042_000 as Weight) - // Standard Error: 28_000 - .saturating_add((6_116_000 as Weight).saturating_mul(r as Weight)) + (5_957_000 as Weight) + // Standard Error: 101_000 + .saturating_add((1_278_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eqz(r: u32, ) -> Weight { - (22_018_000 as Weight) - // Standard Error: 34_000 - .saturating_add((5_130_000 as Weight).saturating_mul(r as Weight)) + (5_780_000 as Weight) + // Standard Error: 36_000 + .saturating_add((2_257_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendsi32(r: u32, ) -> Weight { - (21_933_000 as Weight) - // Standard Error: 29_000 - .saturating_add((5_005_000 as Weight).saturating_mul(r as Weight)) + (5_733_000 as Weight) + // Standard Error: 107_000 + .saturating_add((1_527_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendui32(r: u32, ) -> Weight { - (22_066_000 as Weight) - // Standard Error: 34_000 - .saturating_add((4_877_000 as Weight).saturating_mul(r as Weight)) + (5_860_000 as Weight) + // Standard Error: 36_000 + .saturating_add((1_610_000 as Weight).saturating_mul(r as Weight)) } fn instr_i32wrapi64(r: u32, ) -> Weight { - (22_003_000 as Weight) + (5_765_000 as Weight) // Standard Error: 25_000 - .saturating_add((5_018_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_429_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eq(r: u32, ) -> Weight { - (22_130_000 as Weight) - // Standard Error: 35_000 - .saturating_add((7_071_000 as Weight).saturating_mul(r as Weight)) + (5_734_000 as Weight) + // Standard Error: 36_000 + .saturating_add((2_506_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ne(r: u32, ) -> Weight { - (22_112_000 as Weight) - // Standard Error: 24_000 - .saturating_add((7_056_000 as Weight).saturating_mul(r as Weight)) + (5_746_000 as Weight) + // Standard Error: 29_000 + .saturating_add((2_345_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64lts(r: u32, ) -> Weight { - (22_114_000 as Weight) + (5_763_000 as Weight) // Standard Error: 27_000 - .saturating_add((6_974_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((2_347_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ltu(r: u32, ) -> Weight { - (22_111_000 as Weight) - // Standard Error: 32_000 - .saturating_add((7_183_000 as Weight).saturating_mul(r as Weight)) + (5_689_000 as Weight) + // Standard Error: 42_000 + .saturating_add((2_583_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gts(r: u32, ) -> Weight { - (22_148_000 as Weight) - // Standard Error: 28_000 - .saturating_add((7_044_000 as Weight).saturating_mul(r as Weight)) + (6_062_000 as Weight) + // Standard Error: 59_000 + .saturating_add((2_066_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gtu(r: u32, ) -> Weight { - (22_158_000 as Weight) - // Standard Error: 33_000 - .saturating_add((7_116_000 as Weight).saturating_mul(r as Weight)) + (5_717_000 as Weight) + // Standard Error: 31_000 + .saturating_add((2_425_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64les(r: u32, ) -> Weight { - (22_194_000 as Weight) - // Standard Error: 31_000 - .saturating_add((7_039_000 as Weight).saturating_mul(r as Weight)) + (5_868_000 as Weight) + // Standard Error: 41_000 + .saturating_add((2_089_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64leu(r: u32, ) -> Weight { - (22_219_000 as Weight) - // Standard Error: 23_000 - .saturating_add((7_076_000 as Weight).saturating_mul(r as Weight)) + (6_130_000 as Weight) + // Standard Error: 86_000 + .saturating_add((1_922_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ges(r: u32, ) -> Weight { - (22_170_000 as Weight) - // Standard Error: 50_000 - .saturating_add((7_122_000 as Weight).saturating_mul(r as Weight)) + (5_719_000 as Weight) + // Standard Error: 41_000 + .saturating_add((2_393_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64geu(r: u32, ) -> Weight { - (22_113_000 as Weight) - // Standard Error: 27_000 - .saturating_add((7_069_000 as Weight).saturating_mul(r as Weight)) + (5_751_000 as Weight) + // Standard Error: 42_000 + .saturating_add((2_554_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64add(r: u32, ) -> Weight { - (22_090_000 as Weight) - // Standard Error: 29_000 - .saturating_add((6_956_000 as Weight).saturating_mul(r as Weight)) + (5_698_000 as Weight) + // Standard Error: 22_000 + .saturating_add((2_259_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64sub(r: u32, ) -> Weight { - (22_006_000 as Weight) - // Standard Error: 30_000 - .saturating_add((7_094_000 as Weight).saturating_mul(r as Weight)) + (5_905_000 as Weight) + // Standard Error: 50_000 + .saturating_add((1_311_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64mul(r: u32, ) -> Weight { - (22_111_000 as Weight) - // Standard Error: 29_000 - .saturating_add((6_825_000 as Weight).saturating_mul(r as Weight)) + (5_667_000 as Weight) + // Standard Error: 33_000 + .saturating_add((2_465_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divs(r: u32, ) -> Weight { - (22_041_000 as Weight) - // Standard Error: 29_000 - .saturating_add((13_164_000 as Weight).saturating_mul(r as Weight)) + (5_664_000 as Weight) + // Standard Error: 31_000 + .saturating_add((8_475_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divu(r: u32, ) -> Weight { - (21_989_000 as Weight) - // Standard Error: 28_000 - .saturating_add((12_808_000 as Weight).saturating_mul(r as Weight)) + (6_258_000 as Weight) + // Standard Error: 124_000 + .saturating_add((6_918_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rems(r: u32, ) -> Weight { - (22_045_000 as Weight) - // Standard Error: 39_000 - .saturating_add((13_387_000 as Weight).saturating_mul(r as Weight)) + (5_717_000 as Weight) + // Standard Error: 49_000 + .saturating_add((13_956_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64remu(r: u32, ) -> Weight { - (22_075_000 as Weight) - // Standard Error: 40_000 - .saturating_add((12_791_000 as Weight).saturating_mul(r as Weight)) + (5_713_000 as Weight) + // Standard Error: 14_000 + .saturating_add((7_458_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64and(r: u32, ) -> Weight { - (22_044_000 as Weight) - // Standard Error: 32_000 - .saturating_add((7_090_000 as Weight).saturating_mul(r as Weight)) + (5_751_000 as Weight) + // Standard Error: 28_000 + .saturating_add((2_310_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64or(r: u32, ) -> Weight { - (22_133_000 as Weight) - // Standard Error: 40_000 - .saturating_add((6_967_000 as Weight).saturating_mul(r as Weight)) + (5_806_000 as Weight) + // Standard Error: 38_000 + .saturating_add((2_032_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64xor(r: u32, ) -> Weight { - (22_069_000 as Weight) + (5_877_000 as Weight) // Standard Error: 41_000 - .saturating_add((7_026_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((2_036_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shl(r: u32, ) -> Weight { - (22_165_000 as Weight) - // Standard Error: 44_000 - .saturating_add((7_440_000 as Weight).saturating_mul(r as Weight)) + (5_789_000 as Weight) + // Standard Error: 25_000 + .saturating_add((1_984_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shrs(r: u32, ) -> Weight { - (22_063_000 as Weight) - // Standard Error: 34_000 - .saturating_add((7_309_000 as Weight).saturating_mul(r as Weight)) + (5_885_000 as Weight) + // Standard Error: 23_000 + .saturating_add((1_905_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shru(r: u32, ) -> Weight { - (22_086_000 as Weight) - // Standard Error: 36_000 - .saturating_add((7_188_000 as Weight).saturating_mul(r as Weight)) + (5_865_000 as Weight) + // Standard Error: 22_000 + .saturating_add((1_967_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotl(r: u32, ) -> Weight { - (22_109_000 as Weight) - // Standard Error: 45_000 - .saturating_add((7_169_000 as Weight).saturating_mul(r as Weight)) + (5_696_000 as Weight) + // Standard Error: 37_000 + .saturating_add((2_107_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotr(r: u32, ) -> Weight { - (22_076_000 as Weight) - // Standard Error: 28_000 - .saturating_add((7_070_000 as Weight).saturating_mul(r as Weight)) + (5_914_000 as Weight) + // Standard Error: 56_000 + .saturating_add((885_000 as Weight).saturating_mul(r as Weight)) } } From 2de979333caa79bd9ea843916b0760c17d512098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 16 Aug 2021 10:15:12 +0200 Subject: [PATCH 84/88] Revert "cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_contracts --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/contracts/src/weights.rs --template=./.maintain/frame-weight-template.hbs" This reverts commit d713590ba45387c4204b2ad97c8bd6f6ebabda4e. --- frame/contracts/src/weights.rs | 1230 ++++++++++++++++---------------- 1 file changed, 617 insertions(+), 613 deletions(-) diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 1cba71db46939..cffdb6ca9f006 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-08-09, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-08-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -155,46 +155,46 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize() -> Weight { - (3_323_000 as Weight) + (3_175_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn on_initialize_per_trie_key(k: u32, ) -> Weight { (0 as Weight) // Standard Error: 3_000 - .saturating_add((2_350_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((2_201_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (158_387_000 as Weight) - // Standard Error: 39_000 - .saturating_add((39_461_000 as Weight).saturating_mul(q as Weight)) + (66_035_000 as Weight) + // Standard Error: 6_000 + .saturating_add((38_159_000 as Weight).saturating_mul(q as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Contracts PristineCode (r:1 w:0) // Storage: Contracts CodeStorage (r:0 w:1) fn instrument(c: u32, ) -> Weight { - (33_203_000 as Weight) + (35_007_000 as Weight) // Standard Error: 110_000 - .saturating_add((76_504_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((75_739_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:0) fn code_load(c: u32, ) -> Weight { - (6_741_000 as Weight) + (6_238_000 as Weight) // Standard Error: 0 - .saturating_add((1_669_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((1_671_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:1) fn code_refcount(c: u32, ) -> Weight { - (10_937_000 as Weight) - // Standard Error: 1_000 + (10_080_000 as Weight) + // Standard Error: 0 .saturating_add((2_694_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -206,11 +206,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (558_616_000 as Weight) - // Standard Error: 294_000 - .saturating_add((381_602_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 19_000 - .saturating_add((2_309_000 as Weight).saturating_mul(s as Weight)) + (182_161_000 as Weight) + // Standard Error: 115_000 + .saturating_add((113_515_000 as Weight).saturating_mul(c as Weight)) + // Standard Error: 7_000 + .saturating_add((2_314_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -220,9 +220,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn instantiate(s: u32, ) -> Weight { - (276_361_000 as Weight) - // Standard Error: 3_000 - .saturating_add((2_296_000 as Weight).saturating_mul(s as Weight)) + (183_914_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_224_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -231,7 +231,7 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn call() -> Weight { - (275_359_000 as Weight) + (166_507_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -305,9 +305,9 @@ impl WeightInfo for SubstrateWeight { // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743aeb9db1dfeed3a7b47b] (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743abdc9db5edf43ffcb0d] (r:1 w:0) fn claim_surcharge(c: u32, ) -> Weight { - (135_558_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_860_000 as Weight).saturating_mul(c as Weight)) + (126_115_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_829_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -316,9 +316,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_caller(r: u32, ) -> Weight { - (270_209_000 as Weight) - // Standard Error: 700_000 - .saturating_add((363_114_000 as Weight).saturating_mul(r as Weight)) + (134_110_000 as Weight) + // Standard Error: 130_000 + .saturating_add((230_337_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -327,9 +327,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_address(r: u32, ) -> Weight { - (342_353_000 as Weight) - // Standard Error: 466_000 - .saturating_add((359_040_000 as Weight).saturating_mul(r as Weight)) + (131_212_000 as Weight) + // Standard Error: 116_000 + .saturating_add((230_568_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -338,9 +338,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas_left(r: u32, ) -> Weight { - (309_341_000 as Weight) - // Standard Error: 523_000 - .saturating_add((355_882_000 as Weight).saturating_mul(r as Weight)) + (135_149_000 as Weight) + // Standard Error: 149_000 + .saturating_add((224_830_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -349,9 +349,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_balance(r: u32, ) -> Weight { - (395_512_000 as Weight) - // Standard Error: 736_000 - .saturating_add((617_968_000 as Weight).saturating_mul(r as Weight)) + (148_463_000 as Weight) + // Standard Error: 246_000 + .saturating_add((480_930_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -360,9 +360,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_value_transferred(r: u32, ) -> Weight { - (350_418_000 as Weight) - // Standard Error: 427_000 - .saturating_add((351_889_000 as Weight).saturating_mul(r as Weight)) + (137_790_000 as Weight) + // Standard Error: 152_000 + .saturating_add((224_961_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -371,9 +371,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_minimum_balance(r: u32, ) -> Weight { - (316_760_000 as Weight) - // Standard Error: 638_000 - .saturating_add((354_662_000 as Weight).saturating_mul(r as Weight)) + (134_238_000 as Weight) + // Standard Error: 135_000 + .saturating_add((224_433_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -382,9 +382,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_tombstone_deposit(r: u32, ) -> Weight { - (336_168_000 as Weight) - // Standard Error: 807_000 - .saturating_add((353_711_000 as Weight).saturating_mul(r as Weight)) + (135_053_000 as Weight) + // Standard Error: 147_000 + .saturating_add((223_955_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -393,9 +393,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_rent_allowance(r: u32, ) -> Weight { - (332_985_000 as Weight) - // Standard Error: 1_350_000 - .saturating_add((354_808_000 as Weight).saturating_mul(r as Weight)) + (138_522_000 as Weight) + // Standard Error: 145_000 + .saturating_add((223_459_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -404,9 +404,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_block_number(r: u32, ) -> Weight { - (340_298_000 as Weight) - // Standard Error: 377_000 - .saturating_add((355_811_000 as Weight).saturating_mul(r as Weight)) + (133_568_000 as Weight) + // Standard Error: 143_000 + .saturating_add((224_792_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -415,9 +415,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_now(r: u32, ) -> Weight { - (345_811_000 as Weight) - // Standard Error: 391_000 - .saturating_add((352_175_000 as Weight).saturating_mul(r as Weight)) + (134_786_000 as Weight) + // Standard Error: 130_000 + .saturating_add((224_331_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -427,9 +427,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) fn seal_weight_to_fee(r: u32, ) -> Weight { - (350_136_000 as Weight) - // Standard Error: 605_000 - .saturating_add((553_639_000 as Weight).saturating_mul(r as Weight)) + (147_402_000 as Weight) + // Standard Error: 233_000 + .saturating_add((439_237_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -438,9 +438,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas(r: u32, ) -> Weight { - (313_206_000 as Weight) - // Standard Error: 446_000 - .saturating_add((194_676_000 as Weight).saturating_mul(r as Weight)) + (115_711_000 as Weight) + // Standard Error: 88_000 + .saturating_add((113_467_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -448,8 +448,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:1 w:0) // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) - fn seal_input(_r: u32, ) -> Weight { - (266_886_000 as Weight) + fn seal_input(r: u32, ) -> Weight { + (123_004_000 as Weight) + // Standard Error: 78_000 + .saturating_add((6_674_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -458,9 +460,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_input_per_kb(n: u32, ) -> Weight { - (280_666_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_091_000 as Weight).saturating_mul(n as Weight)) + (131_611_000 as Weight) + // Standard Error: 0 + .saturating_add((1_035_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -469,9 +471,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return(r: u32, ) -> Weight { - (246_709_000 as Weight) - // Standard Error: 3_895_000 - .saturating_add((39_082_000 as Weight).saturating_mul(r as Weight)) + (118_327_000 as Weight) + // Standard Error: 84_000 + .saturating_add((4_274_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -480,9 +482,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return_per_kb(n: u32, ) -> Weight { - (288_633_000 as Weight) - // Standard Error: 2_000 - .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) + (126_129_000 as Weight) + // Standard Error: 0 + .saturating_add((495_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -492,9 +494,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts DeletionQueue (r:1 w:1) fn seal_terminate(r: u32, ) -> Weight { - (258_057_000 as Weight) - // Standard Error: 1_614_000 - .saturating_add((139_230_000 as Weight).saturating_mul(r as Weight)) + (123_759_000 as Weight) + // Standard Error: 115_000 + .saturating_add((89_730_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -506,9 +508,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743af3fd4cc2fc8d170b6d] (r:1 w:0) fn seal_restore_to(r: u32, ) -> Weight { - (311_627_000 as Weight) - // Standard Error: 1_602_000 - .saturating_add((133_583_000 as Weight).saturating_mul(r as Weight)) + (151_364_000 as Weight) + // Standard Error: 263_000 + .saturating_add((99_367_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -516,9 +518,9 @@ impl WeightInfo for SubstrateWeight { } // Storage: Skipped Metadata (r:0 w:0) fn seal_restore_to_per_delta(d: u32, ) -> Weight { - (293_186_000 as Weight) - // Standard Error: 1_931_000 - .saturating_add((2_475_203_000 as Weight).saturating_mul(d as Weight)) + (0 as Weight) + // Standard Error: 1_919_000 + .saturating_add((2_415_482_000 as Weight).saturating_mul(d as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(d as Weight))) .saturating_add(T::DbWeight::get().writes(7 as Weight)) @@ -530,9 +532,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) fn seal_random(r: u32, ) -> Weight { - (367_617_000 as Weight) - // Standard Error: 706_000 - .saturating_add((728_941_000 as Weight).saturating_mul(r as Weight)) + (137_660_000 as Weight) + // Standard Error: 204_000 + .saturating_add((563_042_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -541,9 +543,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_deposit_event(r: u32, ) -> Weight { - (378_232_000 as Weight) - // Standard Error: 810_000 - .saturating_add((983_125_000 as Weight).saturating_mul(r as Weight)) + (137_087_000 as Weight) + // Standard Error: 413_000 + .saturating_add((835_499_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -553,11 +555,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: System EventTopics (r:100 w:100) fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (1_528_485_000 as Weight) - // Standard Error: 3_632_000 - .saturating_add((542_754_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 715_000 - .saturating_add((158_018_000 as Weight).saturating_mul(n as Weight)) + (1_117_515_000 as Weight) + // Standard Error: 2_167_000 + .saturating_add((494_145_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 427_000 + .saturating_add((150_093_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(t as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -568,9 +570,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_set_rent_allowance(r: u32, ) -> Weight { - (308_772_000 as Weight) - // Standard Error: 445_000 - .saturating_add((263_979_000 as Weight).saturating_mul(r as Weight)) + (132_070_000 as Weight) + // Standard Error: 129_000 + .saturating_add((155_669_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -579,17 +581,17 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_debug_message(r: u32, ) -> Weight { - (288_794_000 as Weight) - // Standard Error: 531_000 - .saturating_add((222_581_000 as Weight).saturating_mul(r as Weight)) + (126_971_000 as Weight) + // Standard Error: 90_000 + .saturating_add((122_445_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_set_storage(r: u32, ) -> Weight { - (396_150_000 as Weight) - // Standard Error: 705_000 - .saturating_add((625_327_000 as Weight).saturating_mul(r as Weight)) + (125_746_000 as Weight) + // Standard Error: 610_000 + .saturating_add((501_265_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -601,17 +603,17 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:1) fn seal_set_storage_per_kb(n: u32, ) -> Weight { - (903_526_000 as Weight) - // Standard Error: 699_000 - .saturating_add((46_708_000 as Weight).saturating_mul(n as Weight)) + (563_219_000 as Weight) + // Standard Error: 219_000 + .saturating_add((41_578_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_clear_storage(r: u32, ) -> Weight { - (174_034_000 as Weight) - // Standard Error: 1_770_000 - .saturating_add((1_140_377_000 as Weight).saturating_mul(r as Weight)) + (0 as Weight) + // Standard Error: 1_727_000 + .saturating_add((1_001_461_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -619,9 +621,9 @@ impl WeightInfo for SubstrateWeight { } // Storage: Skipped Metadata (r:0 w:0) fn seal_get_storage(r: u32, ) -> Weight { - (254_586_000 as Weight) - // Standard Error: 613_000 - .saturating_add((841_011_000 as Weight).saturating_mul(r as Weight)) + (9_115_000 as Weight) + // Standard Error: 784_000 + .saturating_add((660_533_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -632,9 +634,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:0) fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (928_899_000 as Weight) - // Standard Error: 801_000 - .saturating_add((96_065_000 as Weight).saturating_mul(n as Weight)) + (563_175_000 as Weight) + // Standard Error: 206_000 + .saturating_add((89_626_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -643,9 +645,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_transfer(r: u32, ) -> Weight { - (268_870_000 as Weight) - // Standard Error: 1_651_000 - .saturating_add((5_223_725_000 as Weight).saturating_mul(r as Weight)) + (0 as Weight) + // Standard Error: 1_750_000 + .saturating_add((4_820_493_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -657,8 +659,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) fn seal_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 24_770_000 - .saturating_add((19_541_686_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 6_692_000 + .saturating_add((11_477_937_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((200 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -669,13 +671,13 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:101 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_call_per_transfer_input_output_kb(t: u32, i: u32, o: u32, ) -> Weight { - (28_665_061_000 as Weight) - // Standard Error: 289_240_000 - .saturating_add((3_479_153_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 103_000 - .saturating_add((39_897_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 110_000 - .saturating_add((66_181_000 as Weight).saturating_mul(o as Weight)) + (11_238_437_000 as Weight) + // Standard Error: 81_620_000 + .saturating_add((3_700_413_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 29_000 + .saturating_add((32_106_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 31_000 + .saturating_add((54_386_000 as Weight).saturating_mul(o as Weight)) .saturating_add(T::DbWeight::get().reads(205 as Weight)) .saturating_add(T::DbWeight::get().writes(101 as Weight)) .saturating_add(T::DbWeight::get().writes((101 as Weight).saturating_mul(t as Weight))) @@ -687,8 +689,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 38_420_000 - .saturating_add((30_459_849_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 35_258_000 + .saturating_add((20_674_357_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((300 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) @@ -700,13 +702,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate_per_input_output_salt_kb(i: u32, o: u32, s: u32, ) -> Weight { - (21_687_643_000 as Weight) - // Standard Error: 131_000 - .saturating_add((45_430_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 131_000 - .saturating_add((72_656_000 as Weight).saturating_mul(o as Weight)) - // Standard Error: 131_000 - .saturating_add((197_556_000 as Weight).saturating_mul(s as Weight)) + (14_725_288_000 as Weight) + // Standard Error: 53_000 + .saturating_add((33_848_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 53_000 + .saturating_add((57_054_000 as Weight).saturating_mul(o as Weight)) + // Standard Error: 53_000 + .saturating_add((180_033_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(206 as Weight)) .saturating_add(T::DbWeight::get().writes(204 as Weight)) } @@ -715,9 +717,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256(r: u32, ) -> Weight { - (329_994_000 as Weight) - // Standard Error: 469_000 - .saturating_add((324_178_000 as Weight).saturating_mul(r as Weight)) + (131_974_000 as Weight) + // Standard Error: 125_000 + .saturating_add((220_711_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -726,9 +728,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (687_111_000 as Weight) - // Standard Error: 37_000 - .saturating_add((472_129_000 as Weight).saturating_mul(n as Weight)) + (367_148_000 as Weight) + // Standard Error: 12_000 + .saturating_add((462_143_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -737,9 +739,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256(r: u32, ) -> Weight { - (298_723_000 as Weight) - // Standard Error: 463_000 - .saturating_add((336_842_000 as Weight).saturating_mul(r as Weight)) + (134_585_000 as Weight) + // Standard Error: 131_000 + .saturating_add((227_264_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -748,9 +750,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (628_474_000 as Weight) - // Standard Error: 30_000 - .saturating_add((320_036_000 as Weight).saturating_mul(n as Weight)) + (325_319_000 as Weight) + // Standard Error: 12_000 + .saturating_add((313_033_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -759,9 +761,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256(r: u32, ) -> Weight { - (281_202_000 as Weight) - // Standard Error: 557_000 - .saturating_add((308_068_000 as Weight).saturating_mul(r as Weight)) + (135_347_000 as Weight) + // Standard Error: 150_000 + .saturating_add((199_764_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -770,9 +772,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (749_425_000 as Weight) - // Standard Error: 27_000 - .saturating_add((136_471_000 as Weight).saturating_mul(n as Weight)) + (424_473_000 as Weight) + // Standard Error: 13_000 + .saturating_add((130_936_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -781,9 +783,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128(r: u32, ) -> Weight { - (343_669_000 as Weight) - // Standard Error: 761_000 - .saturating_add((312_147_000 as Weight).saturating_mul(r as Weight)) + (128_776_000 as Weight) + // Standard Error: 118_000 + .saturating_add((203_125_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -792,266 +794,266 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (714_529_000 as Weight) - // Standard Error: 25_000 - .saturating_add((136_454_000 as Weight).saturating_mul(n as Weight)) + (445_726_000 as Weight) + // Standard Error: 14_000 + .saturating_add((130_931_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn instr_i64const(r: u32, ) -> Weight { - (5_749_000 as Weight) - // Standard Error: 41_000 - .saturating_add((399_000 as Weight).saturating_mul(r as Weight)) + (22_161_000 as Weight) + // Standard Error: 36_000 + .saturating_add((3_329_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64load(r: u32, ) -> Weight { - (9_666_000 as Weight) - // Standard Error: 83_000 - .saturating_add((134_313_000 as Weight).saturating_mul(r as Weight)) + (24_430_000 as Weight) + // Standard Error: 65_000 + .saturating_add((159_566_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64store(r: u32, ) -> Weight { - (10_188_000 as Weight) - // Standard Error: 167_000 - .saturating_add((207_638_000 as Weight).saturating_mul(r as Weight)) + (24_443_000 as Weight) + // Standard Error: 62_000 + .saturating_add((232_854_000 as Weight).saturating_mul(r as Weight)) } fn instr_select(r: u32, ) -> Weight { - (5_735_000 as Weight) - // Standard Error: 44_000 - .saturating_add((5_642_000 as Weight).saturating_mul(r as Weight)) + (22_158_000 as Weight) + // Standard Error: 34_000 + .saturating_add((12_112_000 as Weight).saturating_mul(r as Weight)) } fn instr_if(r: u32, ) -> Weight { - (5_727_000 as Weight) - // Standard Error: 39_000 - .saturating_add((5_688_000 as Weight).saturating_mul(r as Weight)) + (22_178_000 as Weight) + // Standard Error: 23_000 + .saturating_add((11_374_000 as Weight).saturating_mul(r as Weight)) } fn instr_br(r: u32, ) -> Weight { - (5_701_000 as Weight) - // Standard Error: 14_000 - .saturating_add((3_601_000 as Weight).saturating_mul(r as Weight)) + (22_157_000 as Weight) + // Standard Error: 41_000 + .saturating_add((5_826_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_if(r: u32, ) -> Weight { - (5_775_000 as Weight) - // Standard Error: 36_000 - .saturating_add((5_045_000 as Weight).saturating_mul(r as Weight)) + (22_182_000 as Weight) + // Standard Error: 34_000 + .saturating_add((13_647_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table(r: u32, ) -> Weight { - (5_649_000 as Weight) - // Standard Error: 42_000 - .saturating_add((12_551_000 as Weight).saturating_mul(r as Weight)) + (22_083_000 as Weight) + // Standard Error: 44_000 + .saturating_add((14_901_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table_per_entry(e: u32, ) -> Weight { - (18_118_000 as Weight) - // Standard Error: 0 - .saturating_add((90_000 as Weight).saturating_mul(e as Weight)) + (32_689_000 as Weight) + // Standard Error: 1_000 + .saturating_add((154_000 as Weight).saturating_mul(e as Weight)) } fn instr_call(r: u32, ) -> Weight { - (6_359_000 as Weight) - // Standard Error: 68_000 - .saturating_add((20_800_000 as Weight).saturating_mul(r as Weight)) + (22_313_000 as Weight) + // Standard Error: 383_000 + .saturating_add((89_804_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect(r: u32, ) -> Weight { - (7_708_000 as Weight) - // Standard Error: 143_000 - .saturating_add((20_016_000 as Weight).saturating_mul(r as Weight)) + (29_939_000 as Weight) + // Standard Error: 230_000 + .saturating_add((185_309_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (16_341_000 as Weight) - // Standard Error: 4_000 - .saturating_add((1_777_000 as Weight).saturating_mul(p as Weight)) + (221_596_000 as Weight) + // Standard Error: 3_000 + .saturating_add((4_045_000 as Weight).saturating_mul(p as Weight)) } fn instr_local_get(r: u32, ) -> Weight { - (5_888_000 as Weight) - // Standard Error: 37_000 - .saturating_add((425_000 as Weight).saturating_mul(r as Weight)) + (22_171_000 as Weight) + // Standard Error: 28_000 + .saturating_add((3_362_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_set(r: u32, ) -> Weight { - (6_081_000 as Weight) - // Standard Error: 98_000 - .saturating_add((556_000 as Weight).saturating_mul(r as Weight)) + (22_182_000 as Weight) + // Standard Error: 31_000 + .saturating_add((3_801_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_tee(r: u32, ) -> Weight { - (5_950_000 as Weight) - // Standard Error: 117_000 - .saturating_add((1_339_000 as Weight).saturating_mul(r as Weight)) + (22_200_000 as Weight) + // Standard Error: 27_000 + .saturating_add((5_080_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_get(r: u32, ) -> Weight { - (17_229_000 as Weight) - // Standard Error: 28_000 - .saturating_add((580_000 as Weight).saturating_mul(r as Weight)) + (25_255_000 as Weight) + // Standard Error: 41_000 + .saturating_add((8_875_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_set(r: u32, ) -> Weight { - (17_064_000 as Weight) - // Standard Error: 49_000 - .saturating_add((1_131_000 as Weight).saturating_mul(r as Weight)) + (25_145_000 as Weight) + // Standard Error: 37_000 + .saturating_add((9_556_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_current(r: u32, ) -> Weight { - (9_947_000 as Weight) - // Standard Error: 40_000 - .saturating_add((14_603_000 as Weight).saturating_mul(r as Weight)) + (24_435_000 as Weight) + // Standard Error: 49_000 + .saturating_add((4_204_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_grow(r: u32, ) -> Weight { - (9_976_000 as Weight) - // Standard Error: 54_000 - .saturating_add((6_458_000 as Weight).saturating_mul(r as Weight)) + (23_158_000 as Weight) + // Standard Error: 5_969_000 + .saturating_add((2_339_630_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64clz(r: u32, ) -> Weight { - (5_794_000 as Weight) - // Standard Error: 34_000 - .saturating_add((4_712_000 as Weight).saturating_mul(r as Weight)) + (21_984_000 as Weight) + // Standard Error: 25_000 + .saturating_add((5_421_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ctz(r: u32, ) -> Weight { - (5_755_000 as Weight) - // Standard Error: 33_000 - .saturating_add((4_638_000 as Weight).saturating_mul(r as Weight)) + (22_069_000 as Weight) + // Standard Error: 26_000 + .saturating_add((5_187_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64popcnt(r: u32, ) -> Weight { - (5_957_000 as Weight) - // Standard Error: 101_000 - .saturating_add((1_278_000 as Weight).saturating_mul(r as Weight)) + (22_042_000 as Weight) + // Standard Error: 28_000 + .saturating_add((6_116_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eqz(r: u32, ) -> Weight { - (5_780_000 as Weight) - // Standard Error: 36_000 - .saturating_add((2_257_000 as Weight).saturating_mul(r as Weight)) + (22_018_000 as Weight) + // Standard Error: 34_000 + .saturating_add((5_130_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendsi32(r: u32, ) -> Weight { - (5_733_000 as Weight) - // Standard Error: 107_000 - .saturating_add((1_527_000 as Weight).saturating_mul(r as Weight)) + (21_933_000 as Weight) + // Standard Error: 29_000 + .saturating_add((5_005_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendui32(r: u32, ) -> Weight { - (5_860_000 as Weight) - // Standard Error: 36_000 - .saturating_add((1_610_000 as Weight).saturating_mul(r as Weight)) + (22_066_000 as Weight) + // Standard Error: 34_000 + .saturating_add((4_877_000 as Weight).saturating_mul(r as Weight)) } fn instr_i32wrapi64(r: u32, ) -> Weight { - (5_765_000 as Weight) + (22_003_000 as Weight) // Standard Error: 25_000 - .saturating_add((1_429_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((5_018_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eq(r: u32, ) -> Weight { - (5_734_000 as Weight) - // Standard Error: 36_000 - .saturating_add((2_506_000 as Weight).saturating_mul(r as Weight)) + (22_130_000 as Weight) + // Standard Error: 35_000 + .saturating_add((7_071_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ne(r: u32, ) -> Weight { - (5_746_000 as Weight) - // Standard Error: 29_000 - .saturating_add((2_345_000 as Weight).saturating_mul(r as Weight)) + (22_112_000 as Weight) + // Standard Error: 24_000 + .saturating_add((7_056_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64lts(r: u32, ) -> Weight { - (5_763_000 as Weight) + (22_114_000 as Weight) // Standard Error: 27_000 - .saturating_add((2_347_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((6_974_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ltu(r: u32, ) -> Weight { - (5_689_000 as Weight) - // Standard Error: 42_000 - .saturating_add((2_583_000 as Weight).saturating_mul(r as Weight)) + (22_111_000 as Weight) + // Standard Error: 32_000 + .saturating_add((7_183_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gts(r: u32, ) -> Weight { - (6_062_000 as Weight) - // Standard Error: 59_000 - .saturating_add((2_066_000 as Weight).saturating_mul(r as Weight)) + (22_148_000 as Weight) + // Standard Error: 28_000 + .saturating_add((7_044_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gtu(r: u32, ) -> Weight { - (5_717_000 as Weight) - // Standard Error: 31_000 - .saturating_add((2_425_000 as Weight).saturating_mul(r as Weight)) + (22_158_000 as Weight) + // Standard Error: 33_000 + .saturating_add((7_116_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64les(r: u32, ) -> Weight { - (5_868_000 as Weight) - // Standard Error: 41_000 - .saturating_add((2_089_000 as Weight).saturating_mul(r as Weight)) + (22_194_000 as Weight) + // Standard Error: 31_000 + .saturating_add((7_039_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64leu(r: u32, ) -> Weight { - (6_130_000 as Weight) - // Standard Error: 86_000 - .saturating_add((1_922_000 as Weight).saturating_mul(r as Weight)) + (22_219_000 as Weight) + // Standard Error: 23_000 + .saturating_add((7_076_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ges(r: u32, ) -> Weight { - (5_719_000 as Weight) - // Standard Error: 41_000 - .saturating_add((2_393_000 as Weight).saturating_mul(r as Weight)) + (22_170_000 as Weight) + // Standard Error: 50_000 + .saturating_add((7_122_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64geu(r: u32, ) -> Weight { - (5_751_000 as Weight) - // Standard Error: 42_000 - .saturating_add((2_554_000 as Weight).saturating_mul(r as Weight)) + (22_113_000 as Weight) + // Standard Error: 27_000 + .saturating_add((7_069_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64add(r: u32, ) -> Weight { - (5_698_000 as Weight) - // Standard Error: 22_000 - .saturating_add((2_259_000 as Weight).saturating_mul(r as Weight)) + (22_090_000 as Weight) + // Standard Error: 29_000 + .saturating_add((6_956_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64sub(r: u32, ) -> Weight { - (5_905_000 as Weight) - // Standard Error: 50_000 - .saturating_add((1_311_000 as Weight).saturating_mul(r as Weight)) + (22_006_000 as Weight) + // Standard Error: 30_000 + .saturating_add((7_094_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64mul(r: u32, ) -> Weight { - (5_667_000 as Weight) - // Standard Error: 33_000 - .saturating_add((2_465_000 as Weight).saturating_mul(r as Weight)) + (22_111_000 as Weight) + // Standard Error: 29_000 + .saturating_add((6_825_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divs(r: u32, ) -> Weight { - (5_664_000 as Weight) - // Standard Error: 31_000 - .saturating_add((8_475_000 as Weight).saturating_mul(r as Weight)) + (22_041_000 as Weight) + // Standard Error: 29_000 + .saturating_add((13_164_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divu(r: u32, ) -> Weight { - (6_258_000 as Weight) - // Standard Error: 124_000 - .saturating_add((6_918_000 as Weight).saturating_mul(r as Weight)) + (21_989_000 as Weight) + // Standard Error: 28_000 + .saturating_add((12_808_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rems(r: u32, ) -> Weight { - (5_717_000 as Weight) - // Standard Error: 49_000 - .saturating_add((13_956_000 as Weight).saturating_mul(r as Weight)) + (22_045_000 as Weight) + // Standard Error: 39_000 + .saturating_add((13_387_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64remu(r: u32, ) -> Weight { - (5_713_000 as Weight) - // Standard Error: 14_000 - .saturating_add((7_458_000 as Weight).saturating_mul(r as Weight)) + (22_075_000 as Weight) + // Standard Error: 40_000 + .saturating_add((12_791_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64and(r: u32, ) -> Weight { - (5_751_000 as Weight) - // Standard Error: 28_000 - .saturating_add((2_310_000 as Weight).saturating_mul(r as Weight)) + (22_044_000 as Weight) + // Standard Error: 32_000 + .saturating_add((7_090_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64or(r: u32, ) -> Weight { - (5_806_000 as Weight) - // Standard Error: 38_000 - .saturating_add((2_032_000 as Weight).saturating_mul(r as Weight)) + (22_133_000 as Weight) + // Standard Error: 40_000 + .saturating_add((6_967_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64xor(r: u32, ) -> Weight { - (5_877_000 as Weight) + (22_069_000 as Weight) // Standard Error: 41_000 - .saturating_add((2_036_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((7_026_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shl(r: u32, ) -> Weight { - (5_789_000 as Weight) - // Standard Error: 25_000 - .saturating_add((1_984_000 as Weight).saturating_mul(r as Weight)) + (22_165_000 as Weight) + // Standard Error: 44_000 + .saturating_add((7_440_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shrs(r: u32, ) -> Weight { - (5_885_000 as Weight) - // Standard Error: 23_000 - .saturating_add((1_905_000 as Weight).saturating_mul(r as Weight)) + (22_063_000 as Weight) + // Standard Error: 34_000 + .saturating_add((7_309_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shru(r: u32, ) -> Weight { - (5_865_000 as Weight) - // Standard Error: 22_000 - .saturating_add((1_967_000 as Weight).saturating_mul(r as Weight)) + (22_086_000 as Weight) + // Standard Error: 36_000 + .saturating_add((7_188_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotl(r: u32, ) -> Weight { - (5_696_000 as Weight) - // Standard Error: 37_000 - .saturating_add((2_107_000 as Weight).saturating_mul(r as Weight)) + (22_109_000 as Weight) + // Standard Error: 45_000 + .saturating_add((7_169_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotr(r: u32, ) -> Weight { - (5_914_000 as Weight) - // Standard Error: 56_000 - .saturating_add((885_000 as Weight).saturating_mul(r as Weight)) + (22_076_000 as Weight) + // Standard Error: 28_000 + .saturating_add((7_070_000 as Weight).saturating_mul(r as Weight)) } } @@ -1059,46 +1061,46 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize() -> Weight { - (3_323_000 as Weight) + (3_175_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn on_initialize_per_trie_key(k: u32, ) -> Weight { (0 as Weight) // Standard Error: 3_000 - .saturating_add((2_350_000 as Weight).saturating_mul(k as Weight)) + .saturating_add((2_201_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Contracts DeletionQueue (r:1 w:0) fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (158_387_000 as Weight) - // Standard Error: 39_000 - .saturating_add((39_461_000 as Weight).saturating_mul(q as Weight)) + (66_035_000 as Weight) + // Standard Error: 6_000 + .saturating_add((38_159_000 as Weight).saturating_mul(q as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Contracts PristineCode (r:1 w:0) // Storage: Contracts CodeStorage (r:0 w:1) fn instrument(c: u32, ) -> Weight { - (33_203_000 as Weight) + (35_007_000 as Weight) // Standard Error: 110_000 - .saturating_add((76_504_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((75_739_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:0) fn code_load(c: u32, ) -> Weight { - (6_741_000 as Weight) + (6_238_000 as Weight) // Standard Error: 0 - .saturating_add((1_669_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((1_671_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Contracts CodeStorage (r:1 w:1) fn code_refcount(c: u32, ) -> Weight { - (10_937_000 as Weight) - // Standard Error: 1_000 + (10_080_000 as Weight) + // Standard Error: 0 .saturating_add((2_694_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1110,11 +1112,11 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:1 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (558_616_000 as Weight) - // Standard Error: 294_000 - .saturating_add((381_602_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 19_000 - .saturating_add((2_309_000 as Weight).saturating_mul(s as Weight)) + (182_161_000 as Weight) + // Standard Error: 115_000 + .saturating_add((113_515_000 as Weight).saturating_mul(c as Weight)) + // Standard Error: 7_000 + .saturating_add((2_314_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -1124,9 +1126,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn instantiate(s: u32, ) -> Weight { - (276_361_000 as Weight) - // Standard Error: 3_000 - .saturating_add((2_296_000 as Weight).saturating_mul(s as Weight)) + (183_914_000 as Weight) + // Standard Error: 1_000 + .saturating_add((2_224_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -1135,7 +1137,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Timestamp Now (r:1 w:0) fn call() -> Weight { - (275_359_000 as Weight) + (166_507_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } @@ -1209,9 +1211,9 @@ impl WeightInfo for () { // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743aeb9db1dfeed3a7b47b] (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743abdc9db5edf43ffcb0d] (r:1 w:0) fn claim_surcharge(c: u32, ) -> Weight { - (135_558_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_860_000 as Weight).saturating_mul(c as Weight)) + (126_115_000 as Weight) + // Standard Error: 2_000 + .saturating_add((2_829_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -1220,9 +1222,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_caller(r: u32, ) -> Weight { - (270_209_000 as Weight) - // Standard Error: 700_000 - .saturating_add((363_114_000 as Weight).saturating_mul(r as Weight)) + (134_110_000 as Weight) + // Standard Error: 130_000 + .saturating_add((230_337_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1231,9 +1233,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_address(r: u32, ) -> Weight { - (342_353_000 as Weight) - // Standard Error: 466_000 - .saturating_add((359_040_000 as Weight).saturating_mul(r as Weight)) + (131_212_000 as Weight) + // Standard Error: 116_000 + .saturating_add((230_568_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1242,9 +1244,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas_left(r: u32, ) -> Weight { - (309_341_000 as Weight) - // Standard Error: 523_000 - .saturating_add((355_882_000 as Weight).saturating_mul(r as Weight)) + (135_149_000 as Weight) + // Standard Error: 149_000 + .saturating_add((224_830_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1253,9 +1255,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_balance(r: u32, ) -> Weight { - (395_512_000 as Weight) - // Standard Error: 736_000 - .saturating_add((617_968_000 as Weight).saturating_mul(r as Weight)) + (148_463_000 as Weight) + // Standard Error: 246_000 + .saturating_add((480_930_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1264,9 +1266,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_value_transferred(r: u32, ) -> Weight { - (350_418_000 as Weight) - // Standard Error: 427_000 - .saturating_add((351_889_000 as Weight).saturating_mul(r as Weight)) + (137_790_000 as Weight) + // Standard Error: 152_000 + .saturating_add((224_961_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1275,9 +1277,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_minimum_balance(r: u32, ) -> Weight { - (316_760_000 as Weight) - // Standard Error: 638_000 - .saturating_add((354_662_000 as Weight).saturating_mul(r as Weight)) + (134_238_000 as Weight) + // Standard Error: 135_000 + .saturating_add((224_433_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1286,9 +1288,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_tombstone_deposit(r: u32, ) -> Weight { - (336_168_000 as Weight) - // Standard Error: 807_000 - .saturating_add((353_711_000 as Weight).saturating_mul(r as Weight)) + (135_053_000 as Weight) + // Standard Error: 147_000 + .saturating_add((223_955_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1297,9 +1299,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_rent_allowance(r: u32, ) -> Weight { - (332_985_000 as Weight) - // Standard Error: 1_350_000 - .saturating_add((354_808_000 as Weight).saturating_mul(r as Weight)) + (138_522_000 as Weight) + // Standard Error: 145_000 + .saturating_add((223_459_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1308,9 +1310,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_block_number(r: u32, ) -> Weight { - (340_298_000 as Weight) - // Standard Error: 377_000 - .saturating_add((355_811_000 as Weight).saturating_mul(r as Weight)) + (133_568_000 as Weight) + // Standard Error: 143_000 + .saturating_add((224_792_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1319,9 +1321,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_now(r: u32, ) -> Weight { - (345_811_000 as Weight) - // Standard Error: 391_000 - .saturating_add((352_175_000 as Weight).saturating_mul(r as Weight)) + (134_786_000 as Weight) + // Standard Error: 130_000 + .saturating_add((224_331_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1331,9 +1333,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) fn seal_weight_to_fee(r: u32, ) -> Weight { - (350_136_000 as Weight) - // Standard Error: 605_000 - .saturating_add((553_639_000 as Weight).saturating_mul(r as Weight)) + (147_402_000 as Weight) + // Standard Error: 233_000 + .saturating_add((439_237_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1342,9 +1344,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_gas(r: u32, ) -> Weight { - (313_206_000 as Weight) - // Standard Error: 446_000 - .saturating_add((194_676_000 as Weight).saturating_mul(r as Weight)) + (115_711_000 as Weight) + // Standard Error: 88_000 + .saturating_add((113_467_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1352,8 +1354,10 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:1 w:0) // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) - fn seal_input(_r: u32, ) -> Weight { - (266_886_000 as Weight) + fn seal_input(r: u32, ) -> Weight { + (123_004_000 as Weight) + // Standard Error: 78_000 + .saturating_add((6_674_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1362,9 +1366,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_input_per_kb(n: u32, ) -> Weight { - (280_666_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_091_000 as Weight).saturating_mul(n as Weight)) + (131_611_000 as Weight) + // Standard Error: 0 + .saturating_add((1_035_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1373,9 +1377,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return(r: u32, ) -> Weight { - (246_709_000 as Weight) - // Standard Error: 3_895_000 - .saturating_add((39_082_000 as Weight).saturating_mul(r as Weight)) + (118_327_000 as Weight) + // Standard Error: 84_000 + .saturating_add((4_274_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1384,9 +1388,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_return_per_kb(n: u32, ) -> Weight { - (288_633_000 as Weight) - // Standard Error: 2_000 - .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) + (126_129_000 as Weight) + // Standard Error: 0 + .saturating_add((495_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1396,9 +1400,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts DeletionQueue (r:1 w:1) fn seal_terminate(r: u32, ) -> Weight { - (258_057_000 as Weight) - // Standard Error: 1_614_000 - .saturating_add((139_230_000 as Weight).saturating_mul(r as Weight)) + (123_759_000 as Weight) + // Standard Error: 115_000 + .saturating_add((89_730_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1410,9 +1414,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x3a6368696c645f73746f726167653a64656661756c743af3fd4cc2fc8d170b6d] (r:1 w:0) fn seal_restore_to(r: u32, ) -> Weight { - (311_627_000 as Weight) - // Standard Error: 1_602_000 - .saturating_add((133_583_000 as Weight).saturating_mul(r as Weight)) + (151_364_000 as Weight) + // Standard Error: 263_000 + .saturating_add((99_367_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1420,9 +1424,9 @@ impl WeightInfo for () { } // Storage: Skipped Metadata (r:0 w:0) fn seal_restore_to_per_delta(d: u32, ) -> Weight { - (293_186_000 as Weight) - // Standard Error: 1_931_000 - .saturating_add((2_475_203_000 as Weight).saturating_mul(d as Weight)) + (0 as Weight) + // Standard Error: 1_919_000 + .saturating_add((2_415_482_000 as Weight).saturating_mul(d as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(d as Weight))) .saturating_add(RocksDbWeight::get().writes(7 as Weight)) @@ -1434,9 +1438,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) fn seal_random(r: u32, ) -> Weight { - (367_617_000 as Weight) - // Standard Error: 706_000 - .saturating_add((728_941_000 as Weight).saturating_mul(r as Weight)) + (137_660_000 as Weight) + // Standard Error: 204_000 + .saturating_add((563_042_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1445,9 +1449,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_deposit_event(r: u32, ) -> Weight { - (378_232_000 as Weight) - // Standard Error: 810_000 - .saturating_add((983_125_000 as Weight).saturating_mul(r as Weight)) + (137_087_000 as Weight) + // Standard Error: 413_000 + .saturating_add((835_499_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1457,11 +1461,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: System EventTopics (r:100 w:100) fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (1_528_485_000 as Weight) - // Standard Error: 3_632_000 - .saturating_add((542_754_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 715_000 - .saturating_add((158_018_000 as Weight).saturating_mul(n as Weight)) + (1_117_515_000 as Weight) + // Standard Error: 2_167_000 + .saturating_add((494_145_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 427_000 + .saturating_add((150_093_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(t as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1472,9 +1476,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_set_rent_allowance(r: u32, ) -> Weight { - (308_772_000 as Weight) - // Standard Error: 445_000 - .saturating_add((263_979_000 as Weight).saturating_mul(r as Weight)) + (132_070_000 as Weight) + // Standard Error: 129_000 + .saturating_add((155_669_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1483,17 +1487,17 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_debug_message(r: u32, ) -> Weight { - (288_794_000 as Weight) - // Standard Error: 531_000 - .saturating_add((222_581_000 as Weight).saturating_mul(r as Weight)) + (126_971_000 as Weight) + // Standard Error: 90_000 + .saturating_add((122_445_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_set_storage(r: u32, ) -> Weight { - (396_150_000 as Weight) - // Standard Error: 705_000 - .saturating_add((625_327_000 as Weight).saturating_mul(r as Weight)) + (125_746_000 as Weight) + // Standard Error: 610_000 + .saturating_add((501_265_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1505,17 +1509,17 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:1) fn seal_set_storage_per_kb(n: u32, ) -> Weight { - (903_526_000 as Weight) - // Standard Error: 699_000 - .saturating_add((46_708_000 as Weight).saturating_mul(n as Weight)) + (563_219_000 as Weight) + // Standard Error: 219_000 + .saturating_add((41_578_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) fn seal_clear_storage(r: u32, ) -> Weight { - (174_034_000 as Weight) - // Standard Error: 1_770_000 - .saturating_add((1_140_377_000 as Weight).saturating_mul(r as Weight)) + (0 as Weight) + // Standard Error: 1_727_000 + .saturating_add((1_001_461_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1523,9 +1527,9 @@ impl WeightInfo for () { } // Storage: Skipped Metadata (r:0 w:0) fn seal_get_storage(r: u32, ) -> Weight { - (254_586_000 as Weight) - // Standard Error: 613_000 - .saturating_add((841_011_000 as Weight).saturating_mul(r as Weight)) + (9_115_000 as Weight) + // Standard Error: 784_000 + .saturating_add((660_533_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1536,9 +1540,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: unknown [0x7afa01283080ef247df84e0ba38ea5a587d25ce6633a6bfbba02068c14023441] (r:1 w:0) fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (928_899_000 as Weight) - // Standard Error: 801_000 - .saturating_add((96_065_000 as Weight).saturating_mul(n as Weight)) + (563_175_000 as Weight) + // Standard Error: 206_000 + .saturating_add((89_626_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1547,9 +1551,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_transfer(r: u32, ) -> Weight { - (268_870_000 as Weight) - // Standard Error: 1_651_000 - .saturating_add((5_223_725_000 as Weight).saturating_mul(r as Weight)) + (0 as Weight) + // Standard Error: 1_750_000 + .saturating_add((4_820_493_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((100 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) @@ -1561,8 +1565,8 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) fn seal_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 24_770_000 - .saturating_add((19_541_686_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 6_692_000 + .saturating_add((11_477_937_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((200 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1573,13 +1577,13 @@ impl WeightInfo for () { // Storage: System Account (r:101 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_call_per_transfer_input_output_kb(t: u32, i: u32, o: u32, ) -> Weight { - (28_665_061_000 as Weight) - // Standard Error: 289_240_000 - .saturating_add((3_479_153_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 103_000 - .saturating_add((39_897_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 110_000 - .saturating_add((66_181_000 as Weight).saturating_mul(o as Weight)) + (11_238_437_000 as Weight) + // Standard Error: 81_620_000 + .saturating_add((3_700_413_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 29_000 + .saturating_add((32_106_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 31_000 + .saturating_add((54_386_000 as Weight).saturating_mul(o as Weight)) .saturating_add(RocksDbWeight::get().reads(205 as Weight)) .saturating_add(RocksDbWeight::get().writes(101 as Weight)) .saturating_add(RocksDbWeight::get().writes((101 as Weight).saturating_mul(t as Weight))) @@ -1591,8 +1595,8 @@ impl WeightInfo for () { // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 38_420_000 - .saturating_add((30_459_849_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 35_258_000 + .saturating_add((20_674_357_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((300 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) @@ -1604,13 +1608,13 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: Contracts AccountCounter (r:1 w:1) fn seal_instantiate_per_input_output_salt_kb(i: u32, o: u32, s: u32, ) -> Weight { - (21_687_643_000 as Weight) - // Standard Error: 131_000 - .saturating_add((45_430_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 131_000 - .saturating_add((72_656_000 as Weight).saturating_mul(o as Weight)) - // Standard Error: 131_000 - .saturating_add((197_556_000 as Weight).saturating_mul(s as Weight)) + (14_725_288_000 as Weight) + // Standard Error: 53_000 + .saturating_add((33_848_000 as Weight).saturating_mul(i as Weight)) + // Standard Error: 53_000 + .saturating_add((57_054_000 as Weight).saturating_mul(o as Weight)) + // Standard Error: 53_000 + .saturating_add((180_033_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(206 as Weight)) .saturating_add(RocksDbWeight::get().writes(204 as Weight)) } @@ -1619,9 +1623,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256(r: u32, ) -> Weight { - (329_994_000 as Weight) - // Standard Error: 469_000 - .saturating_add((324_178_000 as Weight).saturating_mul(r as Weight)) + (131_974_000 as Weight) + // Standard Error: 125_000 + .saturating_add((220_711_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1630,9 +1634,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (687_111_000 as Weight) - // Standard Error: 37_000 - .saturating_add((472_129_000 as Weight).saturating_mul(n as Weight)) + (367_148_000 as Weight) + // Standard Error: 12_000 + .saturating_add((462_143_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1641,9 +1645,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256(r: u32, ) -> Weight { - (298_723_000 as Weight) - // Standard Error: 463_000 - .saturating_add((336_842_000 as Weight).saturating_mul(r as Weight)) + (134_585_000 as Weight) + // Standard Error: 131_000 + .saturating_add((227_264_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1652,9 +1656,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (628_474_000 as Weight) - // Standard Error: 30_000 - .saturating_add((320_036_000 as Weight).saturating_mul(n as Weight)) + (325_319_000 as Weight) + // Standard Error: 12_000 + .saturating_add((313_033_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1663,9 +1667,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256(r: u32, ) -> Weight { - (281_202_000 as Weight) - // Standard Error: 557_000 - .saturating_add((308_068_000 as Weight).saturating_mul(r as Weight)) + (135_347_000 as Weight) + // Standard Error: 150_000 + .saturating_add((199_764_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1674,9 +1678,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (749_425_000 as Weight) - // Standard Error: 27_000 - .saturating_add((136_471_000 as Weight).saturating_mul(n as Weight)) + (424_473_000 as Weight) + // Standard Error: 13_000 + .saturating_add((130_936_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1685,9 +1689,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128(r: u32, ) -> Weight { - (343_669_000 as Weight) - // Standard Error: 761_000 - .saturating_add((312_147_000 as Weight).saturating_mul(r as Weight)) + (128_776_000 as Weight) + // Standard Error: 118_000 + .saturating_add((203_125_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1696,265 +1700,265 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (714_529_000 as Weight) - // Standard Error: 25_000 - .saturating_add((136_454_000 as Weight).saturating_mul(n as Weight)) + (445_726_000 as Weight) + // Standard Error: 14_000 + .saturating_add((130_931_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn instr_i64const(r: u32, ) -> Weight { - (5_749_000 as Weight) - // Standard Error: 41_000 - .saturating_add((399_000 as Weight).saturating_mul(r as Weight)) + (22_161_000 as Weight) + // Standard Error: 36_000 + .saturating_add((3_329_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64load(r: u32, ) -> Weight { - (9_666_000 as Weight) - // Standard Error: 83_000 - .saturating_add((134_313_000 as Weight).saturating_mul(r as Weight)) + (24_430_000 as Weight) + // Standard Error: 65_000 + .saturating_add((159_566_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64store(r: u32, ) -> Weight { - (10_188_000 as Weight) - // Standard Error: 167_000 - .saturating_add((207_638_000 as Weight).saturating_mul(r as Weight)) + (24_443_000 as Weight) + // Standard Error: 62_000 + .saturating_add((232_854_000 as Weight).saturating_mul(r as Weight)) } fn instr_select(r: u32, ) -> Weight { - (5_735_000 as Weight) - // Standard Error: 44_000 - .saturating_add((5_642_000 as Weight).saturating_mul(r as Weight)) + (22_158_000 as Weight) + // Standard Error: 34_000 + .saturating_add((12_112_000 as Weight).saturating_mul(r as Weight)) } fn instr_if(r: u32, ) -> Weight { - (5_727_000 as Weight) - // Standard Error: 39_000 - .saturating_add((5_688_000 as Weight).saturating_mul(r as Weight)) + (22_178_000 as Weight) + // Standard Error: 23_000 + .saturating_add((11_374_000 as Weight).saturating_mul(r as Weight)) } fn instr_br(r: u32, ) -> Weight { - (5_701_000 as Weight) - // Standard Error: 14_000 - .saturating_add((3_601_000 as Weight).saturating_mul(r as Weight)) + (22_157_000 as Weight) + // Standard Error: 41_000 + .saturating_add((5_826_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_if(r: u32, ) -> Weight { - (5_775_000 as Weight) - // Standard Error: 36_000 - .saturating_add((5_045_000 as Weight).saturating_mul(r as Weight)) + (22_182_000 as Weight) + // Standard Error: 34_000 + .saturating_add((13_647_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table(r: u32, ) -> Weight { - (5_649_000 as Weight) - // Standard Error: 42_000 - .saturating_add((12_551_000 as Weight).saturating_mul(r as Weight)) + (22_083_000 as Weight) + // Standard Error: 44_000 + .saturating_add((14_901_000 as Weight).saturating_mul(r as Weight)) } fn instr_br_table_per_entry(e: u32, ) -> Weight { - (18_118_000 as Weight) - // Standard Error: 0 - .saturating_add((90_000 as Weight).saturating_mul(e as Weight)) + (32_689_000 as Weight) + // Standard Error: 1_000 + .saturating_add((154_000 as Weight).saturating_mul(e as Weight)) } fn instr_call(r: u32, ) -> Weight { - (6_359_000 as Weight) - // Standard Error: 68_000 - .saturating_add((20_800_000 as Weight).saturating_mul(r as Weight)) + (22_313_000 as Weight) + // Standard Error: 383_000 + .saturating_add((89_804_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect(r: u32, ) -> Weight { - (7_708_000 as Weight) - // Standard Error: 143_000 - .saturating_add((20_016_000 as Weight).saturating_mul(r as Weight)) + (29_939_000 as Weight) + // Standard Error: 230_000 + .saturating_add((185_309_000 as Weight).saturating_mul(r as Weight)) } fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (16_341_000 as Weight) - // Standard Error: 4_000 - .saturating_add((1_777_000 as Weight).saturating_mul(p as Weight)) + (221_596_000 as Weight) + // Standard Error: 3_000 + .saturating_add((4_045_000 as Weight).saturating_mul(p as Weight)) } fn instr_local_get(r: u32, ) -> Weight { - (5_888_000 as Weight) - // Standard Error: 37_000 - .saturating_add((425_000 as Weight).saturating_mul(r as Weight)) + (22_171_000 as Weight) + // Standard Error: 28_000 + .saturating_add((3_362_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_set(r: u32, ) -> Weight { - (6_081_000 as Weight) - // Standard Error: 98_000 - .saturating_add((556_000 as Weight).saturating_mul(r as Weight)) + (22_182_000 as Weight) + // Standard Error: 31_000 + .saturating_add((3_801_000 as Weight).saturating_mul(r as Weight)) } fn instr_local_tee(r: u32, ) -> Weight { - (5_950_000 as Weight) - // Standard Error: 117_000 - .saturating_add((1_339_000 as Weight).saturating_mul(r as Weight)) + (22_200_000 as Weight) + // Standard Error: 27_000 + .saturating_add((5_080_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_get(r: u32, ) -> Weight { - (17_229_000 as Weight) - // Standard Error: 28_000 - .saturating_add((580_000 as Weight).saturating_mul(r as Weight)) + (25_255_000 as Weight) + // Standard Error: 41_000 + .saturating_add((8_875_000 as Weight).saturating_mul(r as Weight)) } fn instr_global_set(r: u32, ) -> Weight { - (17_064_000 as Weight) - // Standard Error: 49_000 - .saturating_add((1_131_000 as Weight).saturating_mul(r as Weight)) + (25_145_000 as Weight) + // Standard Error: 37_000 + .saturating_add((9_556_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_current(r: u32, ) -> Weight { - (9_947_000 as Weight) - // Standard Error: 40_000 - .saturating_add((14_603_000 as Weight).saturating_mul(r as Weight)) + (24_435_000 as Weight) + // Standard Error: 49_000 + .saturating_add((4_204_000 as Weight).saturating_mul(r as Weight)) } fn instr_memory_grow(r: u32, ) -> Weight { - (9_976_000 as Weight) - // Standard Error: 54_000 - .saturating_add((6_458_000 as Weight).saturating_mul(r as Weight)) + (23_158_000 as Weight) + // Standard Error: 5_969_000 + .saturating_add((2_339_630_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64clz(r: u32, ) -> Weight { - (5_794_000 as Weight) - // Standard Error: 34_000 - .saturating_add((4_712_000 as Weight).saturating_mul(r as Weight)) + (21_984_000 as Weight) + // Standard Error: 25_000 + .saturating_add((5_421_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ctz(r: u32, ) -> Weight { - (5_755_000 as Weight) - // Standard Error: 33_000 - .saturating_add((4_638_000 as Weight).saturating_mul(r as Weight)) + (22_069_000 as Weight) + // Standard Error: 26_000 + .saturating_add((5_187_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64popcnt(r: u32, ) -> Weight { - (5_957_000 as Weight) - // Standard Error: 101_000 - .saturating_add((1_278_000 as Weight).saturating_mul(r as Weight)) + (22_042_000 as Weight) + // Standard Error: 28_000 + .saturating_add((6_116_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eqz(r: u32, ) -> Weight { - (5_780_000 as Weight) - // Standard Error: 36_000 - .saturating_add((2_257_000 as Weight).saturating_mul(r as Weight)) + (22_018_000 as Weight) + // Standard Error: 34_000 + .saturating_add((5_130_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendsi32(r: u32, ) -> Weight { - (5_733_000 as Weight) - // Standard Error: 107_000 - .saturating_add((1_527_000 as Weight).saturating_mul(r as Weight)) + (21_933_000 as Weight) + // Standard Error: 29_000 + .saturating_add((5_005_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64extendui32(r: u32, ) -> Weight { - (5_860_000 as Weight) - // Standard Error: 36_000 - .saturating_add((1_610_000 as Weight).saturating_mul(r as Weight)) + (22_066_000 as Weight) + // Standard Error: 34_000 + .saturating_add((4_877_000 as Weight).saturating_mul(r as Weight)) } fn instr_i32wrapi64(r: u32, ) -> Weight { - (5_765_000 as Weight) + (22_003_000 as Weight) // Standard Error: 25_000 - .saturating_add((1_429_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((5_018_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64eq(r: u32, ) -> Weight { - (5_734_000 as Weight) - // Standard Error: 36_000 - .saturating_add((2_506_000 as Weight).saturating_mul(r as Weight)) + (22_130_000 as Weight) + // Standard Error: 35_000 + .saturating_add((7_071_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ne(r: u32, ) -> Weight { - (5_746_000 as Weight) - // Standard Error: 29_000 - .saturating_add((2_345_000 as Weight).saturating_mul(r as Weight)) + (22_112_000 as Weight) + // Standard Error: 24_000 + .saturating_add((7_056_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64lts(r: u32, ) -> Weight { - (5_763_000 as Weight) + (22_114_000 as Weight) // Standard Error: 27_000 - .saturating_add((2_347_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((6_974_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ltu(r: u32, ) -> Weight { - (5_689_000 as Weight) - // Standard Error: 42_000 - .saturating_add((2_583_000 as Weight).saturating_mul(r as Weight)) + (22_111_000 as Weight) + // Standard Error: 32_000 + .saturating_add((7_183_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gts(r: u32, ) -> Weight { - (6_062_000 as Weight) - // Standard Error: 59_000 - .saturating_add((2_066_000 as Weight).saturating_mul(r as Weight)) + (22_148_000 as Weight) + // Standard Error: 28_000 + .saturating_add((7_044_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64gtu(r: u32, ) -> Weight { - (5_717_000 as Weight) - // Standard Error: 31_000 - .saturating_add((2_425_000 as Weight).saturating_mul(r as Weight)) + (22_158_000 as Weight) + // Standard Error: 33_000 + .saturating_add((7_116_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64les(r: u32, ) -> Weight { - (5_868_000 as Weight) - // Standard Error: 41_000 - .saturating_add((2_089_000 as Weight).saturating_mul(r as Weight)) + (22_194_000 as Weight) + // Standard Error: 31_000 + .saturating_add((7_039_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64leu(r: u32, ) -> Weight { - (6_130_000 as Weight) - // Standard Error: 86_000 - .saturating_add((1_922_000 as Weight).saturating_mul(r as Weight)) + (22_219_000 as Weight) + // Standard Error: 23_000 + .saturating_add((7_076_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64ges(r: u32, ) -> Weight { - (5_719_000 as Weight) - // Standard Error: 41_000 - .saturating_add((2_393_000 as Weight).saturating_mul(r as Weight)) + (22_170_000 as Weight) + // Standard Error: 50_000 + .saturating_add((7_122_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64geu(r: u32, ) -> Weight { - (5_751_000 as Weight) - // Standard Error: 42_000 - .saturating_add((2_554_000 as Weight).saturating_mul(r as Weight)) + (22_113_000 as Weight) + // Standard Error: 27_000 + .saturating_add((7_069_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64add(r: u32, ) -> Weight { - (5_698_000 as Weight) - // Standard Error: 22_000 - .saturating_add((2_259_000 as Weight).saturating_mul(r as Weight)) + (22_090_000 as Weight) + // Standard Error: 29_000 + .saturating_add((6_956_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64sub(r: u32, ) -> Weight { - (5_905_000 as Weight) - // Standard Error: 50_000 - .saturating_add((1_311_000 as Weight).saturating_mul(r as Weight)) + (22_006_000 as Weight) + // Standard Error: 30_000 + .saturating_add((7_094_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64mul(r: u32, ) -> Weight { - (5_667_000 as Weight) - // Standard Error: 33_000 - .saturating_add((2_465_000 as Weight).saturating_mul(r as Weight)) + (22_111_000 as Weight) + // Standard Error: 29_000 + .saturating_add((6_825_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divs(r: u32, ) -> Weight { - (5_664_000 as Weight) - // Standard Error: 31_000 - .saturating_add((8_475_000 as Weight).saturating_mul(r as Weight)) + (22_041_000 as Weight) + // Standard Error: 29_000 + .saturating_add((13_164_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64divu(r: u32, ) -> Weight { - (6_258_000 as Weight) - // Standard Error: 124_000 - .saturating_add((6_918_000 as Weight).saturating_mul(r as Weight)) + (21_989_000 as Weight) + // Standard Error: 28_000 + .saturating_add((12_808_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rems(r: u32, ) -> Weight { - (5_717_000 as Weight) - // Standard Error: 49_000 - .saturating_add((13_956_000 as Weight).saturating_mul(r as Weight)) + (22_045_000 as Weight) + // Standard Error: 39_000 + .saturating_add((13_387_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64remu(r: u32, ) -> Weight { - (5_713_000 as Weight) - // Standard Error: 14_000 - .saturating_add((7_458_000 as Weight).saturating_mul(r as Weight)) + (22_075_000 as Weight) + // Standard Error: 40_000 + .saturating_add((12_791_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64and(r: u32, ) -> Weight { - (5_751_000 as Weight) - // Standard Error: 28_000 - .saturating_add((2_310_000 as Weight).saturating_mul(r as Weight)) + (22_044_000 as Weight) + // Standard Error: 32_000 + .saturating_add((7_090_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64or(r: u32, ) -> Weight { - (5_806_000 as Weight) - // Standard Error: 38_000 - .saturating_add((2_032_000 as Weight).saturating_mul(r as Weight)) + (22_133_000 as Weight) + // Standard Error: 40_000 + .saturating_add((6_967_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64xor(r: u32, ) -> Weight { - (5_877_000 as Weight) + (22_069_000 as Weight) // Standard Error: 41_000 - .saturating_add((2_036_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((7_026_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shl(r: u32, ) -> Weight { - (5_789_000 as Weight) - // Standard Error: 25_000 - .saturating_add((1_984_000 as Weight).saturating_mul(r as Weight)) + (22_165_000 as Weight) + // Standard Error: 44_000 + .saturating_add((7_440_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shrs(r: u32, ) -> Weight { - (5_885_000 as Weight) - // Standard Error: 23_000 - .saturating_add((1_905_000 as Weight).saturating_mul(r as Weight)) + (22_063_000 as Weight) + // Standard Error: 34_000 + .saturating_add((7_309_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64shru(r: u32, ) -> Weight { - (5_865_000 as Weight) - // Standard Error: 22_000 - .saturating_add((1_967_000 as Weight).saturating_mul(r as Weight)) + (22_086_000 as Weight) + // Standard Error: 36_000 + .saturating_add((7_188_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotl(r: u32, ) -> Weight { - (5_696_000 as Weight) - // Standard Error: 37_000 - .saturating_add((2_107_000 as Weight).saturating_mul(r as Weight)) + (22_109_000 as Weight) + // Standard Error: 45_000 + .saturating_add((7_169_000 as Weight).saturating_mul(r as Weight)) } fn instr_i64rotr(r: u32, ) -> Weight { - (5_914_000 as Weight) - // Standard Error: 56_000 - .saturating_add((885_000 as Weight).saturating_mul(r as Weight)) + (22_076_000 as Weight) + // Standard Error: 28_000 + .saturating_add((7_070_000 as Weight).saturating_mul(r as Weight)) } } From a9e251d6a84f2c6680783d321de9ad6dd2dc8bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 16 Aug 2021 10:15:43 +0200 Subject: [PATCH 85/88] cargo fmt --- client/executor/common/src/sandbox.rs | 15 ++++++++------- client/executor/common/src/util.rs | 13 ++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/client/executor/common/src/sandbox.rs b/client/executor/common/src/sandbox.rs index 75ac1d960860f..7a92e8e2bd292 100644 --- a/client/executor/common/src/sandbox.rs +++ b/client/executor/common/src/sandbox.rs @@ -177,9 +177,9 @@ pub trait SandboxCapabilities: FunctionContext { /// This first invokes the dispatch_thunk function, passing in the function index of the /// desired function to call and serialized arguments. The thunk calls the desired function /// with the deserialized arguments, then serializes the result into memory and returns - /// reference. The pointer to and length of the result in linear memory is encoded into an `i64`, - /// with the upper 32 bits representing the pointer and the lower 32 bits representing the - /// length. + /// reference. The pointer to and length of the result in linear memory is encoded into an + /// `i64`, with the upper 32 bits representing the pointer and the lower 32 bits representing + /// the length. /// /// # Errors /// @@ -895,9 +895,9 @@ impl Store { let sandbox_instance = DTH::with_dispatch_thunk(|dispatch_thunk| { Rc::new(SandboxInstance { - // In general, it's not a very good idea to use `.not_started_instance()` for anything - // but for extracting memory and tables. But in this particular case, we are extracting - // for the purpose of running `start` function which should be ok. + // In general, it's not a very good idea to use `.not_started_instance()` for + // anything but for extracting memory and tables. But in this particular case, we + // are extracting for the purpose of running `start` function which should be ok. backend_instance: BackendInstance::Wasmi( wasmi_instance.not_started_instance().clone(), ), @@ -916,7 +916,8 @@ impl Store { .run_start(guest_externals) .map_err(|_| InstantiationError::StartTrapped) - // Note: no need to run start on wasmtime instance, since it's done automatically + // Note: no need to run start on wasmtime instance, since it's done + // automatically }, ) })?; diff --git a/client/executor/common/src/util.rs b/client/executor/common/src/util.rs index f7be5da44edab..995424bfa8399 100644 --- a/client/executor/common/src/util.rs +++ b/client/executor/common/src/util.rs @@ -75,7 +75,6 @@ pub mod wasmi { /// access. By returning the memory object "as is" we bypass all of the checks. /// /// Intended to use only during module initialization. - /// pub unsafe fn clone_inner(&self) -> ::wasmi::MemoryRef { self.0.clone() } @@ -160,8 +159,8 @@ pub mod wasmer { /// # Safety /// /// See `[memory_as_slice]`. In addition to those requirements, since a mutable reference is - /// returned it must be ensured that only one mutable and no shared references to memory exists - /// at the same time. + /// returned it must be ensured that only one mutable and no shared references to memory + /// exists at the same time. unsafe fn memory_as_slice_mut(memory: &wasmer::Memory) -> &mut [u8] { let ptr = memory.data_ptr(); let len: usize = @@ -211,8 +210,8 @@ pub mod wasmer { unsafe { let memory = self.buffer.borrow(); - // This should be safe since we don't grow up memory while caching this reference and - // we give up the reference before returning from this function. + // This should be safe since we don't grow up memory while caching this reference + // and we give up the reference before returning from this function. let source = Self::memory_as_slice(&memory); let range = checked_range(source_addr.into(), destination.len(), source.len()) @@ -227,8 +226,8 @@ pub mod wasmer { unsafe { let memory = self.buffer.borrow_mut(); - // This should be safe since we don't grow up memory while caching this reference and - // we give up the reference before returning from this function. + // This should be safe since we don't grow up memory while caching this reference + // and we give up the reference before returning from this function. let destination = Self::memory_as_slice_mut(&memory); let range = checked_range(dest_addr.into(), source.len(), destination.len()) From fb13a8aa81fd06b1cea757b70cf9f653e4796b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 17 Aug 2021 10:00:39 +0200 Subject: [PATCH 86/88] Add ci-check to prevent wasmer sandbox build breaking --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc5b397af1b17..7f5f399a8b2db 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -300,6 +300,14 @@ cargo-check-try-runtime: - time cargo check --features try-runtime - sccache -s +cargo-check-wasmer-sandbox: + stage: test + <<: *docker-env + <<: *test-refs + script: + - time cargo check --features wasmer-sandbox + - sccache -s + test-deterministic-wasm: stage: test <<: *docker-env From cff63156a162f9ffdab23e7cb94a30f44e320f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 17 Aug 2021 15:58:51 +0200 Subject: [PATCH 87/88] Run tests with wasmer-sandbox enabled --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7f5f399a8b2db..2cea85f939d82 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -341,7 +341,9 @@ test-linux-stable: &test-linux WASM_BUILD_NO_COLOR: 1 script: # this job runs all tests in former runtime-benchmarks, frame-staking and wasmtime tests + # the wasmer-sandbox feature runs all pallet_contracts (benchmark) tests using wasmer - time cargo test --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml + - time cargo test --workspace --locked --release --verbose --features runtime-benchmarks,wasmer-sandbox --manifest-path bin/node/cli/Cargo.toml - time cargo test -p frame-support-test --features=conditional-storage --manifest-path frame/support/test/Cargo.toml --test pallet # does not reuse cache 1 min 44 sec - SUBSTRATE_TEST_TIMEOUT=1 time cargo test -p substrate-test-utils --release --verbose --locked -- --ignored timeout - sccache -s From 5e50c3b0a8463da593aad0dc4fe045a17a27282c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 17 Aug 2021 19:25:42 +0200 Subject: [PATCH 88/88] Revert "Run tests with wasmer-sandbox enabled" This reverts commit cff63156a162f9ffdab23e7cb94a30f44e320f8a. --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cea85f939d82..7f5f399a8b2db 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -341,9 +341,7 @@ test-linux-stable: &test-linux WASM_BUILD_NO_COLOR: 1 script: # this job runs all tests in former runtime-benchmarks, frame-staking and wasmtime tests - # the wasmer-sandbox feature runs all pallet_contracts (benchmark) tests using wasmer - time cargo test --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml - - time cargo test --workspace --locked --release --verbose --features runtime-benchmarks,wasmer-sandbox --manifest-path bin/node/cli/Cargo.toml - time cargo test -p frame-support-test --features=conditional-storage --manifest-path frame/support/test/Cargo.toml --test pallet # does not reuse cache 1 min 44 sec - SUBSTRATE_TEST_TIMEOUT=1 time cargo test -p substrate-test-utils --release --verbose --locked -- --ignored timeout - sccache -s