From a3670054be03ebfc8dca919610fb0660199e2242 Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:17:21 -0300 Subject: [PATCH] Move `RewardInterval` to runtime (#34146) Move RewardInterval to runtime --- accounts-db/src/accounts.rs | 8 -------- runtime/src/accounts/mod.rs | 7 +++++-- runtime/src/bank.rs | 10 +++++++++- runtime/src/bank/tests.rs | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/accounts-db/src/accounts.rs b/accounts-db/src/accounts.rs index 0e76c7a71..145fe52b1 100644 --- a/accounts-db/src/accounts.rs +++ b/accounts-db/src/accounts.rs @@ -57,14 +57,6 @@ pub struct AccountLocks { readonly_locks: HashMap, } -#[derive(Debug, PartialEq, Eq, Copy, Clone)] -pub enum RewardInterval { - /// the slot within the epoch is INSIDE the reward distribution interval - InsideInterval, - /// 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 diff --git a/runtime/src/accounts/mod.rs b/runtime/src/accounts/mod.rs index d8f3d8d15..01df5c9bc 100644 --- a/runtime/src/accounts/mod.rs +++ b/runtime/src/accounts/mod.rs @@ -1,12 +1,15 @@ pub mod account_rent_state; use { - crate::accounts::account_rent_state::{check_rent_state_with_account, RentState}, + crate::{ + accounts::account_rent_state::{check_rent_state_with_account, RentState}, + bank::RewardInterval, + }, itertools::Itertools, log::warn, solana_accounts_db::{ account_overrides::AccountOverrides, - accounts::{LoadedTransaction, RewardInterval, TransactionLoadResult, TransactionRent}, + accounts::{LoadedTransaction, TransactionLoadResult, TransactionRent}, accounts_db::AccountsDb, ancestors::Ancestors, blockhash_queue::BlockhashQueue, diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index db85d8b6b..9f6d78e13 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -70,7 +70,7 @@ use { solana_accounts_db::{ account_overrides::AccountOverrides, accounts::{ - AccountAddressFilter, Accounts, LoadedTransaction, PubkeyAccountSlot, RewardInterval, + AccountAddressFilter, Accounts, LoadedTransaction, PubkeyAccountSlot, TransactionLoadResult, }, accounts_db::{ @@ -957,6 +957,14 @@ struct StakeRewardCalculation { total_stake_rewards_lamports: u64, } +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +pub(super) enum RewardInterval { + /// the slot within the epoch is INSIDE the reward distribution interval + InsideInterval, + /// the slot within the epoch is OUTSIDE the reward distribution interval + OutsideInterval, +} + impl Bank { pub fn default_for_tests() -> Self { Self::default_with_accounts(Accounts::default_for_tests()) diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 4e43c4a81..c280bb5f2 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -25,7 +25,7 @@ use { rayon::ThreadPoolBuilder, serde::{Deserialize, Serialize}, solana_accounts_db::{ - accounts::{AccountAddressFilter, RewardInterval}, + accounts::AccountAddressFilter, accounts_db::{AccountShrinkThreshold, DEFAULT_ACCOUNTS_SHRINK_RATIO}, accounts_index::{ AccountIndex, AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ITER_BATCH_SIZE,