adjust cached stake account compare for rent_epoch (#26135)

This commit is contained in:
Jeff Washington (jwash) 2022-06-22 15:11:25 -05:00 committed by GitHub
parent 1ea6a2cb91
commit c5c2b44ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -2794,7 +2794,27 @@ impl Bank {
}
};
if cached_stake_account != &stake_account {
invalid_cached_stake_accounts.fetch_add(1, Relaxed);
let mut cached_account = cached_stake_account.account().clone();
// We could have collected rent on the loaded account already in this new epoch (we could be at partition_index 12, for example).
// So, we may need to adjust the rent_epoch of the cached account. So, update rent_epoch and compare just the accounts.
ExpectedRentCollection::maybe_update_rent_epoch_on_load(
&mut cached_account,
&SlotInfoInEpoch::new_small(self.slot()),
&SlotInfoInEpoch::new_small(self.slot()),
self.epoch_schedule(),
self.rent_collector(),
stake_pubkey,
&self.rewrites_skipped_this_slot,
);
if &cached_account != stake_account.account() {
info!(
"cached stake account mismatch: {}: {:?}, {:?}",
stake_pubkey,
cached_account,
stake_account.account()
);
invalid_cached_stake_accounts.fetch_add(1, Relaxed);
}
}
let stake_delegation = (*stake_pubkey, stake_account);
let mut vote_delegations = if let Some(vote_delegations) =

View File

@ -103,6 +103,12 @@ impl<T> From<StakeAccount<T>> for (AccountSharedData, StakeState) {
}
}
impl<T> StakeAccount<T> {
pub fn account(&self) -> &AccountSharedData {
&self.account
}
}
impl<S, T> PartialEq<StakeAccount<S>> for StakeAccount<T> {
fn eq(&self, other: &StakeAccount<S>) -> bool {
let StakeAccount {