mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
polkadot-service: Make native runtime configurable (#3189)
* polkadot-service: Make native runtime configurable
This pull requests adds support for configuring the native runtimes used
by polkadot-service. While this whole pr doesn't change that much for
polkadot, besides not having the light-node enabled for the default
polkadot binary. However, downstream projects (parachains) will have a
much better compile time. In cumulus for example the `cargo test --all
--release` is about 4m faster to compile.
* Fixes
* Fix
* Enable rococo-native
* Fix light client
* 🤦
* Fixes
This commit is contained in:
@@ -16,33 +16,40 @@
|
||||
|
||||
//! Polkadot chain configurations.
|
||||
|
||||
use rococo::constants::size::MAX_CODE_SIZE;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_consensus_babe::AuthorityId as BabeId;
|
||||
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
|
||||
use grandpa::AuthorityId as GrandpaId;
|
||||
use hex_literal::hex;
|
||||
#[cfg(feature = "kusama-native")]
|
||||
use kusama_runtime as kusama;
|
||||
#[cfg(feature = "kusama-native")]
|
||||
use kusama_runtime::constants::currency::UNITS as KSM;
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use pallet_staking::Forcing;
|
||||
use polkadot::constants::currency::UNITS as DOT;
|
||||
use polkadot_node_primitives::MAX_POV_SIZE;
|
||||
use polkadot_primitives::v1::{AccountId, AccountPublic, AssignmentId, ValidatorId, BlockNumber};
|
||||
use polkadot_primitives::v1::{AccountId, AccountPublic, AssignmentId, ValidatorId};
|
||||
use polkadot_runtime as polkadot;
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
use rococo_runtime as rococo;
|
||||
#[cfg(feature = "rococo-native")]
|
||||
use rococo_runtime::constants::currency::UNITS as ROC;
|
||||
use sc_chain_spec::{ChainSpecExtension, ChainType};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
|
||||
use sp_core::{sr25519, Pair, Public};
|
||||
use sp_runtime::{traits::IdentifyAccount, Perbill};
|
||||
use telemetry::TelemetryEndpoints;
|
||||
#[cfg(feature = "westend-native")]
|
||||
use westend_runtime as westend;
|
||||
#[cfg(feature = "westend-native")]
|
||||
use westend_runtime::constants::currency::UNITS as WND;
|
||||
|
||||
const POLKADOT_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
#[cfg(feature = "kusama-native")]
|
||||
const KUSAMA_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
#[cfg(feature = "westend-native")]
|
||||
const WESTEND_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
#[cfg(feature = "rococo-native")]
|
||||
const ROCOCO_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
const DEFAULT_PROTOCOL_ID: &str = "dot";
|
||||
|
||||
@@ -63,16 +70,35 @@ pub struct Extensions {
|
||||
pub type PolkadotChainSpec = service::GenericChainSpec<polkadot::GenesisConfig, Extensions>;
|
||||
|
||||
/// The `ChainSpec` parameterized for the kusama runtime.
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub type KusamaChainSpec = service::GenericChainSpec<kusama::GenesisConfig, Extensions>;
|
||||
|
||||
/// The `ChainSpec` parameterized for the kusama runtime.
|
||||
// This actually uses the polkadot chain spec, but that is fine when we don't have the native runtime.
|
||||
#[cfg(not(feature = "kusama-native"))]
|
||||
pub type KusamaChainSpec = PolkadotChainSpec;
|
||||
|
||||
/// The `ChainSpec` parameterized for the westend runtime.
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub type WestendChainSpec = service::GenericChainSpec<westend::GenesisConfig, Extensions>;
|
||||
|
||||
/// The `ChainSpec` parameterized for the westend runtime.
|
||||
// This actually uses the polkadot chain spec, but that is fine when we don't have the native runtime.
|
||||
#[cfg(not(feature = "westend-native"))]
|
||||
pub type WestendChainSpec = PolkadotChainSpec;
|
||||
|
||||
/// The `ChainSpec` parameterized for the rococo runtime.
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub type RococoChainSpec = service::GenericChainSpec<RococoGenesisExt, Extensions>;
|
||||
|
||||
/// The `ChainSpec` parameterized for the rococo runtime.
|
||||
// This actually uses the polkadot chain spec, but that is fine when we don't have the native runtime.
|
||||
#[cfg(not(feature = "rococo-native"))]
|
||||
pub type RococoChainSpec = PolkadotChainSpec;
|
||||
|
||||
/// Extension for the Rococo genesis config to support a custom changes to the genesis state.
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub struct RococoGenesisExt {
|
||||
/// The runtime genesis config.
|
||||
runtime_genesis_config: rococo::GenesisConfig,
|
||||
@@ -82,6 +108,7 @@ pub struct RococoGenesisExt {
|
||||
session_length_in_blocks: Option<u32>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
impl sp_runtime::BuildStorage for RococoGenesisExt {
|
||||
fn assimilate_storage(
|
||||
&self,
|
||||
@@ -104,21 +131,27 @@ pub fn kusama_config() -> Result<KusamaChainSpec, String> {
|
||||
KusamaChainSpec::from_json_bytes(&include_bytes!("../res/kusama.json")[..])
|
||||
}
|
||||
|
||||
pub fn westend_config() -> Result<PolkadotChainSpec, String> {
|
||||
PolkadotChainSpec::from_json_bytes(&include_bytes!("../res/westend.json")[..])
|
||||
pub fn westend_config() -> Result<WestendChainSpec, String> {
|
||||
WestendChainSpec::from_json_bytes(&include_bytes!("../res/westend.json")[..])
|
||||
}
|
||||
|
||||
pub fn rococo_config() -> Result<PolkadotChainSpec, String> {
|
||||
PolkadotChainSpec::from_json_bytes(&include_bytes!("../res/rococo.json")[..])
|
||||
pub fn rococo_config() -> Result<RococoChainSpec, String> {
|
||||
RococoChainSpec::from_json_bytes(&include_bytes!("../res/rococo.json")[..])
|
||||
}
|
||||
|
||||
/// This is a temporary testnet that uses the same runtime as rococo.
|
||||
pub fn wococo_config() -> Result<PolkadotChainSpec, String> {
|
||||
PolkadotChainSpec::from_json_bytes(&include_bytes!("../res/wococo.json")[..])
|
||||
pub fn wococo_config() -> Result<RococoChainSpec, String> {
|
||||
RococoChainSpec::from_json_bytes(&include_bytes!("../res/wococo.json")[..])
|
||||
}
|
||||
|
||||
/// The default parachains host configuration.
|
||||
fn default_parachains_host_configuration() -> polkadot_runtime_parachains::configuration::HostConfiguration<BlockNumber> {
|
||||
#[cfg(any(feature = "rococo-native", feature = "kusama-native", feature = "westend-native"))]
|
||||
fn default_parachains_host_configuration() ->
|
||||
polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::v1::BlockNumber>
|
||||
{
|
||||
use polkadot_node_primitives::MAX_POV_SIZE;
|
||||
use polkadot_primitives::v1::MAX_CODE_SIZE;
|
||||
|
||||
polkadot_runtime_parachains::configuration::HostConfiguration {
|
||||
validation_upgrade_frequency: 1u32,
|
||||
validation_upgrade_delay: 1,
|
||||
@@ -179,6 +212,7 @@ fn polkadot_session_keys(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
fn kusama_session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
@@ -197,6 +231,7 @@ fn kusama_session_keys(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
fn westend_session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
@@ -215,6 +250,7 @@ fn westend_session_keys(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
fn rococo_session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
@@ -331,7 +367,11 @@ fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::Gene
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
|
||||
use hex_literal::hex;
|
||||
use sp_core::crypto::UncheckedInto;
|
||||
|
||||
// subkey inspect "$SECRET"
|
||||
let endowed_accounts = vec![
|
||||
// 5DaVh5WRfazkGaKhx1jUu6hjz7EmRe4dtW6PKeVLim84KLe8
|
||||
@@ -492,7 +532,11 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
|
||||
use hex_literal::hex;
|
||||
use sp_core::crypto::UncheckedInto;
|
||||
|
||||
// subkey inspect "$SECRET"
|
||||
let endowed_accounts = vec![
|
||||
// 5CVFESwfkk7NmhQ6FwHCM9roBvr9BGa4vJHFYU8DnGQxrXvz
|
||||
@@ -698,7 +742,11 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
|
||||
use hex_literal::hex;
|
||||
use sp_core::crypto::UncheckedInto;
|
||||
|
||||
// subkey inspect "$SECRET"
|
||||
let endowed_accounts = vec![
|
||||
// 5FeyRQmjtdHoPH56ASFW76AJEP1yaQC1K9aEMvJTF9nzt9S9
|
||||
@@ -967,6 +1015,7 @@ pub fn polkadot_staging_testnet_config() -> Result<PolkadotChainSpec, String> {
|
||||
}
|
||||
|
||||
/// Staging testnet config.
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub fn kusama_staging_testnet_config() -> Result<KusamaChainSpec, String> {
|
||||
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
|
||||
let boot_nodes = vec![];
|
||||
@@ -988,6 +1037,7 @@ pub fn kusama_staging_testnet_config() -> Result<KusamaChainSpec, String> {
|
||||
}
|
||||
|
||||
/// Westend staging testnet config.
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub fn westend_staging_testnet_config() -> Result<WestendChainSpec, String> {
|
||||
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
|
||||
let boot_nodes = vec![];
|
||||
@@ -1009,6 +1059,7 @@ pub fn westend_staging_testnet_config() -> Result<WestendChainSpec, String> {
|
||||
}
|
||||
|
||||
/// Rococo staging testnet config.
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub fn rococo_staging_testnet_config() -> Result<RococoChainSpec, String> {
|
||||
let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?;
|
||||
let boot_nodes = vec![];
|
||||
@@ -1208,6 +1259,7 @@ pub fn polkadot_testnet_genesis(
|
||||
}
|
||||
|
||||
/// Helper function to create kusama GenesisConfig for testing
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub fn kusama_testnet_genesis(
|
||||
wasm_binary: &[u8],
|
||||
initial_authorities: Vec<(
|
||||
@@ -1311,6 +1363,7 @@ pub fn kusama_testnet_genesis(
|
||||
}
|
||||
|
||||
/// Helper function to create westend GenesisConfig for testing
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub fn westend_testnet_genesis(
|
||||
wasm_binary: &[u8],
|
||||
initial_authorities: Vec<(
|
||||
@@ -1398,6 +1451,7 @@ pub fn westend_testnet_genesis(
|
||||
}
|
||||
|
||||
/// Helper function to create rococo GenesisConfig for testing
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub fn rococo_testnet_genesis(
|
||||
wasm_binary: &[u8],
|
||||
initial_authorities: Vec<(
|
||||
@@ -1485,6 +1539,7 @@ fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisC
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
|
||||
kusama_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1494,6 +1549,7 @@ fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfi
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
|
||||
westend_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1503,6 +1559,7 @@ fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisCon
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
fn rococo_development_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
|
||||
rococo_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1530,6 +1587,7 @@ pub fn polkadot_development_config() -> Result<PolkadotChainSpec, String> {
|
||||
}
|
||||
|
||||
/// Kusama development config (single validator Alice)
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub fn kusama_development_config() -> Result<KusamaChainSpec, String> {
|
||||
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
|
||||
|
||||
@@ -1547,6 +1605,7 @@ pub fn kusama_development_config() -> Result<KusamaChainSpec, String> {
|
||||
}
|
||||
|
||||
/// Westend development config (single validator Alice)
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub fn westend_development_config() -> Result<WestendChainSpec, String> {
|
||||
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
|
||||
|
||||
@@ -1564,6 +1623,7 @@ pub fn westend_development_config() -> Result<WestendChainSpec, String> {
|
||||
}
|
||||
|
||||
/// Rococo development config (single validator Alice)
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub fn rococo_development_config() -> Result<RococoChainSpec, String> {
|
||||
let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?;
|
||||
|
||||
@@ -1585,6 +1645,7 @@ pub fn rococo_development_config() -> Result<RococoChainSpec, String> {
|
||||
}
|
||||
|
||||
/// Wococo development config (single validator Alice)
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub fn wococo_development_config() -> Result<RococoChainSpec, String> {
|
||||
const WOCOCO_DEV_PROTOCOL_ID: &str = "woco";
|
||||
let wasm_binary = rococo::WASM_BINARY.ok_or("Wococo development wasm not available")?;
|
||||
@@ -1635,6 +1696,7 @@ pub fn polkadot_local_testnet_config() -> Result<PolkadotChainSpec, String> {
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
|
||||
kusama_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1648,6 +1710,7 @@ fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
|
||||
}
|
||||
|
||||
/// Kusama local testnet config (multivalidator Alice + Bob)
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub fn kusama_local_testnet_config() -> Result<KusamaChainSpec, String> {
|
||||
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
|
||||
|
||||
@@ -1664,6 +1727,7 @@ pub fn kusama_local_testnet_config() -> Result<KusamaChainSpec, String> {
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
|
||||
westend_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1677,6 +1741,7 @@ fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
|
||||
}
|
||||
|
||||
/// Westend local testnet config (multivalidator Alice + Bob)
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
|
||||
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
|
||||
|
||||
@@ -1693,6 +1758,7 @@ pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
fn rococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
|
||||
rococo_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1706,6 +1772,7 @@ fn rococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisCo
|
||||
}
|
||||
|
||||
/// Rococo local testnet config (multivalidator Alice + Bob)
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub fn rococo_local_testnet_config() -> Result<RococoChainSpec, String> {
|
||||
let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?;
|
||||
|
||||
|
||||
@@ -1,452 +0,0 @@
|
||||
// Copyright 2017-2020 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Polkadot Client meta trait
|
||||
|
||||
use std::sync::Arc;
|
||||
use beefy_primitives::ecdsa::AuthorityId as BeefyId;
|
||||
use sp_api::{ProvideRuntimeApi, CallApiAt, NumberFor};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_runtime::{
|
||||
Justifications, generic::{BlockId, SignedBlock}, traits::{Block as BlockT, BlakeTwo256},
|
||||
};
|
||||
use sc_client_api::{Backend as BackendT, BlockchainEvents, KeyIterator, AuxStore, UsageProvider};
|
||||
use sp_storage::{StorageData, StorageKey, ChildInfo, PrefixedStorageKey};
|
||||
use polkadot_primitives::v1::{Block, ParachainHost, AccountId, Nonce, Balance, Header, BlockNumber, Hash};
|
||||
use consensus_common::BlockStatus;
|
||||
|
||||
/// A set of APIs that polkadot-like runtimes must implement.
|
||||
pub trait RuntimeApiCollection:
|
||||
sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
||||
+ sp_api::ApiExt<Block>
|
||||
+ sp_consensus_babe::BabeApi<Block>
|
||||
+ grandpa_primitives::GrandpaApi<Block>
|
||||
+ ParachainHost<Block>
|
||||
+ sp_block_builder::BlockBuilder<Block>
|
||||
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
|
||||
+ pallet_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash>
|
||||
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
|
||||
+ sp_api::Metadata<Block>
|
||||
+ sp_offchain::OffchainWorkerApi<Block>
|
||||
+ sp_session::SessionKeys<Block>
|
||||
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>
|
||||
+ beefy_primitives::BeefyApi<Block, BeefyId>
|
||||
where
|
||||
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
|
||||
{}
|
||||
|
||||
impl<Api> RuntimeApiCollection for Api
|
||||
where
|
||||
Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
||||
+ sp_api::ApiExt<Block>
|
||||
+ sp_consensus_babe::BabeApi<Block>
|
||||
+ grandpa_primitives::GrandpaApi<Block>
|
||||
+ ParachainHost<Block>
|
||||
+ sp_block_builder::BlockBuilder<Block>
|
||||
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
|
||||
+ pallet_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash>
|
||||
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
|
||||
+ sp_api::Metadata<Block>
|
||||
+ sp_offchain::OffchainWorkerApi<Block>
|
||||
+ sp_session::SessionKeys<Block>
|
||||
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>
|
||||
+ beefy_primitives::BeefyApi<Block, BeefyId>,
|
||||
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
|
||||
{}
|
||||
|
||||
/// Trait that abstracts over all available client implementations.
|
||||
///
|
||||
/// For a concrete type there exists [`Client`].
|
||||
pub trait AbstractClient<Block, Backend>:
|
||||
BlockchainEvents<Block> + Sized + Send + Sync
|
||||
+ ProvideRuntimeApi<Block>
|
||||
+ HeaderBackend<Block>
|
||||
+ CallApiAt<
|
||||
Block,
|
||||
StateBackend = Backend::State
|
||||
>
|
||||
+ AuxStore
|
||||
+ UsageProvider<Block>
|
||||
where
|
||||
Block: BlockT,
|
||||
Backend: BackendT<Block>,
|
||||
Backend::State: sp_api::StateBackend<BlakeTwo256>,
|
||||
Self::Api: RuntimeApiCollection<StateBackend = Backend::State>,
|
||||
{}
|
||||
|
||||
impl<Block, Backend, Client> AbstractClient<Block, Backend> for Client
|
||||
where
|
||||
Block: BlockT,
|
||||
Backend: BackendT<Block>,
|
||||
Backend::State: sp_api::StateBackend<BlakeTwo256>,
|
||||
Client: BlockchainEvents<Block>
|
||||
+ ProvideRuntimeApi<Block>
|
||||
+ HeaderBackend<Block>
|
||||
+ AuxStore
|
||||
+ UsageProvider<Block>
|
||||
+ Sized
|
||||
+ Send
|
||||
+ Sync
|
||||
+ CallApiAt<
|
||||
Block,
|
||||
StateBackend = Backend::State
|
||||
>,
|
||||
Client::Api: RuntimeApiCollection<StateBackend = Backend::State>,
|
||||
{}
|
||||
|
||||
/// Execute something with the client instance.
|
||||
///
|
||||
/// As there exist multiple chains inside Polkadot, like Polkadot itself, Kusama, Westend etc,
|
||||
/// there can exist different kinds of client types. As these client types differ in the generics
|
||||
/// that are being used, we can not easily return them from a function. For returning them from a
|
||||
/// function there exists [`Client`]. However, the problem on how to use this client instance still
|
||||
/// exists. This trait "solves" it in a dirty way. It requires a type to implement this trait and
|
||||
/// than the [`execute_with_client`](ExecuteWithClient::execute_with_client) function can be called
|
||||
/// with any possible client instance.
|
||||
///
|
||||
/// In a perfect world, we could make a closure work in this way.
|
||||
pub trait ExecuteWithClient {
|
||||
/// The return type when calling this instance.
|
||||
type Output;
|
||||
|
||||
/// Execute whatever should be executed with the given client instance.
|
||||
fn execute_with_client<Client, Api, Backend>(self, client: Arc<Client>) -> Self::Output
|
||||
where
|
||||
<Api as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
|
||||
Backend: sc_client_api::Backend<Block> + 'static,
|
||||
Backend::State: sp_api::StateBackend<BlakeTwo256>,
|
||||
Api: crate::RuntimeApiCollection<StateBackend = Backend::State>,
|
||||
Client: AbstractClient<Block, Backend, Api = Api> + 'static;
|
||||
}
|
||||
|
||||
/// A handle to a Polkadot client instance.
|
||||
///
|
||||
/// The Polkadot service supports multiple different runtimes (Westend, Polkadot itself, etc). As each runtime has a
|
||||
/// specialized client, we need to hide them behind a trait. This is this trait.
|
||||
///
|
||||
/// When wanting to work with the inner client, you need to use `execute_with`.
|
||||
///
|
||||
/// See [`ExecuteWithClient`](trait.ExecuteWithClient.html) for more information.
|
||||
pub trait ClientHandle {
|
||||
/// Execute the given something with the client.
|
||||
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output;
|
||||
}
|
||||
|
||||
/// A client instance of Polkadot.
|
||||
///
|
||||
/// See [`ExecuteWithClient`] for more information.
|
||||
#[derive(Clone)]
|
||||
pub enum Client {
|
||||
Polkadot(Arc<crate::FullClient<polkadot_runtime::RuntimeApi, crate::PolkadotExecutor>>),
|
||||
Westend(Arc<crate::FullClient<westend_runtime::RuntimeApi, crate::WestendExecutor>>),
|
||||
Kusama(Arc<crate::FullClient<kusama_runtime::RuntimeApi, crate::KusamaExecutor>>),
|
||||
Rococo(Arc<crate::FullClient<rococo_runtime::RuntimeApi, crate::RococoExecutor>>),
|
||||
}
|
||||
|
||||
impl ClientHandle for Client {
|
||||
fn execute_with<T: ExecuteWithClient>(&self, t: T) -> T::Output {
|
||||
match self {
|
||||
Self::Polkadot(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
},
|
||||
Self::Westend(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
},
|
||||
Self::Kusama(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
},
|
||||
Self::Rococo(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UsageProvider<Block> for Client {
|
||||
fn usage_info(&self) -> sc_client_api::ClientInfo<Block> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.usage_info(),
|
||||
Self::Westend(client) => client.usage_info(),
|
||||
Self::Kusama(client) => client.usage_info(),
|
||||
Self::Rococo(client) => client.usage_info(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl sc_client_api::BlockBackend<Block> for Client {
|
||||
fn block_body(
|
||||
&self,
|
||||
id: &BlockId<Block>
|
||||
) -> sp_blockchain::Result<Option<Vec<<Block as BlockT>::Extrinsic>>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.block_body(id),
|
||||
Self::Westend(client) => client.block_body(id),
|
||||
Self::Kusama(client) => client.block_body(id),
|
||||
Self::Rococo(client) => client.block_body(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn block(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Option<SignedBlock<Block>>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.block(id),
|
||||
Self::Westend(client) => client.block(id),
|
||||
Self::Kusama(client) => client.block(id),
|
||||
Self::Rococo(client) => client.block(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn block_status(&self, id: &BlockId<Block>) -> sp_blockchain::Result<BlockStatus> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.block_status(id),
|
||||
Self::Westend(client) => client.block_status(id),
|
||||
Self::Kusama(client) => client.block_status(id),
|
||||
Self::Rococo(client) => client.block_status(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn justifications(
|
||||
&self,
|
||||
id: &BlockId<Block>
|
||||
) -> sp_blockchain::Result<Option<Justifications>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.justifications(id),
|
||||
Self::Westend(client) => client.justifications(id),
|
||||
Self::Kusama(client) => client.justifications(id),
|
||||
Self::Rococo(client) => client.justifications(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn block_hash(
|
||||
&self,
|
||||
number: NumberFor<Block>
|
||||
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.block_hash(number),
|
||||
Self::Westend(client) => client.block_hash(number),
|
||||
Self::Kusama(client) => client.block_hash(number),
|
||||
Self::Rococo(client) => client.block_hash(number),
|
||||
}
|
||||
}
|
||||
|
||||
fn indexed_transaction(
|
||||
&self,
|
||||
id: &<Block as BlockT>::Hash
|
||||
) -> sp_blockchain::Result<Option<Vec<u8>>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.indexed_transaction(id),
|
||||
Self::Westend(client) => client.indexed_transaction(id),
|
||||
Self::Kusama(client) => client.indexed_transaction(id),
|
||||
Self::Rococo(client) => client.indexed_transaction(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn block_indexed_body(
|
||||
&self,
|
||||
id: &BlockId<Block>
|
||||
) -> sp_blockchain::Result<Option<Vec<Vec<u8>>>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.block_indexed_body(id),
|
||||
Self::Westend(client) => client.block_indexed_body(id),
|
||||
Self::Kusama(client) => client.block_indexed_body(id),
|
||||
Self::Rococo(client) => client.block_indexed_body(id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
fn storage(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
key: &StorageKey,
|
||||
) -> sp_blockchain::Result<Option<StorageData>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.storage(id, key),
|
||||
Self::Westend(client) => client.storage(id, key),
|
||||
Self::Kusama(client) => client.storage(id, key),
|
||||
Self::Rococo(client) => client.storage(id, key),
|
||||
}
|
||||
}
|
||||
|
||||
fn storage_keys(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
key_prefix: &StorageKey,
|
||||
) -> sp_blockchain::Result<Vec<StorageKey>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.storage_keys(id, key_prefix),
|
||||
Self::Westend(client) => client.storage_keys(id, key_prefix),
|
||||
Self::Kusama(client) => client.storage_keys(id, key_prefix),
|
||||
Self::Rococo(client) => client.storage_keys(id, key_prefix),
|
||||
}
|
||||
}
|
||||
|
||||
fn storage_hash(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
key: &StorageKey,
|
||||
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.storage_hash(id, key),
|
||||
Self::Westend(client) => client.storage_hash(id, key),
|
||||
Self::Kusama(client) => client.storage_hash(id, key),
|
||||
Self::Rococo(client) => client.storage_hash(id, key),
|
||||
}
|
||||
}
|
||||
|
||||
fn storage_pairs(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
key_prefix: &StorageKey,
|
||||
) -> sp_blockchain::Result<Vec<(StorageKey, StorageData)>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.storage_pairs(id, key_prefix),
|
||||
Self::Westend(client) => client.storage_pairs(id, key_prefix),
|
||||
Self::Kusama(client) => client.storage_pairs(id, key_prefix),
|
||||
Self::Rococo(client) => client.storage_pairs(id, key_prefix),
|
||||
}
|
||||
}
|
||||
|
||||
fn storage_keys_iter<'a>(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
prefix: Option<&'a StorageKey>,
|
||||
start_key: Option<&StorageKey>,
|
||||
) -> sp_blockchain::Result<KeyIterator<'a, <crate::FullBackend as sc_client_api::Backend<Block>>::State, Block>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
Self::Westend(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
Self::Kusama(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
Self::Rococo(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
}
|
||||
}
|
||||
|
||||
fn child_storage(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
child_info: &ChildInfo,
|
||||
key: &StorageKey,
|
||||
) -> sp_blockchain::Result<Option<StorageData>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.child_storage(id, child_info, key),
|
||||
Self::Westend(client) => client.child_storage(id, child_info, key),
|
||||
Self::Kusama(client) => client.child_storage(id, child_info, key),
|
||||
Self::Rococo(client) => client.child_storage(id, child_info, key),
|
||||
}
|
||||
}
|
||||
|
||||
fn child_storage_keys(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
child_info: &ChildInfo,
|
||||
key_prefix: &StorageKey,
|
||||
) -> sp_blockchain::Result<Vec<StorageKey>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
Self::Westend(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
Self::Kusama(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
Self::Rococo(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
}
|
||||
}
|
||||
|
||||
fn child_storage_hash(
|
||||
&self,
|
||||
id: &BlockId<Block>,
|
||||
child_info: &ChildInfo,
|
||||
key: &StorageKey,
|
||||
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.child_storage_hash(id, child_info, key),
|
||||
Self::Westend(client) => client.child_storage_hash(id, child_info, key),
|
||||
Self::Kusama(client) => client.child_storage_hash(id, child_info, key),
|
||||
Self::Rococo(client) => client.child_storage_hash(id, child_info, key),
|
||||
}
|
||||
}
|
||||
|
||||
fn max_key_changes_range(
|
||||
&self,
|
||||
first: NumberFor<Block>,
|
||||
last: BlockId<Block>,
|
||||
) -> sp_blockchain::Result<Option<(NumberFor<Block>, BlockId<Block>)>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.max_key_changes_range(first, last),
|
||||
Self::Westend(client) => client.max_key_changes_range(first, last),
|
||||
Self::Kusama(client) => client.max_key_changes_range(first, last),
|
||||
Self::Rococo(client) => client.max_key_changes_range(first, last),
|
||||
}
|
||||
}
|
||||
|
||||
fn key_changes(
|
||||
&self,
|
||||
first: NumberFor<Block>,
|
||||
last: BlockId<Block>,
|
||||
storage_key: Option<&PrefixedStorageKey>,
|
||||
key: &StorageKey,
|
||||
) -> sp_blockchain::Result<Vec<(NumberFor<Block>, u32)>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.key_changes(first, last, storage_key, key),
|
||||
Self::Westend(client) => client.key_changes(first, last, storage_key, key),
|
||||
Self::Kusama(client) => client.key_changes(first, last, storage_key, key),
|
||||
Self::Rococo(client) => client.key_changes(first, last, storage_key, key),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_blockchain::HeaderBackend<Block> for Client {
|
||||
fn header(&self, id: BlockId<Block>) -> sp_blockchain::Result<Option<Header>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.header(&id),
|
||||
Self::Westend(client) => client.header(&id),
|
||||
Self::Kusama(client) => client.header(&id),
|
||||
Self::Rococo(client) => client.header(&id),
|
||||
}
|
||||
}
|
||||
|
||||
fn info(&self) -> sp_blockchain::Info<Block> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.info(),
|
||||
Self::Westend(client) => client.info(),
|
||||
Self::Kusama(client) => client.info(),
|
||||
Self::Rococo(client) => client.info(),
|
||||
}
|
||||
}
|
||||
|
||||
fn status(&self, id: BlockId<Block>) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.status(id),
|
||||
Self::Westend(client) => client.status(id),
|
||||
Self::Kusama(client) => client.status(id),
|
||||
Self::Rococo(client) => client.status(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn number(&self, hash: Hash) -> sp_blockchain::Result<Option<BlockNumber>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.number(hash),
|
||||
Self::Westend(client) => client.number(hash),
|
||||
Self::Kusama(client) => client.number(hash),
|
||||
Self::Rococo(client) => client.number(hash),
|
||||
}
|
||||
}
|
||||
|
||||
fn hash(&self, number: BlockNumber) -> sp_blockchain::Result<Option<Hash>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.hash(number),
|
||||
Self::Westend(client) => client.hash(number),
|
||||
Self::Kusama(client) => client.hash(number),
|
||||
Self::Rococo(client) => client.hash(number),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
pub mod chain_spec;
|
||||
mod grandpa_support;
|
||||
mod client;
|
||||
mod parachains_db;
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
@@ -53,11 +52,22 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use prometheus_endpoint::Registry;
|
||||
use sc_executor::native_executor_instance;
|
||||
use service::RpcHandlers;
|
||||
use telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
|
||||
|
||||
pub use self::client::{AbstractClient, Client, ClientHandle, ExecuteWithClient, RuntimeApiCollection};
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub use polkadot_client::RococoExecutor;
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub use polkadot_client::WestendExecutor;
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub use polkadot_client::KusamaExecutor;
|
||||
|
||||
pub use polkadot_client::{
|
||||
PolkadotExecutor, FullBackend, FullClient, AbstractClient, Client, ClientHandle, ExecuteWithClient,
|
||||
RuntimeApiCollection,
|
||||
};
|
||||
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
|
||||
pub use consensus_common::{Proposal, SelectChain, BlockImport, block_validation::Chain};
|
||||
pub use polkadot_primitives::v1::{Block, BlockId, CollatorPair, Hash, Id as ParaId};
|
||||
@@ -73,42 +83,17 @@ pub use service::config::{DatabaseConfig, PrometheusConfig};
|
||||
pub use sp_api::{ApiRef, Core as CoreApi, ConstructRuntimeApi, ProvideRuntimeApi, StateBackend};
|
||||
pub use sp_runtime::traits::{DigestFor, HashFor, NumberFor, Block as BlockT, self as runtime_traits, BlakeTwo256};
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub use kusama_runtime;
|
||||
pub use polkadot_runtime;
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub use rococo_runtime;
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub use westend_runtime;
|
||||
|
||||
/// The maximum number of active leaves we forward to the [`Overseer`] on startup.
|
||||
const MAX_ACTIVE_LEAVES: usize = 4;
|
||||
|
||||
native_executor_instance!(
|
||||
pub PolkadotExecutor,
|
||||
polkadot_runtime::api::dispatch,
|
||||
polkadot_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
native_executor_instance!(
|
||||
pub KusamaExecutor,
|
||||
kusama_runtime::api::dispatch,
|
||||
kusama_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
native_executor_instance!(
|
||||
pub WestendExecutor,
|
||||
westend_runtime::api::dispatch,
|
||||
westend_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
native_executor_instance!(
|
||||
pub RococoExecutor,
|
||||
rococo_runtime::api::dispatch,
|
||||
rococo_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
@@ -209,17 +194,17 @@ fn jaeger_launch_collector_with_agent(spawner: impl SpawnNamed, config: &Configu
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub type FullBackend = service::TFullBackend<Block>;
|
||||
#[cfg(feature = "full-node")]
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
pub type FullClient<RuntimeApi, Executor> = service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
#[cfg(feature = "full-node")]
|
||||
type FullGrandpaBlockImport<RuntimeApi, Executor> = grandpa::GrandpaBlockImport<
|
||||
FullBackend, Block, FullClient<RuntimeApi, Executor>, FullSelectChain
|
||||
>;
|
||||
|
||||
#[cfg(feature = "light-node")]
|
||||
type LightBackend = service::TLightBackendWithHash<Block, sp_runtime::traits::BlakeTwo256>;
|
||||
|
||||
#[cfg(feature = "light-node")]
|
||||
type LightClient<RuntimeApi, Executor> =
|
||||
service::TLightClientWithBackend<Block, RuntimeApi, Executor, LightBackend>;
|
||||
|
||||
@@ -975,7 +960,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
min_block_delta: if chain_spec.is_wococo() { 4 } else { 8 },
|
||||
prometheus_registry: prometheus_registry.clone(),
|
||||
};
|
||||
|
||||
|
||||
let gadget = beefy_gadget::start_beefy_gadget::<_, beefy_primitives::ecdsa::AuthorityPair, _, _, _>(
|
||||
beefy_params
|
||||
);
|
||||
@@ -1069,6 +1054,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
}
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
#[cfg(feature = "light-node")]
|
||||
fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(
|
||||
TaskManager,
|
||||
RpcHandlers,
|
||||
@@ -1239,39 +1225,56 @@ pub fn new_chain_ops(
|
||||
>
|
||||
{
|
||||
config.keystore = service::config::KeystoreConfig::InMemory;
|
||||
|
||||
#[cfg(feature = "rococo-native")]
|
||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<rococo_runtime::RuntimeApi, RococoExecutor>(config, jaeger_agent, None)?;
|
||||
Ok((Arc::new(Client::Rococo(client)), backend, import_queue, task_manager))
|
||||
} else if config.chain_spec.is_kusama() {
|
||||
return Ok((Arc::new(Client::Rococo(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
if config.chain_spec.is_kusama() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<kusama_runtime::RuntimeApi, KusamaExecutor>(config, jaeger_agent, None)?;
|
||||
Ok((Arc::new(Client::Kusama(client)), backend, import_queue, task_manager))
|
||||
} else if config.chain_spec.is_westend() {
|
||||
return Ok((Arc::new(Client::Kusama(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
if config.chain_spec.is_westend() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<westend_runtime::RuntimeApi, WestendExecutor>(config, jaeger_agent, None)?;
|
||||
Ok((Arc::new(Client::Westend(client)), backend, import_queue, task_manager))
|
||||
} else {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config, jaeger_agent, None)?;
|
||||
Ok((Arc::new(Client::Polkadot(client)), backend, import_queue, task_manager))
|
||||
return Ok((Arc::new(Client::Westend(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config, jaeger_agent, None)?;
|
||||
Ok((Arc::new(Client::Polkadot(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
|
||||
/// Build a new light node.
|
||||
#[cfg(feature = "light-node")]
|
||||
pub fn build_light(config: Configuration) -> Result<(
|
||||
TaskManager,
|
||||
RpcHandlers,
|
||||
), Error> {
|
||||
#[cfg(feature = "rococo-native")]
|
||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
||||
new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
|
||||
} else if config.chain_spec.is_kusama() {
|
||||
new_light::<kusama_runtime::RuntimeApi, KusamaExecutor>(config)
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_light::<westend_runtime::RuntimeApi, WestendExecutor>(config)
|
||||
} else {
|
||||
new_light::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config)
|
||||
return new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
if config.chain_spec.is_kusama() {
|
||||
return new_light::<kusama_runtime::RuntimeApi, KusamaExecutor>(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
if config.chain_spec.is_westend() {
|
||||
return new_light::<westend_runtime::RuntimeApi, WestendExecutor>(config)
|
||||
}
|
||||
|
||||
new_light::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config)
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
@@ -1283,8 +1286,9 @@ pub fn build_full(
|
||||
jaeger_agent: Option<std::net::SocketAddr>,
|
||||
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
|
||||
) -> Result<NewFull<Client>, Error> {
|
||||
#[cfg(feature = "rococo-native")]
|
||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
||||
new_full::<rococo_runtime::RuntimeApi, RococoExecutor>(
|
||||
return new_full::<rococo_runtime::RuntimeApi, RococoExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
@@ -1293,8 +1297,11 @@ pub fn build_full(
|
||||
telemetry_worker_handle,
|
||||
None,
|
||||
).map(|full| full.with_client(Client::Rococo))
|
||||
} else if config.chain_spec.is_kusama() {
|
||||
new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
}
|
||||
|
||||
#[cfg(feature = "kusama-native")]
|
||||
if config.chain_spec.is_kusama() {
|
||||
return new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
@@ -1303,8 +1310,11 @@ pub fn build_full(
|
||||
telemetry_worker_handle,
|
||||
None,
|
||||
).map(|full| full.with_client(Client::Kusama))
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
}
|
||||
|
||||
#[cfg(feature = "westend-native")]
|
||||
if config.chain_spec.is_westend() {
|
||||
return new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
@@ -1313,15 +1323,15 @@ pub fn build_full(
|
||||
telemetry_worker_handle,
|
||||
None,
|
||||
).map(|full| full.with_client(Client::Westend))
|
||||
} else {
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
disable_beefy,
|
||||
jaeger_agent,
|
||||
telemetry_worker_handle,
|
||||
None,
|
||||
).map(|full| full.with_client(Client::Polkadot))
|
||||
}
|
||||
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
disable_beefy,
|
||||
jaeger_agent,
|
||||
telemetry_worker_handle,
|
||||
None,
|
||||
).map(|full| full.with_client(Client::Polkadot))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user