Skip to content
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

Use parent blockhash to seed EpochRewardsHasher #34744

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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