Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 44cc60e

Browse files
steviezmergify[bot]
authored andcommitted
Output BankHashDetails file when leader drops its' own block (#34256)
Currently, the file is generated when a node drops a block that was produced by another node. However, it would also be beneficial to see the account state when a node drops its' own block. Output the file in this additional failure codepath (cherry picked from commit 935e06f)
1 parent 08eb469 commit 44cc60e

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

core/src/replay_stage.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,14 +1340,22 @@ impl ReplayStage {
13401340
);
13411341
}
13421342

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

13531361
let attempt_no = purge_repair_slot_counter
@@ -1502,7 +1510,11 @@ impl ReplayStage {
15021510
let bank = w_bank_forks
15031511
.remove(*slot)
15041512
.expect("BankForks should not have been purged yet");
1505-
let _ = bank_hash_details::write_bank_hash_details_file(&bank);
1513+
bank_hash_details::write_bank_hash_details_file(&bank)
1514+
.map_err(|err| {
1515+
warn!("Unable to write bank hash details file: {err}");
1516+
})
1517+
.ok();
15061518
((*slot, bank.bank_id()), bank)
15071519
})
15081520
.unzip()

ledger-tool/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,11 @@ fn main() {
26282628
}
26292629
if write_bank_file {
26302630
let working_bank = bank_forks.read().unwrap().working_bank();
2631-
let _ = bank_hash_details::write_bank_hash_details_file(&working_bank);
2631+
bank_hash_details::write_bank_hash_details_file(&working_bank)
2632+
.map_err(|err| {
2633+
warn!("Unable to write bank hash_details file: {err}");
2634+
})
2635+
.ok();
26322636
}
26332637
exit_signal.store(true, Ordering::Relaxed);
26342638
system_monitor_service.join().unwrap();

runtime/src/bank/bank_hash_details.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,10 @@ pub fn write_bank_hash_details_file(bank: &Bank) -> std::result::Result<(), Stri
213213
// path does not exist. So, call std::fs_create_dir_all first.
214214
// https://doc.rust-lang.org/std/fs/fn.write.html
215215
_ = std::fs::create_dir_all(parent_dir);
216-
let file = std::fs::File::create(&path).map_err(|err| {
217-
format!(
218-
"Unable to create bank hash file at {}: {err}",
219-
path.display()
220-
)
221-
})?;
216+
let file = std::fs::File::create(&path)
217+
.map_err(|err| format!("Unable to create file at {}: {err}", path.display()))?;
222218
serde_json::to_writer_pretty(file, &details)
223-
.map_err(|err| format!("Unable to write bank hash file contents: {err}"))?;
219+
.map_err(|err| format!("Unable to write file at {}: {err}", path.display()))?;
224220
}
225221
Ok(())
226222
}

0 commit comments

Comments
 (0)