-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Remove old way of account hashing #16442
Conversation
@@ -2955,53 +2910,14 @@ impl AccountsDb { | |||
hasher.result() | |||
} | |||
|
|||
pub fn hash_account_data( | |||
fn hash_account_data( |
There was a problem hiding this comment.
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.)
); | ||
} | ||
if bank.slot == 128 { | ||
assert_eq!( | ||
bank.hash().to_string(), | ||
"FQnVhDVjhCyfBxFb3bdm3CLiuCePvWuW5TGDsLBZnKAo" | ||
"AtWu4tubU9zGFChfHtQghQx3RVWtMQu6Rj49rQymFc4z" |
There was a problem hiding this comment.
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 Report
@@ 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 |
@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 :) |
There was a problem hiding this 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..
I can confirm that test but it may be Monday.
Sent from my phone.
… On Apr 9, 2021, at 8:38 AM, Brooks Prumo ***@***.***> wrote:
@brooksprumo commented on this pull request.
In runtime/src/accounts_db.rs:
> lamports: 129,
slot: 0,
pubkey: pubkey128,
},
CalculateHashIntermediate {
version: 3,
- hash: Hash::from_str("7nhnUMjRsaA83HgvEJVv3YrDqHd1SCoVbvsWDTXzCgfh").unwrap(),
+ hash: Hash::from_str("BcfjjoWJDE5rEPsZccCQU1pCPMCH5Z2H7uHZVk4Yz4gt").unwrap(),
When you checkout the old code, and replace > with >=, do you see these new hashes?
Great idea! I grabbed master at 8ec7e2e and changed account_db.rs on lines 2885 and 2918 to be if slot >= then ran cargo test --lib from runtime. The tests failed as expected, and the "actual" hashes do match the new ones I've used (at least for accounts_db.rs).
However, doing this method, the test test_accountsdb_calculate_accounts_hash_without_index() at line 5541 also failed. I'm assuming that's OK, but can you confirm, @ryoqun?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Thanks!
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? |
8955469
to
0527a14
Compare
Of course. :) |
0527a14
to
749d02f
Compare
There was a problem hiding this 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.
25c7768
to
b1f211e
Compare
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.
b1f211e
to
7dd2de2
Compare
@@ -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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
There was a problem hiding this comment.
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!
There was a problem hiding this 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.
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 ofif >=
, 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 bychanging
if slot >
toif slot >=
onmaster
and runningcargo test
,then confirming the actual values matched the golden values in this commit.
Validated by running
cargo test
from withinruntime
.(This work was originally based on PR #16375 from @jeffwashington)