Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Remove sp_tasks::spawn API and related code + host functions (#12639)
Browse files Browse the repository at this point in the history
* Remove `sp_tasks::spawn` API and related code

* Remove `RuntimeTasks::{spawn, join}` host functions

* remove unused

* Remove a few more tests that I forgot to remove

Co-authored-by: Shawn Tabrizi <[email protected]>
  • Loading branch information
koute and shawntabrizi authored Nov 10, 2022
1 parent 78f8f70 commit 38a955b
Show file tree
Hide file tree
Showing 18 changed files with 10 additions and 1,147 deletions.
30 changes: 0 additions & 30 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ members = [
"frame/election-provider-support/solution-type/fuzzer",
"frame/examples/basic",
"frame/examples/offchain-worker",
"frame/examples/parallel",
"frame/executive",
"frame/gilt",
"frame/grandpa",
Expand Down Expand Up @@ -205,7 +204,6 @@ members = [
"primitives/state-machine",
"primitives/std",
"primitives/storage",
"primitives/tasks",
"primitives/test-primitives",
"primitives/timestamp",
"primitives/tracing",
Expand Down
1 change: 0 additions & 1 deletion client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ sp-externalities = { version = "0.12.0", path = "../../primitives/externalities"
sp-io = { version = "6.0.0", path = "../../primitives/io" }
sp-panic-handler = { version = "4.0.0", path = "../../primitives/panic-handler" }
sp-runtime-interface = { version = "6.0.0", path = "../../primitives/runtime-interface" }
sp-tasks = { version = "4.0.0-dev", path = "../../primitives/tasks" }
sp-trie = { version = "6.0.0", path = "../../primitives/trie" }
sp-version = { version = "5.0.0", path = "../../primitives/version" }
sp-wasm-interface = { version = "6.0.0", path = "../../primitives/wasm-interface" }
Expand Down
2 changes: 0 additions & 2 deletions client/executor/runtime-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ sp-io = { version = "6.0.0", default-features = false, features = ["improved_pan
sp-runtime = { version = "6.0.0", default-features = false, path = "../../../primitives/runtime" }
sp-sandbox = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/sandbox" }
sp-std = { version = "4.0.0", default-features = false, path = "../../../primitives/std" }
sp-tasks = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/tasks" }

[build-dependencies]
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
Expand All @@ -32,5 +31,4 @@ std = [
"sp-runtime/std",
"sp-sandbox/std",
"sp-std/std",
"sp-tasks/std",
]
37 changes: 0 additions & 37 deletions client/executor/runtime-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,24 +318,6 @@ sp_core::wasm_export_functions! {
message_slice.copy_from_slice(test_message);
}

fn test_spawn() {
let data = vec![1u8, 2u8];
let data_new = sp_tasks::spawn(tasks::incrementer, data).join();

assert_eq!(data_new, vec![2u8, 3u8]);
}

fn test_nested_spawn() {
let data = vec![7u8, 13u8];
let data_new = sp_tasks::spawn(tasks::parallel_incrementer, data).join();

assert_eq!(data_new, vec![10u8, 16u8]);
}

fn test_panic_in_spawned() {
sp_tasks::spawn(tasks::panicker, vec![]).join();
}

fn test_return_i8() -> i8 {
-66
}
Expand All @@ -358,25 +340,6 @@ sp_core::wasm_export_functions! {
}
}

#[cfg(not(feature = "std"))]
mod tasks {
use sp_std::prelude::*;

pub fn incrementer(data: Vec<u8>) -> Vec<u8> {
data.into_iter().map(|v| v + 1).collect()
}

pub fn panicker(_: Vec<u8>) -> Vec<u8> {
panic!()
}

pub fn parallel_incrementer(data: Vec<u8>) -> Vec<u8> {
let first = data.into_iter().map(|v| v + 2).collect::<Vec<_>>();
let second = sp_tasks::spawn(incrementer, first).join();
second
}
}

/// A macro to define a test entrypoint for each available sandbox executor.
macro_rules! wasm_export_sandbox_test_functions {
(
Expand Down
27 changes: 0 additions & 27 deletions client/executor/src/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,33 +770,6 @@ fn wasm_tracing_should_work(wasm_method: WasmExecutionMethod) {
assert_eq!(len, 2);
}

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

call_in_wasm("test_spawn", &[], wasm_method, &mut ext).unwrap();
}

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

call_in_wasm("test_nested_spawn", &[], wasm_method, &mut ext).unwrap();
}

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

let error_result =
call_in_wasm("test_panic_in_spawned", &[], wasm_method, &mut ext).unwrap_err();

assert!(error_result.to_string().contains("Spawned task"));
}

test_wasm_execution!(memory_is_cleared_between_invocations);
fn memory_is_cleared_between_invocations(wasm_method: WasmExecutionMethod) {
// This is based on the code generated by compiling a runtime *without*
Expand Down
Loading

0 comments on commit 38a955b

Please sign in to comment.