@@ -7,10 +7,16 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
7
7
use sugondat_primitives:: { AccountId , AuraId , Signature } ;
8
8
use sugondat_test_runtime:: EXISTENTIAL_DEPOSIT as TEST_EXISTENTIAL_DEPOSIT ;
9
9
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 =
12
14
sc_service:: GenericChainSpec < sugondat_test_runtime:: RuntimeGenesisConfig , Extensions > ;
13
15
16
+ /// Specialized `ChainSpec` for the kusama parachain runtime.
17
+ pub type KusamaRuntimeChainSpec =
18
+ sc_service:: GenericChainSpec < sugondat_kusama_runtime:: RuntimeGenesisConfig , Extensions > ;
19
+
14
20
/// The default XCM version to set in genesis config.
15
21
const SAFE_XCM_VERSION : u32 = xcm:: prelude:: XCM_VERSION ;
16
22
@@ -58,18 +64,25 @@ where
58
64
/// Generate the session keys from individual elements.
59
65
///
60
66
/// 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 {
62
68
sugondat_test_runtime:: SessionKeys { aura : keys }
63
69
}
64
70
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 {
66
79
// Give your base currency a unit name and decimal places
67
80
let mut properties = sc_chain_spec:: Properties :: new ( ) ;
68
81
properties. insert ( "tokenSymbol" . into ( ) , "UNIT" . into ( ) ) ;
69
82
properties. insert ( "tokenDecimals" . into ( ) , 12 . into ( ) ) ;
70
83
properties. insert ( "ss58Format" . into ( ) , 42 . into ( ) ) ;
71
84
72
- ChainSpec :: from_genesis (
85
+ TestRuntimeChainSpec :: from_genesis (
73
86
// Name
74
87
"Development" ,
75
88
// ID
@@ -118,14 +131,66 @@ pub fn development_config() -> ChainSpec {
118
131
)
119
132
}
120
133
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 {
122
187
// Give your base currency a unit name and decimal places
123
188
let mut properties = sc_chain_spec:: Properties :: new ( ) ;
124
189
properties. insert ( "tokenSymbol" . into ( ) , "UNIT" . into ( ) ) ;
125
190
properties. insert ( "tokenDecimals" . into ( ) , 12 . into ( ) ) ;
126
191
properties. insert ( "ss58Format" . into ( ) , 42 . into ( ) ) ;
127
192
128
- ChainSpec :: from_genesis (
193
+ TestRuntimeChainSpec :: from_genesis (
129
194
// Name
130
195
"Local Testnet" ,
131
196
// ID
@@ -180,6 +245,61 @@ pub fn local_testnet_config() -> ChainSpec {
180
245
)
181
246
}
182
247
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
+
183
303
fn testnet_genesis (
184
304
invulnerables : Vec < ( AccountId , AuraId ) > ,
185
305
endowed_accounts : Vec < AccountId > ,
@@ -214,9 +334,9 @@ fn testnet_genesis(
214
334
. into_iter ( )
215
335
. map ( |( acc, aura) | {
216
336
(
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
220
340
)
221
341
} )
222
342
. collect ( ) ,
0 commit comments