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

Commit 38a955b

Browse files
kouteshawntabrizi
andauthored
Remove sp_tasks::spawn API and related code + host functions (#12639)
* 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]>
1 parent 78f8f70 commit 38a955b

File tree

18 files changed

+10
-1147
lines changed

18 files changed

+10
-1147
lines changed

Cargo.lock

Lines changed: 0 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ members = [
9898
"frame/election-provider-support/solution-type/fuzzer",
9999
"frame/examples/basic",
100100
"frame/examples/offchain-worker",
101-
"frame/examples/parallel",
102101
"frame/executive",
103102
"frame/gilt",
104103
"frame/grandpa",
@@ -205,7 +204,6 @@ members = [
205204
"primitives/state-machine",
206205
"primitives/std",
207206
"primitives/storage",
208-
"primitives/tasks",
209207
"primitives/test-primitives",
210208
"primitives/timestamp",
211209
"primitives/tracing",

client/executor/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ sp-externalities = { version = "0.12.0", path = "../../primitives/externalities"
3131
sp-io = { version = "6.0.0", path = "../../primitives/io" }
3232
sp-panic-handler = { version = "4.0.0", path = "../../primitives/panic-handler" }
3333
sp-runtime-interface = { version = "6.0.0", path = "../../primitives/runtime-interface" }
34-
sp-tasks = { version = "4.0.0-dev", path = "../../primitives/tasks" }
3534
sp-trie = { version = "6.0.0", path = "../../primitives/trie" }
3635
sp-version = { version = "5.0.0", path = "../../primitives/version" }
3736
sp-wasm-interface = { version = "6.0.0", path = "../../primitives/wasm-interface" }

client/executor/runtime-test/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ sp-io = { version = "6.0.0", default-features = false, features = ["improved_pan
1919
sp-runtime = { version = "6.0.0", default-features = false, path = "../../../primitives/runtime" }
2020
sp-sandbox = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/sandbox" }
2121
sp-std = { version = "4.0.0", default-features = false, path = "../../../primitives/std" }
22-
sp-tasks = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/tasks" }
2322

2423
[build-dependencies]
2524
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
@@ -32,5 +31,4 @@ std = [
3231
"sp-runtime/std",
3332
"sp-sandbox/std",
3433
"sp-std/std",
35-
"sp-tasks/std",
3634
]

client/executor/runtime-test/src/lib.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -318,24 +318,6 @@ sp_core::wasm_export_functions! {
318318
message_slice.copy_from_slice(test_message);
319319
}
320320

321-
fn test_spawn() {
322-
let data = vec![1u8, 2u8];
323-
let data_new = sp_tasks::spawn(tasks::incrementer, data).join();
324-
325-
assert_eq!(data_new, vec![2u8, 3u8]);
326-
}
327-
328-
fn test_nested_spawn() {
329-
let data = vec![7u8, 13u8];
330-
let data_new = sp_tasks::spawn(tasks::parallel_incrementer, data).join();
331-
332-
assert_eq!(data_new, vec![10u8, 16u8]);
333-
}
334-
335-
fn test_panic_in_spawned() {
336-
sp_tasks::spawn(tasks::panicker, vec![]).join();
337-
}
338-
339321
fn test_return_i8() -> i8 {
340322
-66
341323
}
@@ -358,25 +340,6 @@ sp_core::wasm_export_functions! {
358340
}
359341
}
360342

361-
#[cfg(not(feature = "std"))]
362-
mod tasks {
363-
use sp_std::prelude::*;
364-
365-
pub fn incrementer(data: Vec<u8>) -> Vec<u8> {
366-
data.into_iter().map(|v| v + 1).collect()
367-
}
368-
369-
pub fn panicker(_: Vec<u8>) -> Vec<u8> {
370-
panic!()
371-
}
372-
373-
pub fn parallel_incrementer(data: Vec<u8>) -> Vec<u8> {
374-
let first = data.into_iter().map(|v| v + 2).collect::<Vec<_>>();
375-
let second = sp_tasks::spawn(incrementer, first).join();
376-
second
377-
}
378-
}
379-
380343
/// A macro to define a test entrypoint for each available sandbox executor.
381344
macro_rules! wasm_export_sandbox_test_functions {
382345
(

client/executor/src/integration_tests/mod.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -770,33 +770,6 @@ fn wasm_tracing_should_work(wasm_method: WasmExecutionMethod) {
770770
assert_eq!(len, 2);
771771
}
772772

773-
test_wasm_execution!(spawning_runtime_instance_should_work);
774-
fn spawning_runtime_instance_should_work(wasm_method: WasmExecutionMethod) {
775-
let mut ext = TestExternalities::default();
776-
let mut ext = ext.ext();
777-
778-
call_in_wasm("test_spawn", &[], wasm_method, &mut ext).unwrap();
779-
}
780-
781-
test_wasm_execution!(spawning_runtime_instance_nested_should_work);
782-
fn spawning_runtime_instance_nested_should_work(wasm_method: WasmExecutionMethod) {
783-
let mut ext = TestExternalities::default();
784-
let mut ext = ext.ext();
785-
786-
call_in_wasm("test_nested_spawn", &[], wasm_method, &mut ext).unwrap();
787-
}
788-
789-
test_wasm_execution!(panic_in_spawned_instance_panics_on_joining_its_result);
790-
fn panic_in_spawned_instance_panics_on_joining_its_result(wasm_method: WasmExecutionMethod) {
791-
let mut ext = TestExternalities::default();
792-
let mut ext = ext.ext();
793-
794-
let error_result =
795-
call_in_wasm("test_panic_in_spawned", &[], wasm_method, &mut ext).unwrap_err();
796-
797-
assert!(error_result.to_string().contains("Spawned task"));
798-
}
799-
800773
test_wasm_execution!(memory_is_cleared_between_invocations);
801774
fn memory_is_cleared_between_invocations(wasm_method: WasmExecutionMethod) {
802775
// This is based on the code generated by compiling a runtime *without*

0 commit comments

Comments
 (0)