Skip to content

Commit 1d79dd1

Browse files
committed
update to match agave genesis file format
1 parent 062a21e commit 1d79dd1

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

Diff for: Cargo.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/genesis.rs

+17-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ fn generate_filename(node_type: &NodeType, account_type: &str, index: usize) ->
4545
}
4646
}
4747

48+
#[derive(Serialize, Deserialize)]
49+
struct ValidatorAccountsFile {
50+
validator_accounts: Vec<ValidatorAccounts>,
51+
}
52+
4853
/// A validator account where the data is encoded as a Base64 string.
4954
/// Includes the vote account and stake account.
5055
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -543,8 +548,9 @@ impl Genesis {
543548
Ok(())
544549
}
545550

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)
548554
.args([
549555
"-l",
550556
self.config_dir
@@ -561,6 +567,7 @@ impl Genesis {
561567
"json",
562568
])
563569
.stdout(Stdio::piped())
570+
.stderr(Stdio::piped())
564571
.spawn()?
565572
.stdout
566573
.expect("Failed to capture agave-ledger-tool output");
@@ -620,16 +627,20 @@ impl Genesis {
620627
Ok(())
621628
}
622629

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
623633
fn write_validator_genesis_accouts_to_file(&mut self) -> std::io::Result<()> {
624634
// 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+
627639
let output_file = self.config_dir.join("validator-genesis-accounts.yml");
628640
self.flags.validator_accounts_file = Some(output_file.clone());
629641

630-
// write ValidatorAccouns to yaml file for solana-genesis
631642
let file = File::create(&output_file)?;
632-
serde_yaml::to_writer(file, &validator_accounts_vec)
643+
serde_yaml::to_writer(file, &accounts_file)
633644
.map_err(|err| io::Error::new(io::ErrorKind::Other, format!("{err:?}")))?;
634645

635646
info!("Validator genesis accounts successfully written to {output_file:?}");

Diff for: src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
728728
if !skip_primordial_stakes {
729729
genesis.create_snapshot(&exec_path)?;
730730

731-
let bank_hash = genesis.get_bank_hash()?;
731+
let bank_hash = genesis.get_bank_hash(&exec_path)?;
732732
kub_controller.set_bank_hash(bank_hash);
733733
}
734734
}

0 commit comments

Comments
 (0)