Adds a test to ensure that we clear the heap between calls into runtime (#4903)

* Adds a test to ensure that we clear the heap between calls into runtime

The tests shows that we currently not clearing the heap in wasmtime.
For now we don't run the test for wasmtime.

* Fix compilation
This commit is contained in:
Bastian Köcher
2020-02-14 01:42:27 +01:00
committed by GitHub
parent 78b5a06200
commit d3fa8c91af
6 changed files with 81 additions and 4 deletions
@@ -27,7 +27,7 @@ use sc_executor_common::{
};
use sp_allocator::FreeingBumpHeapAllocator;
use sp_runtime_interface::unpack_ptr_and_len;
use sp_wasm_interface::{Function, Pointer, WordSize};
use sp_wasm_interface::{Function, Pointer, WordSize, Value};
use wasmtime::{Config, Engine, Module, Store};
/// A `WasmRuntime` implementation using wasmtime to compile the runtime module to machine code
@@ -55,6 +55,12 @@ impl WasmRuntime for WasmtimeRuntime {
self.heap_pages,
)
}
fn get_global_val(&self, name: &str) -> Result<Option<Value>> {
// Yeah, there is no better way currently :(
InstanceWrapper::new(&self.module, &self.imports, self.heap_pages)?
.get_global_val(name)
}
}
/// Create a new `WasmtimeRuntime` given the code. This function performs translation from Wasm to