mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Integrate Wasmtime for runtime execution (#3869)
* executor: Use non wasmi-specific execution in tests. * executor: Move all runtime execution tests into tests file. * executor: Use test_case macro to easily execute tests with different Wasm execution methods. * executor: Convert errors to strings with Display, not Debug. * node-executor: Rewrite benchmarks with criterion. They were not passing compilation before and criterion seems to be more widely used in Substrate. * executor: Begin implementation of Wasm runtime. The implementation demonstrates the outline of the execution, but does not link against the external host functions. * executor: Define and implement basic FunctionExecutor. The SandboxCapabilities::invoke is still left unimplemented. * executor: Implement host function trampoline generation. * executor: Instantiate and link runtime module to env module. * executor: Provide input data during wasmtime execution. * executor: Implement SandboxCapabilites::invoke for wasmtime executor. * executor: Integrate and test wasmtime execution method. * executor: Improve FunctionExecution error messages. * Scope the unsafe blocks to be smaller. * Rename TrampolineState to EnvState. * Let EnvState own its own compiler instead of unsafe lifetime cast. * Refactor out some common wasmi/wasmtime logic. * Typos and cosmetic changes. * More trampoline comments. * Cargo.lock update. * cli: CLI option for running Substrate with compiled Wasm execution. * executor: Switch dependency from fork to official wasmtime repo. * Quiet down cranelift logs. * Explicitly catch panics during host calls. We do this to ensure that panics do not cross language boundaries. * Additional checks and clarifications in make_trampoline. * Fixes after merge from master and panic safety for wasmtime instantiation.
This commit is contained in:
@@ -49,6 +49,18 @@ pub enum Value {
|
||||
F64(u64),
|
||||
}
|
||||
|
||||
impl Value {
|
||||
/// Returns the type of this value.
|
||||
pub fn value_type(&self) -> ValueType {
|
||||
match self {
|
||||
Value::I32(_) => ValueType::I32,
|
||||
Value::I64(_) => ValueType::I64,
|
||||
Value::F32(_) => ValueType::F32,
|
||||
Value::F64(_) => ValueType::F64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides `Sealed` trait to prevent implementing trait `PointerType` outside of this crate.
|
||||
mod private {
|
||||
pub trait Sealed {}
|
||||
@@ -212,7 +224,7 @@ pub type MemoryId = u32;
|
||||
pub trait Sandbox {
|
||||
/// Get sandbox memory from the `memory_id` instance at `offset` into the given buffer.
|
||||
fn memory_get(
|
||||
&self,
|
||||
&mut self,
|
||||
memory_id: MemoryId,
|
||||
offset: WordSize,
|
||||
buf_ptr: Pointer<u8>,
|
||||
|
||||
Reference in New Issue
Block a user