Skip to content

Commit

Permalink
[chain-specs] Updated encointer to [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Jan 23, 2024
1 parent ce7edfa commit dcee99c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 53 deletions.
3 changes: 3 additions & 0 deletions chain-spec-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ bridge-hub-kusama-runtime = { path = "../system-parachains/bridge-hubs/bridge-hu
encointer-kusama-runtime = { path = "../system-parachains/encointer" }
glutton-kusama-runtime = { path = "../system-parachains/gluttons/glutton-kusama" }

# encointer is not migrated to the latest release, so we use compatible deps, when needed
sp-core-encointer-compatible = { package = "sp-core", version = "25.0.0" }

[features]
runtime-benchmarks = [
"asset-hub-polkadot-runtime/runtime-benchmarks",
Expand Down
88 changes: 35 additions & 53 deletions chain-spec-generator/src/system_parachains_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ pub type BridgeHubKusamaChainSpec = sc_chain_spec::GenericChainSpec<(), Extensio

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

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

const ASSET_HUB_POLKADOT_ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT;

Expand Down Expand Up @@ -518,55 +517,43 @@ pub fn glutton_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Strin
}

// EncointerKusama
fn encointer_kusama_genesis(
wasm_binary: &[u8],
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> encointer_kusama_runtime::RuntimeGenesisConfig {
encointer_kusama_runtime::RuntimeGenesisConfig {
system: encointer_kusama_runtime::SystemConfig {
code: wasm_binary.to_vec(),
..Default::default()
},
balances: encointer_kusama_runtime::BalancesConfig {
fn encointer_kusama_genesis(endowed_accounts: Vec<AccountId>, id: u32) -> serde_json::Value {
// The Encointer may not be migrated to the latest release, so we use compatible dependencies.
fn get_from_seed<TPublic: sp_core_encointer_compatible::Public>(
seed: &str,
) -> <TPublic::Pair as sp_core_encointer_compatible::Pair>::Public {
use sp_core_encointer_compatible::Pair;
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}

serde_json::json!({
"balances": asset_hub_kusama_runtime::BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, ENCOINTER_KUSAMA_ED * 4096))
.collect(),
},
parachain_info: encointer_kusama_runtime::ParachainInfoConfig {
parachain_id: id,
"parachainInfo": encointer_kusama_runtime::ParachainInfoConfig {
parachain_id: id.into(),
..Default::default()
},
collective: Default::default(),
encointer_balances: Default::default(),
encointer_ceremonies: Default::default(),
encointer_communities: Default::default(),
encointer_faucet: Default::default(),
encointer_scheduler: Default::default(),
membership: Default::default(),
treasury: Default::default(),
aura: encointer_kusama_runtime::AuraConfig {
authorities: vec![get_from_seed::<sr25519::Public>("Alice").into()],
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: encointer_kusama_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
"aura": encointer_kusama_runtime::AuraConfig {
authorities: vec![get_from_seed::<sp_core_encointer_compatible::sr25519::Public>("Alice").into()],
},
}
})
}

fn encointer_kusama_local_genesis(
wasm_binary: &[u8],
) -> encointer_kusama_runtime::RuntimeGenesisConfig {
fn encointer_kusama_local_genesis(para_id: u32) -> serde_json::Value {
encointer_kusama_genesis(
// initial collators.
wasm_binary,
testnet_accounts(),
1001.into(),
para_id,
)
}

Expand All @@ -576,21 +563,16 @@ pub fn encointer_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Str
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());

let wasm_binary =
encointer_kusama_runtime::WASM_BINARY.ok_or("EncointerKusama wasm not available")?;

Ok(Box::new(EncointerKusamaChainSpec::from_genesis(
// Name
"Kusama Encointer Local",
// ID
"encointer-kusama-local",
ChainType::Local,
move || encointer_kusama_local_genesis(wasm_binary),
Vec::new(),
None,
None,
None,
Some(properties),
Extensions { relay_chain: "kusama-local".into(), para_id: 1001 },
)))
Ok(Box::new(
EncointerKusamaChainSpec::builder(
encointer_kusama_runtime::WASM_BINARY.expect("EncointerKusama wasm not available!"),
Extensions { relay_chain: "kusama-local".into(), para_id: 1001 },
)
.with_name("Kusama Encointer Local")
.with_id("encointer-kusama-local")
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(encointer_kusama_local_genesis(1001))
.with_properties(properties)
.build(),
))
}

0 comments on commit dcee99c

Please sign in to comment.