Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions runtime/src/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use {
solana_measure::measure::Measure,
solana_sdk::{
clock::{Epoch, Slot, UnixTimestamp},
deserialize_utils::default_on_eof,
epoch_schedule::EpochSchedule,
fee_calculator::{FeeCalculator, FeeRateGovernor},
genesis_config::GenesisConfig,
Expand Down Expand Up @@ -67,6 +68,12 @@ struct AccountsDbFields<T>(
StoredMetaWriteVersion,
Slot,
BankHashInfo,
/// all slots that were roots within the last epoch
#[serde(deserialize_with = "default_on_eof")]
Vec<Slot>,
/// slots that were roots within the last epoch for which we care about the hash value
#[serde(deserialize_with = "default_on_eof")]
Vec<(Slot, Hash)>,
);

/// Helper type to wrap BufReader streams when deserializing and reconstructing from either just a
Expand All @@ -86,9 +93,9 @@ struct SnapshotAccountsDbFields<T> {

impl<T> SnapshotAccountsDbFields<T> {
/// Collapse the SnapshotAccountsDbFields into a single AccountsDbFields. If there is no
/// incremental snapshot, this returns the AccountsDbFields from the full snapshot. Otherwise
/// this uses the version, slot, and bank hash info from the incremental snapshot, then the
/// combination of the storages from both the full and incremental snapshots.
/// incremental snapshot, this returns the AccountsDbFields from the full snapshot.
/// Otherwise, use the AccountsDbFields from the incremental snapshot, and a combination
/// of the storages from both the full and incremental snapshots.
fn collapse_into(self) -> Result<AccountsDbFields<T>, Error> {
match self.incremental_snapshot_accounts_db_fields {
None => Ok(self.full_snapshot_accounts_db_fields),
Expand All @@ -97,6 +104,8 @@ impl<T> SnapshotAccountsDbFields<T> {
incremental_snapshot_version,
incremental_snapshot_slot,
incremental_snapshot_bank_hash_info,
incremental_snapshot_prior_roots,
incremental_snapshot_prior_roots_with_hash,
)) => {
let full_snapshot_storages = self.full_snapshot_accounts_db_fields.0;
let full_snapshot_slot = self.full_snapshot_accounts_db_fields.2;
Expand All @@ -119,6 +128,8 @@ impl<T> SnapshotAccountsDbFields<T> {
incremental_snapshot_version,
incremental_snapshot_slot,
incremental_snapshot_bank_hash_info,
incremental_snapshot_prior_roots,
incremental_snapshot_prior_roots_with_hash,
))
}
}
Expand Down Expand Up @@ -419,6 +430,8 @@ where
snapshot_version,
snapshot_slot,
snapshot_bank_hash_info,
_snapshot_prior_roots,
_snapshot_prior_roots_with_hash,
) = snapshot_accounts_db_fields.collapse_into()?;

let snapshot_storages = snapshot_storages.into_iter().collect::<Vec<_>>();
Expand Down
1 change: 1 addition & 0 deletions sdk/src/deserialize_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ where
let result = T::deserialize(d);
match result {
Err(err) if err.to_string() == "io error: unexpected end of file" => Ok(T::default()),
Err(err) if err.to_string() == "io error: failed to fill whole buffer" => Ok(T::default()),
result => result,
}
}
Expand Down