diff --git a/Cargo.lock b/Cargo.lock index 85a361e944b..91fa8c5a72b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2332,13 +2332,16 @@ dependencies = [ "cumulus-relay-chain-rpc-interface", "futures", "lru 0.9.0", + "polkadot-availability-recovery", + "polkadot-collator-protocol", "polkadot-core-primitives", "polkadot-network-bridge", + "polkadot-node-collation-generation", + "polkadot-node-core-runtime-api", "polkadot-node-network-protocol", "polkadot-node-subsystem-util", "polkadot-overseer", "polkadot-primitives", - "polkadot-service", "sc-authority-discovery", "sc-client-api", "sc-network", diff --git a/client/relay-chain-interface/src/lib.rs b/client/relay-chain-interface/src/lib.rs index db4fd24c64f..3629aea84cd 100644 --- a/client/relay-chain-interface/src/lib.rs +++ b/client/relay-chain-interface/src/lib.rs @@ -46,7 +46,9 @@ pub enum RelayChainError { WaitTimeout(PHash), #[error("Import listener closed while waiting for relay-chain block `{0}` to be imported.")] ImportListenerClosed(PHash), - #[error("Blockchain returned an error while waiting for relay-chain block `{0}` to be imported: {1}")] + #[error( + "Blockchain returned an error while waiting for relay-chain block `{0}` to be imported: {1}" + )] WaitBlockchainError(PHash, sp_blockchain::Error), #[error("Blockchain returned an error: {0}")] BlockchainError(#[from] sp_blockchain::Error), @@ -86,6 +88,12 @@ impl From for sp_blockchain::Error { } } +impl From> for RelayChainError { + fn from(r: Box) -> Self { + RelayChainError::Application(r) + } +} + /// Trait that provides all necessary methods for interaction between collator and relay chain. #[async_trait] pub trait RelayChainInterface: Send + Sync { diff --git a/client/relay-chain-minimal-node/Cargo.toml b/client/relay-chain-minimal-node/Cargo.toml index 737445c30c1..ff8d8bc11d3 100644 --- a/client/relay-chain-minimal-node/Cargo.toml +++ b/client/relay-chain-minimal-node/Cargo.toml @@ -9,10 +9,14 @@ edition = "2021" polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" } -polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-node-subsystem-util = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-node-network-protocol = { git = "https://github.com/paritytech/polkadot", branch = "master" } + +polkadot-availability-recovery = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-collator-protocol = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-network-bridge = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-node-collation-generation = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-node-core-runtime-api = { git = "https://github.com/paritytech/polkadot", branch = "master" } # substrate deps sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/client/relay-chain-minimal-node/src/collator_overseer.rs b/client/relay-chain-minimal-node/src/collator_overseer.rs index 9bcbc2a67a8..bd3dfa8e0f8 100644 --- a/client/relay-chain-minimal-node/src/collator_overseer.rs +++ b/client/relay-chain-minimal-node/src/collator_overseer.rs @@ -18,6 +18,14 @@ use futures::{select, StreamExt}; use lru::LruCache; use std::sync::Arc; +use polkadot_availability_recovery::AvailabilityRecoverySubsystem; +use polkadot_collator_protocol::{CollatorProtocolSubsystem, ProtocolSide}; +use polkadot_network_bridge::{ + Metrics as NetworkBridgeMetrics, NetworkBridgeRx as NetworkBridgeRxSubsystem, + NetworkBridgeTx as NetworkBridgeTxSubsystem, +}; +use polkadot_node_collation_generation::CollationGenerationSubsystem; +use polkadot_node_core_runtime_api::RuntimeApiSubsystem; use polkadot_node_network_protocol::{ peer_set::PeerSetProtocolNames, request_response::{ @@ -27,18 +35,10 @@ use polkadot_node_network_protocol::{ }; use polkadot_node_subsystem_util::metrics::{prometheus::Registry, Metrics}; use polkadot_overseer::{ - BlockInfo, DummySubsystem, Handle, MetricsTrait, Overseer, OverseerHandle, OverseerMetrics, - SpawnGlue, KNOWN_LEAVES_CACHE_SIZE, + BlockInfo, DummySubsystem, Handle, Overseer, OverseerConnector, OverseerHandle, SpawnGlue, + KNOWN_LEAVES_CACHE_SIZE, }; use polkadot_primitives::CollatorPair; -use polkadot_service::{ - overseer::{ - AvailabilityRecoverySubsystem, CollationGenerationSubsystem, CollatorProtocolSubsystem, - NetworkBridgeMetrics, NetworkBridgeRxSubsystem, NetworkBridgeTxSubsystem, ProtocolSide, - RuntimeApiSubsystem, - }, - Error, OverseerConnector, -}; use sc_authority_discovery::Service as AuthorityDiscoveryService; use sc_network::NetworkStateInfo; @@ -93,9 +93,8 @@ fn build_overseer<'a>( }: CollatorOverseerGenArgs<'a>, ) -> Result< (Overseer, Arc>, OverseerHandle), - Error, + RelayChainError, > { - let metrics = ::register(registry)?; let spawner = SpawnGlue(spawner); let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?; let builder = Overseer::builder() @@ -153,17 +152,19 @@ fn build_overseer<'a>( .active_leaves(Default::default()) .supports_parachains(runtime_client) .known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE)) - .metrics(metrics) + .metrics(Metrics::register(registry)?) .spawner(spawner); - builder.build_with_connector(connector).map_err(|e| e.into()) + builder + .build_with_connector(connector) + .map_err(|e| RelayChainError::Application(e.into())) } pub(crate) fn spawn_overseer( overseer_args: CollatorOverseerGenArgs, task_manager: &TaskManager, relay_chain_rpc_client: Arc, -) -> Result { +) -> Result { let (overseer, overseer_handle) = build_overseer(OverseerConnector::default(), overseer_args) .map_err(|e| { tracing::error!("Failed to initialize overseer: {}", e); diff --git a/client/relay-chain-minimal-node/src/lib.rs b/client/relay-chain-minimal-node/src/lib.rs index 90afd31b8b6..102a8582745 100644 --- a/client/relay-chain-minimal-node/src/lib.rs +++ b/client/relay-chain-minimal-node/src/lib.rs @@ -181,8 +181,7 @@ async fn new_minimal_relay_chain( }; let overseer_handle = - collator_overseer::spawn_overseer(overseer_args, &task_manager, relay_chain_rpc_client) - .map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?; + collator_overseer::spawn_overseer(overseer_args, &task_manager, relay_chain_rpc_client)?; network_starter.start_network();