Skip to content

Commit c53e74b

Browse files
committed
Remove unnecessary and undesirable tokio dependency from subspace-node
1 parent 89a3b33 commit c53e74b

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

Cargo.lock

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

crates/subspace-node/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ subspace-runtime-primitives = { version = "0.1.0", path = "../subspace-runtime-p
5858
subspace-service = { version = "0.1.0", path = "../subspace-service" }
5959
system-domain-runtime = { version = "0.1.0", path = "../../domains/runtime/system" }
6060
thiserror = "1.0.32"
61-
tokio = "1.21.2"
6261

6362
[build-dependencies]
6463
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/subspace/substrate", rev = "6d57dbc639bb3d9460dabeccb063cc6556452535" }

crates/subspace-node/src/bin/subspace-node.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ fn main() -> Result<(), Error> {
199199
..
200200
} = subspace_service::new_partial::<RuntimeApi, ExecutorDispatch>(&config)?;
201201
Ok((
202-
cmd.run(client, import_queue).map_err(Error::SubstrateCli),
202+
cmd.run(client, import_queue, task_manager.spawn_essential_handle())
203+
.map_err(Error::SubstrateCli),
203204
task_manager,
204205
))
205206
})?;

crates/subspace-node/src/import_blocks_from_dsn.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use sc_consensus::{BlockImportError, BlockImportStatus, IncomingBlock, Link};
2222
use sc_service::ImportQueue;
2323
use sc_tracing::tracing::{debug, info, trace};
2424
use sp_consensus::BlockOrigin;
25+
use sp_core::traits::SpawnEssentialNamed;
2526
use sp_runtime::generic::BlockId;
2627
use sp_runtime::traits::{Block as BlockT, Header, NumberFor};
2728
use std::sync::Arc;
@@ -58,15 +59,26 @@ pub struct ImportBlocksFromDsnCmd {
5859

5960
impl ImportBlocksFromDsnCmd {
6061
/// Run the import-blocks command
61-
pub async fn run<B, C, IQ>(&self, client: Arc<C>, import_queue: IQ) -> sc_cli::Result<()>
62+
pub async fn run<B, C, IQ>(
63+
&self,
64+
client: Arc<C>,
65+
import_queue: IQ,
66+
spawner: impl SpawnEssentialNamed,
67+
) -> sc_cli::Result<()>
6268
where
6369
C: HeaderBackend<B> + BlockBackend<B> + Send + Sync + 'static,
6470
B: BlockT + for<'de> serde::Deserialize<'de>,
6571
IQ: sc_service::ImportQueue<B> + 'static,
6672
{
67-
import_blocks(self.bootstrap_node.clone(), client, import_queue, false)
68-
.await
69-
.map_err(Into::into)
73+
import_blocks(
74+
self.bootstrap_node.clone(),
75+
client,
76+
import_queue,
77+
&spawner,
78+
false,
79+
)
80+
.await
81+
.map_err(Into::into)
7082
}
7183
}
7284

@@ -126,6 +138,7 @@ async fn import_blocks<B, IQ, C>(
126138
bootstrap_nodes: Vec<Multiaddr>,
127139
client: Arc<C>,
128140
mut import_queue: IQ,
141+
spawner: &impl SpawnEssentialNamed,
129142
force: bool,
130143
) -> Result<(), sc_service::Error>
131144
where
@@ -142,9 +155,13 @@ where
142155
.await
143156
.map_err(|error| sc_service::Error::Other(error.to_string()))?;
144157

145-
tokio::spawn(async move {
146-
node_runner.run().await;
147-
});
158+
spawner.spawn_essential(
159+
"node-runner",
160+
Some("subspace-networking"),
161+
Box::pin(async move {
162+
node_runner.run().await;
163+
}),
164+
);
148165

149166
debug!("Waiting for connected peers...");
150167
let _ = node.wait_for_connected_peers().await;

0 commit comments

Comments
 (0)