Skip to content

Commit

Permalink
Use parent blockhash to seed EpochRewardsHasher (solana-labs#34744)
Browse files Browse the repository at this point in the history
* Use parent blockhash to seed rewards-partition hasher

* Make blockhash word more consistent
  • Loading branch information
Tyera authored Jan 11, 2024
1 parent 904700c commit 8e29436
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down
4 changes: 2 additions & 2 deletions runtime/src/epoch_rewards_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8e29436

Please sign in to comment.