Skip to content

Commit 101c5bf

Browse files
committed
Make RentCollector crate-private, expose rent() directly
1 parent 63be269 commit 101c5bf

File tree

10 files changed

+19
-25
lines changed

10 files changed

+19
-25
lines changed

core/src/banking_stage/consumer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl Consumer {
473473
&mut fee_payer_account,
474474
0,
475475
error_counters,
476-
&bank.rent_collector().rent,
476+
bank.rent(),
477477
fee,
478478
)
479479
}

rpc/src/rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6407,7 +6407,7 @@ pub mod tests {
64076407
let to_pubkey = to.pubkey();
64086408

64096409
let space = 0;
6410-
let lamports = bank.rent_collector().rent.minimum_balance(space);
6410+
let lamports = bank.rent().minimum_balance(space);
64116411
let owner_pubkey = Pubkey::new_unique();
64126412

64136413
let instruction = TestBuiltinEntrypoint::instruction(

rpc/src/rpc_pubsub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ mod tests {
915915

916916
let balance = {
917917
let bank = bank_forks.read().unwrap().working_bank();
918-
let rent = &bank.rent_collector().rent;
918+
let rent = bank.rent();
919919
rent.minimum_balance(StakeStateV2::size_of())
920920
};
921921

@@ -969,7 +969,7 @@ mod tests {
969969

970970
let balance = {
971971
let bank = bank_forks.read().unwrap().working_bank();
972-
let rent = &bank.rent_collector().rent;
972+
let rent = bank.rent();
973973
rent.minimum_balance(0)
974974
};
975975
let tx =

runtime/src/bank.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ use {
116116
invoke_context::BuiltinFunctionWithContext, loaded_programs::ProgramCacheEntry,
117117
},
118118
solana_pubkey::Pubkey,
119+
solana_rent::Rent,
119120
solana_reward_info::RewardInfo,
120121
solana_runtime_transaction::{
121122
runtime_transaction::RuntimeTransaction, transaction_with_meta::TransactionWithMeta,
@@ -469,7 +470,7 @@ pub struct BankFieldsToSerialize {
469470
pub collector_id: Pubkey,
470471
pub collector_fees: u64,
471472
pub fee_rate_governor: FeeRateGovernor,
472-
pub rent_collector: RentCollector,
473+
pub(crate) rent_collector: RentCollector,
473474
pub epoch_schedule: EpochSchedule,
474475
pub inflation: Inflation,
475476
pub stakes: Stakes<StakeAccount<Delegation>>,
@@ -4917,9 +4918,9 @@ impl Bank {
49174918
*self.inflation.read().unwrap()
49184919
}
49194920

4920-
/// Return the rent collector for this Bank
4921-
pub fn rent_collector(&self) -> &RentCollector {
4922-
&self.rent_collector
4921+
/// Return the rent for this Bank
4922+
pub fn rent(&self) -> &Rent {
4923+
&self.rent_collector.rent
49234924
}
49244925

49254926
/// Return the total capitalization of the Bank

runtime/src/bank/fee_distribution.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,13 @@ impl Bank {
153153
return Err(DepositFeeError::InvalidAccountOwner);
154154
}
155155

156-
let recipient_pre_rent_state =
157-
get_account_rent_state(&self.rent_collector().rent, &account);
156+
let recipient_pre_rent_state = get_account_rent_state(self.rent(), &account);
158157
let distribution = account.checked_add_lamports(fees);
159158
if distribution.is_err() {
160159
return Err(DepositFeeError::LamportOverflow);
161160
}
162161

163-
let recipient_post_rent_state =
164-
get_account_rent_state(&self.rent_collector().rent, &account);
162+
let recipient_post_rent_state = get_account_rent_state(self.rent(), &account);
165163
let rent_state_transition_allowed =
166164
transition_allowed(&recipient_pre_rent_state, &recipient_post_rent_state);
167165
if !rent_state_transition_allowed {

runtime/src/bank/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,7 +3101,7 @@ fn test_bank_cloned_stake_delegations() {
31013101
// to have a stake delegation
31023102

31033103
let (vote_balance, stake_balance) = {
3104-
let rent = &bank.rent_collector().rent;
3104+
let rent = bank.rent();
31053105
let vote_rent_exempt_reserve = rent.minimum_balance(VoteState::size_of());
31063106
let stake_rent_exempt_reserve = rent.minimum_balance(StakeStateV2::size_of());
31073107
let minimum_delegation = solana_stake_program::get_minimum_delegation(
@@ -10615,8 +10615,7 @@ fn test_cap_accounts_data_allocations_per_transaction() {
1061510615
let instruction = system_instruction::create_account(
1061610616
&mint_keypair.pubkey(),
1061710617
&keypair.pubkey(),
10618-
bank.rent_collector()
10619-
.rent
10618+
bank.rent()
1062010619
.minimum_balance(MAX_PERMITTED_DATA_LENGTH as usize),
1062110620
MAX_PERMITTED_DATA_LENGTH,
1062210621
&solana_system_interface::program::id(),

runtime/src/rent_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use {
55

66
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))]
77
#[derive(Clone, Debug, PartialEq, serde_derive::Deserialize, serde_derive::Serialize)]
8-
pub struct RentCollector {
8+
pub(crate) struct RentCollector {
99
pub epoch: Epoch,
1010
pub epoch_schedule: EpochSchedule,
1111
pub slots_per_year: f64,

runtime/src/serde_snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ where
854854
reconstructed_accounts_db_info.accounts_data_len,
855855
);
856856

857-
info!("rent_collector: {:?}", bank.rent_collector());
857+
info!("rent: {:?}", bank.rent());
858858
Ok((
859859
bank,
860860
ReconstructedBankInfo {

runtime/src/snapshot_package.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use solana_hash::Hash;
33
use {
44
crate::{
55
bank::{Bank, BankFieldsToSerialize, BankHashStats, BankSlotDelta},
6-
rent_collector::RentCollector,
76
snapshot_hash::SnapshotHash,
87
},
98
log::*,
@@ -28,7 +27,6 @@ pub struct AccountsPackage {
2827
pub expected_capitalization: u64,
2928
pub accounts: Arc<Accounts>,
3029
pub epoch_schedule: EpochSchedule,
31-
pub rent_collector: RentCollector,
3230

3331
/// Supplemental information needed for snapshots
3432
pub snapshot_info: Option<SupplementalSnapshotInfo>,
@@ -91,7 +89,6 @@ impl AccountsPackage {
9189
expected_capitalization: bank.capitalization(),
9290
accounts: bank.accounts(),
9391
epoch_schedule: bank.epoch_schedule().clone(),
94-
rent_collector: bank.rent_collector().clone(),
9592
snapshot_info,
9693
enqueued: Instant::now(),
9794
}
@@ -112,7 +109,6 @@ impl AccountsPackage {
112109
expected_capitalization: u64::default(),
113110
accounts: Arc::new(accounts),
114111
epoch_schedule: EpochSchedule::default(),
115-
rent_collector: RentCollector::default(),
116112
snapshot_info: Some(SupplementalSnapshotInfo {
117113
status_cache_slot_deltas: Vec::default(),
118114
bank_fields_to_serialize: BankFieldsToSerialize::default_for_tests(),

runtime/tests/stake.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn test_stake_create_and_split_single_signature() {
150150
let authorized = Authorized::auto(&staker_pubkey);
151151

152152
let lamports = {
153-
let rent = &bank.rent_collector().rent;
153+
let rent = bank.rent();
154154
let rent_exempt_reserve = rent.minimum_balance(StakeStateV2::size_of());
155155
let minimum_delegation = solana_stake_program::get_minimum_delegation(
156156
bank.feature_set
@@ -225,7 +225,7 @@ fn test_stake_create_and_split_to_existing_system_account() {
225225
let authorized = Authorized::auto(&staker_pubkey);
226226

227227
let lamports = {
228-
let rent = &bank.rent_collector().rent;
228+
let rent = bank.rent();
229229
let rent_exempt_reserve = rent.minimum_balance(StakeStateV2::size_of());
230230
let minimum_delegation = solana_stake_program::get_minimum_delegation(
231231
bank.feature_set
@@ -311,7 +311,7 @@ fn test_stake_account_lifetime() {
311311
let bank_client = BankClient::new_shared(bank.clone());
312312

313313
let (vote_balance, stake_rent_exempt_reserve, stake_minimum_delegation) = {
314-
let rent = &bank.rent_collector().rent;
314+
let rent = bank.rent();
315315
(
316316
rent.minimum_balance(VoteStateV3::size_of()),
317317
rent.minimum_balance(StakeStateV2::size_of()),
@@ -631,7 +631,7 @@ fn test_create_stake_account_from_seed() {
631631

632632
let authorized = Authorized::auto(&mint_pubkey);
633633
let (balance, delegation) = {
634-
let rent = &bank.rent_collector().rent;
634+
let rent = bank.rent();
635635
let rent_exempt_reserve = rent.minimum_balance(StakeStateV2::size_of());
636636
let minimum_delegation = solana_stake_program::get_minimum_delegation(
637637
bank.feature_set

0 commit comments

Comments
 (0)