Use parent blockhash to seed EpochRewardsHasher (#34744)

* Use parent blockhash to seed rewards-partition hasher

* Make blockhash word more consistent
This commit is contained in:
Tyera 2024-01-11 11:21:11 -07:00 committed by GitHub
parent 904700cc56
commit 8e2943604b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -2355,9 +2355,13 @@ impl Bank {
.unwrap_or_default();
let num_partitions = self.get_reward_distribution_num_blocks(&stake_rewards.stake_rewards);
let parent_blockhash = self
.parent()
.expect("Partitioned rewards calculation must still have access to parent Bank.")
.last_blockhash();
let stake_rewards_by_partition = hash_rewards_into_partitions(
std::mem::take(&mut stake_rewards.stake_rewards),
&self.parent_hash(),
&parent_blockhash,
num_partitions as usize,
);

View File

@ -42,10 +42,10 @@ fn hash_to_partition(hash: u64, partitions: usize) -> usize {
pub(crate) fn hash_rewards_into_partitions(
stake_rewards: StakeRewards,
parent_block_hash: &Hash,
parent_blockhash: &Hash,
num_partitions: usize,
) -> Vec<StakeRewards> {
let hasher = EpochRewardsHasher::new(num_partitions, parent_block_hash);
let hasher = EpochRewardsHasher::new(num_partitions, parent_blockhash);
let mut result = vec![vec![]; num_partitions];
for reward in stake_rewards {