@@ -45,6 +45,11 @@ fn generate_filename(node_type: &NodeType, account_type: &str, index: usize) ->
45
45
}
46
46
}
47
47
48
+ #[ derive( Serialize , Deserialize ) ]
49
+ struct ValidatorAccountsFile {
50
+ validator_accounts : Vec < ValidatorAccounts > ,
51
+ }
52
+
48
53
/// A validator account where the data is encoded as a Base64 string.
49
54
/// Includes the vote account and stake account.
50
55
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
@@ -543,8 +548,9 @@ impl Genesis {
543
548
Ok ( ( ) )
544
549
}
545
550
546
- pub fn get_bank_hash ( & self ) -> Result < String , Box < dyn Error > > {
547
- let agave_output = Command :: new ( "agave-ledger-tool" )
551
+ pub fn get_bank_hash ( & self , exec_path : & Path ) -> Result < String , Box < dyn Error > > {
552
+ let executable_path: PathBuf = exec_path. join ( "agave-ledger-tool" ) ;
553
+ let agave_output = Command :: new ( executable_path)
548
554
. args ( [
549
555
"-l" ,
550
556
self . config_dir
@@ -561,6 +567,7 @@ impl Genesis {
561
567
"json" ,
562
568
] )
563
569
. stdout ( Stdio :: piped ( ) )
570
+ . stderr ( Stdio :: piped ( ) )
564
571
. spawn ( ) ?
565
572
. stdout
566
573
. expect ( "Failed to capture agave-ledger-tool output" ) ;
@@ -620,16 +627,20 @@ impl Genesis {
620
627
Ok ( ( ) )
621
628
}
622
629
630
+ // Creates yaml file solana-genesis can read in for `--validator-stakes-file <FILE>`
631
+ // Yaml file created with the following format dictated in agave/genesis/README.md
632
+ // See: https://github.com/anza-xyz/agave/blob/master/genesis/README.md#3-through-the-validator-accounts-file-flag
623
633
fn write_validator_genesis_accouts_to_file ( & mut self ) -> std:: io:: Result < ( ) > {
624
634
// get ValidatorAccounts vec to write to file for solana-genesis
625
- let validator_accounts_vec: Vec < ValidatorAccounts > =
626
- self . validator_accounts . values ( ) . cloned ( ) . collect ( ) ;
635
+ let accounts_file = ValidatorAccountsFile {
636
+ validator_accounts : self . validator_accounts . values ( ) . cloned ( ) . collect ( ) ,
637
+ } ;
638
+
627
639
let output_file = self . config_dir . join ( "validator-genesis-accounts.yml" ) ;
628
640
self . flags . validator_accounts_file = Some ( output_file. clone ( ) ) ;
629
641
630
- // write ValidatorAccouns to yaml file for solana-genesis
631
642
let file = File :: create ( & output_file) ?;
632
- serde_yaml:: to_writer ( file, & validator_accounts_vec )
643
+ serde_yaml:: to_writer ( file, & accounts_file )
633
644
. map_err ( |err| io:: Error :: new ( io:: ErrorKind :: Other , format ! ( "{err:?}" ) ) ) ?;
634
645
635
646
info ! ( "Validator genesis accounts successfully written to {output_file:?}" ) ;
0 commit comments