1
- use cumulus_primitives_core:: ParaId ;
2
1
use parachain_template_runtime as runtime;
3
- use runtime:: { AccountId , AuraId , Signature , EXISTENTIAL_DEPOSIT } ;
4
2
use sc_chain_spec:: { ChainSpecExtension , ChainSpecGroup } ;
5
3
use sc_service:: ChainType ;
6
4
use serde:: { Deserialize , Serialize } ;
7
- use sp_core:: { sr25519, Pair , Public } ;
8
- use sp_runtime:: traits:: { IdentifyAccount , Verify } ;
9
5
10
6
/// Specialized `ChainSpec` for the normal parachain runtime.
11
7
pub type ChainSpec = sc_service:: GenericChainSpec < Extensions > ;
12
8
13
- /// The default XCM version to set in genesis config.
14
- const SAFE_XCM_VERSION : u32 = xcm:: prelude:: XCM_VERSION ;
15
-
16
- /// Helper function to generate a crypto pair from seed
17
- pub fn get_from_seed < TPublic : Public > ( seed : & str ) -> <TPublic :: Pair as Pair >:: Public {
18
- TPublic :: Pair :: from_string ( & format ! ( "//{}" , seed) , None )
19
- . expect ( "static values are valid; qed" )
20
- . public ( )
21
- }
22
-
23
9
/// The extensions for the [`ChainSpec`].
24
10
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize , ChainSpecGroup , ChainSpecExtension ) ]
25
11
pub struct Extensions {
@@ -38,30 +24,6 @@ impl Extensions {
38
24
}
39
25
}
40
26
41
- type AccountPublic = <Signature as Verify >:: Signer ;
42
-
43
- /// Generate collator keys from seed.
44
- ///
45
- /// This function's return type must always match the session keys of the chain in tuple format.
46
- pub fn get_collator_keys_from_seed ( seed : & str ) -> AuraId {
47
- get_from_seed :: < AuraId > ( seed)
48
- }
49
-
50
- /// Helper function to generate an account ID from seed
51
- pub fn get_account_id_from_seed < TPublic : Public > ( seed : & str ) -> AccountId
52
- where
53
- AccountPublic : From < <TPublic :: Pair as Pair >:: Public > ,
54
- {
55
- AccountPublic :: from ( get_from_seed :: < TPublic > ( seed) ) . into_account ( )
56
- }
57
-
58
- /// Generate the session keys from individual elements.
59
- ///
60
- /// 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 ) -> runtime:: SessionKeys {
62
- runtime:: SessionKeys { aura : keys }
63
- }
64
-
65
27
pub fn development_config ( ) -> ChainSpec {
66
28
// Give your base currency a unit name and decimal places
67
29
let mut properties = sc_chain_spec:: Properties :: new ( ) ;
@@ -80,35 +42,7 @@ pub fn development_config() -> ChainSpec {
80
42
. with_name ( "Development" )
81
43
. with_id ( "dev" )
82
44
. with_chain_type ( ChainType :: Development )
83
- . with_genesis_config_patch ( testnet_genesis (
84
- // initial collators.
85
- vec ! [
86
- (
87
- get_account_id_from_seed:: <sr25519:: Public >( "Alice" ) ,
88
- get_collator_keys_from_seed( "Alice" ) ,
89
- ) ,
90
- (
91
- get_account_id_from_seed:: <sr25519:: Public >( "Bob" ) ,
92
- get_collator_keys_from_seed( "Bob" ) ,
93
- ) ,
94
- ] ,
95
- vec ! [
96
- get_account_id_from_seed:: <sr25519:: Public >( "Alice" ) ,
97
- get_account_id_from_seed:: <sr25519:: Public >( "Bob" ) ,
98
- get_account_id_from_seed:: <sr25519:: Public >( "Charlie" ) ,
99
- get_account_id_from_seed:: <sr25519:: Public >( "Dave" ) ,
100
- get_account_id_from_seed:: <sr25519:: Public >( "Eve" ) ,
101
- get_account_id_from_seed:: <sr25519:: Public >( "Ferdie" ) ,
102
- get_account_id_from_seed:: <sr25519:: Public >( "Alice//stash" ) ,
103
- get_account_id_from_seed:: <sr25519:: Public >( "Bob//stash" ) ,
104
- get_account_id_from_seed:: <sr25519:: Public >( "Charlie//stash" ) ,
105
- get_account_id_from_seed:: <sr25519:: Public >( "Dave//stash" ) ,
106
- get_account_id_from_seed:: <sr25519:: Public >( "Eve//stash" ) ,
107
- get_account_id_from_seed:: <sr25519:: Public >( "Ferdie//stash" ) ,
108
- ] ,
109
- get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ,
110
- 1000 . into ( ) ,
111
- ) )
45
+ . with_genesis_config_preset_name ( "development" )
112
46
. build ( )
113
47
}
114
48
@@ -131,72 +65,8 @@ pub fn local_testnet_config() -> ChainSpec {
131
65
. with_name ( "Local Testnet" )
132
66
. with_id ( "local_testnet" )
133
67
. with_chain_type ( ChainType :: Local )
134
- . with_genesis_config_patch ( testnet_genesis (
135
- // initial collators.
136
- vec ! [
137
- (
138
- get_account_id_from_seed:: <sr25519:: Public >( "Alice" ) ,
139
- get_collator_keys_from_seed( "Alice" ) ,
140
- ) ,
141
- (
142
- get_account_id_from_seed:: <sr25519:: Public >( "Bob" ) ,
143
- get_collator_keys_from_seed( "Bob" ) ,
144
- ) ,
145
- ] ,
146
- vec ! [
147
- get_account_id_from_seed:: <sr25519:: Public >( "Alice" ) ,
148
- get_account_id_from_seed:: <sr25519:: Public >( "Bob" ) ,
149
- get_account_id_from_seed:: <sr25519:: Public >( "Charlie" ) ,
150
- get_account_id_from_seed:: <sr25519:: Public >( "Dave" ) ,
151
- get_account_id_from_seed:: <sr25519:: Public >( "Eve" ) ,
152
- get_account_id_from_seed:: <sr25519:: Public >( "Ferdie" ) ,
153
- get_account_id_from_seed:: <sr25519:: Public >( "Alice//stash" ) ,
154
- get_account_id_from_seed:: <sr25519:: Public >( "Bob//stash" ) ,
155
- get_account_id_from_seed:: <sr25519:: Public >( "Charlie//stash" ) ,
156
- get_account_id_from_seed:: <sr25519:: Public >( "Dave//stash" ) ,
157
- get_account_id_from_seed:: <sr25519:: Public >( "Eve//stash" ) ,
158
- get_account_id_from_seed:: <sr25519:: Public >( "Ferdie//stash" ) ,
159
- ] ,
160
- get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ,
161
- 1000 . into ( ) ,
162
- ) )
68
+ . with_genesis_config_preset_name ( "local_testnet" )
163
69
. with_protocol_id ( "template-local" )
164
70
. with_properties ( properties)
165
71
. build ( )
166
72
}
167
-
168
- fn testnet_genesis (
169
- invulnerables : Vec < ( AccountId , AuraId ) > ,
170
- endowed_accounts : Vec < AccountId > ,
171
- root : AccountId ,
172
- id : ParaId ,
173
- ) -> serde_json:: Value {
174
- serde_json:: json!( {
175
- "balances" : {
176
- "balances" : endowed_accounts. iter( ) . cloned( ) . map( |k| ( k, 1u64 << 60 ) ) . collect:: <Vec <_>>( ) ,
177
- } ,
178
- "parachainInfo" : {
179
- "parachainId" : id,
180
- } ,
181
- "collatorSelection" : {
182
- "invulnerables" : invulnerables. iter( ) . cloned( ) . map( |( acc, _) | acc) . collect:: <Vec <_>>( ) ,
183
- "candidacyBond" : EXISTENTIAL_DEPOSIT * 16 ,
184
- } ,
185
- "session" : {
186
- "keys" : invulnerables
187
- . into_iter( )
188
- . map( |( acc, aura) | {
189
- (
190
- acc. clone( ) , // account id
191
- acc, // validator id
192
- template_session_keys( aura) , // session keys
193
- )
194
- } )
195
- . collect:: <Vec <_>>( ) ,
196
- } ,
197
- "polkadotXcm" : {
198
- "safeXcmVersion" : Some ( SAFE_XCM_VERSION ) ,
199
- } ,
200
- "sudo" : { "key" : Some ( root) }
201
- } )
202
- }
0 commit comments