Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,14 +1349,22 @@ impl ReplayStage {
);
}


// Should not dump slots for which we were the leader
if Some(*my_pubkey) == leader_schedule_cache.slot_leader_at(*duplicate_slot, None) {
panic!("We are attempting to dump a block that we produced. \
This indicates that we are producing duplicate blocks, \
or that there is a bug in our runtime/replay code which \
causes us to compute different bank hashes than the rest of the cluster. \
We froze slot {duplicate_slot} with hash {frozen_hash:?} while the cluster hash is {correct_hash}");
if let Some(bank) = bank_forks.read().unwrap().get(*duplicate_slot) {
bank_hash_details::write_bank_hash_details_file(&bank)
.map_err(|err| {
warn!("Unable to write bank hash details file: {err}");
})
.ok();
} else {
warn!("Unable to get bank for slot {duplicate_slot} from bank forks");
}
panic!("We are attempting to dump a block that we produced. \
This indicates that we are producing duplicate blocks, \
or that there is a bug in our runtime/replay code which \
causes us to compute different bank hashes than the rest of the cluster. \
We froze slot {duplicate_slot} with hash {frozen_hash:?} while the cluster hash is {correct_hash}");
}

let attempt_no = purge_repair_slot_counter
Expand Down Expand Up @@ -1507,7 +1515,11 @@ impl ReplayStage {
let bank = w_bank_forks
.remove(*slot)
.expect("BankForks should not have been purged yet");
let _ = bank_hash_details::write_bank_hash_details_file(&bank);
bank_hash_details::write_bank_hash_details_file(&bank)
.map_err(|err| {
warn!("Unable to write bank hash details file: {err}");
})
.ok();
((*slot, bank.bank_id()), bank)
})
.unzip()
Expand Down
6 changes: 5 additions & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2695,7 +2695,11 @@ fn main() {
}
if write_bank_file {
let working_bank = bank_forks.read().unwrap().working_bank();
let _ = bank_hash_details::write_bank_hash_details_file(&working_bank);
bank_hash_details::write_bank_hash_details_file(&working_bank)
.map_err(|err| {
warn!("Unable to write bank hash_details file: {err}");
})
.ok();
}
exit_signal.store(true, Ordering::Relaxed);
system_monitor_service.join().unwrap();
Expand Down
10 changes: 3 additions & 7 deletions runtime/src/bank/bank_hash_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,10 @@ pub fn write_bank_hash_details_file(bank: &Bank) -> std::result::Result<(), Stri
// path does not exist. So, call std::fs_create_dir_all first.
// https://doc.rust-lang.org/std/fs/fn.write.html
_ = std::fs::create_dir_all(parent_dir);
let file = std::fs::File::create(&path).map_err(|err| {
format!(
"Unable to create bank hash file at {}: {err}",
path.display()
)
})?;
let file = std::fs::File::create(&path)
.map_err(|err| format!("Unable to create file at {}: {err}", path.display()))?;
serde_json::to_writer_pretty(file, &details)
.map_err(|err| format!("Unable to write bank hash file contents: {err}"))?;
.map_err(|err| format!("Unable to write file at {}: {err}", path.display()))?;
}
Ok(())
}
Expand Down