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

Remove old way of account hashing #16442

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

brooksprumo
Copy link
Contributor

@brooksprumo brooksprumo commented Apr 8, 2021

Account data hashing used to use different ways of hashing on different
clusters. That is no longer the case, but the old code still existed.
This commit removes that old, now used code.

NOTE The golden hash values in bank.rs needed to be updated. Since the original code that selected the hash algorithm used if > instead of if >=, this meant that the genesis block's hash always used the old hashing method, which is no longer valid.

The new golden hash values in accounts_db.rs were also validated by
changing if slot > to if slot >= on master and running cargo test,
then confirming the actual values matched the golden values in this commit.

Validated by running cargo test from within runtime.

(This work was originally based on PR #16375 from @jeffwashington)

runtime/src/accounts_db.rs Show resolved Hide resolved
@@ -2955,53 +2910,14 @@ impl AccountsDb {
hasher.result()
}

pub fn hash_account_data(
fn hash_account_data(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's hard to tell from the Github diff; I've basically just renamed the blake3_hash_account_data() function to hash_account_data. (And also removed pub, because it doesn't look like anything else was/is calling this function.)

runtime/src/accounts_db.rs Outdated Show resolved Hide resolved
);
}
if bank.slot == 128 {
assert_eq!(
bank.hash().to_string(),
"FQnVhDVjhCyfBxFb3bdm3CLiuCePvWuW5TGDsLBZnKAo"
"AtWu4tubU9zGFChfHtQghQx3RVWtMQu6Rj49rQymFc4z"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same thing about these hashes too.

@codecov
Copy link

codecov bot commented Apr 8, 2021

Codecov Report

Merging #16442 (7dd2de2) into master (f641429) will decrease coverage by 0.0%.
The diff coverage is 90.6%.

@@            Coverage Diff            @@
##           master   #16442     +/-   ##
=========================================
- Coverage    80.0%    80.0%   -0.1%     
=========================================
  Files         413      413             
  Lines      112207   112135     -72     
=========================================
- Hits        89850    89763     -87     
- Misses      22357    22372     +15     

@ryoqun
Copy link
Member

ryoqun commented Apr 9, 2021

@brooksprumo I've run my-not-merged-yet-too-old hidden facility of running your branch against mainnet-beta and testnet: https://buildkite.com/solana-labs/solana/builds/43855#f4be3751-c5eb-4c49-9f7e-360f03c0d23d :)

#12175

ryoqun
ryoqun previously approved these changes Apr 9, 2021
Copy link
Member

@ryoqun ryoqun left a comment

Choose a reason for hiding this comment

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

code looks pretty what I really wanted to be like! good work!

please check the golden hashes by the method t I said in another comment and wait for the live-cluster tests..

@jeffwashington
Copy link
Contributor

jeffwashington commented Apr 9, 2021 via email

@brooksprumo
Copy link
Contributor Author

code looks pretty what I really wanted to be like! good work!

Thanks!

please check the golden hashes by the method t I said in another comment and wait for the live-cluster tests..

I've checked the golden hashes per the method you described and the hashes match. I left a reply, as there was a new test failure, but I'm assuming its erroneous.

Also, looks like the live-cluster tests have completed successfully. Should I make this a real PR now?

@brooksprumo brooksprumo force-pushed the bprumo/account-hashing branch from 8955469 to 0527a14 Compare April 9, 2021 14:58
@mergify mergify bot dismissed ryoqun’s stale review April 9, 2021 14:59

Pull request has been modified.

@ryoqun
Copy link
Member

ryoqun commented Apr 9, 2021

Should I make this a real PR now?

Of course. :)

@brooksprumo brooksprumo marked this pull request as ready for review April 9, 2021 16:23
@jeffwashington jeffwashington added the CI Pull Request is ready to enter CI label Apr 12, 2021
@solana-grimes solana-grimes removed the CI Pull Request is ready to enter CI label Apr 12, 2021
@brooksprumo brooksprumo force-pushed the bprumo/account-hashing branch from 0527a14 to 749d02f Compare April 12, 2021 22:22
runtime/src/accounts_db.rs Outdated Show resolved Hide resolved
ryoqun
ryoqun previously approved these changes Apr 13, 2021
Copy link
Member

@ryoqun ryoqun left a comment

Choose a reason for hiding this comment

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

LGTM with nit. Thanks for working on this carefully.

@ryoqun ryoqun mentioned this pull request Apr 13, 2021
@mergify mergify bot dismissed ryoqun’s stale review April 13, 2021 14:09

Pull request has been modified.

@brooksprumo brooksprumo force-pushed the bprumo/account-hashing branch from 25c7768 to b1f211e Compare April 13, 2021 14:12
Account data hashing used to use different ways of hashing on different
clusters.  That is no longer the case, but the old code still existed.
This commit removes that old, now used code.

**NOTE** The golden hash values in bank.rs needed to be updated.  Since
the original code that selected the hash algorithm used `if >` instead
of `if >=`, this meant that the genesis block's hash _always_ used the
old hashing method, which is no longer valid.

Validated by running `cargo test` successfully.
@brooksprumo brooksprumo force-pushed the bprumo/account-hashing branch from b1f211e to 7dd2de2 Compare April 13, 2021 14:16
@@ -979,7 +979,6 @@ pub fn process_accounts_package_pre(
let (hash, lamports) = AccountsDb::calculate_accounts_hash_without_index(
&accounts_package.storages,
thread_pool,
accounts_package.cluster_type,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, @brooksprumo , in another pr you could consider removing cluster_type from accounts_package maybe. Maybe we don't need it for anything else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

Copy link
Contributor Author

@brooksprumo brooksprumo Apr 13, 2021

Choose a reason for hiding this comment

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

@ryoqun Do you know if cluster_type is used for anything still?

It looks like Cluster Type isn't really used in accounts.rs nor accounts_db.rs, but is used in bank.rs, and therefore Genesis config/utils. I'm not sure if the Cluster Type is bank.rs still needs to be there though. Same thing for Snapshot Utils/Serde.

In the Bank impl, there's also a lot of test-only configuration only. I'm still trying to understand if all the cluster type related code can be moved to the actual test module. I'm going to keep reading through to code to learn more; happy to get your thoughts on Cluster Type in general too!

@jeffwashington jeffwashington self-requested a review April 13, 2021 19:27
Copy link
Contributor

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

lgtm.
Ran bench-tps, ledger-tool verify, and joined mainnet-beta. All looked fine.

@brooksprumo brooksprumo merged commit 17aa45f into solana-labs:master Apr 13, 2021
@brooksprumo brooksprumo deleted the bprumo/account-hashing branch April 13, 2021 19:43
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.

4 participants