diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index 08df727cb1..37946dac1a 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/Cargo.lock @@ -3982,6 +3982,7 @@ dependencies = [ "polkadot-runtime 0.7.11", "polkadot-validation 0.7.11", "sc-authority-discovery 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "sc-chain-spec 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sc-client 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sc-client-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sc-client-db 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", @@ -3993,6 +3994,7 @@ dependencies = [ "sc-service 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sc-telemetry 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sc-transaction-pool 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "sp-authority-discovery 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", diff --git a/polkadot/service/Cargo.toml b/polkadot/service/Cargo.toml index 39efab8e52..c7ae4ea45f 100644 --- a/polkadot/service/Cargo.toml +++ b/polkadot/service/Cargo.toml @@ -6,6 +6,7 @@ edition = "2018" [dependencies] parking_lot = "0.9.0" +serde = { version = "1.0.102", features = ["derive"] } lazy_static = "1.4.0" log = "0.4.8" futures = "0.3.1" @@ -27,6 +28,7 @@ primitives = { package = "sp-core", git = "https://github.com/paritytech/substra client = { package = "sc-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } client-api = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } client-db = { package = "sc-client-db", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } +sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } diff --git a/polkadot/service/res/kusama.json b/polkadot/service/res/kusama.json index ed21130a9b..12ea502915 100644 --- a/polkadot/service/res/kusama.json +++ b/polkadot/service/res/kusama.json @@ -25,6 +25,7 @@ "tokenSymbol": "KSM" }, "consensusEngine": null, + "forkBlocks": null, "genesis": { "raw": [ { diff --git a/polkadot/service/src/chain_spec.rs b/polkadot/service/src/chain_spec.rs index 9466c0733b..1bace1edad 100644 --- a/polkadot/service/src/chain_spec.rs +++ b/polkadot/service/src/chain_spec.rs @@ -20,7 +20,9 @@ use primitives::{Pair, Public, crypto::UncheckedInto, sr25519}; use polkadot_primitives::{AccountId, AccountPublic, parachain::ValidatorId}; use polkadot_runtime as polkadot; use polkadot_runtime::constants::currency::DOTS; +use sc_chain_spec::ChainSpecExtension; use sp_runtime::{traits::IdentifyAccount, Perbill}; +use serde::{Serialize, Deserialize}; use telemetry::TelemetryEndpoints; use hex_literal::hex; use babe_primitives::AuthorityId as BabeId; @@ -32,11 +34,25 @@ use pallet_staking::Forcing; const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; const DEFAULT_PROTOCOL_ID: &str = "dot"; +/// Node `ChainSpec` extensions. +/// +/// Additional parameters for some Substrate core modules, +/// customizable from the chain spec. +#[derive(Default, Clone, Serialize, Deserialize, ChainSpecExtension)] +#[serde(rename_all = "camelCase")] +pub struct Extensions { + /// Block numbers with known hashes. + pub fork_blocks: client::ForkBlocks, +} + /// The `ChainSpec`. /// /// We use the same `ChainSpec` type for Polkadot and Kusama. As Kusama /// is only loaded from a file, the `GenesisConfig` type is not used. -pub type ChainSpec = service::ChainSpec; +pub type ChainSpec = service::ChainSpec< + polkadot::GenesisConfig, + Extensions, +>; pub fn kusama_config() -> Result { ChainSpec::from_json_bytes(&include_bytes!("../res/kusama.json")[..]) @@ -214,7 +230,7 @@ pub fn staging_testnet_config() -> ChainSpec { Some(TelemetryEndpoints::new(vec![(STAGING_TELEMETRY_URL.to_string(), 0)])), Some(DEFAULT_PROTOCOL_ID), None, - None, + Default::default(), ) } @@ -361,7 +377,7 @@ pub fn development_config() -> ChainSpec { None, Some(DEFAULT_PROTOCOL_ID), None, - None, + Default::default(), ) } @@ -386,6 +402,6 @@ pub fn local_testnet_config() -> ChainSpec { None, Some(DEFAULT_PROTOCOL_ID), None, - None, + Default::default(), ) } diff --git a/polkadot/service/src/lib.rs b/polkadot/service/src/lib.rs index 22945b8eac..6e5d4833ea 100644 --- a/polkadot/service/src/lib.rs +++ b/polkadot/service/src/lib.rs @@ -84,7 +84,11 @@ pub struct CustomConfiguration { /// Configuration type that is being used. /// /// See [`ChainSpec`] for more information why Polkadot `GenesisConfig` is safe here. -pub type Configuration = service::Configuration; +pub type Configuration = service::Configuration< + CustomConfiguration, + polkadot_runtime::GenesisConfig, + chain_spec::Extensions, +>; impl Default for CustomConfiguration { fn default() -> Self {