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

* Remove polkadot-service dependency from minimal-node

* Clean up error handline

* Remove unwanted changes

* Unused deps
This commit is contained in:
Sebastian Kunert
2023-04-04 17:05:38 +02:00
committed by GitHub
parent eaf6c45445
commit 6c896b1ee6
5 changed files with 35 additions and 20 deletions
+4 -1
View File
@@ -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",
@@ -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<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 {
@@ -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" }
@@ -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<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()
@@ -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<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);
@@ -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();