From 57f4df4f0e1d32a85d257e7f783d065a997702e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3nal=20Murray?= Date: Wed, 14 Aug 2024 10:48:51 +0100 Subject: [PATCH] Add coretime chainspecs for kusama and polkadot and presets for live chains (#432) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the invulnerables set directly to the preset and generate chain-specs for the "live" (production) networks directly from the `chain-spec-builder` instead of using a bash script to post-process these from generated local chain-specs. The Kusama Coretime Chain is added here for completeness and a sanity check with the original genesis chain-specs. Note that the SS58 prefix is ignored when generating the chain-specs, as noted in https://github.com/paritytech/polkadot-sdk/issues/5271 Supersedes https://github.com/seadanda/runtimes/pull/4 since it seems you can't change the target branch of a PR across forks. Note that this branch was made from the tip of another, so the commit history includes changes from that branch. --------- Co-authored-by: Bastian Köcher Co-authored-by: Branislav Kontur Co-authored-by: Tom Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com> --- CHANGELOG.md | 1 + Cargo.lock | 1 + Cargo.toml | 1 + chain-spec-generator/Cargo.toml | 1 + chain-spec-generator/src/main.rs | 8 ++ .../src/system_parachains_specs.rs | 75 +++++++++++++++++++ .../src/genesis_config_presets.rs | 66 +++++++++++++++- .../src/genesis_config_presets.rs | 63 +++++++++++++++- 8 files changed, 212 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e90d1c5f6..76fcfeb532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - All runtimes: add `LocationToAccountApi` ([polkadot-fellows/runtimes#413](https://github.com/polkadot-fellows/runtimes/pull/413)) - Enable Agile Coretime on Polkadot ([polkadot-fellows/runtimes#401](https://github.com/polkadot-fellows/runtimes/pull/401)) - Add the Polkadot Coretime Chain runtime ([polkadot-fellows/runtimes#410](https://github.com/polkadot-fellows/runtimes/pull/410)) +- Add the Polkadot and Kusama Coretime Chain specs ([polkadot-fellows/runtimes#432](https://github.com/polkadot-fellows/runtimes/pull/432)) #### From [#322](https://github.com/polkadot-fellows/runtimes/pull/322): diff --git a/Cargo.lock b/Cargo.lock index 957509ac98..832e3ade73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2245,6 +2245,7 @@ dependencies = [ "people-polkadot-runtime", "polkadot-runtime", "sc-chain-spec", + "sc-network", "serde", "serde_json", "staging-kusama-runtime", diff --git a/Cargo.toml b/Cargo.toml index ac26a8686d..280dcd504a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -188,6 +188,7 @@ frame-metadata-hash-extension = { version = "0.4.0", default-features = false } remote-externalities = { version = "0.43.0", package = "frame-remote-externalities" } runtime-parachains = { version = "15.0.1", default-features = false, package = "polkadot-runtime-parachains" } sc-chain-spec = { version = "35.0.0" } +sc-network = { version = "0.42.0" } scale-info = { version = "2.10.0", default-features = false } separator = { version = "0.4.1" } serde = { version = "1.0.196" } diff --git a/chain-spec-generator/Cargo.toml b/chain-spec-generator/Cargo.toml index a302073ad2..66640c7e1b 100644 --- a/chain-spec-generator/Cargo.toml +++ b/chain-spec-generator/Cargo.toml @@ -15,6 +15,7 @@ polkadot-runtime = { workspace = true } kusama-runtime = { workspace = true } sc-chain-spec = { workspace = true } +sc-network = { workspace = true } asset-hub-polkadot-runtime = { workspace = true } asset-hub-kusama-runtime = { workspace = true } diff --git a/chain-spec-generator/src/main.rs b/chain-spec-generator/src/main.rs index 40dde75490..3b6ed2288c 100644 --- a/chain-spec-generator/src/main.rs +++ b/chain-spec-generator/src/main.rs @@ -76,10 +76,18 @@ fn main() -> Result<(), String> { "encointer-kusama-local", Box::new(system_parachains_specs::encointer_kusama_local_testnet_config) as Box<_>, ), + ( + "coretime-kusama", + Box::new(system_parachains_specs::coretime_kusama_config) as Box<_>, + ), ( "coretime-kusama-local", Box::new(system_parachains_specs::coretime_kusama_local_testnet_config) as Box<_>, ), + ( + "coretime-polkadot", + Box::new(system_parachains_specs::coretime_polkadot_config) as Box<_>, + ), ( "coretime-polkadot-local", Box::new(system_parachains_specs::coretime_polkadot_local_testnet_config) as Box<_>, diff --git a/chain-spec-generator/src/system_parachains_specs.rs b/chain-spec-generator/src/system_parachains_specs.rs index 57d80dd42a..db726d7f0d 100644 --- a/chain-spec-generator/src/system_parachains_specs.rs +++ b/chain-spec-generator/src/system_parachains_specs.rs @@ -16,7 +16,9 @@ // along with Polkadot. If not, see . use sc_chain_spec::{ChainSpec, ChainSpecExtension, ChainSpecGroup, ChainType}; +use sc_network::config::MultiaddrWithPeerId; use serde::{Deserialize, Serialize}; +use std::str::FromStr; /// Generic extensions for Parachain ChainSpecs. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)] @@ -218,6 +220,41 @@ pub fn coretime_kusama_local_testnet_config() -> Result, Stri )) } +pub fn coretime_kusama_config() -> Result, String> { + let mut properties = sc_chain_spec::Properties::new(); + properties.insert("ss58Format".into(), 2.into()); + properties.insert("tokenSymbol".into(), "KSM".into()); + properties.insert("tokenDecimals".into(), 12.into()); + + let boot_nodes = [ + "/dns/kusama-coretime-connect-a-0.polkadot.io/tcp/30334/p2p/12D3KooWR7Biy6nPgQFhk2eYP62pAkcFA6he9RUFURTDh7ewTjpo", + "/dns/kusama-coretime-connect-a-1.polkadot.io/tcp/30334/p2p/12D3KooWAGFiMZDF9RxdacrkenzGdo8nhfSe9EXofHc5mHeJ9vGX", + "/dns/kusama-coretime-connect-a-0.polkadot.io/tcp/443/wss/p2p/12D3KooWR7Biy6nPgQFhk2eYP62pAkcFA6he9RUFURTDh7ewTjpo", + "/dns/kusama-coretime-connect-a-1.polkadot.io/tcp/443/wss/p2p/12D3KooWAGFiMZDF9RxdacrkenzGdo8nhfSe9EXofHc5mHeJ9vGX", + ]; + + Ok(Box::new( + CoretimeKusamaChainSpec::builder( + coretime_kusama_runtime::WASM_BINARY.expect("Kusama Coretime wasm not available!"), + Extensions { relay_chain: "kusama".into(), para_id: 1005 }, + ) + .with_name("Kusama Coretime") + .with_id("coretime-kusama") + .with_chain_type(ChainType::Live) + .with_genesis_config_preset_name("live") + .with_properties(properties) + .with_boot_nodes( + boot_nodes + .iter() + .map(|addr| { + MultiaddrWithPeerId::from_str(addr).expect("Boot node address is incorrect.") + }) + .collect(), + ) + .build(), + )) +} + pub fn coretime_polkadot_local_testnet_config() -> Result, String> { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 0.into()); @@ -238,6 +275,44 @@ pub fn coretime_polkadot_local_testnet_config() -> Result, St )) } +pub fn coretime_polkadot_config() -> Result, String> { + let mut properties = sc_chain_spec::Properties::new(); + properties.insert("ss58Format".into(), 0.into()); + properties.insert("tokenSymbol".into(), "DOT".into()); + properties.insert("tokenDecimals".into(), 10.into()); + + let boot_nodes = [ + "/dns/polkadot-coretime-connect-a-0.polkadot.io/tcp/30334/p2p/12D3KooWKjnixAHbKMsPTJwGx8SrBeGEJLHA8KmKcEDYMp3YmWgR", + "/dns/polkadot-coretime-connect-a-1.polkadot.io/tcp/30334/p2p/12D3KooWQ7B7p4DFv1jWqaKfhrZBcMmi5g8bWFnmskguLaGEmT6n", + "/dns/polkadot-coretime-connect-a-0.polkadot.io/tcp/443/wss/p2p/12D3KooWKjnixAHbKMsPTJwGx8SrBeGEJLHA8KmKcEDYMp3YmWgR", + "/dns/polkadot-coretime-connect-a-1.polkadot.io/tcp/443/wss/p2p/12D3KooWQ7B7p4DFv1jWqaKfhrZBcMmi5g8bWFnmskguLaGEmT6n", + "/dns4/coretime-polkadot.boot.stake.plus/tcp/30332/wss/p2p/12D3KooWFJ2yBTKFKYwgKUjfY3F7XfaxHV8hY6fbJu5oMkpP7wZ9", + "/dns4/coretime-polkadot.boot.stake.plus/tcp/31332/wss/p2p/12D3KooWCy5pToLafcQzPHn5kadxAftmF6Eh8ZJGPXhSeXSUDfjv", + + ]; + + Ok(Box::new( + CoretimePolkadotChainSpec::builder( + coretime_polkadot_runtime::WASM_BINARY.expect("Polkadot Coretime wasm not available!"), + Extensions { relay_chain: "polkadot".into(), para_id: 1005 }, + ) + .with_name("Polkadot Coretime") + .with_id("coretime-polkadot") + .with_chain_type(ChainType::Live) + .with_genesis_config_preset_name("live") + .with_properties(properties) + .with_boot_nodes( + boot_nodes + .iter() + .map(|addr| { + MultiaddrWithPeerId::from_str(addr).expect("Boot node address is incorrect.") + }) + .collect(), + ) + .build(), + )) +} + pub fn people_kusama_local_testnet_config() -> Result, String> { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 2.into()); diff --git a/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs b/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs index 9b8c7ec0b2..545d0a87e4 100644 --- a/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs +++ b/system-parachains/coretime/coretime-kusama/src/genesis_config_presets.rs @@ -17,6 +17,8 @@ //! Genesis configs presets for the CoretimeKusama runtime use crate::*; +use hex_literal::hex; +use sp_core::crypto::UncheckedInto; use sp_std::vec::Vec; use system_parachains_constants::genesis_presets::*; @@ -49,9 +51,9 @@ fn coretime_kusama_genesis( .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - SessionKeys { aura }, // session keys + acc.clone(), // account id + acc, // validator id + SessionKeys { aura }, // session keys ) }) .collect(), @@ -72,9 +74,67 @@ fn coretime_kusama_development_genesis(para_id: ParaId) -> serde_json::Value { coretime_kusama_local_testnet_genesis(para_id) } +fn coretime_kusama_live_genesis(para_id: ParaId) -> serde_json::Value { + coretime_kusama_genesis( + vec![ + // HRn3a4qLmv1ejBHvEbnjaiEWjt154iFi2Wde7bXKGUwGvtL + ( + hex!("d6a941f3a15918925170cc4e703c0beacc8915e2a04b3e86985915d2d84d2d52").into(), + hex!("4491cfc3ef17b4e02c66a7161f34fcacabf86ad64a783c1dbbe74e4ef82a7966") + .unchecked_into(), + ), + // Cx9Uu2sxp3Xt1QBUbGQo7j3imTvjWJrqPF1PApDoy6UVkWP + ( + hex!("10a59d610a39fc102624c8e8aa1096f0188f3fdd24b226c6a27eeed5b4774e12").into(), + hex!("04e3a3ecadbd493eb64ab2c19d215ccbc9eebea686dc3cea4833194674a8285e") + .unchecked_into(), + ), + // CdW8izFcLeicL3zZUQaC3a39AGeNSTgc9Jb5E5sjREPryA2 + ( + hex!("026d79399d627961c528d648413b2aa54595245d97158a8b90900287dee28216").into(), + hex!("de05506c73f35cf0bd50652b719369c2e20be9bf2c8522bd6cb61059a0cb0033") + .unchecked_into(), + ), + // H1tAQMm3eizGcmpAhL9aA9gR844kZpQfkU7pkmMiLx9jSzE + ( + hex!("c46ff658221e07564fde2764017590264f9dfced3538e283856c43e0ee456e51").into(), + hex!("786b7889aecde64fc8942c1d52e2d7220da83636275edfd467624a06ffc3c935") + .unchecked_into(), + ), + // J11Rp4mjz3vRb2DL51HqRGRjhuEQRyXgtuFskebXb8zMZ9s + ( + hex!("f00168a3d082a8ccf93945b1f173fdaecc1ce76fc09bbde18423640194be7212").into(), + hex!("0a2cee67864d1d4c9433bfd45324b8f72425f096e01041546be48c5d3bc9a746") + .unchecked_into(), + ), + // DtuntvQBh9vajFTnd42aTTCiuCyY3ep6EVwhhPji2ejyyhW + ( + hex!("3a6a0745688c52b4709f65fa2e4508dfa0940ccc0d282cd16be9bc043b2f4a04").into(), + hex!("064842b69c1e8dc6e2263dedd129d96488cae3f6953631da4ebba097c241eb23") + .unchecked_into(), + ), + // HmatizNhXrZtXwQK2LfntvjCy3x1EuKs1WnRQ6CP3KkNfmA + ( + hex!("e5c49f7bc76b9e1b91566945e2eb539d960da57ca8e9ccd0e6030e4b11b60099").into(), + hex!("7e126fa970a75ae2cd371d01ee32e9387f0b256832e408ca8ea7b254e6bcde7d") + .unchecked_into(), + ), + // HPUEzi4v3YJmhBfSbcGEFFiNKPAGVnGkfDiUzBNTR7j1CxT + ( + hex!("d4e6d6256f56677bcdbc0543f1a2c40aa82497b33af1748fc10113b1e2a1b460").into(), + hex!("cade3f02e0acf9e85d9a4f919abeaeda12b55202c74f78d506ccd1ea2e16a271") + .unchecked_into(), + ), + ], + Vec::new(), + para_id, + ) +} + /// Provides the JSON representation of predefined genesis config for given `id`. pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { let patch = match id.try_into() { + Ok("live") => coretime_kusama_live_genesis(1005.into()), Ok("development") => coretime_kusama_development_genesis(1005.into()), Ok("local_testnet") => coretime_kusama_local_testnet_genesis(1005.into()), _ => return None, diff --git a/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs b/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs index fac3672475..509a23d52e 100644 --- a/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs +++ b/system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs @@ -17,6 +17,8 @@ //! Genesis configs presets for the Polkadot Coretime runtime use crate::*; +use hex_literal::hex; +use sp_core::crypto::UncheckedInto; use sp_genesis_builder::PresetId; use sp_std::vec::Vec; use system_parachains_constants::genesis_presets::*; @@ -73,13 +75,72 @@ fn coretime_polkadot_development_genesis(para_id: ParaId) -> serde_json::Value { coretime_polkadot_local_testnet_genesis(para_id) } +fn coretime_polkadot_live_genesis(para_id: ParaId) -> serde_json::Value { + coretime_polkadot_genesis( + vec![ + // Parity polkadot-coretime-collator-a-0 + // 13umUoWwGb765EPzMUrMmYTcEjKfNJiNyCDwdqAvCMzteGzi + ( + hex!("80b6f570f356fef7b891afa2e1c30fca89bc7a2cddd545fd8a173106fce3a11f").into(), + hex!("4a69b6ec0eda668471d806db625681a147efc35a4baeacf0bca95d12d13cd942") + .unchecked_into(), + ), + // Parity polkadot-coretime-collator-a-1 + // 13NAwtroa2efxgtih1oscJqjxcKpWJeQF8waWPTArBewi2CQ + ( + hex!("689e1a66fa33b75f66415021aacc4fa23f49306a3c21407748b8b2d39b4abf63").into(), + hex!("f0d0e90c36f95605510f00a9f0821675bc0c7b70e5c8d113b0426c21d627773b") + .unchecked_into(), + ), + // Stakeworld.io + // 13Jpq4n3PXXaSAbJTMmFD78mXAzs8PzgUUQd5ve8saw7HQS5 + ( + hex!("6610a5024c2a5db3d02056d4344d120ec7be283100d71a6715f09275167e4f38").into(), + hex!("dcaa0b4c6840028f6d4fa8c460d5a7d687d1f81c9de453ef2f5ead88767fd22a") + .unchecked_into(), + ), + // STKD + // 173Wc3mSdXa9ja9nv7C1z6GQHEBK4HZ9U4NGhHnvmTfJaJb + ( + hex!("049bec59fb5fe6adea4578250578e89dd7e51ad88c7c92493d6f451c6680925c").into(), + hex!("7283ea6b8648673305a3e06be6dd83b7bc1840081d50d4deef1ce53eba21e914") + .unchecked_into(), + ), + // Staker Space + // 1k4vuCxwbNcHfsNdQ3MgTGixwvrT7wbLc2XiZj68Gru6bLM + ( + hex!("20d8c795eef2620fba2bde74dbc36461c07998ebf600ed265b746c1e05c70606").into(), + hex!("248dbf89d86998772b66900d78e98980ea2afc3c8fe5b93f4b38052f3018a230") + .unchecked_into(), + ), + // openbitlab_ + // 12iho9gjSMvF9smJjnihmn9j9Qqr3S1LFD97e8Lkcw4R6Yeb + ( + hex!("4c0aa0240b2d7485675e52cdb283a87973652f6acb42c830a5a5faa80f7a707e").into(), + hex!("1c346cb44aa03f8995eeee230970772d6268cd7606740f269bb4e609a01a3a15") + .unchecked_into(), + ), + // Math Crypto + // 112FKz5UNxjXqe3Wowe73a8FHnR5B4R9qi2pbMaXJczGNJsx + ( + hex!("00f379b621bd73c45c7d155d2a1fe6a04649e3ece7c7e03b70b3a6242bc7c127").into(), + hex!("e063247ca37058db551a8d99f2f15cfede61fc796acc464a9cdce4c18f6a4659") + .unchecked_into(), + ), + ], + Vec::new(), + para_id, + ) +} + pub(super) fn preset_names() -> Vec { - vec![PresetId::from("development"), PresetId::from("local_testnet")] + vec![PresetId::from("live"), PresetId::from("development"), PresetId::from("local_testnet")] } /// Provides the JSON representation of predefined genesis config for given `id`. pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { let patch = match id.try_into() { + Ok("live") => coretime_polkadot_live_genesis(1005.into()), Ok("development") => coretime_polkadot_development_genesis(1005.into()), Ok("local_testnet") => coretime_polkadot_local_testnet_genesis(1005.into()), _ => return None,