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

relay-chain-interface: Do not depend on polkadot-service #2287

Merged
merged 1 commit into from
Mar 7, 2023
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
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ pub fn build_inprocess_relay_chain(
parachain_config,
telemetry_worker_handle,
hwbench,
)?;
)
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;

let relay_chain_interface_builder = RelayChainInProcessInterfaceBuilder {
polkadot_client: full_node.client.clone(),
Expand Down
1 change: 0 additions & 1 deletion client/relay-chain-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"

[dependencies]
polkadot-overseer = { git = "/~https://github.com/paritytech/polkadot", branch = "master" }
polkadot-service = { git = "/~https://github.com/paritytech/polkadot", branch = "master" }

cumulus-primitives-core = { path = "../../primitives/core" }

Expand Down
7 changes: 2 additions & 5 deletions client/relay-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use std::{collections::BTreeMap, pin::Pin, sync::Arc};

use polkadot_overseer::prometheus::PrometheusError;
use polkadot_service::SubstrateServiceError;
use sc_client_api::StorageProof;

use futures::Stream;
Expand Down Expand Up @@ -61,10 +60,8 @@ pub enum RelayChainError {
WorkerCommunicationError(String),
#[error("Scale codec deserialization error: {0}")]
DeserializationError(CodecError),
#[error("Polkadot service error: {0}")]
ServiceError(#[from] polkadot_service::Error),
#[error("Substrate service error: {0}")]
SubServiceError(#[from] SubstrateServiceError),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also get that inner error from sc_service without including Polkadot, but it dont have a strong opinion on this code.

#[error(transparent)]
Application(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
#[error("Prometheus error: {0}")]
PrometheusError(#[from] PrometheusError),
#[error("Unspecified error occured: {0}")]
Expand Down
6 changes: 4 additions & 2 deletions client/relay-chain-minimal-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ async fn new_minimal_relay_chain(
client: relay_chain_rpc_client.clone(),
spawn_handle: task_manager.spawn_handle(),
genesis_hash,
})?;
})
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;

let authority_discovery_service = build_authority_discovery_service(
&task_manager,
Expand Down Expand Up @@ -186,7 +187,8 @@ async fn new_minimal_relay_chain(
overseer_args,
&task_manager,
relay_chain_rpc_client.clone(),
)?;
)
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;

network_starter.start_network();

Expand Down
7 changes: 2 additions & 5 deletions parachain-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use cumulus_client_service::{
start_full_node, BuildNetworkParams, StartCollatorParams, StartFullNodeParams,
};
use cumulus_primitives_core::ParaId;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
use cumulus_relay_chain_interface::RelayChainInterface;

// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
Expand Down Expand Up @@ -162,10 +162,7 @@ async fn start_node_impl(
hwbench.clone(),
)
.await
.map_err(|e| match e {
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
s => s.to_string().into(),
})?;
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;

let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority();
Expand Down
17 changes: 4 additions & 13 deletions polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use cumulus_primitives_core::{
relay_chain::{Hash as PHash, PersistedValidationData},
ParaId,
};
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
use cumulus_relay_chain_interface::RelayChainInterface;
use sp_core::Pair;

use jsonrpsee::RpcModule;
Expand Down Expand Up @@ -383,10 +383,7 @@ where
hwbench.clone(),
)
.await
.map_err(|e| match e {
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
s => s.to_string().into(),
})?;
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;

let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority();
Expand Down Expand Up @@ -573,10 +570,7 @@ where
hwbench.clone(),
)
.await
.map_err(|e| match e {
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
s => s.to_string().into(),
})?;
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;

let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority();
Expand Down Expand Up @@ -1346,10 +1340,7 @@ where
hwbench.clone(),
)
.await
.map_err(|e| match e {
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
s => s.to_string().into(),
})?;
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;

let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority();
Expand Down
8 changes: 3 additions & 5 deletions test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ async fn build_relay_chain_interface(
polkadot_service::IsCollator::Yes(CollatorPair::generate().0)
},
None,
)?;
)
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;

task_manager.add_child(relay_chain_full_node.task_manager);
tracing::info!("Using inprocess node.");
Expand Down Expand Up @@ -309,10 +310,7 @@ where
&mut task_manager,
)
.await
.map_err(|e| match e {
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
s => s.to_string().into(),
})?;
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;

let import_queue_service = params.import_queue.service();
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
Expand Down