service: support setting fork blocks in config (#719)

This commit is contained in:
André Silva
2020-01-06 12:51:41 +00:00
committed by Bastian Köcher
parent c975d4ee84
commit ec0a7604a0
5 changed files with 30 additions and 5 deletions
+2
View File
@@ -3982,6 +3982,7 @@ dependencies = [
"polkadot-runtime 0.7.11", "polkadot-runtime 0.7.11",
"polkadot-validation 0.7.11", "polkadot-validation 0.7.11",
"sc-authority-discovery 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "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 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-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)", "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-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-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)", "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)", "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-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)", "sp-authority-discovery 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)",
+2
View File
@@ -6,6 +6,7 @@ edition = "2018"
[dependencies] [dependencies]
parking_lot = "0.9.0" parking_lot = "0.9.0"
serde = { version = "1.0.102", features = ["derive"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
log = "0.4.8" log = "0.4.8"
futures = "0.3.1" 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 = { 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-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" } 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-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sc-network = { 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" } consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
+1
View File
@@ -25,6 +25,7 @@
"tokenSymbol": "KSM" "tokenSymbol": "KSM"
}, },
"consensusEngine": null, "consensusEngine": null,
"forkBlocks": null,
"genesis": { "genesis": {
"raw": [ "raw": [
{ {
+20 -4
View File
@@ -20,7 +20,9 @@ use primitives::{Pair, Public, crypto::UncheckedInto, sr25519};
use polkadot_primitives::{AccountId, AccountPublic, parachain::ValidatorId}; use polkadot_primitives::{AccountId, AccountPublic, parachain::ValidatorId};
use polkadot_runtime as polkadot; use polkadot_runtime as polkadot;
use polkadot_runtime::constants::currency::DOTS; use polkadot_runtime::constants::currency::DOTS;
use sc_chain_spec::ChainSpecExtension;
use sp_runtime::{traits::IdentifyAccount, Perbill}; use sp_runtime::{traits::IdentifyAccount, Perbill};
use serde::{Serialize, Deserialize};
use telemetry::TelemetryEndpoints; use telemetry::TelemetryEndpoints;
use hex_literal::hex; use hex_literal::hex;
use babe_primitives::AuthorityId as BabeId; 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 STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
const DEFAULT_PROTOCOL_ID: &str = "dot"; 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<polkadot_primitives::Block>,
}
/// The `ChainSpec`. /// The `ChainSpec`.
/// ///
/// We use the same `ChainSpec` type for Polkadot and Kusama. As Kusama /// We use the same `ChainSpec` type for Polkadot and Kusama. As Kusama
/// is only loaded from a file, the `GenesisConfig` type is not used. /// is only loaded from a file, the `GenesisConfig` type is not used.
pub type ChainSpec = service::ChainSpec<polkadot::GenesisConfig>; pub type ChainSpec = service::ChainSpec<
polkadot::GenesisConfig,
Extensions,
>;
pub fn kusama_config() -> Result<ChainSpec, String> { pub fn kusama_config() -> Result<ChainSpec, String> {
ChainSpec::from_json_bytes(&include_bytes!("../res/kusama.json")[..]) 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(TelemetryEndpoints::new(vec![(STAGING_TELEMETRY_URL.to_string(), 0)])),
Some(DEFAULT_PROTOCOL_ID), Some(DEFAULT_PROTOCOL_ID),
None, None,
None, Default::default(),
) )
} }
@@ -361,7 +377,7 @@ pub fn development_config() -> ChainSpec {
None, None,
Some(DEFAULT_PROTOCOL_ID), Some(DEFAULT_PROTOCOL_ID),
None, None,
None, Default::default(),
) )
} }
@@ -386,6 +402,6 @@ pub fn local_testnet_config() -> ChainSpec {
None, None,
Some(DEFAULT_PROTOCOL_ID), Some(DEFAULT_PROTOCOL_ID),
None, None,
None, Default::default(),
) )
} }
+5 -1
View File
@@ -84,7 +84,11 @@ pub struct CustomConfiguration {
/// Configuration type that is being used. /// Configuration type that is being used.
/// ///
/// See [`ChainSpec`] for more information why Polkadot `GenesisConfig` is safe here. /// See [`ChainSpec`] for more information why Polkadot `GenesisConfig` is safe here.
pub type Configuration = service::Configuration<CustomConfiguration, polkadot_runtime::GenesisConfig>; pub type Configuration = service::Configuration<
CustomConfiguration,
polkadot_runtime::GenesisConfig,
chain_spec::Extensions,
>;
impl Default for CustomConfiguration { impl Default for CustomConfiguration {
fn default() -> Self { fn default() -> Self {