diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index fee913c82b593d..7ae39975545ff2 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -8,6 +8,7 @@ use { ledger_utils::*, output::{ output_account, AccountsOutputConfig, AccountsOutputMode, AccountsOutputStreamer, + SlotBankHash, }, program::*, }, @@ -1791,9 +1792,12 @@ fn main() { process_options.slot_callback = slot_callback; + let output_format = + OutputFormat::from_matches(arg_matches, "output_format", false); let print_accounts_stats = arg_matches.is_present("print_accounts_stats"); let print_bank_hash = arg_matches.is_present("print_bank_hash"); let write_bank_file = arg_matches.is_present("write_bank_file"); + let genesis_config = open_genesis_config_by(&ledger_path, arg_matches); info!("genesis hash: {}", genesis_config.hash()); @@ -1817,11 +1821,11 @@ fn main() { working_bank.print_accounts_stats(); } if print_bank_hash { - println!( - "Bank hash for slot {}: {}", - working_bank.slot(), - working_bank.hash() - ); + let slot_bank_hash = SlotBankHash { + slot: working_bank.slot(), + hash: working_bank.hash().to_string(), + }; + println!("{}", output_format.formatted_string(&slot_bank_hash)); } if write_bank_file { bank_hash_details::write_bank_hash_details_file(&working_bank) diff --git a/ledger-tool/src/output.rs b/ledger-tool/src/output.rs index 3de08cec989806..7ee2e7b2f5372d 100644 --- a/ledger-tool/src/output.rs +++ b/ledger-tool/src/output.rs @@ -101,6 +101,22 @@ impl Display for SlotBounds<'_> { } } +#[derive(Serialize, Debug, Default)] +#[serde(rename_all = "camelCase")] +pub struct SlotBankHash { + pub slot: Slot, + pub hash: String, +} + +impl VerboseDisplay for SlotBankHash {} +impl QuietDisplay for SlotBankHash {} + +impl Display for SlotBankHash { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + writeln!(f, "Bank hash for slot {}: {}", self.slot, self.hash) + } +} + fn writeln_entry(f: &mut dyn fmt::Write, i: usize, entry: &CliEntry, prefix: &str) -> fmt::Result { writeln!( f, diff --git a/net/gce.sh b/net/gce.sh index 058dcdcf0e7590..2c48cb7132f4a8 100755 --- a/net/gce.sh +++ b/net/gce.sh @@ -805,6 +805,7 @@ $( install-certbot.sh \ install-earlyoom.sh \ install-iftop.sh \ + install-jq.sh \ install-libssl-compatability.sh \ install-rsync.sh \ install-perf.sh \ diff --git a/net/remote/remote-node.sh b/net/remote/remote-node.sh index 71378019730f05..882f7891702cde 100755 --- a/net/remote/remote-node.sh +++ b/net/remote/remote-node.sh @@ -263,7 +263,7 @@ EOF agave-ledger-tool -l config/bootstrap-validator shred-version --max-genesis-archive-unpacked-size 1073741824 | tee config/shred-version if [[ -n "$maybeWaitForSupermajority" ]]; then - bankHash=$(agave-ledger-tool -l config/bootstrap-validator bank-hash --halt-at-slot 0) + bankHash=$(agave-ledger-tool -l config/bootstrap-validator verify --halt-at-slot 0 --print-bank-hash --output json | jq -r ".hash") shredVersion="$(cat "$SOLANA_CONFIG_DIR"/shred-version)" extraNodeArgs="$extraNodeArgs --expected-bank-hash $bankHash --expected-shred-version $shredVersion" echo "$bankHash" > config/bank-hash diff --git a/net/scripts/install-jq.sh b/net/scripts/install-jq.sh new file mode 100755 index 00000000000000..9d7c837c8dd9f1 --- /dev/null +++ b/net/scripts/install-jq.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +# jq setup +# +set -ex + +[[ $(uname) = Linux ]] || exit 1 +[[ $USER = root ]] || exit 1 + +apt-get --assume-yes install jq