Include account.owner into account hash (#9917)

automerge
This commit is contained in:
Ryo Onodera 2020-05-08 05:01:11 +09:00 committed by GitHub
parent 3757754c89
commit 2ac50177a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -1303,6 +1303,7 @@ impl AccountsDB {
Self::hash_account_data( Self::hash_account_data(
slot, slot,
account.account_meta.lamports, account.account_meta.lamports,
&account.account_meta.owner,
account.account_meta.executable, account.account_meta.executable,
account.account_meta.rent_epoch, account.account_meta.rent_epoch,
account.data, account.data,
@ -1314,6 +1315,7 @@ impl AccountsDB {
Self::hash_account_data( Self::hash_account_data(
slot, slot,
account.lamports, account.lamports,
&account.owner,
account.executable, account.executable,
account.rent_epoch, account.rent_epoch,
&account.data, &account.data,
@ -1339,6 +1341,7 @@ impl AccountsDB {
pub fn hash_account_data( pub fn hash_account_data(
slot: Slot, slot: Slot,
lamports: u64, lamports: u64,
owner: &Pubkey,
executable: bool, executable: bool,
rent_epoch: Epoch, rent_epoch: Epoch,
data: &[u8], data: &[u8],
@ -1368,6 +1371,7 @@ impl AccountsDB {
hasher.hash(&[0u8; 1]); hasher.hash(&[0u8; 1]);
} }
hasher.hash(&owner.as_ref());
hasher.hash(&pubkey.as_ref()); hasher.hash(&pubkey.as_ref());
hasher.result() hasher.result()
@ -3469,7 +3473,7 @@ pub mod tests {
}; };
let account = stored_account.clone_account(); let account = stored_account.clone_account();
let expected_account_hash = let expected_account_hash =
Hash::from_str("GGTsxvxwnMsNfN6yYbBVQaRgvbVLfxeWnGXNyB8iXDyE").unwrap(); Hash::from_str("5iRNZVcAnq9JLYjSF2ibFhGEeq48r9Eq9HXxwm3BxywN").unwrap();
assert_eq!( assert_eq!(
AccountsDB::hash_stored_account(slot, &stored_account), AccountsDB::hash_stored_account(slot, &stored_account),