Skip to content

Commit

Permalink
rialto: use upstream polkadot_client::RuntimeApiCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
acatangiu committed Nov 30, 2021
1 parent 2f19d3d commit 0cbfb98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 53 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions bin/rialto/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "mast
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot Dependencies

polkadot-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }

# Polkadot (parachain) Dependencies

polkadot-approval-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
Expand Down
58 changes: 5 additions & 53 deletions bin/rialto/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use crate::overseer::{OverseerGen, OverseerGenArgs};

use polkadot_client::RuntimeApiCollection;
use polkadot_node_core_approval_voting::Config as ApprovalVotingConfig;
use polkadot_node_core_av_store::Config as AvailabilityConfig;
use polkadot_node_core_candidate_validation::Config as CandidateValidationConfig;
Expand All @@ -37,7 +38,7 @@ use sc_service::{config::PrometheusConfig, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_api::{ConstructRuntimeApi, HeaderT};
use sp_consensus::SelectChain;
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};
use sp_runtime::traits::Block as BlockT;
use std::{sync::Arc, time::Duration};
use substrate_prometheus_endpoint::Registry;

Expand Down Expand Up @@ -109,55 +110,6 @@ type FullBabeBlockImport =
type FullBabeLink = sc_consensus_babe::BabeLink<Block>;
type FullGrandpaLink = sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>;

/// A set of APIs that polkadot-like runtimes must implement.
///
/// This is a copy of `polkadot_service::RuntimeApiCollection`.
pub trait RequiredApiCollection:
sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::ApiExt<Block>
+ sp_consensus_babe::BabeApi<Block>
+ sp_finality_grandpa::GrandpaApi<Block>
+ polkadot_primitives::v1::ParachainHost<Block>
+ sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<
Block,
bp_rialto::AccountId,
rialto_runtime::Index,
> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, bp_rialto::Balance>
+ pallet_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>
+ beefy_primitives::BeefyApi<Block>
where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
}

impl<Api> RequiredApiCollection for Api
where
Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::ApiExt<Block>
+ sp_consensus_babe::BabeApi<Block>
+ sp_finality_grandpa::GrandpaApi<Block>
+ polkadot_primitives::v1::ParachainHost<Block>
+ sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<
Block,
bp_rialto::AccountId,
rialto_runtime::Index,
> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, bp_rialto::Balance>
+ pallet_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>
+ beefy_primitives::BeefyApi<Block>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
}

// If we're using prometheus, use a registry with a prefix of `polkadot`.
fn set_prometheus_registry(config: &mut Configuration) -> Result<(), Error> {
if let Some(PrometheusConfig { registry, .. }) = config.prometheus_config.as_mut() {
Expand Down Expand Up @@ -199,7 +151,7 @@ pub fn new_partial(
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient> + Send + Sync + 'static,
<RuntimeApi as ConstructRuntimeApi<Block, FullClient>>::RuntimeApi:
RequiredApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
ExecutorDispatch: NativeExecutionDispatch + 'static,
{
set_prometheus_registry(config)?;
Expand Down Expand Up @@ -377,7 +329,7 @@ async fn active_leaves(
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient> + Send + Sync + 'static,
<RuntimeApi as ConstructRuntimeApi<Block, FullClient>>::RuntimeApi:
RequiredApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
ExecutorDispatch: NativeExecutionDispatch + 'static,
{
let best_block = select_chain.best_chain().await?;
Expand Down Expand Up @@ -422,7 +374,7 @@ pub fn new_full(
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient> + Send + Sync + 'static,
<RuntimeApi as ConstructRuntimeApi<Block, FullClient>>::RuntimeApi:
RequiredApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
ExecutorDispatch: NativeExecutionDispatch + 'static,
{
let is_collator = false;
Expand Down

0 comments on commit 0cbfb98

Please sign in to comment.