Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
refactor bool logic for partition reward single slot enable
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Jan 25, 2024
1 parent d97eb22 commit 5231891
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,13 @@ impl Bank {
}
}

fn force_partition_rewards_in_first_block_of_epoch(&self) -> bool {
self.partitioned_epoch_rewards_config()
.test_enable_partitioned_rewards
&& self.get_reward_calculation_num_blocks() == 0
&& self.partitioned_rewards_stake_account_stores_per_block() == u64::MAX
}

/// Begin the process of calculating and distributing rewards.
/// This process can take multiple slots.
fn begin_partitioned_rewards(
Expand Down Expand Up @@ -1638,14 +1645,10 @@ impl Bank {
self.create_epoch_rewards_sysvar(total_rewards, distributed_rewards, credit_end_exclusive);

// Skip creating data account when we are testing partitioned rewards
let skip_reward_partition_account = !self.is_partitioned_rewards_feature_enabled()
&& (self
.partitioned_epoch_rewards_config()
.test_enable_partitioned_rewards
&& self.get_reward_calculation_num_blocks() == 0
&& self.partitioned_rewards_stake_account_stores_per_block() == u64::MAX);
let should_create = self.is_partitioned_rewards_code_enabled()
|| !self.force_partition_rewards_in_first_block_of_epoch();

if !(skip_reward_partition_account) {
if should_create {
self.create_epoch_rewards_partition_data_account(num_partitions, parent_blockhash);
}

Expand Down Expand Up @@ -7017,12 +7020,8 @@ impl Bank {
fn hash_internal_state(&self) -> Hash {
let slot = self.slot();
let ignore = (!self.is_partitioned_rewards_feature_enabled()
&& (self
.partitioned_epoch_rewards_config()
.test_enable_partitioned_rewards
&& self.get_reward_calculation_num_blocks() == 0
&& self.partitioned_rewards_stake_account_stores_per_block() == u64::MAX))
.then_some(sysvar::epoch_rewards::id());
&& self.force_partition_rewards_in_first_block_of_epoch())
.then_some(sysvar::epoch_rewards::id());
let accounts_delta_hash = self
.rc
.accounts
Expand Down

0 comments on commit 5231891

Please sign in to comment.