Move BankIncrementalSnapshotPersistence (#31236)

* Move BankIncrementalSnapshotPersistence

* Update bank serialize ABI digest
This commit is contained in:
Brennan 2023-04-18 11:18:17 -07:00 committed by GitHub
parent f5fe2607b6
commit 2164a50d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 25 deletions

View File

@ -14,7 +14,7 @@ use {
AccountsHash, AccountsHashEnum, CalcAccountsHashConfig, HashStats, AccountsHash, AccountsHashEnum, CalcAccountsHashConfig, HashStats,
IncrementalAccountsHash, IncrementalAccountsHash,
}, },
bank::BankIncrementalSnapshotPersistence, serde_snapshot::BankIncrementalSnapshotPersistence,
snapshot_config::SnapshotConfig, snapshot_config::SnapshotConfig,
snapshot_package::{ snapshot_package::{
self, retain_max_n_elements, AccountsPackage, AccountsPackageType, SnapshotPackage, self, retain_max_n_elements, AccountsPackage, AccountsPackageType, SnapshotPackage,

View File

@ -64,7 +64,7 @@ use {
rent_collector::{CollectedInfo, RentCollector}, rent_collector::{CollectedInfo, RentCollector},
rent_debits::RentDebits, rent_debits::RentDebits,
runtime_config::RuntimeConfig, runtime_config::RuntimeConfig,
serde_snapshot::{SerdeAccountsHash, SerdeIncrementalAccountsHash}, serde_snapshot::BankIncrementalSnapshotPersistence,
snapshot_hash::SnapshotHash, snapshot_hash::SnapshotHash,
sorted_storages::SortedStorages, sorted_storages::SortedStorages,
stake_account::{self, StakeAccount}, stake_account::{self, StakeAccount},
@ -217,25 +217,6 @@ struct RentMetrics {
count: AtomicUsize, count: AtomicUsize,
} }
/// Incremental snapshots only calculate their accounts hash based on the account changes WITHIN the incremental slot range.
/// So, we need to keep track of the full snapshot expected accounts hash results.
/// We also need to keep track of the hash and capitalization specific to the incremental snapshot slot range.
/// The capitalization we calculate for the incremental slot will NOT be consistent with the bank's capitalization.
/// It is not feasible to calculate a capitalization delta that is correct given just incremental slots account data and the full snapshot's capitalization.
#[derive(Serialize, Deserialize, AbiExample, Clone, Debug, Default, PartialEq, Eq)]
pub struct BankIncrementalSnapshotPersistence {
/// slot of full snapshot
pub full_slot: Slot,
/// accounts hash from the full snapshot
pub full_hash: SerdeAccountsHash,
/// capitalization from the full snapshot
pub full_capitalization: u64,
/// hash of the accounts in the incremental snapshot slot range, including zero-lamport accounts
pub incremental_hash: SerdeIncrementalAccountsHash,
/// capitalization of the accounts in the incremental snapshot slot range
pub incremental_capitalization: u64,
}
pub type BankStatusCache = StatusCache<Result<()>>; pub type BankStatusCache = StatusCache<Result<()>>;
#[frozen_abi(digest = "GBTLfFjModD9ykS9LV4pGi4S8eCrUj2JjWSDQLf8tMwV")] #[frozen_abi(digest = "GBTLfFjModD9ykS9LV4pGi4S8eCrUj2JjWSDQLf8tMwV")]
pub type BankSlotDelta = SlotDelta<Result<()>>; pub type BankSlotDelta = SlotDelta<Result<()>>;

View File

@ -10,7 +10,7 @@ use {
accounts_hash::AccountsHash, accounts_hash::AccountsHash,
accounts_index::AccountSecondaryIndexes, accounts_index::AccountSecondaryIndexes,
accounts_update_notifier_interface::AccountsUpdateNotifier, accounts_update_notifier_interface::AccountsUpdateNotifier,
bank::{Bank, BankFieldsToDeserialize, BankIncrementalSnapshotPersistence, BankRc}, bank::{Bank, BankFieldsToDeserialize, BankRc},
blockhash_queue::BlockhashQueue, blockhash_queue::BlockhashQueue,
builtins::Builtins, builtins::Builtins,
epoch_accounts_hash::EpochAccountsHash, epoch_accounts_hash::EpochAccountsHash,
@ -85,6 +85,28 @@ pub struct AccountsDbFields<T>(
Vec<(Slot, Hash)>, Vec<(Slot, Hash)>,
); );
/// Incremental snapshots only calculate their accounts hash based on the
/// account changes WITHIN the incremental slot range. So, we need to keep track
/// of the full snapshot expected accounts hash results. We also need to keep
/// track of the hash and capitalization specific to the incremental snapshot
/// slot range. The capitalization we calculate for the incremental slot will
/// NOT be consistent with the bank's capitalization. It is not feasible to
/// calculate a capitalization delta that is correct given just incremental
/// slots account data and the full snapshot's capitalization.
#[derive(Serialize, Deserialize, AbiExample, Clone, Debug, Default, PartialEq, Eq)]
pub struct BankIncrementalSnapshotPersistence {
/// slot of full snapshot
pub full_slot: Slot,
/// accounts hash from the full snapshot
pub full_hash: SerdeAccountsHash,
/// capitalization from the full snapshot
pub full_capitalization: u64,
/// hash of the accounts in the incremental snapshot slot range, including zero-lamport accounts
pub incremental_hash: SerdeIncrementalAccountsHash,
/// capitalization of the accounts in the incremental snapshot slot range
pub incremental_capitalization: u64,
}
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)] #[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)]
struct BankHashInfo { struct BankHashInfo {
accounts_delta_hash: SerdeAccountsDeltaHash, accounts_delta_hash: SerdeAccountsDeltaHash,

View File

@ -721,7 +721,7 @@ mod test_bank_serialize {
// This some what long test harness is required to freeze the ABI of // This some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature // Bank's serialization due to versioned nature
#[frozen_abi(digest = "6JEjZCVdbC7CgpEexb9BKEtyMBL6aTHNZrjEWmhzmgp3")] #[frozen_abi(digest = "GbEcrk8sgqbQ5kJ8mAaHTh2REmHyESQ6GXnGWxkGbxDe")]
#[derive(Serialize, AbiExample)] #[derive(Serialize, AbiExample)]
pub struct BankAbiTestWrapperNewer { pub struct BankAbiTestWrapperNewer {
#[serde(serialize_with = "wrapper_newer")] #[serde(serialize_with = "wrapper_newer")]

View File

@ -9,7 +9,7 @@ use {
accounts_index::AccountSecondaryIndexes, accounts_index::AccountSecondaryIndexes,
accounts_update_notifier_interface::AccountsUpdateNotifier, accounts_update_notifier_interface::AccountsUpdateNotifier,
append_vec::AppendVec, append_vec::AppendVec,
bank::{Bank, BankFieldsToDeserialize, BankIncrementalSnapshotPersistence, BankSlotDelta}, bank::{Bank, BankFieldsToDeserialize, BankSlotDelta},
builtins::Builtins, builtins::Builtins,
hardened_unpack::{ hardened_unpack::{
streaming_unpack_snapshot, unpack_snapshot, ParallelSelector, UnpackError, streaming_unpack_snapshot, unpack_snapshot, ParallelSelector, UnpackError,
@ -17,7 +17,8 @@ use {
}, },
runtime_config::RuntimeConfig, runtime_config::RuntimeConfig,
serde_snapshot::{ serde_snapshot::{
bank_from_streams, bank_to_stream, fields_from_streams, SerdeStyle, SnapshotStreams, bank_from_streams, bank_to_stream, fields_from_streams,
BankIncrementalSnapshotPersistence, SerdeStyle, SnapshotStreams,
}, },
shared_buffer_reader::{SharedBuffer, SharedBufferReader}, shared_buffer_reader::{SharedBuffer, SharedBufferReader},
snapshot_archive_info::{ snapshot_archive_info::{