Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion client/relay-chain-rpc-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions parachain-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,20 @@ 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,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
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,
),
}
}

Expand Down Expand Up @@ -267,6 +266,7 @@ where

let (relay_chain_interface, collator_key) = build_relay_chain_interface(
polkadot_config,
&parachain_config,
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
Expand Down
18 changes: 10 additions & 8 deletions polkadot-parachains/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,20 @@ 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,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
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,
),
}
}

Expand Down Expand Up @@ -386,6 +385,7 @@ where

let (relay_chain_interface, collator_key) = build_relay_chain_interface(
polkadot_config,
&parachain_config,
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
Expand Down Expand Up @@ -571,6 +571,7 @@ where
let mut task_manager = params.task_manager;
let (relay_chain_interface, collator_key) = build_relay_chain_interface(
polkadot_config,
&parachain_config,
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
Expand Down Expand Up @@ -1372,6 +1373,7 @@ where

let (relay_chain_interface, collator_key) = build_relay_chain_interface(
polkadot_config,
&parachain_config,
telemetry_worker_handle,
&mut task_manager,
collator_options.clone(),
Expand Down