From 8e2943604b9069b98a195b6c8a5690236f5b2b24 Mon Sep 17 00:00:00 2001 From: Tyera Date: Thu, 11 Jan 2024 11:21:11 -0700 Subject: [PATCH] Use parent blockhash to seed EpochRewardsHasher (#34744) * Use parent blockhash to seed rewards-partition hasher * Make blockhash word more consistent --- runtime/src/bank.rs | 6 +++++- runtime/src/epoch_rewards_hasher.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 612f567ad..77ac0dee4 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -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, ); diff --git a/runtime/src/epoch_rewards_hasher.rs b/runtime/src/epoch_rewards_hasher.rs index f03f00f5e..3f85d96af 100644 --- a/runtime/src/epoch_rewards_hasher.rs +++ b/runtime/src/epoch_rewards_hasher.rs @@ -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 { - 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 {