@@ -55,29 +55,25 @@ impl OcamlNode {
55
55
} ;
56
56
let peer_id = peer_id. parse ( ) ?;
57
57
58
- if config. daemon_json_update_timestamp {
59
- todo ! ( )
60
- } else {
61
- match & config. daemon_json {
62
- DaemonJson :: Custom ( path) => {
63
- std:: fs:: copy ( path, & daemon_json_path) . map_err ( |err| {
64
- anyhow:: anyhow!(
65
- "failed to copy daemon_json from: '{}', to: '{}'; error: {}" ,
66
- path,
67
- daemon_json_path. display( ) ,
68
- err
69
- )
70
- } ) ?;
71
- }
72
- DaemonJson :: InMem ( json) => {
73
- std:: fs:: write ( & daemon_json_path, json. to_string ( ) ) . map_err ( |err| {
74
- anyhow:: anyhow!(
75
- "failed to write InMem daemon.json to {}; error: {}" ,
76
- daemon_json_path. display( ) ,
77
- err
78
- )
79
- } ) ?;
80
- }
58
+ match & config. daemon_json {
59
+ DaemonJson :: Custom ( path) => {
60
+ std:: fs:: copy ( path, & daemon_json_path) . map_err ( |err| {
61
+ anyhow:: anyhow!(
62
+ "failed to copy daemon_json from: '{}', to: '{}'; error: {}" ,
63
+ path,
64
+ daemon_json_path. display( ) ,
65
+ err
66
+ )
67
+ } ) ?;
68
+ }
69
+ DaemonJson :: InMem ( json) => {
70
+ std:: fs:: write ( & daemon_json_path, json. to_string ( ) ) . map_err ( |err| {
71
+ anyhow:: anyhow!(
72
+ "failed to write InMem daemon.json to {}; error: {}" ,
73
+ daemon_json_path. display( ) ,
74
+ err
75
+ )
76
+ } ) ?;
81
77
}
82
78
}
83
79
@@ -164,6 +160,48 @@ impl OcamlNode {
164
160
}
165
161
166
162
const PRIVKEY_PATH : & ' static str = ".libp2p/key" ;
163
+ const LIBP2P_KEYS : [ ( & ' static str , & ' static str ) ; 10 ] = [
164
+ (
165
+ "12D3KooWKG1ZakBYEirEWdFYSstTEvxzTxCyuyaebojKthiESfWi" ,
166
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"7fZJwAwzGgwFGipwjVBTiinHt5NfjTFjSnhk8rA","pwsalt":"9Gz996pkoUjJ8docbT7fJvJg16iL","pwdiff":[134217728,6],"ciphertext":"7oHFyFJd9kWTfH6R7GvbHD4WXBw5JQeiQYBGUpFhiPuiAyEgi1BVbczrzS6njWJ9FkRdNgZqwmSo23GPX4Zs27m3U66dJvyahendHCndG3Wu9wi8yaees78AQpbsU7JRa7U5DyCs9d34QLwpsgrGC2CqtDHJD3K3YncxVDjk4CCKeHseukZXUvkFToqY9CZRLHgYXR29hiB8JyTgoQ4maDDBdqBpFRb6Rjfb3LX8WEat6NpTjWi4A9uvNyDqk68a2aAo8ofjP811SBYxjZY3PMdD4hs5UAAZqbUNA"}"# ,
167
+ ) ,
168
+ (
169
+ "12D3KooWQoSDqpenkrjCnKCCLnwEMRVRqUfZJXqD8Y8awEnBAJZX" ,
170
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"8psKzkQReBbhoWYriYSNGFVKsb7GMARxfSZLWDF","pwsalt":"9MdeSxJxE33e5sxYhnmPQNTDxbKj","pwdiff":[134217728,6],"ciphertext":"6YnXZjwJue344VEkLnFJ62VY9E2QxZPEtDoZSBXnNzJUEEK5MVjcC63GeM37kVXTVvoj8r9C9i4mUbTiwjpL9wg4NqxkcJpTMVBe6WDsYYrtt7S9o6p4xWAjm1hvbxXcsTzPN361amo2ZNCAuMGpCWQPnxeZ69bwLQkn4vKeGkdiUMdnziNfhKRaFcya4C1dNNoz8kAWFRexzZrjvSBymzZCvZPgof1mApyzcoWuYtAdENqbNURg2DBv53nLetmqA9zLTcDbXYE5hTgkVzMHa6qiia4xAhDbrax4r"}"# ,
171
+ ) ,
172
+ (
173
+ "12D3KooWEHSJwkn5ZdYVAcULpb3D3k6U2K4sU2BFh5xhoig1J4NK" ,
174
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"84F8XwEf5k2yPqgC8NSTdf5wQEw7kmRgEdyss91","pwsalt":"BeSN6EXqWBCx9fndvnib5BYnNNdc","pwdiff":[134217728,6],"ciphertext":"7ECwoC7vK5QRKrPZvrBmaWrTKJiHKq9fCZr8YyVPgfHFS2VQ1BeKgQPvoc5JHNhy2Yju8PDDKzS3zHCdRSGaVRX49VrxjSU9wg4Fj7EWPGEs6VNCQahudCovGFd69iqS8WvcDSSw6acaEstSssTFYV3mUviDbkRA5HM9fUvE8SBkg9rHeeghCQ4qLK7cFRywCx9P6nronv5b5yy15xJDjAp6h7fwNxA7daXGa3E8dhtsE6FaPCtefkLBKJFXzuo3CMdRcBMZTt2XVGHS27rxtn1j5jeT9y34EMA5t"}"# ,
175
+ ) ,
176
+ (
177
+ "12D3KooWA1qcHYLWKZ7EUBMh3KKWbwys1DhH35WmH4y96scpntmv" ,
178
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"6ifkqZVQ8MXHP5StG5umfJ2HhuSEpwxx33bRD4e","pwsalt":"9qREDkkiXgKV7VtryRcAkrzGY41p","pwdiff":[134217728,6],"ciphertext":"6uYbsTw56Vzaj4Jb9vWVQLTNHk92Qv6kFgZrqit8gUBya1M76U4wuNqQ1XMk5iKFSXFxf9hjtKN1NAbruUTnoySaCdCuLfjVJwUpDJFWwjRV3vmFjmZch9YjAL4H81z89V52BZkGpSantUxqGMLSrJjz8z5Rrr3C7ZCvooZddFieFkFfDtLBfhAsB3U2usMh83L6VMPg5Hawn7krdznSVzagiS1ENDPR92LfsCvxVVGxSNvUbBbjFCdroDb7eYi8mshiC3nGQWDYRQu9kQkHC6xsgarTsumkXnYpd"}"# ,
179
+ ) ,
180
+ (
181
+ "12D3KooWC14WLzaCT6fkR5WzzrayXDhmBpox7yWkif7Pg6Sk4uz1" ,
182
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"7rGH8gCM5UL9LvatyUP6Lka8b4Ev2o5Mbe5ou7L","pwsalt":"BKcQuXkYx6H4xfcLLGM8ykJP5a3D","pwdiff":[134217728,6],"ciphertext":"7tZEvuCoXyXRVxh9NNrMCRLXgXj8MHxNgwoesztLQTagMzKhf48EepzUReYEViNC2EpWb2h7yoJdXMUbDGUuSQdoM1eF3qum9rHtmU4xdv8SGBEP9q9YHb1n8YS2SEr7WNcN3DsX7cqrzfnSjDsXNZaGzR5CbrK7g3NGv8RVyT1uZF2VHHeapDY6nFCyKN9nUJKpizbbRguR25QwWyx2nzcKF3mGq2iuCNVN5Z6gqzk7fhD8XFayxj57MqwvWTRD6pLRBJcmqCF5L9ZqpKEHAjXMcv3nwkKBHJaAF"}"# ,
183
+ ) ,
184
+ (
185
+ "12D3KooWRJEo19dU5eWgab1YrBPnK9HQA4SqDeQwx9NrankTcfSi" ,
186
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"6VMHa83xqvbDzAppmfe9B8wn7dzzdAC1fyP5bXs","pwsalt":"9cXcTqJGi651tpA1ZBKSPVBP2h3q","pwdiff":[134217728,6],"ciphertext":"783EDXabmg2PmWhrSqcDog82NhWNMWasKC4o2d1oxVDTDxhmH5yGcjY74wV8HH16DpJw4ZxzW8gUCyC7Mhx1hEG8kc7wn38yBsoAqGfkA34g9n4FYJzwHvAB7on7zK3cveh2jXF3TTt3Etg4advpM7LvbY2eE9pz95TU1pCagu7haB83JHn2qSnfSCcMUTjS9copfJgkVD6YQYUxJmVi9erYUufjJqiF9p4ciCSuicU5SaJVB3rpSaRt1VgWMXeg47qWXVg98byNadHi8PgQZNnFifJc4FUDPtHDj"}"# ,
187
+ ) ,
188
+ (
189
+ "12D3KooWPTtAt3LXFqs8vbGL9VACn5wgcBm1jvaHZTGHnHzFq7c4" ,
190
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"8q2jNrxkiwzvk8LWuU8zWy93APjitkaZUKr3fDP","pwsalt":"B5YVY1p2yFfGRsjs2us7WnmhWqPq","pwdiff":[134217728,6],"ciphertext":"7xxCXkAf3DokjZQ6CtwbuuXMBeYB5p6KxQAqaFLx96yBAsqQaK3EprR3xDKVR78x7Zrzj4NXWrFow2cg4xtze12SS43t46E3QhSsYPohcuZzKJe4agGJMDZVHaqd1aAPtJd2CX1fZCrWmxpa3hB72H2EKYPFSG1FYv77cYxU45aJx3V1XQAEQtoYKP9FmL95xogJHVHQSe2xWrvga8CLY4qtshJWkwHP1mV59xam9WhhZZjZkSThYTJMW9f4NTQ2EwRuud9zReLkh8fGEvfoxFjMsw8NCVxrtdTi5"}"# ,
191
+ ) ,
192
+ (
193
+ "12D3KooWLrjE3v7wZSCT4HsnXYmRsQnCWsaGcmU9mSJfPDRyjvpd" ,
194
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"7zKo7kmPLjoJdvgxyMp2jguDnGDnyZ49TWfajiZ","pwsalt":"ARyFY4GSnyTC8ZjhvEaCSq3QeGsU","pwdiff":[134217728,6],"ciphertext":"7FfzcAPsEM7Lv5JzL7rYqgrHGV5bBDVVTEukULpDaCMGbHJDRFkgjxx6c6gbxCRbMJKma9yMrr5zxHsT9tfYCU7PAzqgVqa87TfphNXmqdSrNKWZVTS5SGMXAqku6vfJ19PA7TzJdr7oHZSjoim5Lh8r2x9iUTto7tdCBy4xWJQXE7aQYQ2ybB95DjzA3CtK7ypjxnZJDnvYq8zgXx9netbAX3NdTtsRDKQwNmjBzoQiKWd5jrqMigfFNcRTnJdpEn8jYMfa4fmXsnUe9ziXvjYdH9DJQA1354UQq"}"# ,
195
+ ) ,
196
+ (
197
+ "12D3KooWKPaZfwU42A9SDxyuDGWsLYiedudJvDAHY81UMXLLEgTe" ,
198
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"7QAvnHnfp1MMJgEYN8VVwLuwWF3GEMUG5DA2KWP","pwsalt":"9YP8yrJRfF6w4efUSTZrPRhoV8xZ","pwdiff":[134217728,6],"ciphertext":"6i8Efh1z9AZi2ExYLFBLsPGSAXQT72pgQNP9yPBfDwqr8dtQxvqdh6V8qXwjyVSiWLGs6zbUFQj1mJ17F9irLzUTFLQ9WG98HveuUJLxv2WPoEekb2AUntAYNkbgVEmtWEYytWqYZnJUx5g1cnLo5ENzrcDTDcbHbQnYVkyH2GNpNrH4WqjK3TyDS2PzKwTwBFVMyhK4BUDVtjJWxfHnQNSaxT7gsGFNQTJjizxpqaqFk7Nc11GPaJmJFJKoVYD4ozCkeR2RKM9Dk7ct49vTQvULqqETwJmK1yMTf"}"# ,
199
+ ) ,
200
+ (
201
+ "12D3KooWKrWvpCzTJs45HS8c8Hbo9sfe65wBVCLWW2gyJDmnDDif" ,
202
+ r#"{"box_primitive":"xsalsa20poly1305","pw_primitive":"argon2i","nonce":"8QEpCE7a48EdYXQ44ff9PXWDKw2AMmHMxc3nUaq","pwsalt":"8UUffeMbTFAwUwkamE1xWoVTJqDi","pwdiff":[134217728,6],"ciphertext":"93Wdv4Xq9794GWuZPZUPug2gfPpXD2dnLxSx9jGjtr7rTGv14W7JPieGJJ4zTw6T54x1NwyhH9HcDwsQxmUT364KibpbczuA9bnTFcp6ahoYpetrHB8FJTk7TprkmazqprJm7QDqJ97jyE7PuVNWg9NSbMRzet1c5Jxk2qfUYVdtSNgcQB5J5oUTibL6fc5UKZmfBoSixw3E3QFPnBRN8W7X3nfcHykK9eck2u5YJrv1gRYoupp2EX1CjWwKp3ebDa9bLLZiWTTSBKsj7uhLh5aCxgHpoPCyNcnaq"}"# ,
203
+ ) ,
204
+ ] ;
167
205
168
206
fn privkey_path ( dir : & Path ) -> PathBuf {
169
207
dir. join ( Self :: PRIVKEY_PATH )
@@ -178,18 +216,31 @@ impl OcamlNode {
178
216
}
179
217
180
218
fn generate_libp2p_keypair ( config : & OcamlNodeConfig , dir : & Path ) -> anyhow:: Result < String > {
181
- let mut child = config
182
- . cmd ( [ ( "MINA_LIBP2P_PASS" , "" ) , ( "UMASK" , "0700" ) ] )
183
- . args ( [ "libp2p" , "generate-keypair" , "--privkey-path" ] )
184
- . arg ( Self :: privkey_path ( dir) )
185
- . spawn ( ) ?;
186
- if child. wait ( ) ?. success ( ) {
187
- config. executable . kill ( & config. dir ) ;
188
- let peer_id = Self :: read_peer_id ( dir) ?;
189
- Ok ( peer_id)
190
- } else {
191
- anyhow:: bail!( "error generating keypair" ) ;
192
- }
219
+ use std:: {
220
+ fs:: OpenOptions ,
221
+ io:: Write ,
222
+ os:: unix:: fs:: { DirBuilderExt , OpenOptionsExt } ,
223
+ } ;
224
+
225
+ let ( peer_id, key) = Self :: LIBP2P_KEYS [ config. libp2p_keypair_i ] ;
226
+ let privkey_path = Self :: privkey_path ( dir) ;
227
+ let privkey_parent_dir = privkey_path. as_path ( ) . parent ( ) . unwrap ( ) ;
228
+ std:: fs:: DirBuilder :: new ( )
229
+ . recursive ( true )
230
+ . mode ( 0o700 )
231
+ . create ( privkey_parent_dir) ?;
232
+
233
+ let mut file = OpenOptions :: new ( )
234
+ . create ( true )
235
+ . write ( true )
236
+ . mode ( 0o600 )
237
+ . open ( & privkey_path) ?;
238
+ file. write_all ( key. as_bytes ( ) ) ?;
239
+ std:: fs:: write (
240
+ privkey_path. with_extension ( "peerid" ) ,
241
+ format ! ( "peerid:{peer_id}" ) ,
242
+ ) ?;
243
+ Ok ( peer_id. to_owned ( ) )
193
244
}
194
245
195
246
fn read_stream < R : std:: io:: Read , W : std:: io:: Write > (
@@ -316,12 +367,12 @@ fn run_ocaml() {
316
367
let mut node = OcamlNode :: start ( OcamlNodeConfig {
317
368
executable : OcamlNodeExecutable :: find_working ( ) . unwrap ( ) ,
318
369
dir : temp_dir:: TempDir :: new ( ) . unwrap ( ) ,
370
+ libp2p_keypair_i : 0 ,
319
371
libp2p_port : 8302 ,
320
372
graphql_port : 3086 ,
321
373
client_port : 8301 ,
322
374
initial_peers : Vec :: new ( ) ,
323
375
daemon_json : DaemonJson :: Custom ( "/var/lib/coda/berkeley.json" . to_owned ( ) ) ,
324
- daemon_json_update_timestamp : false ,
325
376
} )
326
377
. unwrap ( ) ;
327
378
let stdout = node. child . stdout . take ( ) . unwrap ( ) ;
0 commit comments