dcou: set_accounts_hash() (#32829)
This commit is contained in:
parent
6bbf514e78
commit
e316db2ab4
|
@ -7476,7 +7476,8 @@ impl AccountsDb {
|
||||||
/// Set the accounts hash for `slot`
|
/// Set the accounts hash for `slot`
|
||||||
///
|
///
|
||||||
/// returns the previous accounts hash for `slot`
|
/// returns the previous accounts hash for `slot`
|
||||||
pub fn set_accounts_hash(
|
#[cfg_attr(feature = "dev-context-only-utils", fn_qualifiers(pub))]
|
||||||
|
fn set_accounts_hash(
|
||||||
&self,
|
&self,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
accounts_hash: (AccountsHash, /*capitalization*/ u64),
|
accounts_hash: (AccountsHash, /*capitalization*/ u64),
|
||||||
|
@ -9664,10 +9665,6 @@ impl AccountsDb {
|
||||||
&self.accounts_hashes
|
&self.accounts_hashes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_accounts_hash_for_tests(&self, slot: Slot, accounts_hash: AccountsHash) {
|
|
||||||
self.set_accounts_hash(slot, (accounts_hash, u64::default()));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn assert_load_account(&self, slot: Slot, pubkey: Pubkey, expected_lamports: u64) {
|
pub fn assert_load_account(&self, slot: Slot, pubkey: Pubkey, expected_lamports: u64) {
|
||||||
let ancestors = vec![(slot, 0)].into_iter().collect();
|
let ancestors = vec![(slot, 0)].into_iter().collect();
|
||||||
let (account, slot) = self.load_without_fixed_root(&ancestors, &pubkey).unwrap();
|
let (account, slot) = self.load_without_fixed_root(&ancestors, &pubkey).unwrap();
|
||||||
|
|
|
@ -131,10 +131,10 @@ mod tests {
|
||||||
bank2.freeze();
|
bank2.freeze();
|
||||||
bank2.squash();
|
bank2.squash();
|
||||||
bank2.force_flush_accounts_cache();
|
bank2.force_flush_accounts_cache();
|
||||||
bank2
|
bank2.accounts().accounts_db.set_accounts_hash(
|
||||||
.accounts()
|
bank2.slot(),
|
||||||
.accounts_db
|
(AccountsHash(Hash::new(&[0; 32])), u64::default()),
|
||||||
.set_accounts_hash_for_tests(bank2.slot(), AccountsHash(Hash::new(&[0; 32])));
|
);
|
||||||
|
|
||||||
let snapshot_storages = bank2.get_snapshot_storages(None);
|
let snapshot_storages = bank2.get_snapshot_storages(None);
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
|
@ -164,10 +164,10 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if update_accounts_hash {
|
if update_accounts_hash {
|
||||||
bank2
|
bank2.accounts().accounts_db.set_accounts_hash(
|
||||||
.accounts()
|
bank2.slot(),
|
||||||
.accounts_db
|
(AccountsHash(Hash::new(&[1; 32])), u64::default()),
|
||||||
.set_accounts_hash_for_tests(bank2.slot(), AccountsHash(Hash::new(&[1; 32])));
|
);
|
||||||
}
|
}
|
||||||
let accounts_hash = bank2.get_accounts_hash().unwrap();
|
let accounts_hash = bank2.get_accounts_hash().unwrap();
|
||||||
|
|
||||||
|
@ -353,10 +353,10 @@ mod tests {
|
||||||
.accounts
|
.accounts
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique()));
|
.set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique()));
|
||||||
bank.rc
|
bank.rc.accounts.accounts_db.set_accounts_hash(
|
||||||
.accounts
|
bank.slot(),
|
||||||
.accounts_db
|
(AccountsHash(Hash::new_unique()), u64::default()),
|
||||||
.set_accounts_hash_for_tests(bank.slot(), AccountsHash(Hash::new_unique()));
|
);
|
||||||
|
|
||||||
// Set extra fields
|
// Set extra fields
|
||||||
bank.fee_rate_governor.lamports_per_signature = 7000;
|
bank.fee_rate_governor.lamports_per_signature = 7000;
|
||||||
|
@ -544,10 +544,10 @@ mod tests {
|
||||||
.accounts
|
.accounts
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique()));
|
.set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique()));
|
||||||
bank.rc
|
bank.rc.accounts.accounts_db.set_accounts_hash(
|
||||||
.accounts
|
bank.slot(),
|
||||||
.accounts_db
|
(AccountsHash(Hash::new_unique()), u64::default()),
|
||||||
.set_accounts_hash_for_tests(bank.slot(), AccountsHash(Hash::new_unique()));
|
);
|
||||||
|
|
||||||
// Set extra fields
|
// Set extra fields
|
||||||
bank.fee_rate_governor.lamports_per_signature = 7000;
|
bank.fee_rate_governor.lamports_per_signature = 7000;
|
||||||
|
@ -626,10 +626,10 @@ mod tests {
|
||||||
.accounts
|
.accounts
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique()));
|
.set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique()));
|
||||||
bank.rc
|
bank.rc.accounts.accounts_db.set_accounts_hash(
|
||||||
.accounts
|
bank.slot(),
|
||||||
.accounts_db
|
(AccountsHash(Hash::new_unique()), u64::default()),
|
||||||
.set_accounts_hash_for_tests(bank.slot(), AccountsHash(Hash::new_unique()));
|
);
|
||||||
let snapshot_storages = bank.rc.accounts.accounts_db.get_snapshot_storages(..=0).0;
|
let snapshot_storages = bank.rc.accounts.accounts_db.get_snapshot_storages(..=0).0;
|
||||||
// ensure there is a single snapshot storage example for ABI digesting
|
// ensure there is a single snapshot storage example for ABI digesting
|
||||||
assert_eq!(snapshot_storages.len(), 1);
|
assert_eq!(snapshot_storages.len(), 1);
|
||||||
|
|
|
@ -239,7 +239,7 @@ mod serde_snapshot_tests {
|
||||||
let accounts_hash = AccountsHash(Hash::new_unique());
|
let accounts_hash = AccountsHash(Hash::new_unique());
|
||||||
accounts
|
accounts
|
||||||
.accounts_db
|
.accounts_db
|
||||||
.set_accounts_hash_for_tests(slot, accounts_hash);
|
.set_accounts_hash(slot, (accounts_hash, u64::default()));
|
||||||
|
|
||||||
let mut writer = Cursor::new(vec![]);
|
let mut writer = Cursor::new(vec![]);
|
||||||
accountsdb_to_stream(
|
accountsdb_to_stream(
|
||||||
|
|
Loading…
Reference in New Issue