Skip to content

Commit 95cbbf1

Browse files
committed
node: add kusama staging chainspec
1 parent f77adcb commit 95cbbf1

File tree

2 files changed

+132
-11
lines changed

2 files changed

+132
-11
lines changed

sugondat-chain/node/src/chain_spec/mod.rs

Lines changed: 130 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
77
use sugondat_primitives::{AccountId, AuraId, Signature};
88
use sugondat_test_runtime::EXISTENTIAL_DEPOSIT as TEST_EXISTENTIAL_DEPOSIT;
99

10-
/// Specialized `ChainSpec` for the normal parachain runtime.
11-
pub type ChainSpec =
10+
pub type GenericChainSpec = sc_service::GenericChainSpec<(), Extensions>;
11+
12+
/// Specialized `ChainSpec` for the test parachain runtime.
13+
pub type TestRuntimeChainSpec =
1214
sc_service::GenericChainSpec<sugondat_test_runtime::RuntimeGenesisConfig, Extensions>;
1315

16+
/// Specialized `ChainSpec` for the kusama parachain runtime.
17+
pub type KusamaRuntimeChainSpec =
18+
sc_service::GenericChainSpec<sugondat_kusama_runtime::RuntimeGenesisConfig, Extensions>;
19+
1420
/// The default XCM version to set in genesis config.
1521
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
1622

@@ -58,18 +64,25 @@ where
5864
/// Generate the session keys from individual elements.
5965
///
6066
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
61-
pub fn template_session_keys(keys: AuraId) -> sugondat_test_runtime::SessionKeys {
67+
pub fn test_runtime_session_keys(keys: AuraId) -> sugondat_test_runtime::SessionKeys {
6268
sugondat_test_runtime::SessionKeys { aura: keys }
6369
}
6470

65-
pub fn development_config() -> ChainSpec {
71+
/// Generate the session keys from individual elements.
72+
///
73+
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
74+
pub fn kusama_runtime_session_keys(keys: AuraId) -> sugondat_kusama_runtime::SessionKeys {
75+
sugondat_kusama_runtime::SessionKeys { aura: keys }
76+
}
77+
78+
pub fn development_config() -> TestRuntimeChainSpec {
6679
// Give your base currency a unit name and decimal places
6780
let mut properties = sc_chain_spec::Properties::new();
6881
properties.insert("tokenSymbol".into(), "UNIT".into());
6982
properties.insert("tokenDecimals".into(), 12.into());
7083
properties.insert("ss58Format".into(), 42.into());
7184

72-
ChainSpec::from_genesis(
85+
TestRuntimeChainSpec::from_genesis(
7386
// Name
7487
"Development",
7588
// ID
@@ -118,14 +131,66 @@ pub fn development_config() -> ChainSpec {
118131
)
119132
}
120133

121-
pub fn local_testnet_config() -> ChainSpec {
134+
const KUSAMA_PARA_ID: u32 = 3338;
135+
136+
// For use with the Kusama network.
137+
pub fn kusama_staging_config() -> KusamaRuntimeChainSpec {
138+
// Use KSM
139+
let mut properties = sc_chain_spec::Properties::new();
140+
properties.insert("tokenSymbol".into(), "KSM".into());
141+
properties.insert("tokenDecimals".into(), 12.into());
142+
properties.insert("ss58Format".into(), 2.into());
143+
144+
KusamaRuntimeChainSpec::from_genesis(
145+
// Name
146+
"Sugondat Kusama Staging",
147+
// Id
148+
"sugondat_kusama_staging",
149+
ChainType::Local,
150+
move || {
151+
kusama_runtime_genesis(
152+
// initial collators
153+
vec![
154+
(
155+
get_account_id_from_seed::<sr25519::Public>("Alice"),
156+
get_collator_keys_from_seed("Alice"),
157+
),
158+
(
159+
get_account_id_from_seed::<sr25519::Public>("Bob"),
160+
get_collator_keys_from_seed("Bob"),
161+
),
162+
],
163+
vec![], // no endowed accounts - must teleport.
164+
get_account_id_from_seed::<sr25519::Public>("Alice"),
165+
KUSAMA_PARA_ID.into(),
166+
)
167+
},
168+
// Bootnodes
169+
Vec::new(),
170+
// Telemetry
171+
None,
172+
// Protocol ID
173+
Some("sugondat-kusama"),
174+
// Fork ID
175+
None,
176+
// Properties
177+
Some(properties),
178+
// Extensions
179+
Extensions {
180+
relay_chain: "kusama".into(), // You MUST set this to the correct network!
181+
para_id: KUSAMA_PARA_ID,
182+
},
183+
)
184+
}
185+
186+
pub fn local_testnet_config() -> TestRuntimeChainSpec {
122187
// Give your base currency a unit name and decimal places
123188
let mut properties = sc_chain_spec::Properties::new();
124189
properties.insert("tokenSymbol".into(), "UNIT".into());
125190
properties.insert("tokenDecimals".into(), 12.into());
126191
properties.insert("ss58Format".into(), 42.into());
127192

128-
ChainSpec::from_genesis(
193+
TestRuntimeChainSpec::from_genesis(
129194
// Name
130195
"Local Testnet",
131196
// ID
@@ -180,6 +245,61 @@ pub fn local_testnet_config() -> ChainSpec {
180245
)
181246
}
182247

248+
fn kusama_runtime_genesis(
249+
invulnerables: Vec<(AccountId, AuraId)>,
250+
endowed_accounts: Vec<AccountId>,
251+
root: AccountId,
252+
id: ParaId,
253+
) -> sugondat_kusama_runtime::RuntimeGenesisConfig {
254+
sugondat_kusama_runtime::RuntimeGenesisConfig {
255+
system: sugondat_kusama_runtime::SystemConfig {
256+
code: sugondat_kusama_runtime::WASM_BINARY
257+
.expect("WASM binary was not build, please build it!")
258+
.to_vec(),
259+
..Default::default()
260+
},
261+
balances: sugondat_kusama_runtime::BalancesConfig {
262+
balances: endowed_accounts
263+
.iter()
264+
.cloned()
265+
.map(|k| (k, 1 << 60))
266+
.collect(),
267+
},
268+
parachain_info: sugondat_kusama_runtime::ParachainInfoConfig {
269+
parachain_id: id,
270+
..Default::default()
271+
},
272+
collator_selection: sugondat_kusama_runtime::CollatorSelectionConfig {
273+
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
274+
candidacy_bond: TEST_EXISTENTIAL_DEPOSIT * 16,
275+
..Default::default()
276+
},
277+
session: sugondat_kusama_runtime::SessionConfig {
278+
keys: invulnerables
279+
.into_iter()
280+
.map(|(acc, aura)| {
281+
(
282+
acc.clone(), // account id
283+
acc, // validator id
284+
kusama_runtime_session_keys(aura), // session keys
285+
)
286+
})
287+
.collect(),
288+
},
289+
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
290+
// of this.
291+
aura: Default::default(),
292+
aura_ext: Default::default(),
293+
parachain_system: Default::default(),
294+
polkadot_xcm: sugondat_kusama_runtime::PolkadotXcmConfig {
295+
safe_xcm_version: Some(SAFE_XCM_VERSION),
296+
..Default::default()
297+
},
298+
transaction_payment: Default::default(),
299+
sudo: sugondat_kusama_runtime::SudoConfig { key: Some(root) },
300+
}
301+
}
302+
183303
fn testnet_genesis(
184304
invulnerables: Vec<(AccountId, AuraId)>,
185305
endowed_accounts: Vec<AccountId>,
@@ -214,9 +334,9 @@ fn testnet_genesis(
214334
.into_iter()
215335
.map(|(acc, aura)| {
216336
(
217-
acc.clone(), // account id
218-
acc, // validator id
219-
template_session_keys(aura), // session keys
337+
acc.clone(), // account id
338+
acc, // validator id
339+
test_runtime_session_keys(aura), // session keys
220340
)
221341
})
222342
.collect(),

sugondat-chain/node/src/command.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
2121
Ok(match id {
2222
"dev" => Box::new(chain_spec::development_config()),
2323
"sugondat-rococo" => Box::new(chain_spec::local_testnet_config()),
24+
"sugondat-kusama-staging" => Box::new(chain_spec::kusama_staging_config()),
2425
"" | "local" => Box::new(chain_spec::local_testnet_config()),
25-
path => Box::new(chain_spec::ChainSpec::from_json_file(
26+
path => Box::new(chain_spec::GenericChainSpec::from_json_file(
2627
std::path::PathBuf::from(path),
2728
)?),
2829
})

0 commit comments

Comments
 (0)