-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Include account.owner into account hash #9917
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1303,6 +1303,7 @@ impl AccountsDB { | |
Self::hash_account_data( | ||
slot, | ||
account.account_meta.lamports, | ||
&account.account_meta.owner, | ||
account.account_meta.executable, | ||
account.account_meta.rent_epoch, | ||
account.data, | ||
|
@@ -1314,6 +1315,7 @@ impl AccountsDB { | |
Self::hash_account_data( | ||
slot, | ||
account.lamports, | ||
&account.owner, | ||
account.executable, | ||
account.rent_epoch, | ||
&account.data, | ||
|
@@ -1339,6 +1341,7 @@ impl AccountsDB { | |
pub fn hash_account_data( | ||
slot: Slot, | ||
lamports: u64, | ||
owner: &Pubkey, | ||
executable: bool, | ||
rent_epoch: Epoch, | ||
data: &[u8], | ||
|
@@ -1368,6 +1371,7 @@ impl AccountsDB { | |
hasher.hash(&[0u8; 1]); | ||
} | ||
|
||
hasher.hash(&owner.as_ref()); | ||
hasher.hash(&pubkey.as_ref()); | ||
|
||
hasher.result() | ||
|
@@ -3469,7 +3473,7 @@ pub mod tests { | |
}; | ||
let account = stored_account.clone_account(); | ||
let expected_account_hash = | ||
Hash::from_str("GGTsxvxwnMsNfN6yYbBVQaRgvbVLfxeWnGXNyB8iXDyE").unwrap(); | ||
Hash::from_str("5iRNZVcAnq9JLYjSF2ibFhGEeq48r9Eq9HXxwm3BxywN").unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This time, I've checked against $ echo 5iRNZVcAnq9JLYjSF2ibFhGEeq48r9Eq9HXxwm3BxywN | base58 -d | od --format=x1
0000000 46 0b 1e 3a 60 89 c1 c2 c5 81 9c 0f 80 47 0a 61
0000020 fe a8 92 17 00 82 9c 17 68 c4 52 76 9a 56 65 a9
0000040
$ (
# lamports
echo -ne '\x68\x67\x66\x65\x64\x63\x62\x61' &&
# slot
echo -ne '\xa0\x9f\x9e\x9d\x9c\x9b\x9a\x99' &&
# rent epoch
echo -ne '\x60\x5f\x5e\x5d\x5c\x5b\x5a\x59' &&
# data
echo -ne '\x28\x27\x26' &&
# executable
echo -ne '\x00' &&
# owner
echo -ne '\x58\x57\x56\x55\x54\x53\x52\x51\x50\x4f\x4e\x4d\x4c\x4b\x4a\x49\x48\x47\x46\x45\x44\x43\x42\x41\x40\x3f\x3e\x3d\x3c\x3b\x3a\x39' &&
# pubkey
echo -ne '\x88\x87\x86\x85\x84\x83\x82\x81\x80\x7f\x7e\x7d\x7c\x7b\x7a\x79\x78\x77\x76\x75\x74\x73\x72\x71\x70\x6f\x6e\x6d\x6c\x6b\x6a\x69'
) | sha256sum
460b1e3a6089c1c2c5819c0f80470a61fea8921700829c1768c452769a5665a9 - |
||
|
||
assert_eq!( | ||
AccountsDB::hash_stored_account(slot, &stored_account), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This time, I've checked against
coreutils
'ssha256sum
.