From 4870a2cbac565840d8e63a6047ce1d095327f328 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 3 Oct 2019 19:44:23 -0700 Subject: [PATCH] Panic when a snapshot fails to verify --- core/src/snapshot_utils.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/snapshot_utils.rs b/core/src/snapshot_utils.rs index ec5858badf..c9803848c3 100644 --- a/core/src/snapshot_utils.rs +++ b/core/src/snapshot_utils.rs @@ -136,6 +136,11 @@ pub fn add_snapshot>(snapshot_path: P, bank: &Bank) -> Result<()> bank.slot(), snapshot_file_path, ); + if !bank.verify_hash_internal_state() { + // Sanity check that the new snapshot is valid. If not then there's a bad bug somewhere + panic!("Snapshot bank failed to verify"); + } + let snapshot_file = File::create(&snapshot_file_path)?; // snapshot writer let mut snapshot_stream = BufWriter::new(snapshot_file); @@ -194,9 +199,7 @@ pub fn bank_from_archive>( )?; if !bank.verify_hash_internal_state() { - warn!("Invalid snapshot hash value!"); - } else { - info!("Snapshot hash value matches."); + panic!("Snapshot bank failed to verify"); } // Move the unpacked snapshots into `snapshot_config.snapshot_path`