Skip to content

Commit

Permalink
Skip creating reward partition account for `--partitioned-epoch-rewar…
Browse files Browse the repository at this point in the history
…ds-force-enable-single-slot` (solana-labs#34946)

* skip creating reward partition account when we are testing agains mainnet

* Update runtime/src/bank.rs

Co-authored-by: Brooks <[email protected]>

* Update runtime/src/bank.rs

Co-authored-by: Brooks <[email protected]>

* refactor bool logic for partition reward single slot enable

* Update runtime/src/bank.rs

Co-authored-by: Tyera <[email protected]>

* move force_partition_rewards check into data account create fn

* share code

---------

Co-authored-by: HaoranYi <[email protected]>
Co-authored-by: Brooks <[email protected]>
Co-authored-by: Tyera <[email protected]>
  • Loading branch information
4 people authored Jan 26, 2024
1 parent c656ca6 commit 8a0c91d
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,11 +1533,7 @@ impl Bank {
// After saving a snapshot of stakes, apply stake rewards and commission
let (_, update_rewards_with_thread_pool_time) = measure!(
{
if self.is_partitioned_rewards_feature_enabled()
|| self
.partitioned_epoch_rewards_config()
.test_enable_partitioned_rewards
{
if self.is_partitioned_rewards_code_enabled() {
self.begin_partitioned_rewards(
reward_calc_tracer,
&thread_pool,
Expand Down Expand Up @@ -1595,6 +1591,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 @@ -3622,7 +3625,18 @@ impl Bank {
&solana_sdk::sysvar::id(),
)
.unwrap();
self.store_account_and_update_capitalization(&address, &new_account);

info!(
"create epoch rewards partition data account {} {address} \
{epoch_rewards_partition_data:?}",
self.slot
);

// Skip storing data account when we are testing partitioned
// rewards but feature is not yet active
if !self.force_partition_rewards_in_first_block_of_epoch() {
self.store_account_and_update_capitalization(&address, &new_account);
}
}

fn update_recent_blockhashes_locked(&self, locked_blockhash_queue: &BlockhashQueue) {
Expand Down Expand Up @@ -6993,12 +7007,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 8a0c91d

Please sign in to comment.