mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
Better wasm instance cache (#5109)
* Wasm instance cache * Reduce slot locking * Fixed test * Dispose of instance in case of error * Fixed benches * Style, comments, some renames * Replaced upgradable lock with mutex * Bump dependencies * Re-export CallInWasm * Update client/executor/src/wasm_runtime.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/executor/src/native_executor.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/executor/src/native_executor.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/executor/src/wasm_runtime.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/executor/wasmtime/src/runtime.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/executor/src/wasm_runtime.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/executor/src/wasm_runtime.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/executor/src/wasm_runtime.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Indents * Whitespace * Formatting * Added issue link Co-authored-by: Benjamin Kampmann <ben.kampmann@googlemail.com> Co-authored-by: Gavin Wood <github@gavwood.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
40b243f1c8
commit
d3208aa7bc
@@ -22,26 +22,27 @@
|
||||
use sp_runtime_interface::*;
|
||||
use sp_runtime_interface_test_wasm::{WASM_BINARY, test_api::HostFunctions};
|
||||
use sp_wasm_interface::HostFunctions as HostFunctionsT;
|
||||
use sc_executor::CallInWasm;
|
||||
|
||||
type TestExternalities = sp_state_machine::TestExternalities<sp_runtime::traits::BlakeTwo256, u64>;
|
||||
|
||||
fn call_wasm_method<HF: HostFunctionsT>(method: &str) -> TestExternalities {
|
||||
let mut ext = TestExternalities::default();
|
||||
let mut ext_ext = ext.ext();
|
||||
let mut host_functions = HF::host_functions();
|
||||
host_functions.extend(sp_io::SubstrateHostFunctions::host_functions());
|
||||
|
||||
sc_executor::call_in_wasm::<
|
||||
(
|
||||
HF,
|
||||
sp_io::SubstrateHostFunctions,
|
||||
)
|
||||
>(
|
||||
let executor = sc_executor::WasmExecutor::new(
|
||||
sc_executor::WasmExecutionMethod::Interpreted,
|
||||
Some(8),
|
||||
host_functions,
|
||||
false,
|
||||
);
|
||||
executor.call_in_wasm(
|
||||
&WASM_BINARY[..],
|
||||
method,
|
||||
&[],
|
||||
sc_executor::WasmExecutionMethod::Interpreted,
|
||||
&mut ext_ext,
|
||||
&WASM_BINARY[..],
|
||||
8,
|
||||
false,
|
||||
).expect(&format!("Executes `{}`", method));
|
||||
|
||||
ext
|
||||
@@ -87,7 +88,7 @@ fn test_return_input_public_key() {
|
||||
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected = "Other(\"Instantiation: Export ext_test_api_return_input_version_1 not found\")"
|
||||
expected = "\"Instantiation: Export ext_test_api_return_input_version_1 not found\""
|
||||
)]
|
||||
fn host_function_not_found() {
|
||||
call_wasm_method::<()>("test_return_data");
|
||||
@@ -96,8 +97,9 @@ fn host_function_not_found() {
|
||||
#[test]
|
||||
#[should_panic(
|
||||
expected =
|
||||
"FunctionExecution(\"ext_test_api_invalid_utf8_data_version_1\", \
|
||||
\"Invalid utf8 data provided\")"
|
||||
"Executes `test_invalid_utf8_data_should_return_an_error`: \
|
||||
\"Trap: Trap { kind: Host(FunctionExecution(\\\"ext_test_api_invalid_utf8_data_version_1\\\", \
|
||||
\\\"Invalid utf8 data provided\\\")) }\""
|
||||
)]
|
||||
fn test_invalid_utf8_data_should_return_an_error() {
|
||||
call_wasm_method::<HostFunctions>("test_invalid_utf8_data_should_return_an_error");
|
||||
|
||||
Reference in New Issue
Block a user