From 1489cbf5a00661a25a2a79a574437962597b0049 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 8 Apr 2022 09:55:00 -0500 Subject: [PATCH] Note this is a modified backport that does not SAVE the new fields, but does load them. (#24074) (#24078) Original: Start saving/loading prior_roots(_with_hash) to snapshot (#23844) * Start saving/loading prior_roots(_with_hash) to snapshot * Update runtime/src/accounts_index.rs Co-authored-by: Michael Vines * Update runtime/src/accounts_index.rs Co-authored-by: Michael Vines * update comment Co-authored-by: Michael Vines (cherry picked from commit 396b49a7c10edec5d82b8c15648b4fa42370653c) Co-authored-by: Jeff Washington (jwash) (cherry picked from commit b157a9111f736084131bcd49fd0bfd06d4701869) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- runtime/src/serde_snapshot.rs | 19 ++++++++++++++++--- sdk/src/deserialize_utils.rs | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index 51c5f07d8f..ba9be87a11 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -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, @@ -67,6 +68,12 @@ struct AccountsDbFields( StoredMetaWriteVersion, Slot, BankHashInfo, + /// all slots that were roots within the last epoch + #[serde(deserialize_with = "default_on_eof")] + Vec, + /// 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 @@ -86,9 +93,9 @@ struct SnapshotAccountsDbFields { impl SnapshotAccountsDbFields { /// 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, Error> { match self.incremental_snapshot_accounts_db_fields { None => Ok(self.full_snapshot_accounts_db_fields), @@ -97,6 +104,8 @@ impl SnapshotAccountsDbFields { 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; @@ -119,6 +128,8 @@ impl SnapshotAccountsDbFields { incremental_snapshot_version, incremental_snapshot_slot, incremental_snapshot_bank_hash_info, + incremental_snapshot_prior_roots, + incremental_snapshot_prior_roots_with_hash, )) } } @@ -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::>(); diff --git a/sdk/src/deserialize_utils.rs b/sdk/src/deserialize_utils.rs index 9eb37d2e05..4413fac293 100644 --- a/sdk/src/deserialize_utils.rs +++ b/sdk/src/deserialize_utils.rs @@ -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, } }