diff --git a/cumulus/Cargo.lock b/cumulus/Cargo.lock index 512fa3fb65deff7a78cad408ca7efaa4a45a62df..f4b5448178055ae8f0a3e2e8bc7cdf256dff30ee 100644 --- a/cumulus/Cargo.lock +++ b/cumulus/Cargo.lock @@ -2093,7 +2093,7 @@ dependencies = [ "futures-timer", "jsonrpsee 0.9.0", "parity-scale-codec", - "parking_lot 0.11.2", + "parking_lot 0.12.0", "polkadot-service", "sc-client-api", "sc-rpc-api", diff --git a/cumulus/client/relay-chain-inprocess-interface/src/lib.rs b/cumulus/client/relay-chain-inprocess-interface/src/lib.rs index e6df0ea0ad208143a9528b04b5c4b172f244ece4..83cb4d1336154780e35842248270f893d179498c 100644 --- a/cumulus/client/relay-chain-inprocess-interface/src/lib.rs +++ b/cumulus/client/relay-chain-inprocess-interface/src/lib.rs @@ -325,42 +325,44 @@ impl ExecuteWithClient for RelayChainInProcessInterfaceBuilder { #[sc_tracing::logging::prefix_logs_with("Relaychain")] fn build_polkadot_full_node( config: Configuration, + parachain_config: &Configuration, telemetry_worker_handle: Option<TelemetryWorkerHandle>, -) -> Result<(NewFull<polkadot_client::Client>, CollatorPair), polkadot_service::Error> { +) -> Result<(NewFull<polkadot_client::Client>, Option<CollatorPair>), polkadot_service::Error> { let is_light = matches!(config.role, Role::Light); if is_light { Err(polkadot_service::Error::Sub("Light client not supported.".into())) } else { - let collator_key = CollatorPair::generate().0; + let (is_collator, maybe_collator_key) = if parachain_config.role.is_authority() { + let collator_key = CollatorPair::generate().0; + (polkadot_service::IsCollator::Yes(collator_key.clone()), Some(collator_key)) + } else { + (polkadot_service::IsCollator::No, None) + }; let relay_chain_full_node = polkadot_service::build_full( config, - polkadot_service::IsCollator::Yes(collator_key.clone()), + is_collator, None, true, None, telemetry_worker_handle, - false, + true, polkadot_service::RealOverseerGen, )?; - Ok((relay_chain_full_node, collator_key)) + Ok((relay_chain_full_node, maybe_collator_key)) } } /// Builds a relay chain interface by constructing a full relay chain node pub fn build_inprocess_relay_chain( polkadot_config: Configuration, + parachain_config: &Configuration, telemetry_worker_handle: Option<TelemetryWorkerHandle>, task_manager: &mut TaskManager, -) -> Result<(Arc<(dyn RelayChainInterface + 'static)>, CollatorPair), polkadot_service::Error> { +) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> { let (full_node, collator_key) = - build_polkadot_full_node(polkadot_config, telemetry_worker_handle).map_err( - |e| match e { - polkadot_service::Error::Sub(x) => x, - s => format!("{}", s).into(), - }, - )?; + build_polkadot_full_node(polkadot_config, parachain_config, telemetry_worker_handle)?; let sync_oracle: Box<dyn SyncOracle + Send + Sync> = Box::new(full_node.network.clone()); let sync_oracle = Arc::new(Mutex::new(sync_oracle)); @@ -370,6 +372,7 @@ pub fn build_inprocess_relay_chain( sync_oracle, overseer_handle: full_node.overseer_handle.clone(), }; + task_manager.add_child(full_node.task_manager); Ok((relay_chain_interface_builder.build(), collator_key)) diff --git a/cumulus/client/relay-chain-rpc-interface/Cargo.toml b/cumulus/client/relay-chain-rpc-interface/Cargo.toml index 7a36779993fdcc084148ae208ee1e6b0325db076..da1c02277aa1d600e0bb1fa72e8f0b1494a1e706 100644 --- a/cumulus/client/relay-chain-rpc-interface/Cargo.toml +++ b/cumulus/client/relay-chain-rpc-interface/Cargo.toml @@ -22,7 +22,7 @@ sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master futures = "0.3.21" futures-timer = "3.0.2" parity-scale-codec = "3.0.0" -parking_lot = "0.11.1" +parking_lot = "0.12.0" jsonrpsee = { version = "0.9.0", features = ["client"] } tracing = "0.1.25" async-trait = "0.1.52" diff --git a/cumulus/parachain-template/node/src/service.rs b/cumulus/parachain-template/node/src/service.rs index f7093222af24e2b7d56e6b1ccf3b2a95fe6b391a..108d7c1851118a301591cc343c04e923f4701664 100644 --- a/cumulus/parachain-template/node/src/service.rs +++ b/cumulus/parachain-template/node/src/service.rs @@ -166,6 +166,7 @@ where async fn build_relay_chain_interface( polkadot_config: Configuration, + parachain_config: &Configuration, telemetry_worker_handle: Option<TelemetryWorkerHandle>, task_manager: &mut TaskManager, collator_options: CollatorOptions, @@ -173,14 +174,12 @@ async fn build_relay_chain_interface( match collator_options.relay_chain_rpc_url { Some(relay_chain_url) => Ok((Arc::new(RelayChainRPCInterface::new(relay_chain_url).await?) as Arc<_>, None)), - None => { - let relay_chain_local = build_inprocess_relay_chain( - polkadot_config, - telemetry_worker_handle, - task_manager, - )?; - Ok((relay_chain_local.0, Some(relay_chain_local.1))) - }, + None => build_inprocess_relay_chain( + polkadot_config, + parachain_config, + telemetry_worker_handle, + task_manager, + ), } } @@ -267,6 +266,7 @@ where let (relay_chain_interface, collator_key) = build_relay_chain_interface( polkadot_config, + ¶chain_config, telemetry_worker_handle, &mut task_manager, collator_options.clone(), diff --git a/cumulus/polkadot-parachains/src/service.rs b/cumulus/polkadot-parachains/src/service.rs index ea890fd33fe03600db74e33f613b63d0277069ad..b72753590c6047c3af5d6f35f78478eed05b61cc 100644 --- a/cumulus/polkadot-parachains/src/service.rs +++ b/cumulus/polkadot-parachains/src/service.rs @@ -287,6 +287,7 @@ where async fn build_relay_chain_interface( polkadot_config: Configuration, + parachain_config: &Configuration, telemetry_worker_handle: Option<TelemetryWorkerHandle>, task_manager: &mut TaskManager, collator_options: CollatorOptions, @@ -294,14 +295,12 @@ async fn build_relay_chain_interface( match collator_options.relay_chain_rpc_url { Some(relay_chain_url) => Ok((Arc::new(RelayChainRPCInterface::new(relay_chain_url).await?) as Arc<_>, None)), - None => { - let relay_chain_local = build_inprocess_relay_chain( - polkadot_config, - telemetry_worker_handle, - task_manager, - )?; - Ok((relay_chain_local.0, Some(relay_chain_local.1))) - }, + None => build_inprocess_relay_chain( + polkadot_config, + parachain_config, + telemetry_worker_handle, + task_manager, + ), } } @@ -386,6 +385,7 @@ where let (relay_chain_interface, collator_key) = build_relay_chain_interface( polkadot_config, + ¶chain_config, telemetry_worker_handle, &mut task_manager, collator_options.clone(), @@ -571,6 +571,7 @@ where let mut task_manager = params.task_manager; let (relay_chain_interface, collator_key) = build_relay_chain_interface( polkadot_config, + ¶chain_config, telemetry_worker_handle, &mut task_manager, collator_options.clone(), @@ -1372,6 +1373,7 @@ where let (relay_chain_interface, collator_key) = build_relay_chain_interface( polkadot_config, + ¶chain_config, telemetry_worker_handle, &mut task_manager, collator_options.clone(),