Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polkadot people nits and weights #2

Merged
merged 5 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions chain-spec-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ encointer-kusama-runtime = { workspace = true }
glutton-kusama-runtime = { workspace = true }
coretime-kusama-runtime = { workspace = true }
people-kusama-runtime = { workspace = true }
people-polkadot-runtime = { workspace = true }

[features]
fast-runtime = ["kusama-runtime/fast-runtime", "polkadot-runtime/fast-runtime"]
Expand All @@ -56,6 +57,7 @@ runtime-benchmarks = [
"pallet-staking/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"people-kusama-runtime/runtime-benchmarks",
"people-polkadot-runtime/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime/runtime-benchmarks",
"runtime-parachains/runtime-benchmarks",
Expand Down
6 changes: 5 additions & 1 deletion chain-spec-generator/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
system_parachains_specs::{
AssetHubKusamaChainSpec, AssetHubPolkadotChainSpec, BridgeHubKusamaChainSpec,
BridgeHubPolkadotChainSpec, CollectivesPolkadotChainSpec, EncointerKusamaChainSpec,
GluttonKusamaChainSpec,
GluttonKusamaChainSpec, PeopleKusamaChainSpec, PeoplePolkadotChainSpec,
},
ChainSpec,
};
Expand Down Expand Up @@ -90,6 +90,10 @@ pub fn from_json_file(filepath: &str, supported: String) -> Result<Box<dyn Chain
Ok(Box::new(GluttonKusamaChainSpec::from_json_file(path)?)),
x if x.starts_with("encointer-kusama") =>
Ok(Box::new(EncointerKusamaChainSpec::from_json_file(path)?)),
x if x.starts_with("people-kusama") =>
Ok(Box::new(PeopleKusamaChainSpec::from_json_file(path)?)),
x if x.starts_with("people-polkadot") =>
Ok(Box::new(PeoplePolkadotChainSpec::from_json_file(path)?)),
_ => Err(format!("Unknown chain 'id' in json file. Only supported: {supported}'")),
}
}
4 changes: 4 additions & 0 deletions chain-spec-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ fn main() -> Result<(), String> {
"people-kusama-local",
Box::new(system_parachains_specs::people_kusama_local_testnet_config) as Box<_>,
),
(
"people-polkadot-local",
Box::new(system_parachains_specs::people_polkadot_local_testnet_config) as Box<_>,
),
]);

if let Some(function) = supported_chains.get(&*cli.chain) {
Expand Down
85 changes: 85 additions & 0 deletions chain-spec-generator/src/system_parachains_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub type CoretimeKusamaChainSpec = sc_chain_spec::GenericChainSpec<(), Extension

pub type PeopleKusamaChainSpec = sc_chain_spec::GenericChainSpec<(), Extensions>;

pub type PeoplePolkadotChainSpec = sc_chain_spec::GenericChainSpec<(), Extensions>;

const ASSET_HUB_POLKADOT_ED: Balance = asset_hub_polkadot_runtime::ExistentialDeposit::get();

const ASSET_HUB_KUSAMA_ED: Balance = asset_hub_kusama_runtime::ExistentialDeposit::get();
Expand All @@ -66,6 +68,8 @@ const CORETIME_KUSAMA_ED: Balance = coretime_kusama_runtime::ExistentialDeposit:

const PEOPLE_KUSAMA_ED: Balance = people_kusama_runtime::ExistentialDeposit::get();

const PEOPLE_POLKADOT_ED: Balance = people_polkadot_runtime::ExistentialDeposit::get();

/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

Expand Down Expand Up @@ -144,6 +148,13 @@ pub fn people_kusama_session_keys(keys: AuraId) -> people_kusama_runtime::Sessio
people_kusama_runtime::SessionKeys { aura: keys }
}

/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn people_polkadot_session_keys(keys: AuraId) -> people_polkadot_runtime::SessionKeys {
people_polkadot_runtime::SessionKeys { aura: keys }
}

// AssetHubPolkadot
fn asset_hub_polkadot_genesis(
invulnerables: Vec<(AccountId, AssetHubPolkadotAuraId)>,
Expand Down Expand Up @@ -757,3 +768,77 @@ pub fn people_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, String
.build(),
))
}

// PeoplePolkadot
fn people_polkadot_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": people_polkadot_runtime::BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, PEOPLE_POLKADOT_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": people_polkadot_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": people_polkadot_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: PEOPLE_POLKADOT_ED * 16,
..Default::default()
},
"session": people_polkadot_runtime::SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
people_polkadot_session_keys(aura), // session keys
)
})
.collect(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
// 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 people_polkadot_local_genesis(para_id: ParaId) -> serde_json::Value {
crate::system_parachains_specs::people_polkadot_genesis(
// initial collators.
invulnerables(),
testnet_accounts(),
para_id,
)
}

pub fn people_polkadot_local_testnet_config() -> Result<Box<dyn ChainSpec>, 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());

Ok(Box::new(
PeoplePolkadotChainSpec::builder(
people_polkadot_runtime::WASM_BINARY.expect("PeoplePolkadot wasm not available!"),
Extensions { relay_chain: "polkadot-local".into(), para_id: 1004 },
)
.with_name("Polkadot People Local")
.with_id("people-polkadot-local")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(crate::system_parachains_specs::people_polkadot_local_genesis(
1004.into(),
))
.with_properties(properties)
.build(),
))
}
2 changes: 2 additions & 0 deletions system-parachains/people/people-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ mod benches {
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_identity, Identity]
[pallet_message_queue, MessageQueue]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_session, SessionBench::<Runtime>]
Expand All @@ -567,6 +568,7 @@ mod benches {
// Polkadot
[polkadot_runtime_common::identity_migrator, IdentityMigrator]
// Cumulus
[cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_collator_selection, CollatorSelection]
// XCM
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading