Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a6b9624
Statically register host WASM functions
koute Nov 30, 2021
1d8649f
Fix `substrate-test-client` compilation
koute Nov 30, 2021
2a4658f
Move `ExtendedHostFunctions` to `sp-wasm-interface`
koute Dec 2, 2021
878d512
Fix `sp-runtime-interface` tests' compilation
koute Dec 2, 2021
7efc4f5
Fix `sc-executor-wasmtime` tests' compilation
koute Dec 2, 2021
570788d
Use `runtime_interface` macro in `test-runner`
koute Dec 2, 2021
7610cde
Fix `sc-executor` tests' compilation
koute Dec 6, 2021
0c51a64
Reformatting/`rustfmt`
koute Dec 6, 2021
963f9e7
Add an extra comment regarding the `H` generic arg in `create_runtime`
koute Dec 6, 2021
76e8c96
Even more `rustfmt`
koute Dec 6, 2021
e853225
Depend on `wasmtime` without default features in `sp-wasm-interface`
koute Dec 6, 2021
df38788
Merge branch 'master' into master_statically_register_wasmtime_ffi
koute Dec 6, 2021
3699f6d
Merge branch 'master' into master_statically_register_wasmtime_ffi
koute Dec 9, 2021
cd14ed1
Merge branch 'master' into master_statically_register_wasmtime_ffi
koute Dec 10, 2021
f825113
Bump version of `sp-wasm-interface` to 4.0.1
koute Dec 10, 2021
8ffb42d
Bump `sp-wasm-interface` in `Cargo.lock` too
koute Dec 10, 2021
0f7ccf8
Bump all of the `sp-wasm-interface` requirements to 4.0.1
koute Dec 10, 2021
e429bb9
Revert "Bump all of the `sp-wasm-interface` requirements to 4.0.1"
koute Dec 10, 2021
9ce2fb7
Make `cargo-unleash` happy (maybe)
koute Dec 10, 2021
f9019cd
Use `cargo-unleash` to bump the crates' versions
koute Dec 13, 2021
acc2835
Merge branch 'master' into master_statically_register_wasmtime_ffi
koute Dec 13, 2021
61ce0b2
Align to review comments
koute Dec 13, 2021
bdd38da
Merge branch 'master' into master_statically_register_wasmtime_ffi
koute Dec 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions client/executor/runtime-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ sp_core::wasm_export_functions! {
fn test_panic_in_spawned() {
sp_tasks::spawn(tasks::panicker, vec![]).join();
}

fn test_return_i8() -> i8 {
-66
}

fn test_take_i8(value: i8) {
assert_eq!(value, -66);
}
}

#[cfg(not(feature = "std"))]
Expand Down
40 changes: 24 additions & 16 deletions client/executor/src/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use sp_core::{
use sp_runtime::traits::BlakeTwo256;
use sp_state_machine::TestExternalities as CoreTestExternalities;
use sp_trie::{trie_types::Layout, TrieConfiguration};
use sp_wasm_interface::HostFunctions as _;
use std::sync::Arc;
use tracing_subscriber::layer::SubscriberExt;

Expand Down Expand Up @@ -124,13 +123,7 @@ fn call_in_wasm<E: Externalities>(
execution_method: WasmExecutionMethod,
ext: &mut E,
) -> Result<Vec<u8>, String> {
let executor = crate::WasmExecutor::new(
execution_method,
Some(1024),
HostFunctions::host_functions(),
8,
None,
);
let executor = crate::WasmExecutor::<HostFunctions>::new(execution_method, Some(1024), 8, None);
executor.uncached_call(
RuntimeBlob::uncompress_if_needed(&wasm_binary_unwrap()[..]).unwrap(),
ext,
Expand Down Expand Up @@ -474,10 +467,9 @@ test_wasm_execution!(should_trap_when_heap_exhausted);
fn should_trap_when_heap_exhausted(wasm_method: WasmExecutionMethod) {
let mut ext = TestExternalities::default();

let executor = crate::WasmExecutor::new(
let executor = crate::WasmExecutor::<HostFunctions>::new(
wasm_method,
Some(17), // `17` is the initial number of pages compiled into the binary.
HostFunctions::host_functions(),
8,
None,
);
Expand All @@ -499,11 +491,10 @@ fn mk_test_runtime(wasm_method: WasmExecutionMethod, pages: u64) -> Arc<dyn Wasm
let blob = RuntimeBlob::uncompress_if_needed(&wasm_binary_unwrap()[..])
.expect("failed to create a runtime blob out of test runtime");

crate::wasm_runtime::create_wasm_runtime_with_code(
crate::wasm_runtime::create_wasm_runtime_with_code::<HostFunctions>(
wasm_method,
pages,
blob,
HostFunctions::host_functions(),
true,
None,
)
Expand Down Expand Up @@ -587,10 +578,9 @@ fn heap_is_reset_between_calls(wasm_method: WasmExecutionMethod) {

test_wasm_execution!(parallel_execution);
fn parallel_execution(wasm_method: WasmExecutionMethod) {
let executor = std::sync::Arc::new(crate::WasmExecutor::new(
let executor = std::sync::Arc::new(crate::WasmExecutor::<HostFunctions>::new(
wasm_method,
Some(1024),
HostFunctions::host_functions(),
8,
None,
));
Expand Down Expand Up @@ -760,11 +750,10 @@ fn memory_is_cleared_between_invocations(wasm_method: WasmExecutionMethod) {
)
)"#).unwrap();

let runtime = crate::wasm_runtime::create_wasm_runtime_with_code(
let runtime = crate::wasm_runtime::create_wasm_runtime_with_code::<HostFunctions>(
wasm_method,
1024,
RuntimeBlob::uncompress_if_needed(&binary[..]).unwrap(),
HostFunctions::host_functions(),
true,
None,
)
Expand All @@ -777,3 +766,22 @@ fn memory_is_cleared_between_invocations(wasm_method: WasmExecutionMethod) {
let res = instance.call_export("returns_no_bss_mutable_static", &[0]).unwrap();
assert_eq!(1, u64::decode(&mut &res[..]).unwrap());
}

test_wasm_execution!(return_i8);
fn return_i8(wasm_method: WasmExecutionMethod) {
let mut ext = TestExternalities::default();
let mut ext = ext.ext();

assert_eq!(
call_in_wasm("test_return_i8", &[], wasm_method, &mut ext).unwrap(),
(-66_i8).encode()
);
}

test_wasm_execution!(take_i8);
fn take_i8(wasm_method: WasmExecutionMethod) {
let mut ext = TestExternalities::default();
let mut ext = ext.ext();

call_in_wasm("test_take_i8", &(-66_i8).encode(), wasm_method, &mut ext).unwrap();
}
4 changes: 1 addition & 3 deletions client/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,15 @@ mod tests {
use sc_executor_common::runtime_blob::RuntimeBlob;
use sc_runtime_test::wasm_binary_unwrap;
use sp_io::TestExternalities;
use sp_wasm_interface::HostFunctions;

#[test]
fn call_in_interpreted_wasm_works() {
let mut ext = TestExternalities::default();
let mut ext = ext.ext();

let executor = WasmExecutor::new(
let executor = WasmExecutor::<sp_io::SubstrateHostFunctions>::new(
WasmExecutionMethod::Interpreted,
Some(8),
sp_io::SubstrateHostFunctions::host_functions(),
8,
None,
);
Expand Down
Loading