Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses AccountHash in StorableAccountsWithHashesAndWriteVersions #33751

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Oct 18, 2023

Problem

Now that we added AccountHash in #33597, we can use it in places where we were previously using a bare Hash. One of those places is in StorableAccountsWithHashesAndWriteVersions.

Summary of Changes

Use AccountHash instead of bare Hash in StorableAccountsWithHashesAndWriteVersions.

@brooksprumo brooksprumo added the noCI Suppress CI on this Pull Request label Oct 18, 2023
@brooksprumo brooksprumo self-assigned this Oct 18, 2023
@brooksprumo brooksprumo force-pushed the account-hash/StorableAccountsWithHashesAndWriteVersions branch from 9e5d2a2 to e2f6683 Compare October 18, 2023 13:32
@@ -30,7 +31,7 @@ pub struct StorableAccountsWithHashesAndWriteVersions<
'b,
T: ReadableAccount + Sync + 'b,
U: StorableAccounts<'a, T>,
V: Borrow<Hash>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change.

Comment on lines +128 to +133
pub fn hash(&self) -> &'storage AccountHash {
let hash = match self {
Self::AppendVec(av) => av.hash(),
Self::Hot(hot) => hot.hash().unwrap_or(&DEFAULT_ACCOUNT_HASH),
}
Self::Hot(hot) => hot.hash().unwrap_or(&DEFAULT_ACCOUNT_HASH.0),
};
bytemuck::cast_ref(hash)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subsequent PRs will handle returning AccountHash from the underlying AppendVec and TieredStorage. For now, it's safe to cast them.

@@ -6612,7 +6612,7 @@ impl AccountsDb {
let pubkeys = self.get_filler_account_pubkeys(filler_accounts as usize);
pubkeys.iter().for_each(|key| {
accounts.push((key, &account));
hashes.push(hash);
hashes.push(AccountHash(hash));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be fixed up (i.e. go away) once a subsequent PR changes get_filler_account_pubkeys() to return an AccountHash instead of a bare Hash.

@brooksprumo brooksprumo force-pushed the account-hash/StorableAccountsWithHashesAndWriteVersions branch 2 times, most recently from c5370a5 to 6f0056d Compare October 18, 2023 19:52
@brooksprumo brooksprumo added CI Pull Request is ready to enter CI and removed noCI Suppress CI on this Pull Request labels Oct 18, 2023
@solana-grimes solana-grimes removed the CI Pull Request is ready to enter CI label Oct 18, 2023
@brooksprumo brooksprumo marked this pull request as ready for review October 18, 2023 20:07
@brooksprumo brooksprumo force-pushed the account-hash/StorableAccountsWithHashesAndWriteVersions branch from 6f0056d to 2a62ecd Compare October 18, 2023 21:00
@brooksprumo
Copy link
Contributor Author

Rebased and force-pushed to address a merge conflict. No new changes were made.

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #33751 (2a62ecd) into master (93d882f) will increase coverage by 0.0%.
The diff coverage is 92.1%.

@@           Coverage Diff           @@
##           master   #33751   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         806      806           
  Lines      217908   217911    +3     
=======================================
+ Hits       178270   178297   +27     
+ Misses      39638    39614   -24     

Copy link
Contributor

@yhchiang-sol yhchiang-sol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG!

@brooksprumo brooksprumo merged commit 1045548 into solana-labs:master Oct 18, 2023
31 checks passed
@brooksprumo brooksprumo deleted the account-hash/StorableAccountsWithHashesAndWriteVersions branch October 18, 2023 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants