use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
use grandpa::AuthorityId as GrandpaId;
#[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;
#[cfg(any(
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
))]
use pallet_staking::Forcing;
use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, ValidatorId};
#[cfg(feature = "polkadot-native")]
use polkadot_runtime as polkadot;
#[cfg(feature = "polkadot-native")]
use polkadot_runtime_constants::currency::UNITS as DOT;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
#[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;
#[cfg(any(
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
feature = "rococo-native"
))]
use sc_chain_spec::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::IdentifyAccount;
#[cfg(any(
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
))]
use sp_runtime::Perbill;
#[cfg(any(
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
feature = "rococo-native"
))]
use telemetry::TelemetryEndpoints;
#[cfg(feature = "westend-native")]
use westend_runtime as westend;
#[cfg(feature = "westend-native")]
use westend_runtime_constants::currency::UNITS as WND;
#[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/";
#[cfg(feature = "rococo-native")]
const VERSI_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
#[cfg(any(
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
feature = "rococo-native"
))]
const DEFAULT_PROTOCOL_ID: &str = "dot";
#[derive(Default, Clone, Serialize, Deserialize, ChainSpecExtension)]
#[serde(rename_all = "camelCase")]
pub struct Extensions {
pub fork_blocks: sc_client_api::ForkBlocks<polkadot_primitives::Block>,
pub bad_blocks: sc_client_api::BadBlocks<polkadot_primitives::Block>,
pub light_sync_state: sc_sync_state_rpc::LightSyncStateExtension,
}
#[cfg(feature = "polkadot-native")]
pub type PolkadotChainSpec = service::GenericChainSpec<polkadot::RuntimeGenesisConfig, Extensions>;
pub type DummyChainSpec = service::GenericChainSpec<(), Extensions>;
#[cfg(not(feature = "polkadot-native"))]
pub type PolkadotChainSpec = DummyChainSpec;
#[cfg(feature = "kusama-native")]
pub type KusamaChainSpec = service::GenericChainSpec<kusama::RuntimeGenesisConfig, Extensions>;
#[cfg(not(feature = "kusama-native"))]
pub type KusamaChainSpec = DummyChainSpec;
#[cfg(feature = "westend-native")]
pub type WestendChainSpec = service::GenericChainSpec<westend::RuntimeGenesisConfig, Extensions>;
#[cfg(not(feature = "westend-native"))]
pub type WestendChainSpec = DummyChainSpec;
#[cfg(feature = "rococo-native")]
pub type RococoChainSpec = service::GenericChainSpec<RococoGenesisExt, Extensions>;
pub type VersiChainSpec = RococoChainSpec;
#[cfg(not(feature = "rococo-native"))]
pub type RococoChainSpec = DummyChainSpec;
#[derive(serde::Serialize, serde::Deserialize)]
#[cfg(feature = "rococo-native")]
pub struct RococoGenesisExt {
runtime_genesis_config: rococo::RuntimeGenesisConfig,
session_length_in_blocks: Option<u32>,
}
#[cfg(feature = "rococo-native")]
impl sp_runtime::BuildStorage for RococoGenesisExt {
fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> {
sp_state_machine::BasicExternalities::execute_with_storage(storage, || {
if let Some(length) = self.session_length_in_blocks.as_ref() {
rococo_runtime_constants::time::EpochDurationInBlocks::set(length);
}
});
self.runtime_genesis_config.assimilate_storage(storage)
}
}
pub fn polkadot_config() -> Result<PolkadotChainSpec, String> {
PolkadotChainSpec::from_json_bytes(&include_bytes!("../chain-specs/polkadot.json")[..])
}
pub fn kusama_config() -> Result<KusamaChainSpec, String> {
KusamaChainSpec::from_json_bytes(&include_bytes!("../chain-specs/kusama.json")[..])
}
pub fn westend_config() -> Result<WestendChainSpec, String> {
WestendChainSpec::from_json_bytes(&include_bytes!("../chain-specs/westend.json")[..])
}
pub fn rococo_config() -> Result<RococoChainSpec, String> {
RococoChainSpec::from_json_bytes(&include_bytes!("../chain-specs/rococo.json")[..])
}
pub fn wococo_config() -> Result<RococoChainSpec, String> {
RococoChainSpec::from_json_bytes(&include_bytes!("../chain-specs/wococo.json")[..])
}
#[cfg(any(
feature = "rococo-native",
feature = "kusama-native",
feature = "westend-native",
feature = "polkadot-native"
))]
fn default_parachains_host_configuration(
) -> polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::BlockNumber>
{
use polkadot_primitives::{MAX_CODE_SIZE, MAX_POV_SIZE};
polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_cooldown: 2u32,
validation_upgrade_delay: 2,
code_retention_period: 1200,
max_code_size: MAX_CODE_SIZE,
max_pov_size: MAX_POV_SIZE,
max_head_data_size: 32 * 1024,
group_rotation_frequency: 20,
paras_availability_period: 4,
max_upward_queue_count: 8,
max_upward_queue_size: 1024 * 1024,
max_downward_message_size: 1024 * 1024,
max_upward_message_size: 50 * 1024,
max_upward_message_num_per_candidate: 5,
hrmp_sender_deposit: 0,
hrmp_recipient_deposit: 0,
hrmp_channel_max_capacity: 8,
hrmp_channel_max_total_size: 8 * 1024,
hrmp_max_parachain_inbound_channels: 4,
hrmp_channel_max_message_size: 1024 * 1024,
hrmp_max_parachain_outbound_channels: 4,
hrmp_max_message_num_per_candidate: 5,
dispute_period: 6,
no_show_slots: 2,
n_delay_tranches: 25,
needed_approvals: 2,
relay_vrf_modulo_samples: 2,
zeroth_delay_tranche_width: 0,
minimum_validation_upgrade_delay: 5,
..Default::default()
}
}
#[cfg(any(
feature = "rococo-native",
feature = "kusama-native",
feature = "westend-native",
feature = "polkadot-native"
))]
#[test]
fn default_parachains_host_configuration_is_consistent() {
default_parachains_host_configuration().panic_if_not_consistent();
}
#[cfg(feature = "polkadot-native")]
fn polkadot_session_keys(
babe: BabeId,
grandpa: GrandpaId,
im_online: ImOnlineId,
para_validator: ValidatorId,
para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId,
) -> polkadot::SessionKeys {
polkadot::SessionKeys {
babe,
grandpa,
im_online,
para_validator,
para_assignment,
authority_discovery,
}
}
#[cfg(feature = "kusama-native")]
fn kusama_session_keys(
babe: BabeId,
grandpa: GrandpaId,
im_online: ImOnlineId,
para_validator: ValidatorId,
para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> kusama::SessionKeys {
kusama::SessionKeys {
babe,
grandpa,
im_online,
para_validator,
para_assignment,
authority_discovery,
beefy,
}
}
#[cfg(feature = "westend-native")]
fn westend_session_keys(
babe: BabeId,
grandpa: GrandpaId,
im_online: ImOnlineId,
para_validator: ValidatorId,
para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> westend::SessionKeys {
westend::SessionKeys {
babe,
grandpa,
im_online,
para_validator,
para_assignment,
authority_discovery,
beefy,
}
}
#[cfg(feature = "rococo-native")]
fn rococo_session_keys(
babe: BabeId,
grandpa: GrandpaId,
im_online: ImOnlineId,
para_validator: ValidatorId,
para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> rococo_runtime::SessionKeys {
rococo_runtime::SessionKeys {
babe,
grandpa,
im_online,
para_validator,
para_assignment,
authority_discovery,
beefy,
}
}
#[cfg(feature = "westend-native")]
fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::RuntimeGenesisConfig {
use hex_literal::hex;
use sp_core::crypto::UncheckedInto;
let endowed_accounts = vec![
hex!["c416837e232d9603e83162ef4bda08e61580eeefe60fe92fc044aa508559ae42"].into(),
];
let initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)> = vec![
(
hex!["7ecfd50629cdd246649959d88d490b31508db511487e111a52a392e6e458f518"].into(),
hex!["eca2cca09bdc66a7e6d8c3d9499a0be2ad4690061be8a9834972e17d13d2fe7e"].into(),
hex!["ae27367cb77850fb195fe1f9c60b73210409e68c5ad953088070f7d8513d464c"]
.unchecked_into(),
hex!["6faae44b21c6f2681a7f60df708e9f79d340f7d441d28bd987fab8d05c6487e8"]
.unchecked_into(),
hex!["18f5d55f138bfa8e0ea26ed6fa56817b247de3c2e2030a908c63fb37c146473f"]
.unchecked_into(),
hex!["a6c1a5b501985a83cb1c37630c5b41e6b0a15b3675b2fd94694758e6cfa6794d"]
.unchecked_into(),
hex!["485051748ab9c15732f19f3fbcf1fd00a6d9709635f084505107fbb059c33d2f"]
.unchecked_into(),
hex!["be59ed75a72f7b47221ce081ba4262cf2e1ea7867e30e0b3781822f942b97677"]
.unchecked_into(),
hex!["0207e43990799e1d02b0507451e342a1240ff836ea769c57297589a5fd072ad8f4"]
.unchecked_into(),
),
(
hex!["34b7b3efd35fcc3c1926ca065381682b1af29b57dabbcd091042c6de1d541b7d"].into(),
hex!["4226796fa792ac78875e023ff2e30e3c2cf79f0b7b3431254cd0f14a3007bc0e"].into(),
hex!["0e9b60f04be3bffe362eb2212ea99d2b909b052f4bff7c714e13c2416a797f5d"]
.unchecked_into(),
hex!["98f4d81cb383898c2c3d54dab28698c0f717c81b509cb32dc6905af3cc697b18"]
.unchecked_into(),
hex!["06bd7dd4ab4c808c7d09d9cb6bd27fbcd99ad8400e99212b335056c475c24031"]
.unchecked_into(),
hex!["162508accd470e379b04cb0c7c60b35a7d5357e84407a89ed2dd48db4b726960"]
.unchecked_into(),
hex!["4a559c028b69a7f784ce553393e547bec0aa530352157603396d515f9c83463b"]
.unchecked_into(),
hex!["d464908266c878acbf181bf8fda398b3aa3fd2d05508013e414aaece4cf0d702"]
.unchecked_into(),
hex!["02fdf30222d2cb88f2376d558d3de9cb83f9fde3aa4b2dd40c93e3104e3488bcd2"]
.unchecked_into(),
),
(
hex!["56e0f73c563d49ee4a3971c393e17c44eaa313dabad7fcf297dc3271d803f303"].into(),
hex!["2c58e5e1d5aef77774480cead4f6876b1a1a6261170166995184d7f86140572b"].into(),
hex!["6ed45cb7af613be5d88a2622921e18d147225165f24538af03b93f2a03ce6e13"]
.unchecked_into(),
hex!["b0f8d2b9e4e1eafd4dab6358e0b9d5380d78af27c094e69ae9d6d30ca300fd86"]
.unchecked_into(),
hex!["f03c3e184b2883eec9beaeb97f54321587e7476b228831ea0b5fc6da847ea975"]
.unchecked_into(),
hex!["1055100a283968271a0781450b389b9093231be809be1e48a305ebad2a90497e"]
.unchecked_into(),
hex!["3cea4ab74bab4adf176cf05a6e18c1599a7bc217d4c6c217275bfbe3b037a527"]
.unchecked_into(),
hex!["169faa81aebfe74533518bda28567f2e2664014c8905aa07ea003336afda5a58"]
.unchecked_into(),
hex!["03429d0d20f6ac5ca8b349f04d014f7b5b864acf382a744104d5d9a51108156c0f"]
.unchecked_into(),
),
(
hex!["deb804ed2ed2bb696a3dd4ed7de4cd5c496528a2b204051c6ace385bacd66a3a"].into(),
hex!["366da6a748afedb31f07902f2de36ab265beccee37762d3ae1f237de234d9c36"].into(),
hex!["1089bc0cd60237d061872925e81d36c9d9205d250d5d8b542c8e08a8ecf1b911"]
.unchecked_into(),
hex!["1c309a70b4e274314b84c9a0a1f973c9c4fc084df5479ef686c54b1ae4950424"]
.unchecked_into(),
hex!["4c64868ba6d8ace235d3efb4c10d745a67cf3bdfeae23b264d7ea2f3439dec42"]
.unchecked_into(),
hex!["2ee4d78f328db178c54f205ac809da12e291a33bcbd4f29f081ce7e74bdc5044"]
.unchecked_into(),
hex!["d88e40e3c2c7a7c5abf96ffdd8f7b7bec8798cc277bc97e255881871ab73b529"]
.unchecked_into(),
hex!["4cb3863271b70daa38612acd5dae4f5afcb7c165fa277629e5150d2214df322a"]
.unchecked_into(),
hex!["03be5ec86d10a94db89c9b7a396d3c7742e3bec5f85159d4cf308cef505966ddf5"]
.unchecked_into(),
),
];
const ENDOWMENT: u128 = 1_000_000 * WND;
const STASH: u128 = 100 * WND;
westend::RuntimeGenesisConfig {
system: westend::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
balances: westend::BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(),
},
beefy: Default::default(),
indices: westend::IndicesConfig { indices: vec![] },
session: westend::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
westend_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
x.8.clone(),
),
)
})
.collect::<Vec<_>>(),
},
staking: westend::StakingConfig {
validator_count: 50,
minimum_validator_count: 4,
stakers: initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, westend::StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::ForceNone,
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
babe: westend::BabeConfig {
authorities: Default::default(),
epoch_config: Some(westend::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: westend::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
vesting: westend::VestingConfig { vesting: vec![] },
sudo: westend::SudoConfig { key: Some(endowed_accounts[0].clone()) },
hrmp: Default::default(),
configuration: westend::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
paras: Default::default(),
registrar: westend_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
assigned_slots: Default::default(),
}
}
#[cfg(feature = "kusama-native")]
fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeGenesisConfig {
use hex_literal::hex;
use sp_core::crypto::UncheckedInto;
let endowed_accounts = vec![
hex!["7a0fe424217ed176da7abf12e08198db0d0949298e1372c80a1930cb6dc21d3e"].into(),
];
let initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)> = vec![
(
hex!["2ca4a9582244a3356a0d96e59d71f7e4d12aa88bca6d46f360ef11f6487cab1f"].into(),
hex!["7e237806f642b7f45f70ec45fbc41034516c8e5561bae2a62cd287129e1d0712"].into(),
hex!["c89cb7afc47ec0b5aac5824e5338a62959c92978167d3f841491836746e70b3d"]
.unchecked_into(),
hex!["b98b200021a608148f9817aeb553596b6968a5aa61b6d320c522f520ecc9cf9c"]
.unchecked_into(),
hex!["da0690438c0dd7a9aa26e03c9f1deaa58ba2b88d0bec0954b06478632164a401"]
.unchecked_into(),
hex!["1e6554d35f6f17a37176c71801426204d6df400a1869114e4f00564b35d31150"]
.unchecked_into(),
hex!["20bddf09b1d0a2d93bafeb87fe19eb5bd59950c174f23a141a6d99736a5e700d"]
.unchecked_into(),
hex!["5a91b2546f1aac1c388eb0739c83e42d9972884d74360200ce32b7595bc65a04"]
.unchecked_into(),
hex!["02fd1e7e8455ab888ad054bbec7bc19409e6b1a5bb0300feefc6b58e60efae7e85"]
.unchecked_into(),
),
(
hex!["ea478deab0ebfbeab7342febc236a9f1af5129ca0083fa25e6b0cf6a998d8354"].into(),
hex!["607b4e88129804eca8cd6fa26cbe2dd36667130e2a061050b08d9015871f4263"].into(),
hex!["34d949c39fae5801ba328ac6d0ddc76e469b7d5a4372a4a0d94f6aad6f9c1600"]
.unchecked_into(),
hex!["6e47830dcfc1f2b53a1b5db3f76702fc2760c1cc119119aceb00a57ec6658465"]
.unchecked_into(),
hex!["50f6ef6326cd61ac500f167493e435f1204ce1d66ad18024bc5810d09673785e"]
.unchecked_into(),
hex!["38e7fb2f6a1dcec73d93b07a0dc7cff1f9a9cc32cde8eb1e6ea1782f5316b431"]
.unchecked_into(),
hex!["72889a7b6ada28c3bd05a5a7298437f01d6d3270559768d16275efaf11864c0a"]
.unchecked_into(),
hex!["925f03f6211c68377987b0f78cd02aa882ad1fa9cc00c01fe6ce68e14c23340d"]
.unchecked_into(),
hex!["030e77039e470ccdec7fe23dbc41c66f1c187ec8345e8919d3dc1250d975c3ce82"]
.unchecked_into(),
),
(
hex!["30d203d942c1d056245b51e466a50b684f172a37c1cdde678f5346a0b3dbcd52"].into(),
hex!["4e194bbafeec45647b2679e6b615b2a879d2e74fe706921930509ab3c9dbb22d"].into(),
hex!["5a0037b6bfc5e879ba5ef480ac29c59a12873854159686899082f41950ffd472"]
.unchecked_into(),
hex!["87638aef8ab75db093150a6677c0919292ff66fc17f9f006a71fd0618415e164"]
.unchecked_into(),
hex!["6409c85a1125fa456b9dc6e85408a6d931aa8e04f48511c87fc147d1c103e902"]
.unchecked_into(),
hex!["dc3cab0f94fa974cba826984f23dd4dc77ade20f25d935af5f07b85518da8044"]
.unchecked_into(),
hex!["50379866eb62e5c8aac31133efc4a1723e964a8e30c93c3ce2e7758bd03eb776"]
.unchecked_into(),
hex!["5843c339c39d2c308bfb1841cd10beecfa157580492db05b66db8553e8d6512c"]
.unchecked_into(),
hex!["03c81d4e72cbdb96a7e6aad76830ae783b0b4650dc19703dde96866d8894dc921f"]
.unchecked_into(),
),
(
hex!["927f8b12a0fa7185077353d9f6b4fe6bc6cd9682bd498642fa3801280909711a"].into(),
hex!["ce03638cd1e8496793b0540ba23370034511ea5d08837deb17f6c4d905b8d017"].into(),
hex!["b67d3ed42ab1fcf3fcd7dee99bd6963bc22058ee22bcfddddb776492e85bd76e"]
.unchecked_into(),
hex!["d0dd492b1a33d2f06a9aa7213e1aaa41d8820a6b56e95cd2462129b446574014"]
.unchecked_into(),
hex!["bc04e9764e23330b9f4e6922aa6437f87f3dd17b8590825e824724ae89d4ac51"]
.unchecked_into(),
hex!["de78b26966c08357d66f7f56e7dcac7e4beb16aa0b74939290a42b3f5949bc36"]
.unchecked_into(),
hex!["96d61fe92a50a79944ea93e3afc0a95a328773878e774cf8c8fbe8eba81cd95c"]
.unchecked_into(),
hex!["38791c68ee472b94105c66cf150387979c49175062a687d1a1509119cfdc9e0c"]
.unchecked_into(),
hex!["025185a88886008267d27797fc74e34241e3aa8da767fafc9dd3ae5a59546802bb"]
.unchecked_into(),
),
];
const ENDOWMENT: u128 = 1_000_000 * KSM;
const STASH: u128 = 100 * KSM;
kusama::RuntimeGenesisConfig {
system: kusama::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
balances: kusama::BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(),
},
beefy: Default::default(),
indices: kusama::IndicesConfig { indices: vec![] },
session: kusama::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
kusama_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
x.8.clone(),
),
)
})
.collect::<Vec<_>>(),
},
staking: kusama::StakingConfig {
validator_count: 50,
minimum_validator_count: 4,
stakers: initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, kusama::StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::ForceNone,
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
babe: kusama::BabeConfig {
authorities: Default::default(),
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: kusama::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: kusama::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: kusama::VestingConfig { vesting: vec![] },
treasury: Default::default(),
hrmp: Default::default(),
configuration: kusama::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
paras: Default::default(),
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
nis_counterpart_balances: Default::default(),
}
}
#[cfg(feature = "rococo-native")]
fn rococo_staging_testnet_config_genesis(
wasm_binary: &[u8],
) -> rococo_runtime::RuntimeGenesisConfig {
use hex_literal::hex;
use sp_core::crypto::UncheckedInto;
let endowed_accounts = vec![
hex!["52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649"].into(),
];
let initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)> = vec![
(
hex!["62475fe5406a7cb6a64c51d0af9d3ab5c2151bcae982fb812f7a76b706914d6a"].into(),
hex!["9e6e781a76810fe93187af44c79272c290c2b9e2b8b92ee11466cd79d8023f50"].into(),
hex!["a076ef1280d768051f21d060623da3ab5b56944d681d303ed2d4bf658c5bed35"]
.unchecked_into(),
hex!["0e6d7d1afbcc6547b92995a394ba0daed07a2420be08220a5a1336c6731f0bfa"]
.unchecked_into(),
hex!["86975a37211f8704e947a365b720f7a3e2757988eaa7d0f197e83dba355ef743"]
.unchecked_into(),
hex!["0e07a51d3213842f8e9363ce8e444255990a225f87e80a3d651db7841e1a0205"]
.unchecked_into(),
hex!["ec60e71fe4a567ef9fef99d4bbf37ffae70564b41aa6f94ef0317c13e0a5477b"]
.unchecked_into(),
hex!["f49eae66a0ac9f610316906ec8f1a0928e20d7059d76a5ca53cbcb5a9b50dd3c"]
.unchecked_into(),
hex!["034f68c5661a41930c82f26a662276bf89f33467e1c850f2fb8ef687fe43d62276"]
.unchecked_into(),
),
(
hex!["520b48452969f6ddf263b664de0adb0c729d0e0ad3b0e5f3cb636c541bc9022a"].into(),
hex!["6618289af7ae8621981ffab34591e7a6486e12745dfa3fd3b0f7e6a3994c7b5b"].into(),
hex!["38757d0de00a0c739e7d7984ef4bc01161bd61e198b7c01b618425c16bb5bd5f"]
.unchecked_into(),
hex!["fcd5f87a6fd5707a25122a01b4dac0a8482259df7d42a9a096606df1320df08d"]
.unchecked_into(),
hex!["48a910c0af90898f11bd57d37ceaea53c78994f8e1833a7ade483c9a84bde055"]
.unchecked_into(),
hex!["669a10892119453e9feb4e3f1ee8e028916cc3240022920ad643846fbdbee816"]
.unchecked_into(),
hex!["68bf52c482630a8d1511f2edd14f34127a7d7082219cccf7fd4c6ecdb535f80d"]
.unchecked_into(),
hex!["f6f8fe475130d21165446a02fb1dbce3a7bf36412e5d98f4f0473aed9252f349"]
.unchecked_into(),
hex!["03a90c2bb6d3b7000020f6152fe2e5002fa970fd1f42aafb6c8edda8dacc2ea77e"]
.unchecked_into(),
),
(
hex!["92ef83665b39d7a565e11bf8d18d41d45a8011601c339e57a8ea88c8ff7bba6f"].into(),
hex!["b235f57244230589523271c27b8a490922ffd7dccc83b044feaf22273c1dc735"].into(),
hex!["d2644c1ab2c63a3ad8d40ad70d4b260969e3abfe6d7e6665f50dc9f6365c9d2a"]
.unchecked_into(),
hex!["e1b68fbd84333e31486c08e6153d9a1415b2e7e71b413702b7d64e9b631184a1"]
.unchecked_into(),
hex!["ee93e26259decb89afcf17ef2aa0fa2db2e1042fb8f56ecfb24d19eae8629878"]
.unchecked_into(),
hex!["a8e61ffacafaf546283dc92d14d7cc70ea0151a5dd81fdf73ff5a2951f2b6037"]
.unchecked_into(),
hex!["244f3421b310c68646e99cdbf4963e02067601f57756b072a4b19431448c186e"]
.unchecked_into(),
hex!["2c57f81fd311c1ab53813c6817fe67f8947f8d39258252663b3384ab4195494d"]
.unchecked_into(),
hex!["039d065fe4f9234f0a4f13cc3ae585f2691e9c25afa469618abb6645111f607a53"]
.unchecked_into(),
),
(
hex!["38f3c2f38f6d47f161e98c697bbe3ca0e47c033460afda0dda314ab4222a0404"].into(),
hex!["ba0898c1964196474c0be08d364cdf4e9e1d47088287f5235f70b0590dfe1704"].into(),
hex!["764186bc30fd5a02477f19948dc723d6d57ab174debd4f80ed6038ec960bfe21"]
.unchecked_into(),
hex!["36be9069cdb4a8a07ecd51f257875150f0a8a1be44a10d9d98dabf10a030aef4"]
.unchecked_into(),
hex!["8e95b9b5b4dc69790b67b566567ca8bf8cdef3a3a8bb65393c0d1d1c87cd2d2c"]
.unchecked_into(),
hex!["882d72965e642677583b333b2d173ac94b5fd6c405c76184bb14293be748a13b"]
.unchecked_into(),
hex!["821271c99c958b9220f1771d9f5e29af969edfa865631dba31e1ab7bc0582b75"]
.unchecked_into(),
hex!["2496f28d887d84705c6dae98aee8bf90fc5ad10bb5545eca1de6b68425b70f7c"]
.unchecked_into(),
hex!["0307d29bbf6a5c4061c2157b44fda33b7bb4ec52a5a0305668c74688cedf288d58"]
.unchecked_into(),
),
(
hex!["02a2d8cfcf75dda85fafc04ace3bcb73160034ed1964c43098fb1fe831de1b16"].into(),
hex!["90cab33f0bb501727faa8319f0845faef7d31008f178b65054b6629fe531b772"].into(),
hex!["7c94715e5dd8ab54221b1b6b2bfa5666f593f28a92a18e28052531de1bd80813"]
.unchecked_into(),
hex!["6c878e33b83c20324238d22240f735457b6fba544b383e70bb62a27b57380c81"]
.unchecked_into(),
hex!["d2f9d537ffa59919a4028afdb627c14c14c97a1547e13e8e82203d2049b15b1a"]
.unchecked_into(),
hex!["6a8570b9c6408e54bacf123cc2bb1b0f087f9c149147d0005badba63a5a4ac01"]
.unchecked_into(),
hex!["16c69ea8d595e80b6736f44be1eaeeef2ac9c04a803cc4fd944364cb0d617a33"]
.unchecked_into(),
hex!["306ac5c772fe858942f92b6e28bd82fb7dd8cdd25f9a4626c1b0eee075fcb531"]
.unchecked_into(),
hex!["02fb0330356e63a35dd930bc74525edf28b3bf5eb44aab9e9e4962c8309aaba6a6"]
.unchecked_into(),
),
(
hex!["02ea6bfa8b23b92fe4b5db1063a1f9475e3acd0ab61e6b4f454ed6ba00b5f864"].into(),
hex!["d4ffc4c05b47d1115ad200f7f86e307b20b46c50e1b72a912ec4f6f7db46b616"].into(),
hex!["bab3cccdcc34401e9b3971b96a662686cf755aa869a5c4b762199ce531b12c5b"]
.unchecked_into(),
hex!["d9c056c98ca0e6b4eb7f5c58c007c1db7be0fe1f3776108f797dd4990d1ccc33"]
.unchecked_into(),
hex!["c4a980da30939d5bb9e4a734d12bf81259ae286aa21fa4b65405347fa40eff35"]
.unchecked_into(),
hex!["1efc23c0b51ad609ab670ecf45807e31acbd8e7e5cb7c07cf49ee42992d2867c"]
.unchecked_into(),
hex!["4c64d3f06d28adeb36a892fdaccecace150bec891f04694448a60b74fa469c22"]
.unchecked_into(),
hex!["160ea09c5717270e958a3da42673fa011613a9539b2e4ebcad8626bc117ca04a"]
.unchecked_into(),
hex!["020019a8bb188f8145d02fa855e9c36e9914457d37c500e03634b5223aa5702474"]
.unchecked_into(),
),
(
hex!["fa373e25a1c4fe19c7148acde13bc3db1811cf656dc086820f3dda736b9c4a00"].into(),
hex!["62145d721967bd88622d08625f0f5681463c0f1b8bcd97eb3c2c53f7660fd513"].into(),
hex!["720537e2c1c554654d73b3889c3ef4c3c2f95a65dd3f7c185ebe4afebed78372"]
.unchecked_into(),
hex!["4bea0b37e0cce9bddd80835fa2bfd5606f5dcfb8388bbb10b10c483f0856cf14"]
.unchecked_into(),
hex!["560d90ca51e9c9481b8a9810060e04d0708d246714960439f804e5c6f40ca651"]
.unchecked_into(),
hex!["042f07fc5268f13c026bbe199d63e6ac77a0c2a780f71cda05cee5a6f1b3f11f"]
.unchecked_into(),
hex!["fab485e87ed1537d089df521edf983a777c57065a702d7ed2b6a2926f31da74f"]
.unchecked_into(),
hex!["64d59feddb3d00316a55906953fb3db8985797472bd2e6c7ea1ab730cc339d7f"]
.unchecked_into(),
hex!["033f1a6d47fe86f88934e4b83b9fae903b92b5dcf4fec97d5e3e8bf4f39df03685"]
.unchecked_into(),
),
(
hex!["8062e9c21f1d92926103119f7e8153cebdb1e5ab3e52d6f395be80bb193eab47"].into(),
hex!["fa0388fa88f3f0cb43d583e2571fbc0edad57dff3a6fd89775451dd2c2b8ea00"].into(),
hex!["da6b2df18f0f9001a6dcf1d301b92534fe9b1f3ccfa10c49449fee93adaa8349"]
.unchecked_into(),
hex!["4ee66173993dd0db5d628c4c9cb61a27b76611ad3c3925947f0d0011ee2c5dcc"]
.unchecked_into(),
hex!["92156f54a114ee191415898f2da013d9db6a5362d6b36330d5fc23e27360ab66"]
.unchecked_into(),
hex!["d822d4088b20dca29a580a577a97d6f024bb24c9550bebdfd7d2d18e946a1c7d"]
.unchecked_into(),
hex!["481538f8c2c011a76d7d57db11c2789a5e83b0f9680dc6d26211d2f9c021ae4c"]
.unchecked_into(),
hex!["4e262811acdfe94528bfc3c65036080426a0e1301b9ada8d687a70ffcae99c26"]
.unchecked_into(),
hex!["025e84e95ed043e387ddb8668176b42f8e2773ddd84f7f58a6d9bf436a4b527986"]
.unchecked_into(),
),
];
const ENDOWMENT: u128 = 1_000_000 * ROC;
const STASH: u128 = 100 * ROC;
rococo_runtime::RuntimeGenesisConfig {
system: rococo_runtime::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
balances: rococo_runtime::BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(),
},
beefy: Default::default(),
indices: rococo_runtime::IndicesConfig { indices: vec![] },
session: rococo_runtime::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
rococo_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
x.8.clone(),
),
)
})
.collect::<Vec<_>>(),
},
phragmen_election: Default::default(),
babe: rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
democracy: rococo_runtime::DemocracyConfig::default(),
council: rococo::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: rococo::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
treasury: Default::default(),
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: rococo::VestingConfig { vesting: vec![] },
sudo: rococo_runtime::SudoConfig { key: Some(endowed_accounts[0].clone()) },
paras: rococo_runtime::ParasConfig { paras: vec![], ..Default::default() },
hrmp: Default::default(),
configuration: rococo_runtime::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
registrar: rococo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nis_counterpart_balances: Default::default(),
assigned_slots: Default::default(),
}
}
pub fn polkadot_chain_spec_properties() -> serde_json::map::Map<String, serde_json::Value> {
serde_json::json!({
"tokenDecimals": 10,
})
.as_object()
.expect("Map given; qed")
.clone()
}
#[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![];
Ok(KusamaChainSpec::from_genesis(
"Kusama Staging Testnet",
"kusama_staging_testnet",
ChainType::Live,
move || kusama_staging_testnet_config_genesis(wasm_binary),
boot_nodes,
Some(
TelemetryEndpoints::new(vec![(KUSAMA_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Kusama Staging telemetry url is valid; qed"),
),
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[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![];
Ok(WestendChainSpec::from_genesis(
"Westend Staging Testnet",
"westend_staging_testnet",
ChainType::Live,
move || westend_staging_testnet_config_genesis(wasm_binary),
boot_nodes,
Some(
TelemetryEndpoints::new(vec![(WESTEND_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Westend Staging telemetry url is valid; qed"),
),
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[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![];
Ok(RococoChainSpec::from_genesis(
"Rococo Staging Testnet",
"rococo_staging_testnet",
ChainType::Live,
move || RococoGenesisExt {
runtime_genesis_config: rococo_staging_testnet_config_genesis(wasm_binary),
session_length_in_blocks: None,
},
boot_nodes,
Some(
TelemetryEndpoints::new(vec![(ROCOCO_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Rococo Staging telemetry url is valid; qed"),
),
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
pub fn versi_chain_spec_properties() -> serde_json::map::Map<String, serde_json::Value> {
serde_json::json!({
"ss58Format": 42,
"tokenDecimals": 12,
"tokenSymbol": "VRS",
})
.as_object()
.expect("Map given; qed")
.clone()
}
#[cfg(feature = "rococo-native")]
pub fn versi_staging_testnet_config() -> Result<RococoChainSpec, String> {
let wasm_binary = rococo::WASM_BINARY.ok_or("Versi development wasm not available")?;
let boot_nodes = vec![];
Ok(RococoChainSpec::from_genesis(
"Versi Staging Testnet",
"versi_staging_testnet",
ChainType::Live,
move || RococoGenesisExt {
runtime_genesis_config: rococo_staging_testnet_config_genesis(wasm_binary),
session_length_in_blocks: Some(100),
},
boot_nodes,
Some(
TelemetryEndpoints::new(vec![(VERSI_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Versi Staging telemetry url is valid; qed"),
),
Some("versi"),
None,
Some(versi_chain_spec_properties()),
Default::default(),
))
}
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
pub fn get_authority_keys_from_seed(
seed: &str,
) -> (
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
) {
let keys = get_authority_keys_from_seed_no_beefy(seed);
(keys.0, keys.1, keys.2, keys.3, keys.4, keys.5, keys.6, keys.7, get_from_seed::<BeefyId>(seed))
}
pub fn get_authority_keys_from_seed_no_beefy(
seed: &str,
) -> (
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
) {
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<BabeId>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<ImOnlineId>(seed),
get_from_seed::<ValidatorId>(seed),
get_from_seed::<AssignmentId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
)
}
#[cfg(any(
feature = "polkadot-native",
feature = "kusama-native",
feature = "westend-native",
feature = "rococo-native"
))]
fn testnet_accounts() -> Vec<AccountId> {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
]
}
#[cfg(feature = "polkadot-native")]
pub fn polkadot_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
)>,
_root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> polkadot::RuntimeGenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * DOT;
const STASH: u128 = 100 * DOT;
polkadot::RuntimeGenesisConfig {
system: polkadot::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
indices: polkadot::IndicesConfig { indices: vec![] },
balances: polkadot::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
},
session: polkadot::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
polkadot_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
),
)
})
.collect::<Vec<_>>(),
},
staking: polkadot::StakingConfig {
minimum_validator_count: 1,
validator_count: initial_authorities.len() as u32,
stakers: initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, polkadot::StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::NotForcing,
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
babe: polkadot::BabeConfig {
authorities: Default::default(),
epoch_config: Some(polkadot::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: polkadot::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: polkadot::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: polkadot::VestingConfig { vesting: vec![] },
treasury: Default::default(),
hrmp: Default::default(),
configuration: polkadot::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
paras: Default::default(),
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
}
}
#[cfg(feature = "kusama-native")]
pub fn kusama_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)>,
_root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> kusama::RuntimeGenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * KSM;
const STASH: u128 = 100 * KSM;
kusama::RuntimeGenesisConfig {
system: kusama::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
indices: kusama::IndicesConfig { indices: vec![] },
balances: kusama::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
},
beefy: Default::default(),
session: kusama::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
kusama_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
x.8.clone(),
),
)
})
.collect::<Vec<_>>(),
},
staking: kusama::StakingConfig {
minimum_validator_count: 1,
validator_count: initial_authorities.len() as u32,
stakers: initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, kusama::StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::NotForcing,
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
babe: kusama::BabeConfig {
authorities: Default::default(),
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: kusama::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
claims: kusama::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: kusama::VestingConfig { vesting: vec![] },
treasury: Default::default(),
hrmp: Default::default(),
configuration: kusama::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
paras: Default::default(),
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
nis_counterpart_balances: Default::default(),
}
}
#[cfg(feature = "westend-native")]
pub fn westend_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> westend::RuntimeGenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * WND;
const STASH: u128 = 100 * WND;
westend::RuntimeGenesisConfig {
system: westend::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
indices: westend::IndicesConfig { indices: vec![] },
balances: westend::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
},
beefy: Default::default(),
session: westend::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
westend_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
x.8.clone(),
),
)
})
.collect::<Vec<_>>(),
},
staking: westend::StakingConfig {
minimum_validator_count: 1,
validator_count: initial_authorities.len() as u32,
stakers: initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, westend::StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::NotForcing,
slash_reward_fraction: Perbill::from_percent(10),
..Default::default()
},
babe: westend::BabeConfig {
authorities: Default::default(),
epoch_config: Some(westend::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
authority_discovery: westend::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
vesting: westend::VestingConfig { vesting: vec![] },
sudo: westend::SudoConfig { key: Some(root_key) },
hrmp: Default::default(),
configuration: westend::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
paras: Default::default(),
registrar: westend_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
assigned_slots: Default::default(),
}
}
#[cfg(feature = "rococo-native")]
pub fn rococo_testnet_genesis(
wasm_binary: &[u8],
initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> rococo_runtime::RuntimeGenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * ROC;
rococo_runtime::RuntimeGenesisConfig {
system: rococo_runtime::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
beefy: Default::default(),
indices: rococo_runtime::IndicesConfig { indices: vec![] },
balances: rococo_runtime::BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
},
session: rococo_runtime::SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
rococo_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
x.8.clone(),
),
)
})
.collect::<Vec<_>>(),
},
babe: rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: Default::default(),
im_online: Default::default(),
phragmen_election: Default::default(),
democracy: rococo::DemocracyConfig::default(),
council: rococo::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: rococo::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
treasury: Default::default(),
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: rococo::VestingConfig { vesting: vec![] },
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
..Default::default()
},
sudo: rococo_runtime::SudoConfig { key: Some(root_key.clone()) },
hrmp: Default::default(),
configuration: rococo_runtime::ConfigurationConfig {
config: polkadot_runtime_parachains::configuration::HostConfiguration {
max_validators_per_core: Some(1),
..default_parachains_host_configuration()
},
},
paras: rococo_runtime::ParasConfig { paras: vec![], ..Default::default() },
registrar: rococo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::LOWEST_PUBLIC_ID,
..Default::default()
},
xcm_pallet: Default::default(),
nis_counterpart_balances: Default::default(),
assigned_slots: Default::default(),
}
}
#[cfg(feature = "polkadot-native")]
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::RuntimeGenesisConfig {
polkadot_testnet_genesis(
wasm_binary,
vec![get_authority_keys_from_seed_no_beefy("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[cfg(feature = "kusama-native")]
fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeGenesisConfig {
kusama_testnet_genesis(
wasm_binary,
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[cfg(feature = "westend-native")]
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::RuntimeGenesisConfig {
westend_testnet_genesis(
wasm_binary,
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[cfg(feature = "rococo-native")]
fn rococo_development_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::RuntimeGenesisConfig {
rococo_testnet_genesis(
wasm_binary,
vec![get_authority_keys_from_seed("Alice")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[cfg(feature = "polkadot-native")]
pub fn polkadot_development_config() -> Result<PolkadotChainSpec, String> {
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
Ok(PolkadotChainSpec::from_genesis(
"Development",
"polkadot_dev",
ChainType::Development,
move || polkadot_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Some(polkadot_chain_spec_properties()),
Default::default(),
))
}
#[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")?;
Ok(KusamaChainSpec::from_genesis(
"Development",
"kusama_dev",
ChainType::Development,
move || kusama_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[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")?;
Ok(WestendChainSpec::from_genesis(
"Development",
"westend_dev",
ChainType::Development,
move || westend_development_config_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[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")?;
Ok(RococoChainSpec::from_genesis(
"Development",
"rococo_dev",
ChainType::Development,
move || RococoGenesisExt {
runtime_genesis_config: rococo_development_config_genesis(wasm_binary),
session_length_in_blocks: Some(10),
},
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[cfg(feature = "rococo-native")]
pub fn versi_development_config() -> Result<RococoChainSpec, String> {
let wasm_binary = rococo::WASM_BINARY.ok_or("Versi development wasm not available")?;
Ok(RococoChainSpec::from_genesis(
"Development",
"versi_dev",
ChainType::Development,
move || RococoGenesisExt {
runtime_genesis_config: rococo_development_config_genesis(wasm_binary),
session_length_in_blocks: Some(10),
},
vec![],
None,
Some("versi"),
None,
None,
Default::default(),
))
}
#[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")?;
Ok(RococoChainSpec::from_genesis(
"Development",
"wococo_dev",
ChainType::Development,
move || RococoGenesisExt {
runtime_genesis_config: rococo_development_config_genesis(wasm_binary),
session_length_in_blocks: Some(10),
},
vec![],
None,
Some(WOCOCO_DEV_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[cfg(feature = "polkadot-native")]
fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::RuntimeGenesisConfig {
polkadot_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed_no_beefy("Alice"),
get_authority_keys_from_seed_no_beefy("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[cfg(feature = "polkadot-native")]
pub fn polkadot_local_testnet_config() -> Result<PolkadotChainSpec, String> {
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
Ok(PolkadotChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
ChainType::Local,
move || polkadot_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
Some(polkadot_chain_spec_properties()),
Default::default(),
))
}
#[cfg(feature = "kusama-native")]
fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::RuntimeGenesisConfig {
kusama_testnet_genesis(
wasm_binary,
vec![get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[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")?;
Ok(KusamaChainSpec::from_genesis(
"Kusama Local Testnet",
"kusama_local_testnet",
ChainType::Local,
move || kusama_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[cfg(feature = "westend-native")]
fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::RuntimeGenesisConfig {
westend_testnet_genesis(
wasm_binary,
vec![get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[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")?;
Ok(WestendChainSpec::from_genesis(
"Westend Local Testnet",
"westend_local_testnet",
ChainType::Local,
move || westend_local_testnet_genesis(wasm_binary),
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[cfg(feature = "rococo-native")]
fn rococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::RuntimeGenesisConfig {
rococo_testnet_genesis(
wasm_binary,
vec![get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[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")?;
Ok(RococoChainSpec::from_genesis(
"Rococo Local Testnet",
"rococo_local_testnet",
ChainType::Local,
move || RococoGenesisExt {
runtime_genesis_config: rococo_local_testnet_genesis(wasm_binary),
session_length_in_blocks: Some(10),
},
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[cfg(feature = "rococo-native")]
fn wococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::RuntimeGenesisConfig {
rococo_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
get_authority_keys_from_seed("Charlie"),
get_authority_keys_from_seed("Dave"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[cfg(feature = "rococo-native")]
pub fn wococo_local_testnet_config() -> Result<RococoChainSpec, String> {
let wasm_binary = rococo::WASM_BINARY.ok_or("Wococo development wasm not available")?;
Ok(RococoChainSpec::from_genesis(
"Wococo Local Testnet",
"wococo_local_testnet",
ChainType::Local,
move || RococoGenesisExt {
runtime_genesis_config: wococo_local_testnet_genesis(wasm_binary),
session_length_in_blocks: Some(10),
},
vec![],
None,
Some(DEFAULT_PROTOCOL_ID),
None,
None,
Default::default(),
))
}
#[cfg(feature = "rococo-native")]
fn versi_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::RuntimeGenesisConfig {
rococo_testnet_genesis(
wasm_binary,
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
get_authority_keys_from_seed("Charlie"),
get_authority_keys_from_seed("Dave"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
None,
)
}
#[cfg(feature = "rococo-native")]
pub fn versi_local_testnet_config() -> Result<RococoChainSpec, String> {
let wasm_binary = rococo::WASM_BINARY.ok_or("Versi development wasm not available")?;
Ok(RococoChainSpec::from_genesis(
"Versi Local Testnet",
"versi_local_testnet",
ChainType::Local,
move || RococoGenesisExt {
runtime_genesis_config: versi_local_testnet_genesis(wasm_binary),
session_length_in_blocks: Some(10),
},
vec![],
None,
Some("versi"),
None,
None,
Default::default(),
))
}