Skip to content

Commit

Permalink
People chain nit + added to the runtimes-matrix.json (#245)
Browse files Browse the repository at this point in the history
##TODO 

<!-- Remember that you can run `/merge` to enable auto-merge in the PR
-->

<!-- Remember to modify the changelog. If you don't need to modify it,
you can check the following box.
Instead, if you have already modified it, simply delete the following
line. -->

- [x] Does not require a CHANGELOG entry
- [x] create tracking issue for adding `uri` to the
`runtimes-matrix.json` when deployed live - as a part of
#186
- [x] regenerate weights
  • Loading branch information
bkontur authored Mar 24, 2024
1 parent 8b7b1cb commit b171390
Show file tree
Hide file tree
Showing 20 changed files with 1,474 additions and 1,249 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/runtimes-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
"uri": "wss://polkadot-collectives-rpc.polkadot.io:443",
"is_relay": false
},
{
"name": "people-kusama",
"package": "people-kusama-runtime",
"path": "system-parachains/people/people-kusama",
"is_relay": false
},
{
"name": "encointer-kusama",
"package": "encointer-kusama-runtime",
Expand Down
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 @@ -37,6 +37,7 @@ bridge-hub-polkadot-runtime = { path = "../system-parachains/bridge-hubs/bridge-
bridge-hub-kusama-runtime = { path = "../system-parachains/bridge-hubs/bridge-hub-kusama" }
encointer-kusama-runtime = { path = "../system-parachains/encointer" }
glutton-kusama-runtime = { path = "../system-parachains/gluttons/glutton-kusama" }
people-kusama-runtime = { path = "../system-parachains/people/people-kusama" }

[features]
fast-runtime = [
Expand All @@ -53,4 +54,5 @@ runtime-benchmarks = [
"polkadot-runtime/runtime-benchmarks",
"encointer-kusama-runtime/runtime-benchmarks",
"glutton-kusama-runtime/runtime-benchmarks",
"people-kusama-runtime/runtime-benchmarks",
]
5 changes: 5 additions & 0 deletions chain-spec-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ fn main() -> Result<(), String> {
Box::new(|| system_parachains_specs::encointer_kusama_local_testnet_config())
as Box<_>,
),
(
"people-kusama-local",
Box::new(|| system_parachains_specs::people_kusama_local_testnet_config())
as Box<_>,
),
]);

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

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

pub type PeopleKusamaChainSpec = 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 @@ -58,6 +60,8 @@ const BRIDGE_HUB_KUSAMA_ED: Balance = bridge_hub_kusama_runtime::ExistentialDepo

const ENCOINTER_KUSAMA_ED: Balance = encointer_kusama_runtime::ExistentialDeposit::get();

const PEOPLE_KUSAMA_ED: Balance = people_kusama_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 @@ -122,6 +126,13 @@ pub fn bridge_hub_kusama_session_keys(keys: AuraId) -> bridge_hub_kusama_runtime
bridge_hub_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_kusama_session_keys(keys: AuraId) -> people_kusama_runtime::SessionKeys {
people_kusama_runtime::SessionKeys { aura: keys }
}

// AssetHubPolkadot
fn asset_hub_polkadot_genesis(
invulnerables: Vec<(AccountId, AssetHubPolkadotAuraId)>,
Expand Down Expand Up @@ -564,3 +575,75 @@ pub fn encointer_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Str
.build(),
))
}

// PeopleKusama
fn people_kusama_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> serde_json::Value {
serde_json::json!({
"balances": people_kusama_runtime::BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, PEOPLE_KUSAMA_ED * 4096 * 4096))
.collect(),
},
"parachainInfo": people_kusama_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
"collatorSelection": people_kusama_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: PEOPLE_KUSAMA_ED * 16,
..Default::default()
},
"session": people_kusama_runtime::SessionConfig {
keys: invulnerables
.into_iter()
.map(|(acc, aura)| {
(
acc.clone(), // account id
acc, // validator id
people_kusama_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_kusama_local_genesis(para_id: ParaId) -> serde_json::Value {
people_kusama_genesis(
// initial collators.
invulnerables(),
testnet_accounts(),
para_id,
)
}

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

Ok(Box::new(
PeopleKusamaChainSpec::builder(
people_kusama_runtime::WASM_BINARY.expect("PeopleKusama wasm not available!"),
Extensions { relay_chain: "kusama-local".into(), para_id: 1004 },
)
.with_name("Kusama People Local")
.with_id("people-kusama-local")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(people_kusama_local_genesis(1004.into()))
.with_properties(properties)
.build(),
))
}

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

Loading

0 comments on commit b171390

Please sign in to comment.