-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
180 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Genesis configs presets for the BridgeHubKusama runtime | ||
|
||
use crate::*; | ||
use sp_std::vec::Vec; | ||
use system_parachains_constants::genesis_presets::*; | ||
|
||
const BRIDGE_HUB_KUSAMA_ED: Balance = crate::ExistentialDeposit::get(); | ||
|
||
fn bridge_hub_kusama_genesis( | ||
invulnerables: Vec<(AccountId, AuraId)>, | ||
endowed_accounts: Vec<AccountId>, | ||
id: ParaId, | ||
) -> serde_json::Value { | ||
serde_json::json!({ | ||
"balances": BalancesConfig { | ||
balances: endowed_accounts | ||
.iter() | ||
.cloned() | ||
.map(|k| (k, BRIDGE_HUB_KUSAMA_ED * 4096 * 4096)) | ||
.collect(), | ||
}, | ||
"parachainInfo": ParachainInfoConfig { | ||
parachain_id: id, | ||
..Default::default() | ||
}, | ||
"collatorSelection": CollatorSelectionConfig { | ||
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), | ||
candidacy_bond: BRIDGE_HUB_KUSAMA_ED * 16, | ||
..Default::default() | ||
}, | ||
"session": SessionConfig { | ||
keys: invulnerables | ||
.into_iter() | ||
.map(|(acc, aura)| { | ||
( | ||
acc.clone(), // account id | ||
acc, // validator id | ||
SessionKeys { aura }, // session keys | ||
) | ||
}) | ||
.collect(), | ||
}, | ||
"polkadotXcm": { | ||
"safeXcmVersion": Some(SAFE_XCM_VERSION), | ||
}, | ||
"ethereumSystem": EthereumSystemConfig { | ||
para_id: id, | ||
asset_hub_para_id: kusama_runtime_constants::system_parachain::ASSET_HUB_ID.into(), | ||
..Default::default() | ||
}, | ||
// no need to pass anything to aura, in fact it will panic if we do. Session will take care | ||
// of this. `aura: Default::default()` | ||
}) | ||
} | ||
|
||
fn bridge_hub_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value { | ||
bridge_hub_kusama_genesis(invulnerables(), testnet_accounts(), para_id) | ||
} | ||
|
||
fn bridge_hub_kusama_development_genesis(para_id: ParaId) -> serde_json::Value { | ||
bridge_hub_kusama_local_testnet_genesis(para_id) | ||
} | ||
|
||
/// Provides the JSON representation of predefined genesis config for given `id`. | ||
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> { | ||
let patch = match id.try_into() { | ||
Ok("development") => bridge_hub_kusama_development_genesis(1002.into()), | ||
Ok("local_testnet") => bridge_hub_kusama_local_testnet_genesis(1002.into()), | ||
_ => return None, | ||
}; | ||
Some( | ||
serde_json::to_string(&patch) | ||
.expect("serialization to json is expected to work. qed.") | ||
.into_bytes(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md | ||
// for a list of specific contributors. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Polkadot is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use parachains_common::AuraId; | ||
use polkadot_primitives::{AccountId, AccountPublic}; | ||
use sp_core::{sr25519, Pair, Public}; | ||
use sp_runtime::traits::IdentifyAccount; | ||
#[cfg(not(feature = "std"))] | ||
use sp_std::alloc::format; | ||
use sp_std::vec::Vec; | ||
|
||
/// Invulnerable Collators | ||
pub fn invulnerables() -> Vec<(parachains_common::AccountId, AuraId)> { | ||
Vec::from([ | ||
(get_account_id_from_seed::<sr25519::Public>("Alice"), get_from_seed::<AuraId>("Alice")), | ||
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_from_seed::<AuraId>("Bob")), | ||
]) | ||
} | ||
|
||
/// Test accounts | ||
pub fn testnet_accounts() -> Vec<AccountId> { | ||
Vec::from([ | ||
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"), | ||
]) | ||
} | ||
|
||
/// Helper function to generate a crypto pair from seed | ||
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() | ||
} | ||
|
||
/// Helper function to generate an account ID from seed | ||
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() | ||
} | ||
|
||
/// The default XCM version to set in genesis config. | ||
pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters