Skip to content

Commit

Permalink
v1.18: Recompute hash on load if default hash is stored for the accou…
Browse files Browse the repository at this point in the history
…nt (backport of solana-labs#519) (solana-labs#546)

Recompute hash on load if default hash is stored for the account (solana-labs#519)

recompute hash on load if default hash is stored for the account

Co-authored-by: HaoranYi <[email protected]>
(cherry picked from commit 9ea627c)

Co-authored-by: HaoranYi <[email protected]>
  • Loading branch information
mergify[bot] and HaoranYi authored Apr 16, 2024
1 parent 6f45ff2 commit 2444794
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7837,7 +7837,10 @@ impl AccountsDb {
Some((*loaded_account.pubkey(), loaded_account.loaded_hash()))
},
|accum: &DashMap<Pubkey, AccountHash>, loaded_account: LoadedAccount| {
let loaded_hash = loaded_account.loaded_hash();
let mut loaded_hash = loaded_account.loaded_hash();
if loaded_hash == AccountHash(Hash::default()) {
loaded_hash = Self::hash_account(&loaded_account, loaded_account.pubkey())
}
accum.insert(*loaded_account.pubkey(), loaded_hash);
},
);
Expand Down Expand Up @@ -7869,9 +7872,13 @@ impl AccountsDb {
|accum: &DashMap<Pubkey, (AccountHash, AccountSharedData)>,
loaded_account: LoadedAccount| {
// Storage may have duplicates so only keep the latest version for each key
let mut loaded_hash = loaded_account.loaded_hash();
if loaded_hash == AccountHash(Hash::default()) {
loaded_hash = Self::hash_account(&loaded_account, loaded_account.pubkey())
}
accum.insert(
*loaded_account.pubkey(),
(loaded_account.loaded_hash(), loaded_account.take_account()),
(loaded_hash, loaded_account.take_account()),
);
},
);
Expand Down

0 comments on commit 2444794

Please sign in to comment.