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

Promotes accounts hash to a strong type #28930

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

brooksprumo
Copy link
Contributor

Problem

The accounts hash is used as a plain Hash in the code base. To add support for Incremental Accounts Hash, we'll need to distinguish between different flavors of accounts hashes. Without any type information, this will be error-prone.

Summary of Changes

Promote accounts hash to a strong type: AccountsHash.

(Future work for Incremental Accounts Hash will expand/alter this type)

@brooksprumo brooksprumo self-assigned this Nov 22, 2022
@@ -684,7 +685,7 @@ mod test_bank_serialize {

// This some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature
#[frozen_abi(digest = "B9ui5cFeJ5NGtXAVFXRCSX4GJ77yLc3izv1E8QE34TdQ")]
#[frozen_abi(digest = "464v92sAyLDZWCXjH6cuQfgrSNuB3PY8cmoVu2dciXvV")]
Copy link
Contributor Author

@brooksprumo brooksprumo Nov 22, 2022

Choose a reason for hiding this comment

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

ABI digest changed due to giving the accounts hash a type.

diff serde_snapshot__tests__test_bank_serialize__BankAbiTestWrapperNewer_frozen_abi__test_abi_digest_* -bc
--- 1702,1708 ----
!                             field accounts_hash: solana_program::hash::Hash
                                  struct Hash([u8; 32]) (newtype)
                                      tuple (elements = 32)
                                          element u8
*** 1702,1709 ****
!                             field accounts_hash: solana_runtime::accounts_hash::AccountsHash
!                                 struct AccountsHash(solana_program::hash::Hash) (newtype)
                                      struct Hash([u8; 32]) (newtype)
                                          tuple (elements = 32)
                                              element u8

@@ -1152,7 +1152,7 @@ impl BankHashStats {
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, Eq, AbiExample)]
pub struct BankHashInfo {
pub accounts_delta_hash: Hash,
pub accounts_hash: Hash,
pub accounts_hash: AccountsHash,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The heart of the change.

@brooksprumo brooksprumo marked this pull request as ready for review November 23, 2022 18:01
@@ -141,7 +141,7 @@ fn main() {
}
println!(
"hash,{},{},{},{}%",
results.0,
results.0 .0,
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt here? Not sure what formatter is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yah, fmt adds a space when there are multiple tuple indirections. Always makes me look twice...

@jeffwashington jeffwashington self-requested a review November 27, 2022 22:42
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. I love the idea. It will eliminate errors.

@brooksprumo brooksprumo merged commit 9327658 into solana-labs:master Nov 28, 2022
@brooksprumo brooksprumo deleted the iah/accounts-hash branch November 28, 2022 15:09
gnapoli23 pushed a commit to gnapoli23/solana that referenced this pull request Dec 16, 2022
nickfrosty pushed a commit to nickfrosty/solana that referenced this pull request Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants