Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
7 changes: 6 additions & 1 deletion cumulus/client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ use sc_network::{
};
use sc_network_sync::SyncingService;
use sc_network_transactions::TransactionsHandlerController;
use sc_service::{Configuration, SpawnTaskHandle, TaskManager, WarpSyncConfig};
use sc_service::{
Configuration, SpawnEssentialTaskHandle, SpawnTaskHandle, TaskManager, WarpSyncConfig,
};
use sc_telemetry::{log, TelemetryWorkerHandle};
use sc_tracing::block::TracingExecuteBlock;
use sc_utils::mpsc::TracingUnboundedSender;
Expand Down Expand Up @@ -291,6 +293,7 @@ pub struct BuildNetworkParams<
pub para_id: ParaId,
pub relay_chain_interface: RCInterface,
pub spawn_handle: SpawnTaskHandle,
pub spawn_essential_handle: SpawnEssentialTaskHandle,
pub import_queue: IQ,
pub sybil_resistance_level: CollatorSybilResistance,
pub metrics: sc_network::NotificationMetrics,
Expand All @@ -305,6 +308,7 @@ pub async fn build_network<'a, Block, Client, RCInterface, IQ, Network>(
transaction_pool,
para_id,
spawn_handle,
spawn_essential_handle,
relay_chain_interface,
import_queue,
sybil_resistance_level,
Expand Down Expand Up @@ -374,6 +378,7 @@ where
client,
transaction_pool,
spawn_handle,
spawn_essential_handle,
import_queue,
block_announce_validator_builder: Some(Box::new(move |_| block_announce_validator)),
warp_sync_config,
Expand Down
1 change: 1 addition & 0 deletions cumulus/polkadot-omni-node/lib/src/common/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
transaction_pool: transaction_pool.clone(),
para_id,
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
relay_chain_interface: relay_chain_interface.clone(),
import_queue: params.import_queue,
sybil_resistance_level: Self::SYBIL_RESISTANCE,
Expand Down
1 change: 1 addition & 0 deletions cumulus/polkadot-omni-node/lib/src/nodes/aura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ where
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
net_config,
block_announce_validator_builder: None,
Expand Down
1 change: 1 addition & 0 deletions cumulus/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ where
transaction_pool: transaction_pool.clone(),
para_id,
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
relay_chain_interface: relay_chain_interface.clone(),
import_queue: params.import_queue,
metrics: Net::register_notification_metrics(
Expand Down
1 change: 1 addition & 0 deletions polkadot/node/service/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ where
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_config: Some(WarpSyncConfig::WithProvider(warp_sync)),
Expand Down
1 change: 1 addition & 0 deletions substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_config: Some(WarpSyncConfig::WithProvider(warp_sync)),
Expand Down
16 changes: 13 additions & 3 deletions substrate/client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use crate::{
config::{Configuration, ExecutorConfiguration, KeystoreConfig, Multiaddr, PrometheusConfig},
error::Error,
metrics::MetricsService,
start_rpc_servers, BuildGenesisBlock, GenesisBlockBuilder, RpcHandlers, SpawnTaskHandle,
TaskManager, TransactionPoolAdapter,
start_rpc_servers, BuildGenesisBlock, GenesisBlockBuilder, RpcHandlers,
SpawnEssentialTaskHandle, SpawnTaskHandle, TaskManager, TransactionPoolAdapter,
};
use futures::{select, FutureExt, StreamExt};
use jsonrpsee::RpcModule;
Expand Down Expand Up @@ -955,6 +955,8 @@ where
pub transaction_pool: Arc<TxPool>,
/// A handle for spawning tasks.
pub spawn_handle: SpawnTaskHandle,
/// A handle for spawning essential tasks.
pub spawn_essential_handle: SpawnEssentialTaskHandle,
/// An import queue.
pub import_queue: IQ,
/// A block announce validator builder.
Expand Down Expand Up @@ -1003,6 +1005,7 @@ where
client,
transaction_pool,
spawn_handle,
spawn_essential_handle,
import_queue,
block_announce_validator_builder,
warp_sync_config,
Expand Down Expand Up @@ -1083,6 +1086,7 @@ where
client,
transaction_pool,
spawn_handle,
spawn_essential_handle,
import_queue,
sync_service,
block_announce_config,
Expand Down Expand Up @@ -1116,6 +1120,8 @@ where
pub transaction_pool: Arc<TxPool>,
/// A handle for spawning tasks.
pub spawn_handle: SpawnTaskHandle,
/// A handle for spawning essential tasks.
pub spawn_essential_handle: SpawnEssentialTaskHandle,
/// An import queue.
pub import_queue: IQ,
/// Syncing service to communicate with syncing engine.
Expand Down Expand Up @@ -1168,6 +1174,7 @@ where
client,
transaction_pool,
spawn_handle,
spawn_essential_handle,
import_queue,
sync_service,
block_announce_config,
Expand Down Expand Up @@ -1286,7 +1293,10 @@ where
// issue, and ideally we would like to fix the network future to take as little time as
// possible, but we also take the extra harm-prevention measure to execute the networking
// future using `spawn_blocking`.
spawn_handle.spawn_blocking("network-worker", Some("networking"), future);
//
// The network worker is spawned as an essential task, meaning if it exits unexpectedly
// the service will shut down.
spawn_essential_handle.spawn_blocking("network-worker", Some("networking"), future);

Ok((network, system_rpc_tx, tx_handler_controller, sync_service.clone()))
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async fn build_network_future<
// If this stream is shut down, that means the client has shut down, and the
// most appropriate thing to do for the network future is to shut down too.
None => {
debug!("Block import stream has terminated, shutting down the network future.");
warn!("Block import stream has terminated, shutting down the network future. Ignore if the node is stopping.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we would see this on normal shutdown also some times?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I would expect to see this pop in the logs a few times during panics / closing of other essential tasks

I've tried to reproduce this locally by interurpting a running substrate node, however these logs did not appear locally:

2026-01-23 13:55:54.012  INFO tokio-runtime-worker babe: 🔖 Pre-sealed block for proposal at 7. Hash now 0x6e7d798d7ea35d48089a6cdbbb5dfc2c5f5086bb7a3b4cbbd3a81531d8ebb5c6, previously 0xca0dd9d74932c11638c1e4e568dfb4d0f3f47cc57022da6524f7686d28d29e84.
2026-01-23 13:55:54.013  INFO tokio-runtime-worker substrate: 🏆 Imported #7 (0xeb5a…8b99 → 0x6e7d…b5c6)

^C2026-01-23 13:55:54.830 ERROR tokio-runtime-worker sc_service::task_manager: Essential task `txpool-background` failed. Shutting down service.

return
},
};
Expand All @@ -235,7 +235,7 @@ async fn build_network_future<

// Drive the network. Shut down the network future if `NetworkWorker` has terminated.
_ = network_run => {
debug!("`NetworkWorker` has terminated, shutting down the network future.");
warn!("`NetworkWorker` has terminated, shutting down the network future. Ignore if the node is stopping.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question.

return
}
}
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/revive/dev-node/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_config: None,
Expand Down
1 change: 1 addition & 0 deletions templates/minimal/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_config: None,
Expand Down
1 change: 1 addition & 0 deletions templates/parachain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ pub async fn start_parachain_node(
transaction_pool: transaction_pool.clone(),
para_id,
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
relay_chain_interface: relay_chain_interface.clone(),
import_queue: params.import_queue,
sybil_resistance_level: CollatorSybilResistance::Resistant, // because of Aura
Expand Down
1 change: 1 addition & 0 deletions templates/solochain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ pub fn new_full<
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_config: Some(WarpSyncConfig::WithProvider(warp_sync)),
Expand Down
Loading