Serialize a bank to a snapshot
Make a snapshot archive out of the snapshot package
Utility for parsing out bank specific information from a snapshot archive. This utility can be used
to parse out bank specific information like the leader schedule, epoch schedule, etc.
Rebuild bank from snapshot archives. This function searches full_snapshot_archives_dir
and incremental_snapshot_archives_dir
for the
highest full snapshot and highest corresponding incremental snapshot, then rebuilds the bank.
follow the prototype of fn bank_from_latest_snapshot_archives, implement the from_dir case
Rebuild bank from snapshot archives. Handles either just a full snapshot, or both a full
snapshot and an incremental snapshot.
Build bank from a snapshot (a snapshot directory, not a snapshot archive)
Convenience function to create a full snapshot archive out of any Bank, regardless of state.
The Bank will be frozen during the process.
This is only called from ledger-tool or tests. Warping is a special case as well.
Convenience function to create an incremental snapshot archive out of any Bank, regardless of
state. The Bank will be frozen during the process.
This is only called from ledger-tool or tests. Warping is a special case as well.
Build the full snapshot archive path from its components: the snapshot archives directory, the
snapshot slot, the accounts hash, and the archive format.
Build the incremental snapshot archive path from its components: the snapshot archives
directory, the snapshot base slot, the snapshot slot, the accounts hash, and the archive
format.
Perform the common tasks when deserialize a snapshot. Handles reading snapshot file, reading the version file,
and then returning those fields plus the rebuilt storage
Check if an incremental snapshot is compatible with a full snapshot. This is done by checking
if the incremental snapshot’s base slot is the same as the full snapshot’s slot.
After running the deserializer function, perform common checks to ensure the snapshot archive
files were consumed correctly.
The account snapshot directories under <account_path>/snapshot/ contain account files hardlinked
from <account_path>/run taken at snapshot time. They are referenced by the symlinks from the
bank snapshot dir snapshot//accounts_hardlinks/. We observed that sometimes the bank snapshot dir
could be deleted but the account snapshot directories were left behind, possibly by some manual operations
or some legacy code not using the symlinks to clean up the acccount snapshot hardlink directories.
This function cleans up any account snapshot directories that are no longer referenced by the bank
snapshot dirs, to ensure proper snapshot operations.
To allow generating a bank snapshot directory with full state information, we need to
hardlink account appendvec files from the runtime operation directory to a snapshot
hardlink directory. This is to create the run/ and snapshot sub directories for an
account_path provided by the user. These two sub directories are on the same file
system partition to allow hard-linking.
For all account_paths, create the run/ and snapshot/ sub directories.
If an account_path directory does not exist, create it.
It returns (account_run_paths, account_snapshot_paths) or error
Before running the deserializer function, perform common operations on the snapshot archive
files, such as checking the file size and opening the file into a stream.
BankSnapshotInfo::new_from_dir() requires a few meta files to accept a snapshot dir
as a valid one. A dir unpacked from an archive lacks these files. Fill them here to
allow new_from_dir() checks to pass. These checks are not needed for unpacked dirs,
but it is not clean to add another flag to new_from_dir() to skip them.
Delete the files and subdirectories in a directory.
This is useful if the process does not have permission
to delete the top level directory it might be able to
delete the contents of that directory.
Return account path from the appendvec path after checking its format.
Get the bank snapshots in a directory
Get the bank snapshots in a directory
Get the bank snapshots in a directory
Get a list of the full snapshot archives from a directory
Get the bank snapshot with the highest slot in a directory
Get the bank snapshot with the highest slot in a directory
Get the bank snapshot with the highest slot in a directory
Get the path (and metadata) for the full snapshot archive with the highest slot in a directory
Get the highest slot of the full snapshot archives in a directory
Get the path for the incremental snapshot archive with the highest slot, for a given full
snapshot slot, in a directory
Get the highest slot of the incremental snapshot archives in a directory, for a given full
snapshot slot
Get a list of the incremental snapshot archives from a directory
From an appendvec path, derive the snapshot hardlink path. If the corresponding snapshot hardlink
directory does not exist, create it.
Walk down the snapshot archive to collect snapshot archive file info
Get the snapshot storages for this bank
serializing needs Vec<Vec<Arc
>>, but data structure at runtime is Vec<Arc>
translates to what we needHard-link the files from accounts/ to snapshot/<bank_slot>/accounts/
This keeps the appendvec files alive and with the bank snapshot. The slot and id
in the file names are also updated in case its file is a recycled one with inconsistent slot
and id.
Delete directories/files asynchronously to avoid blocking on it.
Fist, in sync context, rename the original path to *_deleted,
then spawn a thread to delete the renamed path.
If the process is killed and the deleting process is not done,
the leftover path will be deleted in the next process life, so
there is no file space leaking.
Helper function to hold shared code to package, process, and archive full snapshots
Helper function to hold shared code to package, process, and archive incremental snapshots
Parse a full snapshot archive filename into its Slot, Hash, and Archive Format
Parse an incremental snapshot archive filename into its base Slot, actual Slot, Hash, and Archive Format
Get the &str
from a &Path
Remove outdated bank snapshots
Remove the snapshot directory for this slot
If the validator halts in the middle of archive_snapshot_package()
, the temporary staging
directory won’t be cleaned up. Call this function to clean them up.
Reads the snapshot_version
from a file. Before opening the file, its size
is compared to MAX_SNAPSHOT_VERSION_FILE_SIZE
. If the size exceeds this
threshold, it is not opened and an error is returned.
Spawns a thread for unpacking a snapshot
Streams snapshot dir files across channel
Follow the flow of streaming_unarchive_snapshot(), but handle the from_dir case.
Streams unpacked files across channel
Perform the common tasks when unarchiving a snapshot. Handles creating the temporary
directories, untaring, reading the version file, and then returning those fields plus the
rebuilt storage
Check to make sure the deserialized bank’s slot and hash matches the snapshot archive’s slot
and hash
Verify that the snapshot’s slot deltas are not corrupt/invalid
Verify that the snapshot’s slot deltas are not corrupt/invalid
These checks are simple/structural
Verify that the snapshot’s slot deltas are not corrupt/invalid
These checks use the slot history for verification
Write the snapshot version as a file into the bank snapshot directory