Wasm executor should provide stubs for unknown externs (wasmi) (#4550)

Related to #4456
This commit is contained in:
Cecile Tonglet
2020-01-09 11:18:14 +01:00
committed by GitHub
parent 189bd2349c
commit cc573bc106
6 changed files with 193 additions and 25 deletions
@@ -191,10 +191,11 @@ pub fn create_wasm_runtime_with_code(
heap_pages: u64,
code: &[u8],
host_functions: Vec<&'static dyn Function>,
allow_missing_imports: bool,
) -> Result<Box<dyn WasmRuntime>, WasmError> {
match wasm_method {
WasmExecutionMethod::Interpreted =>
sc_executor_wasmi::create_instance(code, heap_pages, host_functions)
sc_executor_wasmi::create_instance(code, heap_pages, host_functions, allow_missing_imports)
.map(|runtime| -> Box<dyn WasmRuntime> { Box::new(runtime) }),
#[cfg(feature = "wasmtime")]
WasmExecutionMethod::Compiled =>
@@ -212,7 +213,7 @@ fn create_versioned_wasm_runtime<E: Externalities>(
let code = ext
.original_storage(well_known_keys::CODE)
.ok_or(WasmError::CodeNotFound)?;
let mut runtime = create_wasm_runtime_with_code(wasm_method, heap_pages, &code, host_functions)?;
let mut runtime = create_wasm_runtime_with_code(wasm_method, heap_pages, &code, host_functions, false)?;
// Call to determine runtime version.
let version_result = {