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

Cleanup dependencies + dead code #2302

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Clean up polkadot-service deps
  • Loading branch information
skunert committed Mar 10, 2023
commit 2c651cd35638289f66f4f45d45063471cc087a6a
3 changes: 2 additions & 1 deletion Cargo.lock

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

47 changes: 11 additions & 36 deletions client/relay-chain-minimal-node/src/blockchain_rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ use std::pin::Pin;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainResult};
use cumulus_relay_chain_rpc_interface::RelayChainRpcClient;
use futures::{Future, Stream, StreamExt};
use polkadot_core_primitives::{Block, Hash, Header};
use polkadot_core_primitives::{Block, BlockNumber, Hash, Header};
use polkadot_overseer::RuntimeApiSubsystemClient;
use polkadot_service::{AuxStore, HeaderBackend};
use sc_authority_discovery::AuthorityDiscovery;

use sp_api::{ApiError, RuntimeApiInfo};
use sp_blockchain::Info;
use sp_blockchain::{HeaderBackend, Info};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};

#[derive(Clone)]
pub struct BlockChainRpcClient {
Expand All @@ -46,34 +45,12 @@ impl BlockChainRpcClient {

pub async fn block_get_hash(
&self,
number: Option<polkadot_service::BlockNumber>,
number: Option<BlockNumber>,
) -> Result<Option<Hash>, RelayChainError> {
self.rpc_client.chain_get_block_hash(number).await
}
}

// Implementation required by Availability-Distribution subsystem
// but never called in our case.
impl AuxStore for BlockChainRpcClient {
fn insert_aux<
'a,
'b: 'a,
'c: 'a,
I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
D: IntoIterator<Item = &'a &'b [u8]>,
>(
&self,
_insert: I,
_delete: D,
) -> sp_blockchain::Result<()> {
unimplemented!("Not supported on the RPC collator")
}

fn get_aux(&self, _key: &[u8]) -> sp_blockchain::Result<Option<Vec<u8>>> {
unimplemented!("Not supported on the RPC collator")
}
}

#[async_trait::async_trait]
impl RuntimeApiSubsystemClient for BlockChainRpcClient {
async fn validators(
Expand Down Expand Up @@ -359,8 +336,8 @@ fn block_local<T>(fut: impl Future<Output = T>) -> T {
impl HeaderBackend<Block> for BlockChainRpcClient {
fn header(
&self,
hash: <Block as polkadot_service::BlockT>::Hash,
) -> sp_blockchain::Result<Option<<Block as polkadot_service::BlockT>::Header>> {
hash: <Block as BlockT>::Hash,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Header>> {
Ok(block_local(self.rpc_client.chain_get_header(Some(hash)))?)
}

Expand Down Expand Up @@ -389,7 +366,7 @@ impl HeaderBackend<Block> for BlockChainRpcClient {

fn status(
&self,
hash: <Block as polkadot_service::BlockT>::Hash,
hash: <Block as BlockT>::Hash,
) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
if self.header(hash)?.is_some() {
Ok(sc_client_api::blockchain::BlockStatus::InChain)
Expand All @@ -400,19 +377,17 @@ impl HeaderBackend<Block> for BlockChainRpcClient {

fn number(
&self,
hash: <Block as polkadot_service::BlockT>::Hash,
) -> sp_blockchain::Result<
Option<<<Block as polkadot_service::BlockT>::Header as polkadot_service::HeaderT>::Number>,
> {
hash: <Block as BlockT>::Hash,
) -> sp_blockchain::Result<Option<<<Block as BlockT>::Header as HeaderT>::Number>> {
let result = block_local(self.rpc_client.chain_get_header(Some(hash)))?
.map(|maybe_header| maybe_header.number);
Ok(result)
}

fn hash(
&self,
number: polkadot_service::NumberFor<Block>,
) -> sp_blockchain::Result<Option<<Block as polkadot_service::BlockT>::Hash>> {
number: NumberFor<Block>,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
Ok(block_local(self.rpc_client.chain_get_block_hash(number.into()))?)
}
}
18 changes: 9 additions & 9 deletions client/relay-chain-minimal-node/src/collator_overseer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use cumulus_relay_chain_interface::RelayChainError;
use futures::{select, StreamExt};
use lru::LruCache;
use std::sync::Arc;

use polkadot_node_network_protocol::{
peer_set::PeerSetProtocolNames,
request_response::{
Expand All @@ -25,8 +27,8 @@ use polkadot_node_network_protocol::{
};
use polkadot_node_subsystem_util::metrics::{prometheus::Registry, Metrics};
use polkadot_overseer::{
BlockInfo, DummySubsystem, MetricsTrait, Overseer, OverseerHandle, OverseerMetrics, SpawnGlue,
KNOWN_LEAVES_CACHE_SIZE,
BlockInfo, DummySubsystem, Handle, MetricsTrait, Overseer, OverseerHandle, OverseerMetrics,
SpawnGlue, KNOWN_LEAVES_CACHE_SIZE,
};
use polkadot_primitives::CollatorPair;
use polkadot_service::{
Expand All @@ -37,18 +39,16 @@ use polkadot_service::{
},
Error, OverseerConnector,
};

use sc_authority_discovery::Service as AuthorityDiscoveryService;
use sc_network::NetworkStateInfo;

use std::sync::Arc;
use sc_service::TaskManager;
use sp_runtime::traits::Block as BlockT;

use cumulus_primitives_core::relay_chain::{Block, Hash as PHash};

use polkadot_service::{Handle, TaskManager};
use cumulus_relay_chain_interface::RelayChainError;

use crate::BlockChainRpcClient;
use futures::{select, StreamExt};
use sp_runtime::traits::Block as BlockT;

/// Arguments passed for overseer construction.
pub(crate) struct CollatorOverseerGenArgs<'a> {
Expand Down
8 changes: 3 additions & 5 deletions client/relay-chain-minimal-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ use polkadot_primitives::CollatorPair;
use sc_authority_discovery::Service as AuthorityDiscoveryService;
use sc_network::{Event, NetworkService};
use sc_network_common::service::NetworkEventStream;
use std::sync::Arc;

use polkadot_service::{Configuration, TaskManager};
use sc_service::{Configuration, TaskManager};
use sp_runtime::{app_crypto::Pair, traits::Block as BlockT};

use futures::StreamExt;

use sp_runtime::{app_crypto::Pair, traits::Block as BlockT};
use std::sync::Arc;

mod collator_overseer;

Expand Down
2 changes: 1 addition & 1 deletion client/relay-chain-minimal-node/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use polkadot_core_primitives::{Block, Hash};
use polkadot_service::{BlockT, NumberFor};
use sp_runtime::traits::{Block as BlockT, NumberFor};

use sc_network::NetworkService;

Expand Down
4 changes: 3 additions & 1 deletion client/relay-chain-rpc-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"


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

cumulus-primitives-core = { path = "../../primitives/core" }
cumulus-relay-chain-interface = { path = "../relay-chain-interface" }
Expand All @@ -19,6 +19,8 @@ sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }

tokio = { version = "1.25.0", features = ["sync"] }

futures = "0.3.26"
Expand Down
3 changes: 2 additions & 1 deletion client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use cumulus_primitives_core::{
};
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use futures::{FutureExt, Stream, StreamExt};
use polkadot_service::Handle;
use polkadot_overseer::Handle;

use sc_client_api::StorageProof;
use sp_core::sp_std::collections::btree_map::BTreeMap;
use sp_state_machine::StorageValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use jsonrpsee::{
ws_client::WsClientBuilder,
};
use lru::LruCache;
use polkadot_service::TaskManager;
use sc_service::TaskManager;
use std::{num::NonZeroUsize, sync::Arc};
use tokio::sync::mpsc::{
channel as tokio_channel, Receiver as TokioReceiver, Sender as TokioSender,
Expand Down
33 changes: 18 additions & 15 deletions client/relay-chain-rpc-interface/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use crate::reconnecting_ws_client::ReconnectingWsClient;
use futures::channel::mpsc::Receiver;
use jsonrpsee::{core::params::ArrayParams, rpc_params};
use parity_scale_codec::{Decode, Encode};
use serde::de::DeserializeOwned;
pub use url::Url;

use sc_client_api::StorageData;
use sc_rpc_api::{state::ReadProof, system::Health};
use sc_service::TaskManager;
use sp_api::RuntimeVersion;
use sp_consensus_babe::Epoch;
use sp_core::sp_std::collections::btree_map::BTreeMap;
use sp_storage::StorageKey;

use cumulus_primitives_core::{
relay_chain::{
vstaging::ExecutorParams, CandidateCommitments, CandidateEvent, CandidateHash,
vstaging::ExecutorParams, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash,
CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash as RelayHash,
Header as RelayHeader, InboundHrmpMessage, OccupiedCoreAssumption, PvfCheckStatement,
ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash,
Expand All @@ -26,18 +39,8 @@ use cumulus_primitives_core::{
InboundDownwardMessage, ParaId, PersistedValidationData,
};
use cumulus_relay_chain_interface::{RelayChainError, RelayChainResult};
use futures::channel::mpsc::Receiver;
use jsonrpsee::{core::params::ArrayParams, rpc_params};
use parity_scale_codec::{Decode, Encode};
use polkadot_service::{BlockNumber, TaskManager};
use sc_client_api::StorageData;
use sc_rpc_api::{state::ReadProof, system::Health};
use serde::de::DeserializeOwned;
use sp_api::RuntimeVersion;
use sp_consensus_babe::Epoch;
use sp_core::sp_std::collections::btree_map::BTreeMap;
use sp_storage::StorageKey;
pub use url::Url;

use crate::reconnecting_ws_client::ReconnectingWsClient;

const LOG_TARGET: &str = "relay-chain-rpc-client";

Expand Down Expand Up @@ -261,7 +264,7 @@ impl RelayChainRpcClient {
/// Get hash of n-th block.
pub async fn chain_get_block_hash(
&self,
block_number: Option<polkadot_service::BlockNumber>,
block_number: Option<BlockNumber>,
) -> Result<Option<RelayHash>, RelayChainError> {
let params = rpc_params![block_number];
self.request("chain_getBlockHash", params).await
Expand Down