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

Commit 6d1ac27

Browse files
committed
relay-chain-interface: Do not depend on polkadot-service (#2287)
1 parent 3275e27 commit 6d1ac27

File tree

8 files changed

+17
-33
lines changed

8 files changed

+17
-33
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/relay-chain-inprocess-interface/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ pub fn build_inprocess_relay_chain(
367367
parachain_config,
368368
telemetry_worker_handle,
369369
hwbench,
370-
)?;
370+
)
371+
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;
371372

372373
let sync_oracle: Arc<dyn SyncOracle + Send + Sync> = Arc::new(full_node.network.clone());
373374
let relay_chain_interface_builder = RelayChainInProcessInterfaceBuilder {

client/relay-chain-interface/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2021"
66

77
[dependencies]
88
polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" }
9-
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" }
109

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

client/relay-chain-interface/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use std::{collections::BTreeMap, pin::Pin, sync::Arc};
1818

1919
use polkadot_overseer::prometheus::PrometheusError;
20-
use polkadot_service::SubstrateServiceError;
2120
use sc_client_api::StorageProof;
2221

2322
use futures::Stream;
@@ -61,10 +60,8 @@ pub enum RelayChainError {
6160
WorkerCommunicationError(String),
6261
#[error("Scale codec deserialization error: {0}")]
6362
DeserializationError(CodecError),
64-
#[error("Polkadot service error: {0}")]
65-
ServiceError(#[from] polkadot_service::Error),
66-
#[error("Substrate service error: {0}")]
67-
SubServiceError(#[from] SubstrateServiceError),
63+
#[error(transparent)]
64+
Application(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
6865
#[error("Prometheus error: {0}")]
6966
PrometheusError(#[from] PrometheusError),
7067
#[error("Unspecified error occured: {0}")]

client/relay-chain-minimal-node/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ async fn new_minimal_relay_chain(
158158
client: relay_chain_rpc_client.clone(),
159159
spawn_handle: task_manager.spawn_handle(),
160160
genesis_hash,
161-
})?;
161+
})
162+
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;
162163

163164
let authority_discovery_service = build_authority_discovery_service(
164165
&task_manager,
@@ -185,7 +186,8 @@ async fn new_minimal_relay_chain(
185186
overseer_args,
186187
&task_manager,
187188
relay_chain_rpc_client.clone(),
188-
)?;
189+
)
190+
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;
189191

190192
network_starter.start_network();
191193

parachain-template/node/src/service.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cumulus_client_service::{
1818
StartCollatorParams, StartFullNodeParams,
1919
};
2020
use cumulus_primitives_core::ParaId;
21-
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
21+
use cumulus_relay_chain_interface::RelayChainInterface;
2222

2323
// Substrate Imports
2424
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
@@ -163,10 +163,7 @@ async fn start_node_impl(
163163
hwbench.clone(),
164164
)
165165
.await
166-
.map_err(|e| match e {
167-
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
168-
s => s.to_string().into(),
169-
})?;
166+
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
170167

171168
let block_announce_validator =
172169
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);

polkadot-parachain/src/service.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use cumulus_primitives_core::{
2929
relay_chain::{Hash as PHash, PersistedValidationData},
3030
ParaId,
3131
};
32-
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
32+
use cumulus_relay_chain_interface::RelayChainInterface;
3333
use sp_core::Pair;
3434

3535
use jsonrpsee::RpcModule;
@@ -385,10 +385,7 @@ where
385385
hwbench.clone(),
386386
)
387387
.await
388-
.map_err(|e| match e {
389-
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
390-
s => s.to_string().into(),
391-
})?;
388+
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
392389

393390
let block_announce_validator =
394391
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
@@ -572,10 +569,7 @@ where
572569
hwbench.clone(),
573570
)
574571
.await
575-
.map_err(|e| match e {
576-
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
577-
s => s.to_string().into(),
578-
})?;
572+
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
579573

580574
let block_announce_validator =
581575
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
@@ -1346,10 +1340,7 @@ where
13461340
hwbench.clone(),
13471341
)
13481342
.await
1349-
.map_err(|e| match e {
1350-
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
1351-
s => s.to_string().into(),
1352-
})?;
1343+
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
13531344

13541345
let block_announce_validator =
13551346
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);

test/service/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ async fn build_relay_chain_interface(
212212
polkadot_service::IsCollator::Yes(CollatorPair::generate().0)
213213
},
214214
None,
215-
)?;
215+
)
216+
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;
216217

217218
task_manager.add_child(relay_chain_full_node.task_manager);
218219
tracing::info!("Using inprocess node.");
@@ -268,10 +269,7 @@ where
268269
&mut task_manager,
269270
)
270271
.await
271-
.map_err(|e| match e {
272-
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
273-
s => s.to_string().into(),
274-
})?;
272+
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
275273

276274
let block_announce_validator =
277275
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);

0 commit comments

Comments
 (0)