diff --git a/ledger/src/snapshot_utils.rs b/ledger/src/snapshot_utils.rs index d5221af67b..9bd099255f 100644 --- a/ledger/src/snapshot_utils.rs +++ b/ledger/src/snapshot_utils.rs @@ -5,7 +5,7 @@ use fs_extra::dir::CopyOptions; use log::*; use solana_measure::measure::Measure; use solana_runtime::{ - bank::{deserialize_from_snapshot, Bank, MAX_SNAPSHOT_DATA_FILE_SIZE}, + bank::{self, deserialize_from_snapshot, Bank, MAX_SNAPSHOT_DATA_FILE_SIZE}, status_cache::SlotDelta, }; use solana_sdk::transaction::Result as TransactionResult; @@ -391,7 +391,7 @@ pub fn untar_snapshot_in, Q: AsRef>( fn rebuild_bank_from_snapshots

( snapshot_version: &str, - local_account_paths: &[PathBuf], + account_paths: &[PathBuf], unpacked_snapshots_dir: &PathBuf, append_vecs_path: P, ) -> Result @@ -413,7 +413,7 @@ where &root_paths.snapshot_file_path, MAX_SNAPSHOT_DATA_FILE_SIZE, |stream| { - let bank: Bank = match snapshot_version { + let mut bank: Bank = match snapshot_version { env!("CARGO_PKG_VERSION") => deserialize_from_snapshot(stream.by_ref())?, "v0.22.3" => { let bank0223: solana_runtime::bank::LegacyBank0223 = @@ -428,11 +428,12 @@ where } }; // Rebuild accounts - bank.rc.accounts_from_stream( - stream.by_ref(), - local_account_paths, - &append_vecs_path, - )?; + bank.set_bank_rc( + bank::BankRc::new(account_paths.to_vec(), 0, bank.slot()), + bank::StatusCacheRc::default(), + ); + bank.rc + .accounts_from_stream(stream.by_ref(), account_paths, &append_vecs_path)?; Ok(bank) }, )?; diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index ada84c6c7d..bcbbf79d89 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -348,7 +348,12 @@ impl<'a> Serialize for AccountsDBSerialize<'a> { let bank_hashes = self.accounts_db.bank_hashes.read().unwrap(); serialize_into( &mut wr, - &(self.slot, &*bank_hashes.get(&self.slot).unwrap()), + &( + self.slot, + &*bank_hashes + .get(&self.slot) + .unwrap_or_else(|| panic!("No bank_hashes entry for slot {}", self.slot)), + ), ) .map_err(Error::custom)?; let len = wr.position() as usize; diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 8c3b6242f5..7725d69f57 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1669,9 +1669,9 @@ impl Bank { self.rc.accounts.clone() } - pub fn set_bank_rc(&mut self, bank_rc: &BankRc, status_cache_rc: &StatusCacheRc) { - self.rc.accounts = bank_rc.accounts.clone(); - self.src.status_cache = status_cache_rc.status_cache.clone() + pub fn set_bank_rc(&mut self, bank_rc: BankRc, status_cache_rc: StatusCacheRc) { + self.rc = bank_rc; + self.src = status_cache_rc; } pub fn set_parent(&mut self, parent: &Arc) { @@ -4610,7 +4610,7 @@ mod tests { let (_accounts_dir, dbank_paths) = get_temp_accounts_paths(4).unwrap(); let ref_sc = StatusCacheRc::default(); ref_sc.status_cache.write().unwrap().add_root(2); - dbank.set_bank_rc(&BankRc::new(dbank_paths.clone(), 0, dbank.slot()), &ref_sc); + dbank.set_bank_rc(BankRc::new(dbank_paths.clone(), 0, dbank.slot()), ref_sc); // Create a directory to simulate AppendVecs unpackaged from a snapshot tar let copied_accounts = TempDir::new().unwrap(); copy_append_vecs(&bank2.rc.accounts.accounts_db, copied_accounts.path()).unwrap();