Unverified Commit b5cc86af authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Bump to latest Substrate (#898)



* Flag to force kusama runtime

* Chainspecs for kusama

* Polkadot config for westend

Co-Authored-By: default avatarBastian Köcher <bkchr@users.noreply.github.com>

* network/src/legacy/gossip: Wrap GossipEngine in Arc Mutex & lock it on use

`GossipEngine` in itself has no need to be Send and Sync, given that it
does not rely on separately spawned background tasks anymore.
`RegisteredMessageValidator` needs to be `Send` and `Sync` due to the
inherited trait bounds from implementing `GossipService`. In addition
`RegisteredMessageValidator` derives `Clone`. Thereby `GossipEngine`
needs to be wrapped in an `Arc` and `Mutex` to keep the status quo.

* Needed fixes.

* Fixes

* Fixed build

* Fixed build w benchmarking CLI

* Fixed building tests

* Added --dev shortcut

Co-authored-by: Arkadiy Paronyan's avatararkpar <arkady.paronyan@gmail.com>
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: default avatarMax Inden <mail@max-inden.de>
parent fb06c824
Pipeline #82831 passed with stages
in 21 minutes and 39 seconds
This diff is collapsed.
...@@ -35,7 +35,7 @@ use polkadot_primitives::{ ...@@ -35,7 +35,7 @@ use polkadot_primitives::{
use sp_runtime::traits::HashFor; use sp_runtime::traits::HashFor;
use sp_blockchain::{Result as ClientResult}; use sp_blockchain::{Result as ClientResult};
use client::{ use client::{
BlockchainEvents, BlockBody, BlockchainEvents, BlockBackend,
}; };
use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_api::{ApiExt, ProvideRuntimeApi};
use codec::{Encode, Decode}; use codec::{Encode, Decode};
...@@ -178,7 +178,7 @@ impl Store { ...@@ -178,7 +178,7 @@ impl Store {
keystore: KeyStorePtr, keystore: KeyStorePtr,
) -> ClientResult<AvailabilityBlockImport<I, P>> ) -> ClientResult<AvailabilityBlockImport<I, P>>
where where
P: ProvideRuntimeApi<Block> + BlockchainEvents<Block> + BlockBody<Block> + Send + Sync + 'static, P: ProvideRuntimeApi<Block> + BlockchainEvents<Block> + BlockBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block>, P::Api: ParachainHost<Block>,
P::Api: ApiExt<Block, Error=sp_blockchain::Error>, P::Api: ApiExt<Block, Error=sp_blockchain::Error>,
// Rust bug: https://github.com/rust-lang/rust/issues/24159 // Rust bug: https://github.com/rust-lang/rust/issues/24159
......
...@@ -24,7 +24,7 @@ use sp_blockchain::{Result as ClientResult}; ...@@ -24,7 +24,7 @@ use sp_blockchain::{Result as ClientResult};
use sp_runtime::traits::{Header as HeaderT, Block as BlockT, HashFor, BlakeTwo256}; use sp_runtime::traits::{Header as HeaderT, Block as BlockT, HashFor, BlakeTwo256};
use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_api::{ApiExt, ProvideRuntimeApi};
use client::{ use client::{
BlockchainEvents, BlockBody, BlockchainEvents, BlockBackend,
blockchain::ProvideCache, blockchain::ProvideCache,
}; };
use consensus_common::{ use consensus_common::{
...@@ -203,7 +203,7 @@ where ...@@ -203,7 +203,7 @@ where
/// Creates a task to prune entries in availability store upon block finalization. /// Creates a task to prune entries in availability store upon block finalization.
async fn prune_unneeded_availability<P, S>(client: Arc<P>, mut sender: S) async fn prune_unneeded_availability<P, S>(client: Arc<P>, mut sender: S)
where where
P: ProvideRuntimeApi<Block> + BlockchainEvents<Block> + BlockBody<Block> + Send + Sync + 'static, P: ProvideRuntimeApi<Block> + BlockchainEvents<Block> + BlockBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + ApiExt<Block, Error=sp_blockchain::Error>, P::Api: ParachainHost<Block> + ApiExt<Block, Error=sp_blockchain::Error>,
S: Sink<WorkerMsg> + Clone + Send + Sync + Unpin, S: Sink<WorkerMsg> + Clone + Send + Sync + Unpin,
// Rust bug: https://github.com/rust-lang/rust/issues/24159 // Rust bug: https://github.com/rust-lang/rust/issues/24159
...@@ -646,7 +646,7 @@ impl<I, P> AvailabilityBlockImport<I, P> { ...@@ -646,7 +646,7 @@ impl<I, P> AvailabilityBlockImport<I, P> {
to_worker: mpsc::UnboundedSender<WorkerMsg>, to_worker: mpsc::UnboundedSender<WorkerMsg>,
) -> Self ) -> Self
where where
P: ProvideRuntimeApi<Block> + BlockBody<Block> + BlockchainEvents<Block> + Send + Sync + 'static, P: ProvideRuntimeApi<Block> + BlockBackend<Block> + BlockchainEvents<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block>, P::Api: ParachainHost<Block>,
P::Api: ApiExt<Block, Error = sp_blockchain::Error>, P::Api: ApiExt<Block, Error = sp_blockchain::Error>,
// Rust bug: https://github.com/rust-lang/rust/issues/24159 // Rust bug: https://github.com/rust-lang/rust/issues/24159
......
...@@ -22,16 +22,22 @@ use service; ...@@ -22,16 +22,22 @@ use service;
/// specification). /// specification).
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum ChainSpec { pub enum ChainSpec {
/// Whatever the current runtime is, with just Alice as an auth. /// Whatever the current polkadot runtime is, with just Alice as an auth.
Development, PolkadotDevelopment,
/// Whatever the current runtime is, with simple Alice/Bob auths. /// Whatever the current pokadot runtime is, with simple Alice/Bob auths.
LocalTestnet, PolkadotLocalTestnet,
/// The Kusama network. /// The Kusama network.
Kusama, Kusama,
/// Whatever the current kusama runtime is, with just Alice as an auth.
KusamaDevelopment,
/// The Westend network, /// The Westend network,
Westend, Westend,
/// Whatever the current runtime is with the "global testnet" defaults. /// Whatever the current polkadot runtime is with the "global testnet" defaults.
StagingTestnet, PolkadotStagingTestnet,
/// Whatever the current kusama runtime is with the "global testnet" defaults.
KusamaStagingTestnet,
/// Whatever the current kusama runtime is, with simple Alice/Bob auths.
KusamaLocalTestnet,
} }
impl Default for ChainSpec { impl Default for ChainSpec {
...@@ -42,23 +48,29 @@ impl Default for ChainSpec { ...@@ -42,23 +48,29 @@ impl Default for ChainSpec {
/// Get a chain config from a spec setting. /// Get a chain config from a spec setting.
impl ChainSpec { impl ChainSpec {
pub(crate) fn load(self) -> Result<service::ChainSpec, String> { pub(crate) fn load(self) -> Result<Box<dyn service::ChainSpec>, String> {
match self { Ok(match self {
ChainSpec::Development => Ok(service::chain_spec::development_config()), ChainSpec::PolkadotDevelopment => Box::new(service::chain_spec::polkadot_development_config()),
ChainSpec::LocalTestnet => Ok(service::chain_spec::local_testnet_config()), ChainSpec::PolkadotLocalTestnet => Box::new(service::chain_spec::polkadot_local_testnet_config()),
ChainSpec::StagingTestnet => Ok(service::chain_spec::staging_testnet_config()), ChainSpec::PolkadotStagingTestnet => Box::new(service::chain_spec::polkadot_staging_testnet_config()),
ChainSpec::Westend => service::chain_spec::westend_config(), ChainSpec::KusamaDevelopment =>Box::new(service::chain_spec::kusama_development_config()),
ChainSpec::Kusama => service::chain_spec::kusama_config(), ChainSpec::KusamaLocalTestnet => Box::new(service::chain_spec::kusama_local_testnet_config()),
} ChainSpec::KusamaStagingTestnet => Box::new(service::chain_spec::kusama_staging_testnet_config()),
ChainSpec::Westend => Box::new(service::chain_spec::westend_config()?),
ChainSpec::Kusama => Box::new(service::chain_spec::kusama_config()?),
})
} }
pub(crate) fn from(s: &str) -> Option<Self> { pub(crate) fn from(s: &str) -> Option<Self> {
match s { match s {
"dev" => Some(ChainSpec::Development), "polkadot-dev" | "dev" => Some(ChainSpec::PolkadotDevelopment),
"local" => Some(ChainSpec::LocalTestnet), "polkadot-local" => Some(ChainSpec::PolkadotLocalTestnet),
"polkadot-staging" => Some(ChainSpec::PolkadotStagingTestnet),
"kusama-dev" => Some(ChainSpec::KusamaDevelopment),
"kusama-local" => Some(ChainSpec::KusamaLocalTestnet),
"kusama-staging" => Some(ChainSpec::KusamaStagingTestnet),
"kusama" => Some(ChainSpec::Kusama), "kusama" => Some(ChainSpec::Kusama),
"westend" => Some(ChainSpec::Westend), "westend" => Some(ChainSpec::Westend),
"staging" => Some(ChainSpec::StagingTestnet),
"" => Some(ChainSpec::default()), "" => Some(ChainSpec::default()),
_ => None, _ => None,
} }
...@@ -66,9 +78,11 @@ impl ChainSpec { ...@@ -66,9 +78,11 @@ impl ChainSpec {
} }
/// Load the `ChainSpec` for the given `id`. /// Load the `ChainSpec` for the given `id`.
pub fn load_spec(id: &str) -> Result<Option<service::ChainSpec>, String> { /// `force_kusama` treats chain specs coming from a file as kusama specs.
pub fn load_spec(id: &str, force_kusama: bool) -> Result<Box<dyn service::ChainSpec>, String> {
Ok(match ChainSpec::from(id) { Ok(match ChainSpec::from(id) {
Some(spec) => Some(spec.load()?), Some(spec) => spec.load()?,
None => None, None if force_kusama => Box::new(service::KusamaChainSpec::from_json_file(std::path::PathBuf::from(id))?),
None => Box::new(service::PolkadotChainSpec::from_json_file(std::path::PathBuf::from(id))?),
}) })
} }
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
//! Polkadot CLI library. //! Polkadot CLI library.
use structopt::StructOpt; use structopt::StructOpt;
pub use sc_cli::RunCmd;
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt, Clone)] #[derive(Debug, StructOpt, Clone)]
...@@ -45,6 +44,18 @@ pub struct ValidationWorkerCommand { ...@@ -45,6 +44,18 @@ pub struct ValidationWorkerCommand {
pub mem_id: String, pub mem_id: String,
} }
#[allow(missing_docs)]
#[derive(Debug, StructOpt, Clone)]
pub struct RunCmd {
#[allow(missing_docs)]
#[structopt(flatten)]
pub base: sc_cli::RunCmd,
/// Force using Kusama native runtime.
#[structopt(long = "force-kusama")]
pub force_kusama: bool,
}
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Debug, StructOpt, Clone)] #[derive(Debug, StructOpt, Clone)]
#[structopt(settings = &[ #[structopt(settings = &[
......
...@@ -29,13 +29,18 @@ pub fn run(version: VersionInfo) -> sc_cli::Result<()> { ...@@ -29,13 +29,18 @@ pub fn run(version: VersionInfo) -> sc_cli::Result<()> {
let mut config = service::Configuration::from_version(&version); let mut config = service::Configuration::from_version(&version);
config.impl_name = "parity-polkadot"; config.impl_name = "parity-polkadot";
let force_kusama = opt.run.force_kusama;
match opt.subcommand { match opt.subcommand {
None => { None => {
opt.run.init(&version)?; opt.run.base.init(&version)?;
opt.run.update_config(&mut config, load_spec, &version)?; opt.run.base.update_config(
&mut config,
|id| load_spec(id, force_kusama),
&version
)?;
let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama()); let is_kusama = config.expect_chain_spec().is_kusama();
info!("{}", version.name); info!("{}", version.name);
info!(" version {}", config.full_version()); info!(" version {}", config.full_version());
...@@ -69,9 +74,13 @@ pub fn run(version: VersionInfo) -> sc_cli::Result<()> { ...@@ -69,9 +74,13 @@ pub fn run(version: VersionInfo) -> sc_cli::Result<()> {
}, },
Some(Subcommand::Base(cmd)) => { Some(Subcommand::Base(cmd)) => {
cmd.init(&version)?; cmd.init(&version)?;
cmd.update_config(&mut config, load_spec, &version)?; cmd.update_config(
&mut config,
|id| load_spec(id, force_kusama),
&version
)?;
let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama()); let is_kusama = config.expect_chain_spec().is_kusama();
if is_kusama { if is_kusama {
cmd.run(config, service::new_chain_ops::< cmd.run(config, service::new_chain_ops::<
...@@ -100,14 +109,12 @@ pub fn run(version: VersionInfo) -> sc_cli::Result<()> { ...@@ -100,14 +109,12 @@ pub fn run(version: VersionInfo) -> sc_cli::Result<()> {
}, },
Some(Subcommand::Benchmark(cmd)) => { Some(Subcommand::Benchmark(cmd)) => {
cmd.init(&version)?; cmd.init(&version)?;
cmd.update_config(&mut config, load_spec, &version)?; cmd.update_config(&mut config, |id| load_spec(id, force_kusama), &version)?;
let is_kusama = config.expect_chain_spec().is_kusama();
let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama());
if is_kusama { if is_kusama {
cmd.run::<_, _, service::kusama_runtime::Block, service::KusamaExecutor>(config) cmd.run::<service::kusama_runtime::Block, service::KusamaExecutor>(config)
} else { } else {
cmd.run::<_, _, service::polkadot_runtime::Block, service::PolkadotExecutor>(config) cmd.run::<service::polkadot_runtime::Block, service::PolkadotExecutor>(config)
} }
}, },
} }
......
...@@ -71,7 +71,7 @@ use std::sync::Arc; ...@@ -71,7 +71,7 @@ use std::sync::Arc;
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use futures::prelude::*; use futures::prelude::*;
use parking_lot::RwLock; use parking_lot::{Mutex, RwLock};
use crate::legacy::{GossipMessageStream, GossipService}; use crate::legacy::{GossipMessageStream, GossipService};
...@@ -289,20 +289,28 @@ pub fn register_validator<C: ChainContext + 'static>( ...@@ -289,20 +289,28 @@ pub fn register_validator<C: ChainContext + 'static>(
}); });
let gossip_side = validator.clone(); let gossip_side = validator.clone();
let gossip_engine = sc_network_gossip::GossipEngine::new( let gossip_engine = Arc::new(Mutex::new(sc_network_gossip::GossipEngine::new(
service.clone(), service.clone(),
POLKADOT_ENGINE_ID, POLKADOT_ENGINE_ID,
POLKADOT_PROTOCOL_NAME, POLKADOT_PROTOCOL_NAME,
gossip_side, gossip_side,
); )));
// Spawn gossip engine.
//
// Ideally this would not be spawned as an orphaned task, but polled by // Ideally this would not be spawned as an orphaned task, but polled by
// `RegisteredMessageValidator` which in turn would be polled by a `ValidationNetwork`. // `RegisteredMessageValidator` which in turn would be polled by a `ValidationNetwork`.
let spawn_res = executor.spawn_obj(futures::task::FutureObj::from(Box::new(gossip_engine.clone()))); {
let gossip_engine = gossip_engine.clone();
let fut = futures::future::poll_fn(move |cx| {
gossip_engine.lock().poll_unpin(cx)
});
let spawn_res = executor.spawn_obj(futures::task::FutureObj::from(Box::new(fut)));
// Note: we consider the chances of an error to spawn a background task almost null. // Note: we consider the chances of an error to spawn a background task almost null.
if spawn_res.is_err() { if spawn_res.is_err() {
log::error!(target: "polkadot-gossip", "Failed to spawn background task"); log::error!(target: "polkadot-gossip", "Failed to spawn background task");
}
} }
RegisteredMessageValidator { RegisteredMessageValidator {
...@@ -350,7 +358,7 @@ pub struct RegisteredMessageValidator { ...@@ -350,7 +358,7 @@ pub struct RegisteredMessageValidator {
// Note: this is always `Some` in real code and `None` in tests. // Note: this is always `Some` in real code and `None` in tests.
service: Option<Arc<NetworkService<Block, Hash>>>, service: Option<Arc<NetworkService<Block, Hash>>>,
// Note: this is always `Some` in real code and `None` in tests. // Note: this is always `Some` in real code and `None` in tests.
gossip_engine: Option<sc_network_gossip::GossipEngine<Block>>, gossip_engine: Option<Arc<Mutex<sc_network_gossip::GossipEngine<Block>>>>,
} }
impl RegisteredMessageValidator { impl RegisteredMessageValidator {
...@@ -398,7 +406,7 @@ impl RegisteredMessageValidator { ...@@ -398,7 +406,7 @@ impl RegisteredMessageValidator {
pub(crate) fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream { pub(crate) fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream {
let topic_stream = if let Some(gossip_engine) = self.gossip_engine.as_ref() { let topic_stream = if let Some(gossip_engine) = self.gossip_engine.as_ref() {
gossip_engine.messages_for(topic) gossip_engine.lock().messages_for(topic)
} else { } else {
log::error!("Called gossip_messages_for on a test engine"); log::error!("Called gossip_messages_for on a test engine");
futures::channel::mpsc::unbounded().1 futures::channel::mpsc::unbounded().1
...@@ -409,7 +417,7 @@ impl RegisteredMessageValidator { ...@@ -409,7 +417,7 @@ impl RegisteredMessageValidator {
pub(crate) fn gossip_message(&self, topic: Hash, message: GossipMessage) { pub(crate) fn gossip_message(&self, topic: Hash, message: GossipMessage) {
if let Some(gossip_engine) = self.gossip_engine.as_ref() { if let Some(gossip_engine) = self.gossip_engine.as_ref() {
gossip_engine.gossip_message( gossip_engine.lock().gossip_message(
topic, topic,
message.encode(), message.encode(),
false, false,
...@@ -421,7 +429,7 @@ impl RegisteredMessageValidator { ...@@ -421,7 +429,7 @@ impl RegisteredMessageValidator {
pub(crate) fn send_message(&self, who: PeerId, message: GossipMessage) { pub(crate) fn send_message(&self, who: PeerId, message: GossipMessage) {
if let Some(gossip_engine) = self.gossip_engine.as_ref() { if let Some(gossip_engine) = self.gossip_engine.as_ref() {
gossip_engine.send_message(vec![who], message.encode()); gossip_engine.lock().send_message(vec![who], message.encode());
} else { } else {
log::error!("Called send_message on a test engine"); log::error!("Called send_message on a test engine");
} }
......
...@@ -31,6 +31,7 @@ use sc_client_api::{ ...@@ -31,6 +31,7 @@ use sc_client_api::{
BlockchainEvents, BlockImportNotification, BlockchainEvents, BlockImportNotification,
FinalityNotifications, ImportNotifications, FinalityNotifications, ImportNotifications,
FinalityNotification, FinalityNotification,
client::BlockBackend,
backend::{TransactionFor, AuxStore, Backend, Finalizer}, backend::{TransactionFor, AuxStore, Backend, Finalizer},
}; };
use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
......
...@@ -164,9 +164,11 @@ pub fn validate_candidate_internal<E: Externalities + 'static>( ...@@ -164,9 +164,11 @@ pub fn validate_candidate_internal<E: Externalities + 'static>(
Some(1024), Some(1024),
HostFunctions::host_functions(), HostFunctions::host_functions(),
false, false,
8
); );
let res = executor.call_in_wasm( let res = executor.call_in_wasm(
validation_code, validation_code,
None,
"validate_block", "validate_block",
encoded_call_data, encoded_call_data,
&mut ext, &mut ext,
...@@ -192,22 +194,6 @@ impl sp_externalities::Externalities for ValidationExternalities { ...@@ -192,22 +194,6 @@ impl sp_externalities::Externalities for ValidationExternalities {
panic!("child_storage_hash: unsupported feature for parachain validation") panic!("child_storage_hash: unsupported feature for parachain validation")
} }
fn original_storage(&self, _: &[u8]) -> Option<Vec<u8>> {
panic!("original_sorage: unsupported feature for parachain validation")
}
fn original_child_storage(&self, _: ChildStorageKey, _: ChildInfo, _: &[u8]) -> Option<Vec<u8>> {
panic!("original_child_storage: unsupported feature for parachain validation")
}
fn original_storage_hash(&self, _: &[u8]) -> Option<Vec<u8>> {
panic!("original_storage_hash: unsupported feature for parachain validation")
}
fn original_child_storage_hash(&self, _: ChildStorageKey, _: ChildInfo, _: &[u8]) -> Option<Vec<u8>> {
panic!("original_child_storage_hash: unsupported feature for parachain validation")
}
fn child_storage(&self, _: ChildStorageKey, _: ChildInfo, _: &[u8]) -> Option<Vec<u8>> { fn child_storage(&self, _: ChildStorageKey, _: ChildInfo, _: &[u8]) -> Option<Vec<u8>> {
panic!("child_storage: unsupported feature for parachain validation") panic!("child_storage: unsupported feature for parachain validation")
} }
......
...@@ -319,5 +319,5 @@ pub fn new_light_fetcher() -> LightFetcher { ...@@ -319,5 +319,5 @@ pub fn new_light_fetcher() -> LightFetcher {
/// Create a new native executor. /// Create a new native executor.
pub fn new_native_executor() -> sc_executor::NativeExecutor<LocalExecutor> { pub fn new_native_executor() -> sc_executor::NativeExecutor<LocalExecutor> {
sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None) sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None, 8)
} }
This diff is collapsed.
...@@ -32,6 +32,7 @@ use log::info; ...@@ -32,6 +32,7 @@ use log::info;
pub use service::{ pub use service::{
AbstractService, Roles, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, ServiceBuilderCommand, AbstractService, Roles, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis, ServiceBuilderCommand,
TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor, TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor,
Configuration, ChainSpec,
}; };
pub use service::config::{DatabaseConfig, PrometheusConfig, full_version_from_strs}; pub use service::config::{DatabaseConfig, PrometheusConfig, full_version_from_strs};
pub use sc_executor::NativeExecutionDispatch; pub use sc_executor::NativeExecutionDispatch;
...@@ -43,7 +44,7 @@ pub use consensus_common::SelectChain; ...@@ -43,7 +44,7 @@ pub use consensus_common::SelectChain;
pub use polkadot_primitives::parachain::{CollatorId, ParachainHost}; pub use polkadot_primitives::parachain::{CollatorId, ParachainHost};
pub use polkadot_primitives::Block; pub use polkadot_primitives::Block;
pub use sp_runtime::traits::{Block as BlockT, self as runtime_traits, BlakeTwo256}; pub use sp_runtime::traits::{Block as BlockT, self as runtime_traits, BlakeTwo256};
pub use chain_spec::ChainSpec; pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec};
#[cfg(not(target_os = "unknown"))] #[cfg(not(target_os = "unknown"))]
pub use consensus::run_validation_worker; pub use consensus::run_validation_worker;
pub use codec::Codec; pub use codec::Codec;
...@@ -51,14 +52,6 @@ pub use polkadot_runtime; ...@@ -51,14 +52,6 @@ pub use polkadot_runtime;
pub use kusama_runtime; pub use kusama_runtime;
use prometheus_endpoint::Registry; use prometheus_endpoint::Registry;
/// Configuration type that is being used.
///
/// See [`ChainSpec`] for more information why Polkadot `GenesisConfig` is safe here.
pub type Configuration = service::Configuration<
polkadot_runtime::GenesisConfig,
chain_spec::Extensions,
>;
native_executor_instance!( native_executor_instance!(
pub PolkadotExecutor, pub PolkadotExecutor,
polkadot_runtime::api::dispatch, polkadot_runtime::api::dispatch,
...@@ -121,9 +114,9 @@ pub trait IsKusama { ...@@ -121,9 +114,9 @@ pub trait IsKusama {
fn is_kusama(&self) -> bool; fn is_kusama(&self) -> bool;
} }
impl IsKusama for ChainSpec { impl IsKusama for &dyn ChainSpec {
fn is_kusama(&self) -> bool { fn is_kusama(&self) -> bool {
self.name().starts_with("Kusama") self.id().starts_with("kusama") || self.id().starts_with("ksm")
} }
} }
...@@ -453,6 +446,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>( ...@@ -453,6 +446,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
sentry_nodes, sentry_nodes,
service.keystore(), service.keystore(),
dht_event_stream, dht_event_stream,
service.prometheus_registry(),
); );
service.spawn_task("authority-discovery", authority_discovery); service.spawn_task("authority-discovery", authority_discovery);
} }
......
...@@ -133,7 +133,7 @@ fn main() { ...@@ -133,7 +133,7 @@ fn main() {
}; };
let mut config = Configuration::default(); let mut config = Configuration::default();
config.chain_spec = load_spec("dev").unwrap(); config.chain_spec = Some(load_spec("dev", false).unwrap());
let res = collator::run_collator( let res = collator::run_collator(
context, context,
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
use std::{time::{Duration, Instant}, sync::Arc}; use std::{time::{Duration, Instant}, sync::Arc};
use std::collections::HashMap; use std::collections::HashMap;
use sc_client_api::{BlockchainEvents, BlockBody}; use sc_client_api::{BlockchainEvents, BlockBackend};
use sp_blockchain::HeaderBackend; use sp_blockchain::HeaderBackend;
use block_builder::BlockBuilderApi; use block_builder::BlockBuilderApi;
use consensus::SelectChain; use consensus::SelectChain;
...@@ -139,7 +139,7 @@ pub struct ServiceBuilder<C, N, P, SC, SP> { ...@@ -139,7 +139,7 @@ pub struct ServiceBuilder<C, N, P, SC, SP> {
impl<C, N, P, SC, SP> ServiceBuilder<C, N, P, SC, SP> where impl<C, N, P, SC, SP> ServiceBuilder<C, N, P, SC, SP> where
C: Collators + Send + Sync + Unpin + 'static, C: Collators + Send + Sync + Unpin + 'static,
C::Collation: Send + Unpin + 'static, C::Collation: Send + Unpin + 'static,
P: BlockchainEvents<Block> + BlockBody<Block>, P: BlockchainEvents<Block> + BlockBackend<Block>,
P: ProvideRuntimeApi<Block> + HeaderBackend<Block> + Send + Sync + 'static, P: ProvideRuntimeApi<Block> + HeaderBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + P::Api: ParachainHost<Block> +
BlockBuilderApi<Block> + BlockBuilderApi<Block> +
...@@ -267,7 +267,7 @@ pub(crate) struct ParachainValidationInstances<C, N, P, SP> { ...@@ -267,7 +267,7 @@ pub(crate) struct ParachainValidationInstances<C, N, P, SP> {
impl<C, N, P, SP> ParachainValidationInstances<C, N, P, SP> where impl<C, N, P, SP> ParachainValidationInstances<C, N, P, SP> where
C: Collators + Send + Unpin + 'static + Sync, C: Collators + Send + Unpin + 'static + Sync,