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:
Jim Posen
2019-11-01 13:32:14 +01:00
committed by GitHub
parent 34bd4c335b
commit 8676c25ef4
25 changed files with 2862 additions and 652 deletions
-21
View File
@@ -17,10 +17,6 @@
//! A `CodeExecutor` specialization which uses natively compiled runtime when the wasm to be
//! executed is equivalent to the natively compiled code.
#![cfg_attr(feature = "benchmarks", feature(test))]
#[cfg(feature = "benchmarks")] extern crate test;
pub use substrate_executor::NativeExecutor;
use substrate_executor::native_executor_instance;
@@ -1208,21 +1204,4 @@ mod tests {
block_number += 1;
}
}
#[cfg(feature = "benchmarks")]
mod benches {
use super::*;
use test::Bencher;
#[bench]
fn wasm_execute_block(b: &mut Bencher) {
let (block1, block2) = blocks();
b.iter(|| {
let mut t = new_test_ext(COMPACT_CODE, false);
WasmExecutor::new().call(&mut t, "Core_execute_block", &block1.0).unwrap();
WasmExecutor::new().call(&mut t, "Core_execute_block", &block2.0).unwrap();
});
}
}
}