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

coretime-kusama nits #2

Merged
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
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": "coretime-kusama",
"package": "coretime-kusama-runtime",
"path": "system-parachains/coretime/coretime-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" }
coretime-kusama-runtime = { path = "../system-parachains/coretime/coretime-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",
"coretime-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<_>,
),
(
"coretime-kusama-local",
Box::new(|| system_parachains_specs::coretime_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 CoretimeKusamaChainSpec = 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 CORETIME_KUSAMA_ED: Balance = coretime_kusama_runtime::ExistentialDeposit::get();

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

Expand All @@ -83,6 +87,13 @@ pub fn invulnerables_asset_hub_polkadot() -> Vec<(AccountId, AssetHubPolkadotAur
]
}

/// 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 coretime_kusama_session_keys(keys: AuraId) -> coretime_kusama_runtime::SessionKeys {
coretime_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).
Expand Down Expand Up @@ -564,3 +575,75 @@ pub fn encointer_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Str
.build(),
))
}

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

pub fn coretime_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(
CoretimeKusamaChainSpec::builder(
coretime_kusama_runtime::WASM_BINARY.expect("CoretimeKusama wasm not available!"),
Extensions { relay_chain: "kusama-local".into(), para_id: 1005 },
)
.with_name("Kusama Coretime Local")
.with_id("coretime-kusama-local")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(coretime_kusama_local_genesis(1005.into()))
.with_properties(properties)
.build(),
))
}
3 changes: 3 additions & 0 deletions system-parachains/coretime/coretime-kusama/src/coretime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,8 @@ impl pallet_broker::Config for Runtime {
type WeightInfo = weights::pallet_broker::WeightInfo<Runtime>;
type PalletId = BrokerPalletId;
type AdminOrigin = EnsureRoot<AccountId>;
#[cfg(feature = "runtime-benchmarks")]
type PriceAdapter = pallet_broker::Linear;
#[cfg(not(feature = "runtime-benchmarks"))]
type PriceAdapter = PriceAdapter;
}

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

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

Loading
Loading