@@ -4,6 +4,7 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId;
4
4
use sp_consensus_grandpa:: AuthorityId as GrandpaId ;
5
5
use sp_core:: { sr25519, Pair , Public } ;
6
6
use sp_runtime:: traits:: { IdentifyAccount , Verify } ;
7
+ use sp_core:: crypto:: Ss58Codec ;
7
8
8
9
// The URL for the telemetry server.
9
10
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
@@ -20,6 +21,7 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
20
21
21
22
type AccountPublic = <Signature as Verify >:: Signer ;
22
23
24
+
23
25
/// Generate an account ID from seed.
24
26
pub fn get_account_id_from_seed < TPublic : Public > ( seed : & str ) -> AccountId
25
27
where
@@ -33,7 +35,42 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
33
35
( get_from_seed :: < AuraId > ( s) , get_from_seed :: < GrandpaId > ( s) )
34
36
}
35
37
38
+ pub fn authority_keys_from_ss58 ( s_aura : & str , s_grandpa : & str ) -> ( AuraId , GrandpaId ) {
39
+ (
40
+ aura_from_ss58_addr ( s_aura) ,
41
+ grandpa_from_ss58_addr ( s_grandpa) ,
42
+ )
43
+ }
44
+
45
+ pub fn aura_from_ss58_addr ( s : & str ) -> AuraId {
46
+ Ss58Codec :: from_ss58check ( s) . unwrap ( )
47
+ }
48
+
49
+ pub fn grandpa_from_ss58_addr ( s : & str ) -> GrandpaId {
50
+ Ss58Codec :: from_ss58check ( s) . unwrap ( )
51
+ }
52
+
53
+ pub fn get_test_accounts ( ) -> Vec < AccountId > {
54
+ let test_accounts = vec ! [
55
+ get_account_id_from_seed:: <sr25519:: Public >( "Alice" ) ,
56
+ get_account_id_from_seed:: <sr25519:: Public >( "Bob" ) ,
57
+ get_account_id_from_seed:: <sr25519:: Public >( "Charlie" ) ,
58
+ get_account_id_from_seed:: <sr25519:: Public >( "Dave" ) ,
59
+ get_account_id_from_seed:: <sr25519:: Public >( "Eve" ) ,
60
+ get_account_id_from_seed:: <sr25519:: Public >( "Ferdie" ) ,
61
+ get_account_id_from_seed:: <sr25519:: Public >( "Alice//stash" ) ,
62
+ get_account_id_from_seed:: <sr25519:: Public >( "Bob//stash" ) ,
63
+ get_account_id_from_seed:: <sr25519:: Public >( "Charlie//stash" ) ,
64
+ get_account_id_from_seed:: <sr25519:: Public >( "Dave//stash" ) ,
65
+ get_account_id_from_seed:: <sr25519:: Public >( "Eve//stash" ) ,
66
+ get_account_id_from_seed:: <sr25519:: Public >( "Ferdie//stash" ) ,
67
+ ] ;
68
+ test_accounts
69
+ }
70
+
36
71
pub fn development_config ( ) -> Result < ChainSpec , String > {
72
+ let mut accounts = ( 0 ..255 ) . map ( |x| get_account_id_from_seed :: < sr25519:: Public > ( & x. to_string ( ) ) ) . collect :: < Vec < _ > > ( ) ;
73
+ accounts. extend ( get_test_accounts ( ) ) ;
37
74
Ok ( ChainSpec :: builder (
38
75
WASM_BINARY . ok_or_else ( || "Development wasm not available" . to_string ( ) ) ?,
39
76
None ,
@@ -47,18 +84,15 @@ pub fn development_config() -> Result<ChainSpec, String> {
47
84
// Sudo account
48
85
get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ,
49
86
// Pre-funded accounts
50
- vec ! [
51
- get_account_id_from_seed:: <sr25519:: Public >( "Alice" ) ,
52
- get_account_id_from_seed:: <sr25519:: Public >( "Bob" ) ,
53
- get_account_id_from_seed:: <sr25519:: Public >( "Alice//stash" ) ,
54
- get_account_id_from_seed:: <sr25519:: Public >( "Bob//stash" ) ,
55
- ] ,
87
+ accounts,
56
88
true ,
57
89
) )
58
90
. build ( ) )
59
91
}
60
92
61
93
pub fn local_testnet_config ( ) -> Result < ChainSpec , String > {
94
+ let mut accounts = ( 0 ..255 ) . map ( |x| get_account_id_from_seed :: < sr25519:: Public > ( & x. to_string ( ) ) ) . collect :: < Vec < _ > > ( ) ;
95
+ accounts. extend ( get_test_accounts ( ) ) ;
62
96
Ok ( ChainSpec :: builder (
63
97
WASM_BINARY . ok_or_else ( || "Development wasm not available" . to_string ( ) ) ?,
64
98
None ,
@@ -72,20 +106,53 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
72
106
// Sudo account
73
107
get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ,
74
108
// Pre-funded accounts
109
+ accounts,
110
+ true ,
111
+ ) )
112
+ . build ( ) )
113
+ }
114
+
115
+ pub fn gavin_config ( ) -> Result < ChainSpec , String > {
116
+ let mut accounts = ( 0 ..255 ) . map ( |x| get_account_id_from_seed :: < sr25519:: Public > ( & x. to_string ( ) ) ) . collect :: < Vec < _ > > ( ) ;
117
+ accounts. extend ( get_test_accounts ( ) ) ;
118
+ Ok ( ChainSpec :: builder (
119
+ WASM_BINARY . ok_or_else ( || "Development wasm not available" . to_string ( ) ) ?,
120
+ None ,
121
+ )
122
+ . with_name ( "Gavin Testnet" )
123
+ . with_id ( "gavin_testnet" )
124
+ . with_chain_type ( ChainType :: Development )
125
+ . with_genesis_config_patch ( testnet_genesis (
126
+ // Initial PoA authorities
75
127
vec ! [
76
- get_account_id_from_seed:: <sr25519:: Public >( "Alice" ) ,
77
- get_account_id_from_seed:: <sr25519:: Public >( "Bob" ) ,
78
- get_account_id_from_seed:: <sr25519:: Public >( "Charlie" ) ,
79
- get_account_id_from_seed:: <sr25519:: Public >( "Dave" ) ,
80
- get_account_id_from_seed:: <sr25519:: Public >( "Eve" ) ,
81
- get_account_id_from_seed:: <sr25519:: Public >( "Ferdie" ) ,
82
- get_account_id_from_seed:: <sr25519:: Public >( "Alice//stash" ) ,
83
- get_account_id_from_seed:: <sr25519:: Public >( "Bob//stash" ) ,
84
- get_account_id_from_seed:: <sr25519:: Public >( "Charlie//stash" ) ,
85
- get_account_id_from_seed:: <sr25519:: Public >( "Dave//stash" ) ,
86
- get_account_id_from_seed:: <sr25519:: Public >( "Eve//stash" ) ,
87
- get_account_id_from_seed:: <sr25519:: Public >( "Ferdie//stash" ) ,
128
+ authority_keys_from_ss58(
129
+ "5F46bJk2dcCmhu7s8phKsRwZCoBpi8xwgS4xknnSviqn8wwA" ,
130
+ "5FjbWKESKnQpJF2BjCZ8YxqCkWK2xq9kAijcpey5jYrMTb4F" ,
131
+ ) ,
132
+ authority_keys_from_ss58(
133
+ "5EX5TgeLSf55eZZrfG1GDPba6b3YXJvc4CoqzBkQoiX6KVKn" ,
134
+ "5HLfb4bHmQJKToTAfK4SumF3AKT17752KU63ytvgxUo8a4cD" ,
135
+ ) ,
136
+ authority_keys_from_ss58(
137
+ "5CrPkhgMsYHX9NgoX3bMkSGSattgw9ukVkeF8wiv7Ewnb7vv" ,
138
+ "5EQzoKrJJEz8ALXnDSQFi6rv8EkvNDHrW9pVTgQ5KCtTcC37" ,
139
+ ) ,
140
+ authority_keys_from_ss58(
141
+ "5DxxktpYcLXtAR6BzsosXbakUFN6cHxJEyfQPPZW1c8jiK7B" ,
142
+ "5HdjyBj6qMEnzsutuKvybSpSFkEaXN16KgUFqJQBxaQVPMWy" ,
143
+ ) ,
88
144
] ,
145
+ // Sudo account
146
+ // get_account_id_from_seed::<sr25519::Public>("Alice"),
147
+ AccountId :: from_ss58check ( "5F46bJk2dcCmhu7s8phKsRwZCoBpi8xwgS4xknnSviqn8wwA" ) . unwrap ( ) ,
148
+ // Pre-funded accounts
149
+ // vec![
150
+ // get_account_id_from_seed::<sr25519::Public>("Alice"),
151
+ // get_account_id_from_seed::<sr25519::Public>("Bob"),
152
+ // get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
153
+ // get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
154
+ // ],
155
+ accounts,
89
156
true ,
90
157
) )
91
158
. build ( ) )
@@ -101,7 +168,7 @@ fn testnet_genesis(
101
168
serde_json:: json!( {
102
169
"balances" : {
103
170
// Configure endowed accounts with initial balance of 1 << 60.
104
- "balances" : endowed_accounts. iter( ) . cloned( ) . map( |k| ( k, 1u64 << 60 ) ) . collect:: <Vec <_>>( ) ,
171
+ "balances" : endowed_accounts. iter( ) . cloned( ) . map( |k| ( k, 10000000000000000000000_u128 ) ) . collect:: <Vec <_>>( ) ,
105
172
} ,
106
173
"aura" : {
107
174
"authorities" : initial_authorities. iter( ) . map( |x| ( x. 0 . clone( ) ) ) . collect:: <Vec <_>>( ) ,
@@ -113,14 +180,5 @@ fn testnet_genesis(
113
180
// Assign network admin rights.
114
181
"key" : Some ( root_key) ,
115
182
} ,
116
- // "pallet_network": {
117
- // "subnet_path": "bigscience/bloom-560m".into(),
118
- // "memory_mb": 560,
119
- // "subnet_nodes": vec![],
120
- // "accounts": vec![],
121
- // "blank": {
122
- // Some(root_key.clone())
123
- // },
124
- // },
125
183
} )
126
184
}
0 commit comments