prepare load_transaction_accounts to recognize reward interval (#31673)

This commit is contained in:
Jeff Washington (jwash) 2023-05-16 14:55:35 -05:00 committed by GitHub
parent cdb430d287
commit 5bc41a0eb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -82,6 +82,12 @@ pub struct AccountLocks {
readonly_locks: HashMap<Pubkey, u64>,
}
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub(crate) enum RewardInterval {
/// the slot within the epoch is OUTSIDE the reward distribution interval
OutsideInterval,
}
impl AccountLocks {
fn is_locked_readonly(&self, key: &Pubkey) -> bool {
self.readonly_locks
@ -336,6 +342,7 @@ impl Accounts {
rent_collector: &RentCollector,
feature_set: &FeatureSet,
account_overrides: Option<&AccountOverrides>,
_reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, &Pubkey>,
loaded_programs: &LoadedProgramsForTxBatch,
) -> Result<LoadedTransaction> {
@ -683,7 +690,7 @@ impl Accounts {
}
#[allow(clippy::too_many_arguments)]
pub fn load_accounts(
pub(crate) fn load_accounts(
&self,
ancestors: &Ancestors,
txs: &[SanitizedTransaction],
@ -694,6 +701,7 @@ impl Accounts {
feature_set: &FeatureSet,
fee_structure: &FeeStructure,
account_overrides: Option<&AccountOverrides>,
in_reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, &Pubkey>,
loaded_programs: &LoadedProgramsForTxBatch,
) -> Vec<TransactionLoadResult> {
@ -731,6 +739,7 @@ impl Accounts {
rent_collector,
feature_set,
account_overrides,
in_reward_interval,
program_accounts,
loaded_programs,
) {
@ -1564,6 +1573,7 @@ mod tests {
feature_set,
fee_structure,
None,
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
)
@ -3368,6 +3378,7 @@ mod tests {
&FeatureSet::all_enabled(),
&FeeStructure::default(),
account_overrides,
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
)

View File

@ -41,7 +41,7 @@ use {
account_overrides::AccountOverrides,
account_rent_state::RentState,
accounts::{
AccountAddressFilter, Accounts, LoadedTransaction, PubkeyAccountSlot,
AccountAddressFilter, Accounts, LoadedTransaction, PubkeyAccountSlot, RewardInterval,
TransactionLoadResult,
},
accounts_db::{
@ -4544,6 +4544,7 @@ impl Bank {
&self.feature_set,
&self.fee_structure,
account_overrides,
RewardInterval::OutsideInterval,
&program_accounts_map,
&programs_loaded_for_tx_batch.borrow(),
);

View File

@ -7,7 +7,7 @@ use {
*,
},
crate::{
accounts::AccountAddressFilter,
accounts::{AccountAddressFilter, RewardInterval},
accounts_background_service::{PrunedBanksRequestHandler, SendDroppedBankCallback},
accounts_db::{AccountShrinkThreshold, DEFAULT_ACCOUNTS_SHRINK_RATIO},
accounts_index::{
@ -11333,6 +11333,7 @@ fn test_rent_state_list_len() {
&bank.feature_set,
&FeeStructure::default(),
None,
RewardInterval::OutsideInterval,
&HashMap::new(),
&LoadedProgramsForTxBatch::default(),
);