Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Cleanup: Remove polkadot-service dependency from minimal node #2430

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion Cargo.lock

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

10 changes: 9 additions & 1 deletion client/relay-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -86,6 +88,12 @@ impl From<RelayChainError> for sp_blockchain::Error {
}
}

impl<T: std::error::Error + Send + Sync + 'static> From<Box<T>> for RelayChainError {
fn from(r: Box<T>) -> Self {
RelayChainError::Application(r)
}
}

/// Trait that provides all necessary methods for interaction between collator and relay chain.
#[async_trait]
pub trait RelayChainInterface: Send + Sync {
Expand Down
6 changes: 5 additions & 1 deletion client/relay-chain-minimal-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
32 changes: 17 additions & 15 deletions client/relay-chain-minimal-node/src/collator_overseer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ use futures::{select, StreamExt};
use lru::LruCache;
use std::sync::Arc;

use polkadot_availability_recovery::AvailabilityRecoverySubsystem;
use polkadot_collator_protocol::CollatorProtocolSubsystem;
use polkadot_collator_protocol::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::{
Expand All @@ -27,18 +36,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, MetricsTrait, Overseer, OverseerConnector, OverseerHandle,
OverseerMetrics, 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;
Expand Down Expand Up @@ -93,9 +94,8 @@ fn build_overseer<'a>(
}: CollatorOverseerGenArgs<'a>,
) -> Result<
(Overseer<SpawnGlue<sc_service::SpawnTaskHandle>, Arc<BlockChainRpcClient>>, OverseerHandle),
Error,
RelayChainError,
> {
let metrics = <OverseerMetrics as MetricsTrait>::register(registry)?;
let spawner = SpawnGlue(spawner);
let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?;
let builder = Overseer::builder()
Expand Down Expand Up @@ -153,17 +153,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<BlockChainRpcClient>,
) -> Result<polkadot_overseer::Handle, polkadot_service::Error> {
) -> Result<polkadot_overseer::Handle, RelayChainError> {
let (overseer, overseer_handle) = build_overseer(OverseerConnector::default(), overseer_args)
.map_err(|e| {
tracing::error!("Failed to initialize overseer: {}", e);
Expand Down
3 changes: 1 addition & 2 deletions client/relay-chain-minimal-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down