Companion PR for Remove the service builder (#1448)

* Switch branch

* Update branch

* Change service code

* Change light service stuff to be functions ^_^

* Update substrate branch

* Remove accidental 'f'

* Rework LightBackend/LightClient types

* Update substrate branch

* Remove unused imports in test-service

* Add #[cfg(feature = full-node)]
This commit is contained in:
Ashley
2020-07-23 14:12:53 +02:00
committed by GitHub
parent 6a1fbae2df
commit 6919c3030c
4 changed files with 1182 additions and 1261 deletions
+269 -314
View File
File diff suppressed because it is too large Load Diff
+217 -199
View File
@@ -23,8 +23,7 @@ mod client;
use std::sync::Arc;
use std::time::Duration;
use polkadot_primitives::v1::{AccountId, Nonce, Balance};
#[cfg(feature = "full-node")]
use service::{error::Error as ServiceError, ServiceBuilder};
use service::{error::Error as ServiceError};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use sc_executor::native_executor_instance;
use log::info;
@@ -93,7 +92,7 @@ pub trait RuntimeApiCollection<Extrinsic: codec::Codec + Send + Sync + 'static>:
+ authority_discovery_primitives::AuthorityDiscoveryApi<Block>
where
Extrinsic: RuntimeExtrinsic,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<HashFor<Block>>,
{}
impl<Api, Extrinsic> RuntimeApiCollection<Extrinsic> for Api
@@ -111,7 +110,7 @@ where
+ sp_session::SessionKeys<Block>
+ authority_discovery_primitives::AuthorityDiscoveryApi<Block>,
Extrinsic: RuntimeExtrinsic,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<HashFor<Block>>,
{}
pub trait RuntimeExtrinsic: codec::Codec + Send + Sync + 'static {}
@@ -145,47 +144,67 @@ fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceErro
Ok(())
}
/// Starts a `ServiceBuilder` for a full service.
///
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
macro_rules! new_full_start {
($config:expr, $runtime:ty, $executor:ty) => {{
set_prometheus_registry(&mut $config)?;
type FullBackend = service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
type FullClient<RuntimeApi, Executor> = service::TFullClient<Block, RuntimeApi, Executor>;
type FullGrandpaBlockImport<RuntimeApi, Executor> = grandpa::GrandpaBlockImport<
FullBackend, Block, FullClient<RuntimeApi, Executor>, FullSelectChain
>;
type LightBackend = service::TLightBackendWithHash<Block, sp_runtime::traits::BlakeTwo256>;
type LightClient<RuntimeApi, Executor> =
service::TLightClientWithBackend<Block, RuntimeApi, Executor, LightBackend>;
#[cfg(feature = "full-node")]
fn full_params<RuntimeApi, Executor, Extrinsic>(mut config: Configuration) -> Result<(
service::ServiceParams<
Block,
FullClient<RuntimeApi, Executor>,
babe::BabeImportQueue<Block, FullClient<RuntimeApi, Executor>>,
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, Executor>>,
polkadot_rpc::RpcExtension,
FullBackend,
>,
FullSelectChain,
(
babe::BabeBlockImport<
Block, FullClient<RuntimeApi, Executor>, FullGrandpaBlockImport<RuntimeApi, Executor>
>,
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
babe::BabeLink<Block>
),
inherents::InherentDataProviders,
grandpa::SharedVoterState,
), Error>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
set_prometheus_registry(&mut config)?;
let mut import_setup = None;
let mut rpc_setup = None;
let inherent_data_providers = inherents::InherentDataProviders::new();
let builder = service::ServiceBuilder::new_full::<
Block, $runtime, $executor
>($config)?
.with_select_chain(|_, backend| {
Ok(sc_consensus::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|builder| {
let (client, backend, keystore, task_manager) =
service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
let client = Arc::new(client);
let select_chain = sc_consensus::LongestChain::new(backend.clone());
let pool_api = sc_transaction_pool::FullChainApi::new(
builder.client().clone(),
builder.prometheus_registry(),
client.clone(), config.prometheus_registry(),
);
let pool = sc_transaction_pool::BasicPool::new_full(
builder.config().transaction_pool.clone(),
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
std::sync::Arc::new(pool_api),
builder.prometheus_registry(),
builder.spawn_handle(),
builder.client().clone(),
config.prometheus_registry(),
task_manager.spawn_handle(),
client.clone(),
);
Ok(pool)
})?
.with_import_queue(|
config,
client,
mut select_chain,
_,
spawn_task_handle,
registry,
| {
let select_chain = select_chain.take()
.ok_or_else(|| service::Error::SelectChainRequired)?;
let grandpa_hard_forks = if config.chain_spec.is_kusama() {
grandpa_support::kusama_hard_forks()
@@ -214,41 +233,32 @@ macro_rules! new_full_start {
block_import.clone(),
Some(Box::new(justification_import)),
None,
client,
select_chain,
client.clone(),
select_chain.clone(),
inherent_data_providers.clone(),
spawn_task_handle,
registry,
&task_manager.spawn_handle(),
config.prometheus_registry(),
)?;
import_setup = Some((block_import, grandpa_link, babe_link));
Ok(import_queue)
})?
.with_rpc_extensions_builder(|builder| {
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();
rpc_setup = Some((shared_voter_state.clone()));
let babe_link = import_setup.as_ref().map(|s| &s.2)
.expect("BabeLink is present for full services or set up faile; qed.");
let import_setup = (block_import.clone(), grandpa_link, babe_link.clone());
let rpc_setup = shared_voter_state.clone();
let babe_config = babe_link.config().clone();
let shared_epoch_changes = babe_link.epoch_changes().clone();
let client = builder.client().clone();
let pool = builder.pool().clone();
let select_chain = builder.select_chain().cloned()
.expect("SelectChain is present for full services or set up failed; qed.");
let keystore = builder.keystore().clone();
let rpc_extensions_builder = {
let client = client.clone();
let keystore = keystore.clone();
let transaction_pool = transaction_pool.clone();
let select_chain = select_chain.clone();
Ok(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
Box::new(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
let deps = polkadot_rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
pool: transaction_pool.clone(),
select_chain: select_chain.clone(),
deny_unsafe,
babe: polkadot_rpc::BabeDeps {
@@ -264,10 +274,22 @@ macro_rules! new_full_start {
polkadot_rpc::create_full(deps)
})
})?;
};
(builder, import_setup, inherent_data_providers, rpc_setup)
}}
let provider = client.clone() as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
let finality_proof_provider = Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider)) as _;
let params = service::ServiceParams {
config, backend, client, import_queue, keystore, task_manager, rpc_extensions_builder,
transaction_pool,
block_announce_validator_builder: None,
finality_proof_provider: Some(finality_proof_provider),
finality_proof_request_builder: None,
on_demand: None,
remote_blockchain: None,
};
Ok((params, select_chain, import_setup, inherent_data_providers, rpc_setup))
}
fn real_overseer<S: SpawnNamed>(
@@ -294,49 +316,54 @@ fn real_overseer<S: SpawnNamed>(
).map_err(|e| ServiceError::Other(format!("Failed to create an Overseer: {:?}", e)))
}
/// Builds a new service for a full client.
#[macro_export]
macro_rules! new_full {
(
$config:expr,
$collating_for:expr,
$authority_discovery_disabled:expr,
$grandpa_pause:expr,
$runtime:ty,
$dispatch:ty,
) => {{
#[cfg(feature = "full-node")]
fn new_full<RuntimeApi, Executor, Extrinsic>(
config: Configuration,
collating_for: Option<(CollatorId, ParaId)>,
_max_block_data_size: Option<u64>,
_authority_discovery_disabled: bool,
_slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
) -> Result<(
TaskManager,
Arc<FullClient<RuntimeApi, Executor>>,
), Error>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
use sc_client_api::ExecutorProvider;
use sp_core::traits::BareCryptoStorePtr;
let is_collator = $collating_for.is_some();
let role = $config.role.clone();
let is_collator = collating_for.is_some();
let role = config.role.clone();
let is_authority = role.is_authority() && !is_collator;
let force_authoring = $config.force_authoring;
let disable_grandpa = $config.disable_grandpa;
let name = $config.network.node_name.clone();
let force_authoring = config.force_authoring;
let disable_grandpa = config.disable_grandpa;
let name = config.network.node_name.clone();
let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) =
new_full_start!($config, $runtime, $dispatch);
let (params, select_chain, import_setup, inherent_data_providers, rpc_setup)
= full_params::<RuntimeApi, Executor, Extrinsic>(config)?;
let client = params.client.clone();
let keystore = params.keystore.clone();
let transaction_pool = params.transaction_pool.clone();
let prometheus_registry = params.config.prometheus_registry().cloned();
let ServiceComponents {
client, network, select_chain, keystore, transaction_pool, prometheus_registry,
task_manager, telemetry_on_connect_sinks, ..
} = builder
.with_finality_proof_provider(|client, backend| {
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build_full()?;
network, task_manager, telemetry_on_connect_sinks, ..
} = service::build(params)?;
let (block_import, link_half, babe_link) = import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
let (block_import, link_half, babe_link) = import_setup;
let shared_voter_state = rpc_setup.take()
.expect("The SharedVoterState is present for Full Services or setup failed before. qed");
let shared_voter_state = rpc_setup;
let overseer_client = client.clone();
let spawner = task_manager.spawn_handle();
let leaves: Vec<_> = select_chain.clone().ok_or(ServiceError::SelectChainRequired)?
let leaves: Vec<_> = select_chain.clone()
.leaves()
.unwrap_or_else(|_| vec![])
.into_iter()
@@ -376,7 +403,6 @@ macro_rules! new_full {
}));
if role.is_authority() {
let select_chain = select_chain.ok_or(ServiceError::SelectChainRequired)?;
let can_author_with =
consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone());
@@ -433,7 +459,7 @@ macro_rules! new_full {
// add a custom voting rule to temporarily stop voting for new blocks
// after the given pause block is finalized and restarting after the
// given delay.
let voting_rule = match $grandpa_pause {
let voting_rule = match grandpa_pause {
Some((block, delay)) => {
info!("GRANDPA scheduled voting pause set for block #{} with a duration of {} blocks.",
block,
@@ -472,57 +498,42 @@ macro_rules! new_full {
)?;
}
(task_manager, client)
}}
Ok((task_manager, client))
}
pub struct FullNodeHandles;
/// Builds a new service for a light client.
#[macro_export]
macro_rules! new_light {
($config:expr, $runtime:ty, $dispatch:ty) => {{
crate::set_prometheus_registry(&mut $config)?;
let inherent_data_providers = inherents::InherentDataProviders::new();
fn new_light<Runtime, Dispatch, Extrinsic>(mut config: Configuration) -> Result<TaskManager, Error>
where
Runtime: 'static + Send + Sync + ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>,
<Runtime as ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>>::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<LightBackend, Block>>,
Dispatch: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
crate::set_prometheus_registry(&mut config)?;
use sc_client_api::backend::RemoteBackend;
let (client, backend, keystore, task_manager, on_demand) =
service::new_light_parts::<Block, Runtime, Dispatch>(&config)?;
let select_chain = sc_consensus::LongestChain::new(backend.clone());
ServiceBuilder::new_light::<Block, $runtime, $dispatch>($config)?
.with_select_chain(|_, backend| {
Ok(sc_consensus::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|builder| {
let fetcher = builder.fetcher()
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = sc_transaction_pool::LightChainApi::new(
builder.client().clone(),
fetcher,
client.clone(),
on_demand.clone(),
);
let pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
builder.config().transaction_pool.clone(),
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
config.transaction_pool.clone(),
Arc::new(pool_api),
builder.prometheus_registry(),
builder.spawn_handle(),
config.prometheus_registry(),
task_manager.spawn_handle(),
));
Ok(pool)
})?
.with_import_queue_and_fprb(|
_config,
client,
backend,
fetcher,
mut select_chain,
_,
spawn_task_handle,
registry,
| {
let select_chain = select_chain.take()
.ok_or_else(|| service::Error::SelectChainRequired)?;
let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
let grandpa_block_import = grandpa::light_block_import(
client.clone(), backend, &(client.clone() as Arc<_>), Arc::new(fetch_checker)
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
Arc::new(on_demand.checker().clone()),
)?;
let finality_proof_import = grandpa_block_import.clone();
@@ -535,94 +546,101 @@ macro_rules! new_light {
client.clone(),
)?;
let inherent_data_providers = inherents::InherentDataProviders::new();
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
let import_queue = babe::import_queue(
babe_link,
babe_block_import,
None,
Some(Box::new(finality_proof_import)),
client,
select_chain,
client.clone(),
select_chain.clone(),
inherent_data_providers.clone(),
spawn_task_handle,
registry,
&task_manager.spawn_handle(),
config.prometheus_registry(),
)?;
Ok((import_queue, finality_proof_request_builder))
})?
.with_finality_proof_provider(|client, backend| {
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _)
})?
.with_rpc_extensions(|builder| {
let fetcher = builder.fetcher()
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
let remote_blockchain = builder.remote_backend()
.ok_or_else(|| "Trying to start node RPC without active remote blockchain")?;
let provider = client.clone() as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
let finality_proof_provider = Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider));
let light_deps = polkadot_rpc::LightDeps {
remote_blockchain,
fetcher,
client: builder.client().clone(),
pool: builder.pool(),
remote_blockchain: backend.remote_blockchain(),
fetcher: on_demand.clone(),
client: client.clone(),
pool: transaction_pool.clone(),
};
Ok(polkadot_rpc::create_light(light_deps))
})?
.build_light()
.map(|ServiceComponents { task_manager, .. }| task_manager)
}}
let rpc_extensions = polkadot_rpc::create_light(light_deps);
let ServiceComponents { task_manager, .. } = service::build(service::ServiceParams {
config,
block_announce_validator_builder: None,
finality_proof_request_builder: Some(finality_proof_request_builder),
finality_proof_provider: Some(finality_proof_provider),
on_demand: Some(on_demand),
remote_blockchain: Some(backend.remote_blockchain()),
rpc_extensions_builder: Box::new(service::NoopRpcExtensionBuilder(rpc_extensions)),
client: client.clone(),
transaction_pool: transaction_pool.clone(),
import_queue, keystore, backend, task_manager,
})?;
Ok(task_manager)
}
/// Builds a new object suitable for chain operations.
#[cfg(feature = "full-node")]
pub fn new_chain_ops<Runtime, Dispatch, Extrinsic>(mut config: Configuration) -> Result<
(
Arc<service::TFullClient<Block, Runtime, Dispatch>>,
Arc<TFullBackend<Block>>,
Arc<FullClient<Runtime, Dispatch>>,
Arc<FullBackend>,
consensus_common::import_queue::BasicQueue<Block, PrefixedMemoryDB<BlakeTwo256>>,
TaskManager,
),
ServiceError
>
where
Runtime: ConstructRuntimeApi<Block, service::TFullClient<Block, Runtime, Dispatch>> + Send + Sync + 'static,
Runtime: ConstructRuntimeApi<Block, FullClient<Runtime, Dispatch>> + Send + Sync + 'static,
Runtime::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>>,
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Dispatch: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
config.keystore = service::config::KeystoreConfig::InMemory;
let (builder, _, _, _) = new_full_start!(config, Runtime, Dispatch);
Ok(builder.to_chain_ops_parts())
let (service::ServiceParams { client, backend, import_queue, task_manager, .. }, ..)
= full_params::<Runtime, Dispatch, Extrinsic>(config)?;
Ok((client, backend, import_queue, task_manager))
}
/// Create a new Polkadot service for a full node.
#[cfg(feature = "full-node")]
pub fn polkadot_new_full(
mut config: Configuration,
config: Configuration,
collating_for: Option<(CollatorId, ParaId)>,
_max_block_data_size: Option<u64>,
_authority_discovery_disabled: bool,
_slot_duration: u64,
max_block_data_size: Option<u64>,
authority_discovery_disabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
)
-> Result<(
TaskManager,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
FullBackend,
polkadot_runtime::RuntimeApi
>>,
FullNodeHandles,
), ServiceError>
{
let (components, client) = new_full!(
let (components, client) = new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor, _>(
config,
collating_for,
max_block_data_size,
authority_discovery_disabled,
slot_duration,
grandpa_pause,
polkadot_runtime::RuntimeApi,
PolkadotExecutor,
);
)?;
Ok((components, client, FullNodeHandles))
}
@@ -630,31 +648,31 @@ pub fn polkadot_new_full(
/// Create a new Kusama service for a full node.
#[cfg(feature = "full-node")]
pub fn kusama_new_full(
mut config: Configuration,
config: Configuration,
collating_for: Option<(CollatorId, ParaId)>,
_max_block_data_size: Option<u64>,
_authority_discovery_disabled: bool,
_slot_duration: u64,
max_block_data_size: Option<u64>,
authority_discovery_disabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
) -> Result<(
TaskManager,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
FullBackend,
kusama_runtime::RuntimeApi
>
>,
FullNodeHandles,
), ServiceError>
{
let (components, client) = new_full!(
let (components, client) = new_full::<kusama_runtime::RuntimeApi, KusamaExecutor, _>(
config,
collating_for,
max_block_data_size,
authority_discovery_disabled,
slot_duration,
grandpa_pause,
kusama_runtime::RuntimeApi,
KusamaExecutor,
);
)?;
Ok((components, client, FullNodeHandles))
}
@@ -662,49 +680,49 @@ pub fn kusama_new_full(
/// Create a new Kusama service for a full node.
#[cfg(feature = "full-node")]
pub fn westend_new_full(
mut config: Configuration,
config: Configuration,
collating_for: Option<(CollatorId, ParaId)>,
_max_block_data_size: Option<u64>,
_authority_discovery_disabled: bool,
_slot_duration: u64,
max_block_data_size: Option<u64>,
authority_discovery_disabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
)
-> Result<(
TaskManager,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
FullBackend,
westend_runtime::RuntimeApi
>>,
FullNodeHandles,
), ServiceError>
{
let (components, client) = new_full!(
let (components, client) = new_full::<westend_runtime::RuntimeApi, WestendExecutor, _>(
config,
collating_for,
max_block_data_size,
authority_discovery_disabled,
slot_duration,
grandpa_pause,
westend_runtime::RuntimeApi,
WestendExecutor,
);
)?;
Ok((components, client, FullNodeHandles))
}
/// Create a new Polkadot service for a light client.
pub fn polkadot_new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
pub fn polkadot_new_light(config: Configuration) -> Result<TaskManager, ServiceError>
{
new_light!(config, polkadot_runtime::RuntimeApi, PolkadotExecutor)
new_light::<polkadot_runtime::RuntimeApi, PolkadotExecutor, _>(config)
}
/// Create a new Kusama service for a light client.
pub fn kusama_new_light(mut config: Configuration) -> Result<TaskManager, ServiceError>
pub fn kusama_new_light(config: Configuration) -> Result<TaskManager, ServiceError>
{
new_light!(config, kusama_runtime::RuntimeApi, KusamaExecutor)
new_light::<kusama_runtime::RuntimeApi, KusamaExecutor, _>(config)
}
/// Create a new Westend service for a light client.
pub fn westend_new_light(mut config: Configuration, ) -> Result<TaskManager, ServiceError>
pub fn westend_new_light(config: Configuration, ) -> Result<TaskManager, ServiceError>
{
new_light!(config, westend_runtime::RuntimeApi, KusamaExecutor)
new_light::<westend_runtime::RuntimeApi, KusamaExecutor, _>(config)
}
+7 -11
View File
@@ -21,17 +21,13 @@
mod chain_spec;
pub use chain_spec::*;
use consensus_common::{block_validation::Chain, SelectChain};
use futures::future::Future;
use grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
use log::info;
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
use polkadot_primitives::v0::{
Block, BlockId, Hash, CollatorId, Id as ParaId,
Block, Hash, CollatorId, Id as ParaId,
};
use polkadot_runtime_common::{parachains, registrar, BlockHashCount};
use polkadot_service::{
new_full, new_full_start, FullNodeHandles, PolkadotClient, ServiceComponents,
new_full, FullNodeHandles, PolkadotClient,
};
use polkadot_test_runtime::{RestrictFunctionality, Runtime, SignedExtra, SignedPayload, VERSION};
use sc_chain_spec::ChainSpec;
@@ -54,7 +50,6 @@ use sp_keyring::Sr25519Keyring;
use sp_runtime::{codec::Encode, generic};
use sp_state_machine::BasicExternalities;
use std::sync::Arc;
use std::time::Duration;
use substrate_test_client::{BlockchainEventsExt, RpcHandlersExt, RpcTransactionOutput, RpcTransactionError};
native_executor_instance!(
@@ -81,15 +76,16 @@ pub fn polkadot_test_new_full(
),
ServiceError,
> {
let (task_manager, client, handles, network, rpc_handlers) = new_full!(test
let (task_manager, client, handles, network, rpc_handlers) =
new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor, _>(
config,
collating_for,
max_block_data_size,
authority_discovery_disabled,
slot_duration,
polkadot_test_runtime::RuntimeApi,
PolkadotTestExecutor,
);
None,
true,
)?;
Ok((task_manager, client, handles, network, rpc_handlers))
}
+222 -270
View File
@@ -25,7 +25,7 @@ use std::time::Duration;
use polkadot_primitives::v0::{self as parachain, Hash, BlockId, AccountId, Nonce, Balance};
#[cfg(feature = "full-node")]
use polkadot_network::{legacy::gossip::Known, protocol as network_protocol};
use service::{error::Error as ServiceError, ServiceBuilder};
use service::{error::Error as ServiceError};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use sc_executor::native_executor_instance;
use log::info;
@@ -135,60 +135,85 @@ impl IdentifyVariant for Box<dyn ChainSpec> {
}
}
/// Starts a `ServiceBuilder` for a full service.
///
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
#[macro_export]
macro_rules! new_full_start {
(prometheus_setup $config:expr) => {{
type FullBackend = service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
type FullClient<RuntimeApi, Executor> = service::TFullClient<Block, RuntimeApi, Executor>;
type FullGrandpaBlockImport<RuntimeApi, Executor> = grandpa::GrandpaBlockImport<
FullBackend, Block, FullClient<RuntimeApi, Executor>, FullSelectChain
>;
type LightBackend = service::TLightBackendWithHash<Block, sp_runtime::traits::BlakeTwo256>;
type LightClient<RuntimeApi, Executor> =
service::TLightClientWithBackend<Block, RuntimeApi, Executor, LightBackend>;
#[cfg(feature = "full-node")]
pub fn full_params<RuntimeApi, Executor, Extrinsic>(mut config: Configuration, test: bool) -> Result<(
service::ServiceParams<
Block,
FullClient<RuntimeApi, Executor>,
babe::BabeImportQueue<Block, FullClient<RuntimeApi, Executor>>,
sc_transaction_pool::FullPool<Block, FullClient<RuntimeApi, Executor>>,
polkadot_rpc::RpcExtension,
FullBackend,
>,
FullSelectChain,
(
babe::BabeBlockImport<
Block, FullClient<RuntimeApi, Executor>, FullGrandpaBlockImport<RuntimeApi, Executor>
>,
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
babe::BabeLink<Block>
),
inherents::InherentDataProviders,
grandpa::SharedVoterState,
), Error>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
if !test {
// If we're using prometheus, use a registry with a prefix of `polkadot`.
if let Some(PrometheusConfig { registry, .. }) = $config.prometheus_config.as_mut() {
if let Some(PrometheusConfig { registry, .. }) = config.prometheus_config.as_mut() {
*registry = Registry::new_custom(Some("polkadot".into()), None)?;
}
}};
(start_builder $config:expr, $runtime:ty, $executor:ty $(,)?) => {{
service::ServiceBuilder::new_full::<
Block, $runtime, $executor
>($config)?
.with_select_chain(|_, backend| {
Ok(sc_consensus::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|builder| {
}
let inherent_data_providers = inherents::InherentDataProviders::new();
let (client, backend, keystore, task_manager) =
service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
let client = Arc::new(client);
let select_chain = sc_consensus::LongestChain::new(backend.clone());
let pool_api = sc_transaction_pool::FullChainApi::new(
builder.client().clone(),
builder.prometheus_registry(),
client.clone(), config.prometheus_registry(),
);
let pool = sc_transaction_pool::BasicPool::new_full(
builder.config().transaction_pool.clone(),
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
std::sync::Arc::new(pool_api),
builder.prometheus_registry(),
builder.spawn_handle(),
builder.client().clone(),
config.prometheus_registry(),
task_manager.spawn_handle(),
client.clone(),
);
Ok(pool)
})?
}};
(import_queue_setup
$builder:expr, $inherent_data_providers:expr, $import_setup:expr, $grandpa_hard_forks:expr, $(,)?
) => {{
$builder.with_import_queue(|
_config,
client,
mut select_chain,
_,
spawn_task_handle,
registry,
| {
let select_chain = select_chain.take()
.ok_or_else(|| service::Error::SelectChainRequired)?;
let grandpa_hard_forks = if config.chain_spec.is_kusama() && !test {
crate::grandpa_support::kusama_hard_forks()
} else {
Vec::new()
};
let (grandpa_block_import, grandpa_link) =
grandpa::block_import_with_authority_set_hard_forks(
client.clone(),
&(client.clone() as Arc<_>),
select_chain.clone(),
$grandpa_hard_forks,
grandpa_hard_forks,
)?;
let justification_import = grandpa_block_import.clone();
@@ -204,45 +229,32 @@ macro_rules! new_full_start {
block_import.clone(),
Some(Box::new(justification_import)),
None,
client,
select_chain,
$inherent_data_providers.clone(),
spawn_task_handle,
registry,
client.clone(),
select_chain.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
config.prometheus_registry(),
)?;
$import_setup = Some((block_import, grandpa_link, babe_link));
Ok(import_queue)
})?
}};
(finish_builder_setup $builder:expr, $inherent_data_providers:expr, $import_setup:expr) => {{
let mut rpc_setup = None;
let builder = $builder.with_rpc_extensions_builder(|builder| {
let grandpa_link = $import_setup.as_ref().map(|s| &s.1)
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();
rpc_setup = Some((shared_voter_state.clone()));
let babe_link = $import_setup.as_ref().map(|s| &s.2)
.expect("BabeLink is present for full services or set up faile; qed.");
let import_setup = (block_import.clone(), grandpa_link, babe_link.clone());
let rpc_setup = shared_voter_state.clone();
let babe_config = babe_link.config().clone();
let shared_epoch_changes = babe_link.epoch_changes().clone();
let client = builder.client().clone();
let pool = builder.pool().clone();
let select_chain = builder.select_chain().cloned()
.expect("SelectChain is present for full services or set up failed; qed.");
let keystore = builder.keystore().clone();
let rpc_extensions_builder = {
let client = client.clone();
let keystore = keystore.clone();
let transaction_pool = transaction_pool.clone();
let select_chain = select_chain.clone();
Ok(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
Box::new(move |deny_unsafe| -> polkadot_rpc::RpcExtension {
let deps = polkadot_rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
pool: transaction_pool.clone(),
select_chain: select_chain.clone(),
deny_unsafe,
babe: polkadot_rpc::BabeDeps {
@@ -258,91 +270,83 @@ macro_rules! new_full_start {
polkadot_rpc::create_full(deps)
})
})?;
(builder, $import_setup, $inherent_data_providers, rpc_setup)
}};
($config:expr, $runtime:ty, $executor:ty $(,)?) => {{
let inherent_data_providers = inherents::InherentDataProviders::new();
let mut import_setup = None;
new_full_start!(prometheus_setup $config);
let grandpa_hard_forks = if $config.chain_spec.is_kusama() {
$crate::grandpa_support::kusama_hard_forks()
} else {
Vec::new()
};
let builder = new_full_start!(start_builder $config, $runtime, $executor);
let builder = new_full_start!(import_queue_setup
builder, inherent_data_providers, import_setup, grandpa_hard_forks,
);
new_full_start!(finish_builder_setup builder, inherent_data_providers, import_setup)
}};
(test $config:expr, $runtime:ty, $executor:ty $(,)?) => {{
let inherent_data_providers = inherents::InherentDataProviders::new();
let mut import_setup = None;
let grandpa_hard_forks = Vec::new();
let builder = new_full_start!(start_builder $config, $runtime, $executor);
let builder = new_full_start!(import_queue_setup
builder, inherent_data_providers, import_setup, grandpa_hard_forks,
);
new_full_start!(finish_builder_setup builder, inherent_data_providers, import_setup)
}};
let provider = client.clone() as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
let finality_proof_provider = Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider)) as _;
let params = service::ServiceParams {
config, backend, client, import_queue, keystore, task_manager, rpc_extensions_builder,
transaction_pool,
block_announce_validator_builder: None,
finality_proof_provider: Some(finality_proof_provider),
finality_proof_request_builder: None,
on_demand: None,
remote_blockchain: None,
};
Ok((params, select_chain, import_setup, inherent_data_providers, rpc_setup))
}
/// Builds a new service for a full client.
#[macro_export]
macro_rules! new_full {
(
with_full_start
$config:expr,
$collating_for:expr,
$max_block_data_size:expr,
$authority_discovery_disabled:expr,
$slot_duration:expr,
$grandpa_pause:expr,
$new_full_start:expr $(,)?
) => {{
#[cfg(feature = "full-node")]
pub fn new_full<RuntimeApi, Executor, Extrinsic>(
config: Configuration,
collating_for: Option<(CollatorId, parachain::Id)>,
max_block_data_size: Option<u64>,
authority_discovery_disabled: bool,
slot_duration: u64,
grandpa_pause: Option<(u32, u32)>,
test: bool,
) -> Result<(
TaskManager,
Arc<FullClient<RuntimeApi, Executor>>,
FullNodeHandles,
Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
Arc<RpcHandlers>,
), Error>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
RuntimeApi::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
use sc_network::Event;
use sc_client_api::ExecutorProvider;
use futures::stream::StreamExt;
use sp_core::traits::BareCryptoStorePtr;
let is_collator = $collating_for.is_some();
let role = $config.role.clone();
let is_collator = collating_for.is_some();
let role = config.role.clone();
let is_authority = role.is_authority() && !is_collator;
let force_authoring = $config.force_authoring;
let db_path = match $config.database.path() {
let force_authoring = config.force_authoring;
let db_path = match config.database.path() {
Some(path) => std::path::PathBuf::from(path),
None => return Err("Starting a Polkadot service with a custom database isn't supported".to_string().into()),
};
let max_block_data_size = $max_block_data_size;
let disable_grandpa = $config.disable_grandpa;
let name = $config.network.node_name.clone();
let authority_discovery_disabled = $authority_discovery_disabled;
let slot_duration = $slot_duration;
let disable_grandpa = config.disable_grandpa;
let name = config.network.node_name.clone();
let (builder, mut import_setup, inherent_data_providers, mut rpc_setup) = $new_full_start;
let (params, select_chain, import_setup, inherent_data_providers, rpc_setup)
= full_params::<RuntimeApi, Executor, Extrinsic>(config, test)?;
let client = params.client.clone();
let keystore = params.keystore.clone();
let transaction_pool = params.transaction_pool.clone();
let prometheus_registry = params.config.prometheus_registry().cloned();
let ServiceComponents {
client, network, select_chain, keystore, transaction_pool, prometheus_registry,
network,
task_manager, telemetry_on_connect_sinks, rpc_handlers, ..
} = builder
.with_finality_proof_provider(|client, backend| {
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build_full()?;
} = service::build(params)?;
let (block_import, link_half, babe_link) = import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
let (block_import, link_half, babe_link) = import_setup;
let shared_voter_state = rpc_setup.take()
.expect("The SharedVoterState is present for Full Services or setup failed before. qed");
let shared_voter_state = rpc_setup;
let known_oracle = client.clone();
let mut handles = FullNodeHandles::default();
let select_chain = select_chain.ok_or(ServiceError::SelectChainRequired)?;
let gossip_validator_select_chain = select_chain.clone();
let is_known = move |block_hash: &Hash| {
@@ -367,7 +371,7 @@ macro_rules! new_full {
let polkadot_network_service = network_protocol::start(
network.clone(),
network_protocol::Config {
collating_for: $collating_for,
collating_for: collating_for,
},
(is_known, client.clone()),
client.clone(),
@@ -522,7 +526,7 @@ macro_rules! new_full {
// add a custom voting rule to temporarily stop voting for new blocks
// after the given pause block is finalized and restarting after the
// given delay.
let voting_rule = match $grandpa_pause {
let voting_rule = match grandpa_pause {
Some((block, delay)) => {
info!("GRANDPA scheduled voting pause set for block #{} with a duration of {} blocks.",
block,
@@ -530,7 +534,7 @@ macro_rules! new_full {
);
grandpa::VotingRulesBuilder::default()
.add($crate::grandpa_support::PauseAfterBlockFor(block, delay))
.add(crate::grandpa_support::PauseAfterBlockFor(block, delay))
.build()
},
None =>
@@ -562,98 +566,44 @@ macro_rules! new_full {
}
handles.polkadot_network = Some(polkadot_network_service);
(task_manager, client, handles, network, rpc_handlers)
}};
(
$config:expr,
$collating_for:expr,
$max_block_data_size:expr,
$authority_discovery_disabled:expr,
$slot_duration:expr,
$grandpa_pause:expr,
$runtime:ty,
$dispatch:ty,
) => {{
new_full!(with_full_start
$config,
$collating_for,
$max_block_data_size,
$authority_discovery_disabled,
$slot_duration,
$grandpa_pause,
new_full_start!($config, $runtime, $dispatch),
)
}};
(
test
$config:expr,
$collating_for:expr,
$max_block_data_size:expr,
$authority_discovery_disabled:expr,
$slot_duration:expr,
$runtime:ty,
$dispatch:ty,
) => {{
new_full!(with_full_start
$config,
$collating_for,
$max_block_data_size,
$authority_discovery_disabled,
$slot_duration,
None,
new_full_start!(test $config, $runtime, $dispatch),
)
}};
Ok((task_manager, client, handles, network, rpc_handlers))
}
/// Builds a new service for a light client.
#[macro_export]
macro_rules! new_light {
($config:expr, $runtime:ty, $dispatch:ty) => {{
fn new_light<Runtime, Dispatch, Extrinsic>(mut config: Configuration) -> Result<(TaskManager, Arc<RpcHandlers>), Error>
where
Runtime: 'static + Send + Sync + ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>,
<Runtime as ConstructRuntimeApi<Block, LightClient<Runtime, Dispatch>>>::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<LightBackend, Block>>,
Dispatch: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
use sc_client_api::backend::RemoteBackend;
// If we're using prometheus, use a registry with a prefix of `polkadot`.
if let Some(PrometheusConfig { registry, .. }) = $config.prometheus_config.as_mut() {
if let Some(PrometheusConfig { registry, .. }) = config.prometheus_config.as_mut() {
*registry = Registry::new_custom(Some("polkadot".into()), None)?;
}
let inherent_data_providers = inherents::InherentDataProviders::new();
ServiceBuilder::new_light::<Block, $runtime, $dispatch>($config)?
.with_select_chain(|_, backend| {
Ok(sc_consensus::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|builder| {
let fetcher = builder.fetcher()
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let (client, backend, keystore, task_manager, on_demand) =
service::new_light_parts::<Block, Runtime, Dispatch>(&config)?;
let select_chain = sc_consensus::LongestChain::new(backend.clone());
let pool_api = sc_transaction_pool::LightChainApi::new(
builder.client().clone(),
fetcher,
client.clone(),
on_demand.clone(),
);
let pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
builder.config().transaction_pool.clone(),
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
config.transaction_pool.clone(),
Arc::new(pool_api),
builder.prometheus_registry(),
builder.spawn_handle(),
config.prometheus_registry(),
task_manager.spawn_handle(),
));
Ok(pool)
})?
.with_import_queue_and_fprb(|
_config,
client,
backend,
fetcher,
mut select_chain,
_,
spawn_task_handle,
registry,
| {
let select_chain = select_chain.take()
.ok_or_else(|| service::Error::SelectChainRequired)?;
let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
let grandpa_block_import = grandpa::light_block_import(
client.clone(), backend, &(client.clone() as Arc<_>), Arc::new(fetch_checker)
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
Arc::new(on_demand.checker().clone()),
)?;
let finality_proof_import = grandpa_block_import.clone();
@@ -666,72 +616,77 @@ macro_rules! new_light {
client.clone(),
)?;
let inherent_data_providers = inherents::InherentDataProviders::new();
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
let import_queue = babe::import_queue(
babe_link,
babe_block_import,
None,
Some(Box::new(finality_proof_import)),
client,
select_chain,
client.clone(),
select_chain.clone(),
inherent_data_providers.clone(),
spawn_task_handle,
registry,
&task_manager.spawn_handle(),
config.prometheus_registry(),
)?;
Ok((import_queue, finality_proof_request_builder))
})?
.with_finality_proof_provider(|client, backend| {
let provider = client as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
Ok(Arc::new(grandpa::FinalityProofProvider::new(backend, provider)) as _)
})?
.with_rpc_extensions(|builder| {
let fetcher = builder.fetcher()
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
let remote_blockchain = builder.remote_backend()
.ok_or_else(|| "Trying to start node RPC without active remote blockchain")?;
let provider = client.clone() as Arc<dyn grandpa::StorageAndProofProvider<_, _>>;
let finality_proof_provider = Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider));
let light_deps = polkadot_rpc::LightDeps {
remote_blockchain,
fetcher,
client: builder.client().clone(),
pool: builder.pool(),
remote_blockchain: backend.remote_blockchain(),
fetcher: on_demand.clone(),
client: client.clone(),
pool: transaction_pool.clone(),
};
Ok(polkadot_rpc::create_light(light_deps))
})?
.build_light()
.map(|ServiceComponents { task_manager, rpc_handlers, .. }| {
(task_manager, rpc_handlers)
})
}}
let rpc_extensions = polkadot_rpc::create_light(light_deps);
let ServiceComponents { task_manager, rpc_handlers, .. } = service::build(service::ServiceParams {
config,
block_announce_validator_builder: None,
finality_proof_request_builder: Some(finality_proof_request_builder),
finality_proof_provider: Some(finality_proof_provider),
on_demand: Some(on_demand),
remote_blockchain: Some(backend.remote_blockchain()),
rpc_extensions_builder: Box::new(service::NoopRpcExtensionBuilder(rpc_extensions)),
client: client.clone(),
transaction_pool: transaction_pool.clone(),
import_queue, keystore, backend, task_manager,
})?;
Ok((task_manager, rpc_handlers))
}
/// Builds a new object suitable for chain operations.
#[cfg(feature = "full-node")]
pub fn new_chain_ops<Runtime, Dispatch, Extrinsic>(mut config: Configuration) -> Result<
(
Arc<service::TFullClient<Block, Runtime, Dispatch>>,
Arc<TFullBackend<Block>>,
Arc<FullClient<Runtime, Dispatch>>,
Arc<FullBackend>,
consensus_common::import_queue::BasicQueue<Block, PrefixedMemoryDB<BlakeTwo256>>,
TaskManager,
),
ServiceError
>
where
Runtime: ConstructRuntimeApi<Block, service::TFullClient<Block, Runtime, Dispatch>> + Send + Sync + 'static,
Runtime: ConstructRuntimeApi<Block, FullClient<Runtime, Dispatch>> + Send + Sync + 'static,
Runtime::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>>,
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Dispatch: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
{
config.keystore = service::config::KeystoreConfig::InMemory;
let (builder, _, _, _) = new_full_start!(config, Runtime, Dispatch);
Ok(builder.to_chain_ops_parts())
let (service::ServiceParams { client, backend, import_queue, task_manager, .. }, ..)
= full_params::<Runtime, Dispatch, Extrinsic>(config, false)?;
Ok((client, backend, import_queue, task_manager))
}
/// Create a new Polkadot service for a full node.
#[cfg(feature = "full-node")]
pub fn polkadot_new_full(
mut config: Configuration,
config: Configuration,
collating_for: Option<(CollatorId, parachain::Id)>,
max_block_data_size: Option<u64>,
authority_discovery_disabled: bool,
@@ -742,22 +697,21 @@ pub fn polkadot_new_full(
TaskManager,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
FullBackend,
polkadot_runtime::RuntimeApi
>>,
FullNodeHandles,
), ServiceError>
{
let (service, client, handles, _, _) = new_full!(
let (service, client, handles, _, _) = new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor, _>(
config,
collating_for,
max_block_data_size,
authority_discovery_disabled,
slot_duration,
grandpa_pause,
polkadot_runtime::RuntimeApi,
PolkadotExecutor,
);
false,
)?;
Ok((service, client, handles))
}
@@ -765,7 +719,7 @@ pub fn polkadot_new_full(
/// Create a new Kusama service for a full node.
#[cfg(feature = "full-node")]
pub fn kusama_new_full(
mut config: Configuration,
config: Configuration,
collating_for: Option<(CollatorId, parachain::Id)>,
max_block_data_size: Option<u64>,
authority_discovery_disabled: bool,
@@ -775,23 +729,22 @@ pub fn kusama_new_full(
TaskManager,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
FullBackend,
kusama_runtime::RuntimeApi
>
>,
FullNodeHandles
), ServiceError>
{
let (service, client, handles, _, _) = new_full!(
let (service, client, handles, _, _) = new_full::<kusama_runtime::RuntimeApi, KusamaExecutor, _>(
config,
collating_for,
max_block_data_size,
authority_discovery_disabled,
slot_duration,
grandpa_pause,
kusama_runtime::RuntimeApi,
KusamaExecutor,
);
false,
)?;
Ok((service, client, handles))
}
@@ -799,7 +752,7 @@ pub fn kusama_new_full(
/// Create a new Kusama service for a full node.
#[cfg(feature = "full-node")]
pub fn westend_new_full(
mut config: Configuration,
config: Configuration,
collating_for: Option<(CollatorId, parachain::Id)>,
max_block_data_size: Option<u64>,
authority_discovery_disabled: bool,
@@ -810,22 +763,21 @@ pub fn westend_new_full(
TaskManager,
Arc<impl PolkadotClient<
Block,
TFullBackend<Block>,
FullBackend,
westend_runtime::RuntimeApi
>>,
FullNodeHandles,
), ServiceError>
{
let (service, client, handles, _, _) = new_full!(
let (service, client, handles, _, _) = new_full::<westend_runtime::RuntimeApi, WestendExecutor, _>(
config,
collating_for,
max_block_data_size,
authority_discovery_disabled,
slot_duration,
grandpa_pause,
westend_runtime::RuntimeApi,
WestendExecutor,
);
false,
)?;
Ok((service, client, handles))
}
@@ -842,25 +794,25 @@ pub struct FullNodeHandles {
}
/// Create a new Polkadot service for a light client.
pub fn polkadot_new_light(mut config: Configuration) -> Result<
pub fn polkadot_new_light(config: Configuration) -> Result<
(TaskManager, Arc<RpcHandlers>), ServiceError
>
{
new_light!(config, polkadot_runtime::RuntimeApi, PolkadotExecutor)
new_light::<polkadot_runtime::RuntimeApi, PolkadotExecutor, _>(config)
}
/// Create a new Kusama service for a light client.
pub fn kusama_new_light(mut config: Configuration) -> Result<
pub fn kusama_new_light(config: Configuration) -> Result<
(TaskManager, Arc<RpcHandlers>), ServiceError
>
{
new_light!(config, kusama_runtime::RuntimeApi, KusamaExecutor)
new_light::<kusama_runtime::RuntimeApi, KusamaExecutor, _>(config)
}
/// Create a new Westend service for a light client.
pub fn westend_new_light(mut config: Configuration, ) -> Result<
pub fn westend_new_light(config: Configuration, ) -> Result<
(TaskManager, Arc<RpcHandlers>), ServiceError
>
{
new_light!(config, westend_runtime::RuntimeApi, KusamaExecutor)
new_light::<westend_runtime::RuntimeApi, KusamaExecutor, _>(config)
}