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

Commit

Permalink
relay-chain-interface: Do not depend on polkadot-service (#2287)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr committed Mar 9, 2023
1 parent 3275e27 commit 6d1ac27
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 33 deletions.
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 sync_oracle: Arc<dyn SyncOracle + Send + Sync> = Arc::new(full_node.network.clone());
let relay_chain_interface_builder = RelayChainInProcessInterfaceBuilder {
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 = "release-v0.9.38" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" }

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),
#[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 All @@ -185,7 +186,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 @@ -18,7 +18,7 @@ use cumulus_client_service::{
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 @@ -163,10 +163,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 block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
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 @@ -29,7 +29,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 @@ -385,10 +385,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 block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
Expand Down Expand Up @@ -572,10 +569,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 block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
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 block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
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 @@ -212,7 +212,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 @@ -268,10 +269,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 block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
Expand Down

0 comments on commit 6d1ac27

Please sign in to comment.