Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prospective-parachain subsystem to minimal-relay-node + QoL improvements #2223

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions cumulus/client/relay-chain-minimal-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ polkadot-collator-protocol = { path = "../../../polkadot/node/network/collator-p
polkadot-network-bridge = { path = "../../../polkadot/node/network/bridge" }
polkadot-node-collation-generation = { path = "../../../polkadot/node/collation-generation" }
polkadot-node-core-runtime-api = { path = "../../../polkadot/node/core/runtime-api" }
polkadot-node-core-prospective-parachains = { path = "../../../polkadot/node/core/prospective-parachains" }

# substrate deps
sc-authority-discovery = { path = "../../../substrate/client/authority-discovery" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use polkadot_network_bridge::{
NetworkBridgeTx as NetworkBridgeTxSubsystem,
};
use polkadot_node_collation_generation::CollationGenerationSubsystem;
use polkadot_node_core_prospective_parachains::ProspectiveParachainsSubsystem;
use polkadot_node_core_runtime_api::RuntimeApiSubsystem;
use polkadot_node_network_protocol::{
peer_set::PeerSetProtocolNames,
Expand Down Expand Up @@ -144,7 +145,7 @@ fn build_overseer(
spawner.clone(),
))
.statement_distribution(DummySubsystem)
.prospective_parachains(DummySubsystem)
.prospective_parachains(ProspectiveParachainsSubsystem::new(Metrics::register(registry)?))
.approval_distribution(DummySubsystem)
.approval_voting(DummySubsystem)
.gossip_support(DummySubsystem)
Expand Down
7 changes: 1 addition & 6 deletions cumulus/client/relay-chain-minimal-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,7 @@ async fn new_minimal_relay_chain(
);
}

let genesis_hash = relay_chain_rpc_client
.block_get_hash(Some(0))
.await
.expect("Genesis block hash is always available; qed")
.unwrap_or_default();

let genesis_hash = relay_chain_rpc_client.block_get_hash(Some(0)).await?.unwrap_or_default();
let peer_set_protocol_names =
PeerSetProtocolNames::new(genesis_hash, config.chain_spec.fork_id());
let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No };
Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl RelayChainRpcClient {

let value = rx.await.map_err(|err| {
RelayChainError::WorkerCommunicationError(format!(
"Unexpected channel close on RPC worker side: {}",
"RPC worker channel closed. This can hint and connectivity issues with the supplied RPC endpoints. Message: {}",
err
))
})??;
Expand Down
18 changes: 11 additions & 7 deletions cumulus/client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use sc_utils::mpsc::TracingUnboundedSender;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{HeaderBackend, HeaderMetadata};
use sp_core::{traits::SpawnNamed, Decode};
use sp_runtime::traits::{Block as BlockT, BlockIdTo};
use sp_runtime::traits::{Block as BlockT, BlockIdTo, Header};
use std::{sync::Arc, time::Duration};

// Given the sporadic nature of the explicit recovery operation and the
Expand Down Expand Up @@ -505,11 +505,11 @@ where
None,
async move {
log::debug!(
target: "cumulus-network",
target: LOG_TARGET_SYNC,
"waiting for announce block in a background task...",
);

let _ = wait_for_target_block::<B, _>(sender, para_id, relay_chain_interface)
let _ = wait_for_finalized_para_head::<B, _>(sender, para_id, relay_chain_interface)
.await
.map_err(|e| {
log::error!(
Expand All @@ -527,7 +527,7 @@ where

/// Waits for the relay chain to have finished syncing and then gets the parachain header that
/// corresponds to the last finalized relay chain block.
async fn wait_for_target_block<B, RCInterface>(
async fn wait_for_finalized_para_head<B, RCInterface>(
sender: oneshot::Sender<<B as BlockT>::Header>,
para_id: ParaId,
relay_chain_interface: RCInterface,
Expand Down Expand Up @@ -560,11 +560,15 @@ where
.map_err(|e| format!("{e:?}"))?
.ok_or("Could not find parachain head in relay chain")?;

let target_block = B::Header::decode(&mut &validation_data.parent_head.0[..])
let finalized_header = B::Header::decode(&mut &validation_data.parent_head.0[..])
.map_err(|e| format!("Failed to decode parachain head: {e}"))?;

log::debug!(target: LOG_TARGET_SYNC, "Target block reached {:?}", target_block);
let _ = sender.send(target_block);
log::info!(
"🎉 Received finalized parachain header #{} ({}) from the relay chain.",
skunert marked this conversation as resolved.
Show resolved Hide resolved
finalized_header.number(),
finalized_header.hash()
);
skunert marked this conversation as resolved.
Show resolved Hide resolved
let _ = sender.send(finalized_header);
return Ok(())
}
}
Expand Down
Loading