@@ -821,9 +821,9 @@ impl<'a> LoadedAccountAccessor<'a> {
821
821
LoadedAccountAccessor::Cached(cached_account) => cached_account
822
822
.as_ref()
823
823
.and_then(|cached_account| {
824
- owners
825
- .contains(&cached_account.account.owner())
826
- .then_some(())
824
+ (!cached_account.account.is_zero_lamport()
825
+ && owners .contains(&cached_account.account.owner() ))
826
+ .then_some(())
827
827
})
828
828
.ok_or(MatchAccountOwnerError::NoMatch),
829
829
LoadedAccountAccessor::Stored(maybe_storage_entry) => {
@@ -4957,8 +4957,7 @@ impl AccountsDb {
4957
4957
if !storage_location.is_cached() {
4958
4958
let result = self.read_only_accounts_cache.load(*account, slot);
4959
4959
if let Some(account) = result {
4960
- return owners
4961
- .contains(&account.owner())
4960
+ return (!account.is_zero_lamport() && owners.contains(&account.owner()))
4962
4961
.then_some(())
4963
4962
.ok_or(MatchAccountOwnerError::NoMatch);
4964
4963
}
@@ -14148,13 +14147,19 @@ pub mod tests {
14148
14147
let account3_key = Pubkey::new_unique();
14149
14148
let account3 = AccountSharedData::new(1, 1, &Pubkey::new_unique());
14150
14149
14150
+ // Account with 0 lamports
14151
+ let account4_key = Pubkey::new_unique();
14152
+ let account4 = AccountSharedData::new(0, 1, &owners[1]);
14153
+
14151
14154
db.store_cached((0, &[(&account1_key, &account1)][..]), None);
14152
14155
db.store_cached((1, &[(&account2_key, &account2)][..]), None);
14153
14156
db.store_cached((2, &[(&account3_key, &account3)][..]), None);
14157
+ db.store_cached((3, &[(&account4_key, &account4)][..]), None);
14154
14158
14155
14159
db.add_root(0);
14156
14160
db.add_root(1);
14157
14161
db.add_root(2);
14162
+ db.add_root(3);
14158
14163
14159
14164
// Flush the cache so that the account meta will be read from the storage
14160
14165
db.flush_accounts_cache(true, None);
@@ -14172,6 +14177,10 @@ pub mod tests {
14172
14177
db.account_matches_owners(&Ancestors::default(), &account3_key, &owners_refs),
14173
14178
Err(MatchAccountOwnerError::NoMatch)
14174
14179
);
14180
+ assert_eq!(
14181
+ db.account_matches_owners(&Ancestors::default(), &account4_key, &owners_refs),
14182
+ Err(MatchAccountOwnerError::NoMatch)
14183
+ );
14175
14184
assert_eq!(
14176
14185
db.account_matches_owners(&Ancestors::default(), &Pubkey::new_unique(), &owners_refs),
14177
14186
Err(MatchAccountOwnerError::UnableToLoad)
@@ -14202,6 +14211,10 @@ pub mod tests {
14202
14211
db.account_matches_owners(&Ancestors::default(), &account3_key, &owners_refs),
14203
14212
Err(MatchAccountOwnerError::NoMatch)
14204
14213
);
14214
+ assert_eq!(
14215
+ db.account_matches_owners(&Ancestors::default(), &account4_key, &owners_refs),
14216
+ Err(MatchAccountOwnerError::NoMatch)
14217
+ );
14205
14218
assert_eq!(
14206
14219
db.account_matches_owners(&Ancestors::default(), &Pubkey::new_unique(), &owners_refs),
14207
14220
Err(MatchAccountOwnerError::UnableToLoad)
0 commit comments