Skip creating reward partition account for `--partitioned-epoch-rewards-force-enable-single-slot` (#34946)

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

* Update runtime/src/bank.rs

Co-authored-by: Brooks <brooks@prumo.org>

* Update runtime/src/bank.rs

Co-authored-by: Brooks <brooks@prumo.org>

* refactor bool logic for partition reward single slot enable

* Update runtime/src/bank.rs

Co-authored-by: Tyera <teulberg@gmail.com>

* move force_partition_rewards check into data account create fn

* share code

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
Co-authored-by: Brooks <brooks@prumo.org>
Co-authored-by: Tyera <teulberg@gmail.com>
This commit is contained in:
HaoranYi 2024-01-26 15:24:54 -06:00 committed by GitHub
parent c656ca68b8
commit 8a0c91d842
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 12 deletions

View File

@ -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,
@ -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(
@ -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) {
@ -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