Skip to content

Commit 896b603

Browse files
authored
statement-store: use many workers for network statements processing (#10617)
# Description Fixes #10814 Adds --statement-network-workers CLI parameter to enable concurrent statement validation from the network. Previously, statements were validated sequentially by a single worker. This change allows multiple workers to process statements in parallel, improving throughput when statement store is enabled ## Integration Non-breaking change with opt-in performance improvement. Default behavior unchanged (single worker).
1 parent 2eb4350 commit 896b603

File tree

11 files changed

+82
-23
lines changed

11 files changed

+82
-23
lines changed

cumulus/polkadot-omni-node/lib/src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ pub struct Cli<Config: CliConfig> {
223223
#[arg(long)]
224224
pub enable_statement_store: bool,
225225

226+
/// Number of concurrent workers for statement validation from the network.
227+
///
228+
/// Only relevant when `--enable-statement-store` is used.
229+
#[arg(long, default_value_t = 1)]
230+
pub statement_network_workers: usize,
231+
226232
#[arg(skip)]
227233
pub(crate) _phantom: PhantomData<Config>,
228234
}
@@ -268,6 +274,7 @@ impl<Config: CliConfig> Cli<Config> {
268274
export_pov: self.export_pov_to_path.clone(),
269275
max_pov_percentage: self.run.experimental_max_pov_percentage,
270276
enable_statement_store: self.enable_statement_store,
277+
statement_network_workers: self.statement_network_workers,
271278
storage_monitor: self.storage_monitor.clone(),
272279
}
273280
}

cumulus/polkadot-omni-node/lib/src/common/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ pub struct NodeExtraArgs {
130130
/// If true then the statement store will be enabled.
131131
pub enable_statement_store: bool,
132132

133+
/// Number of concurrent workers for statement validation from the network.
134+
pub statement_network_workers: usize,
135+
133136
/// Parameters for storage monitoring.
134137
pub storage_monitor: sc_storage_monitor::StorageMonitorParams,
135138
}

cumulus/polkadot-omni-node/lib/src/common/spec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
412412
sync_service.clone(),
413413
params.keystore_container.local_keystore(),
414414
statement_handler_proto,
415+
node_extra_args.statement_network_workers,
415416
)
416417
})
417418
.transpose()?;

cumulus/polkadot-omni-node/lib/src/common/statement_store.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub(crate) fn build_statement_store<
6363
sync_service: Arc<sc_network_sync::service::syncing_service::SyncingService<Block>>,
6464
local_keystore: Arc<sc_keystore::LocalKeystore>,
6565
statement_handler_proto: sc_network_statement::StatementHandlerPrototype,
66+
statement_network_workers: usize,
6667
) -> sc_service::error::Result<Arc<Store>> {
6768
let statement_store = sc_statement_store::Store::new_shared(
6869
&parachain_config.data_path,
@@ -85,6 +86,7 @@ pub(crate) fn build_statement_store<
8586
statement_store.clone(),
8687
parachain_config.prometheus_registry(),
8788
statement_protocol_executor,
89+
statement_network_workers,
8890
)?;
8991
task_manager.spawn_handle().spawn(
9092
"network-statement-handler",

prdoc/pr_10617.prdoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
title: "statement-store: use many workers for network statements processing"
2+
3+
doc:
4+
- audience: [Node Dev, Node Operator]
5+
description: |
6+
Adds --statement-network-workers CLI parameter to enable concurrent statement validation from the network.
7+
Previously, statements were validated sequentially by a single worker. This change allows multiple workers
8+
o process statements in parallel, improving throughput when statement store is enabled
9+
10+
crates:
11+
- name: sc-network-statement
12+
bump: major
13+
- name: polkadot-omni-node-lib
14+
bump: major

substrate/bin/node/cli/benches/block_production.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
117117
config,
118118
None,
119119
false,
120+
1,
120121
|_, _| (),
121122
)
122123
.expect("creating a full node doesn't fail")

substrate/bin/node/cli/benches/transaction_pool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
104104
config,
105105
None,
106106
false,
107+
1,
107108
|_, _| (),
108109
)
109110
.expect("Creates node")

substrate/bin/node/cli/src/chain_spec.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,13 @@ pub(crate) mod tests {
468468

469469
sc_service_test::connectivity(integration_test_config_with_two_authorities(), |config| {
470470
let NewFullBase { task_manager, client, network, sync, transaction_pool, .. } =
471-
new_full_base::<sc_network::NetworkWorker<_, _>>(config, None, false, |_, _| ())?;
471+
new_full_base::<sc_network::NetworkWorker<_, _>>(
472+
config,
473+
None,
474+
false,
475+
1,
476+
|_, _| (),
477+
)?;
472478
Ok(sc_service_test::TestNetComponents::new(
473479
task_manager,
474480
client,

substrate/bin/node/cli/src/cli.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ pub struct Cli {
4343
#[arg(long)]
4444
pub no_hardware_benchmarks: bool,
4545

46+
/// Number of concurrent workers for statement validation from the network.
47+
///
48+
/// Only relevant when `--enable-statement-store` is used.
49+
#[arg(long, default_value_t = 1)]
50+
pub statement_network_workers: usize,
51+
4652
#[allow(missing_docs)]
4753
#[clap(flatten)]
4854
pub storage_monitor: sc_storage_monitor::StorageMonitorParams,

substrate/bin/node/cli/src/service.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
409409
config: Configuration,
410410
mixnet_config: Option<sc_mixnet::Config>,
411411
disable_hardware_benchmarks: bool,
412+
statement_network_workers: usize,
412413
with_startup_data: impl FnOnce(
413414
&sc_consensus_babe::BabeBlockImport<
414415
Block,
@@ -789,6 +790,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
789790
statement_store.clone(),
790791
prometheus_registry.as_ref(),
791792
statement_protocol_executor,
793+
statement_network_workers,
792794
)?;
793795
task_manager.spawn_handle().spawn(
794796
"network-statement-handler",
@@ -840,6 +842,7 @@ pub fn new_full(config: Configuration, cli: Cli) -> Result<TaskManager, ServiceE
840842
config,
841843
mixnet_config,
842844
cli.no_hardware_benchmarks,
845+
cli.statement_network_workers,
843846
|_, _| (),
844847
)
845848
.map(|NewFullBase { task_manager, .. }| task_manager)?;
@@ -850,6 +853,7 @@ pub fn new_full(config: Configuration, cli: Cli) -> Result<TaskManager, ServiceE
850853
config,
851854
mixnet_config,
852855
cli.no_hardware_benchmarks,
856+
cli.statement_network_workers,
853857
|_, _| (),
854858
)
855859
.map(|NewFullBase { task_manager, .. }| task_manager)?;
@@ -937,6 +941,7 @@ mod tests {
937941
config,
938942
None,
939943
false,
944+
1,
940945
|block_import: &sc_consensus_babe::BabeBlockImport<Block, _, _, _, _>,
941946
babe_link: &sc_consensus_babe::BabeLink<Block>| {
942947
setup_handles = Some((block_import.clone(), babe_link.clone()));
@@ -1152,6 +1157,7 @@ mod tests {
11521157
config,
11531158
None,
11541159
false,
1160+
1,
11551161
|_, _| (),
11561162
)?;
11571163
Ok(sc_service_test::TestNetComponents::new(

0 commit comments

Comments
 (0)