Add snapshot_utils::bank_from_latest_snapshot_archives() (#18983)

While reviewing PR #18565, as issue was brought up to refactor some code
around verifying the bank after rebuilding from snapshots.  A new
top-level function has been added to get the latest snapshot archives
and load the bank then verify.  Additionally, new tests have been
written and existing tests have been updated to use this new function.

Fixes #18973

While resolving the issue, it became clear there was some additional
low-hanging fruit this change enabled.  Specifically, the functions
`bank_to_xxx_snapshot_archive()` now return their respective
`SnapshotArchiveInfo`.  And on the flip side,
`bank_from_snapshot_archives()` now takes `SnapshotArchiveInfo`s instead
of separate paths and archive formats.  This bundling simplifies bank
rebuilding.
This commit is contained in:
Brooks Prumo
2021-08-06 20:16:06 -05:00
committed by GitHub
parent 7923c26939
commit 00890957ee
14 changed files with 468 additions and 294 deletions

View File

@ -42,7 +42,7 @@ use {
},
solana_runtime::{
snapshot_config::SnapshotConfig,
snapshot_utils::{self, ArchiveFormat},
snapshot_utils::{self, ArchiveFormat, SnapshotArchiveInfoGetter},
},
solana_sdk::{
account::AccountSharedData,
@ -1855,12 +1855,12 @@ fn test_snapshots_blockstore_floor() {
.snapshot_archives_dir
.path()
.to_path_buf(),
*archive_info.slot(),
archive_info.slot(),
archive_info.hash(),
ArchiveFormat::TarBzip2,
);
fs::hard_link(archive_info.path(), &validator_archive_path).unwrap();
let slot_floor = *archive_info.slot();
let slot_floor = archive_info.slot();
// Start up a new node from a snapshot
let validator_stake = 5;
@ -3411,11 +3411,11 @@ fn wait_for_next_snapshot(
"full snapshot for slot {} exists",
full_snapshot_archive_info.slot()
);
if *full_snapshot_archive_info.slot() >= last_slot {
if full_snapshot_archive_info.slot() >= last_slot {
return (
full_snapshot_archive_info.path().clone(),
(
*full_snapshot_archive_info.slot(),
full_snapshot_archive_info.slot(),
*full_snapshot_archive_info.hash(),
),
);