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>, 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 { impl AccountLocks {
fn is_locked_readonly(&self, key: &Pubkey) -> bool { fn is_locked_readonly(&self, key: &Pubkey) -> bool {
self.readonly_locks self.readonly_locks
@ -336,6 +342,7 @@ impl Accounts {
rent_collector: &RentCollector, rent_collector: &RentCollector,
feature_set: &FeatureSet, feature_set: &FeatureSet,
account_overrides: Option<&AccountOverrides>, account_overrides: Option<&AccountOverrides>,
_reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, &Pubkey>, program_accounts: &HashMap<Pubkey, &Pubkey>,
loaded_programs: &LoadedProgramsForTxBatch, loaded_programs: &LoadedProgramsForTxBatch,
) -> Result<LoadedTransaction> { ) -> Result<LoadedTransaction> {
@ -683,7 +690,7 @@ impl Accounts {
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub fn load_accounts( pub(crate) fn load_accounts(
&self, &self,
ancestors: &Ancestors, ancestors: &Ancestors,
txs: &[SanitizedTransaction], txs: &[SanitizedTransaction],
@ -694,6 +701,7 @@ impl Accounts {
feature_set: &FeatureSet, feature_set: &FeatureSet,
fee_structure: &FeeStructure, fee_structure: &FeeStructure,
account_overrides: Option<&AccountOverrides>, account_overrides: Option<&AccountOverrides>,
in_reward_interval: RewardInterval,
program_accounts: &HashMap<Pubkey, &Pubkey>, program_accounts: &HashMap<Pubkey, &Pubkey>,
loaded_programs: &LoadedProgramsForTxBatch, loaded_programs: &LoadedProgramsForTxBatch,
) -> Vec<TransactionLoadResult> { ) -> Vec<TransactionLoadResult> {
@ -731,6 +739,7 @@ impl Accounts {
rent_collector, rent_collector,
feature_set, feature_set,
account_overrides, account_overrides,
in_reward_interval,
program_accounts, program_accounts,
loaded_programs, loaded_programs,
) { ) {
@ -1564,6 +1573,7 @@ mod tests {
feature_set, feature_set,
fee_structure, fee_structure,
None, None,
RewardInterval::OutsideInterval,
&HashMap::new(), &HashMap::new(),
&LoadedProgramsForTxBatch::default(), &LoadedProgramsForTxBatch::default(),
) )
@ -3368,6 +3378,7 @@ mod tests {
&FeatureSet::all_enabled(), &FeatureSet::all_enabled(),
&FeeStructure::default(), &FeeStructure::default(),
account_overrides, account_overrides,
RewardInterval::OutsideInterval,
&HashMap::new(), &HashMap::new(),
&LoadedProgramsForTxBatch::default(), &LoadedProgramsForTxBatch::default(),
) )

View File

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

View File

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