Skip to content

Commit c372da2

Browse files
authored
rent-collector: Inline struct and const, remove dep (#7297)
* rent-collector: Inline struct and const, remove dep #### Problem As outlined in anza-xyz/solana-sdk#226, the RentCollector is no longer needed, and with #6782, it's needed even less. #### Summary of changes Inline the `RentCollector` struct into `solana-runtime` with the few functions needed. This changes the frozen-abi hash because the type now comes from a different crate. The only other usage was the `RENT_EXEMPT_RENT_EPOCH` constant, which is used in svm and accounts-db. Since there's no good common crate that both of these use, I inlined the const in both places, along with a test to make sure they don't diverge. Finally, remove solana-rent-collector usage everywhere. * Make `RentCollector` crate-private, expose rent() directly * Revert "Make `RentCollector` crate-private, expose rent() directly" This reverts commit 101c5bf. * Put accidentally removed comment back in post-rebase * Also remove it from snapshot_package.rs
1 parent 407c9f1 commit c372da2

File tree

18 files changed

+80
-60
lines changed

18 files changed

+80
-60
lines changed

Cargo.lock

Lines changed: 1 addition & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ solana-quic-definitions = "2.3.0"
486486
solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=3.0.0" }
487487
solana-remote-wallet = { path = "remote-wallet", version = "=3.0.0", default-features = false }
488488
solana-rent = "2.2.1"
489-
solana-rent-collector = "2.2.1"
490489
solana-reward-info = "2.2.1"
491490
solana-rpc = { path = "rpc", version = "=3.0.0" }
492491
solana-rpc-client = { path = "rpc-client", version = "=3.0.0", default-features = false }

accounts-db/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ solana-nohash-hasher = { workspace = true }
8787
solana-pubkey = { workspace = true, features = ["rand"] }
8888
solana-rayon-threadlimit = { workspace = true }
8989
solana-rent = { workspace = true, optional = true }
90-
solana-rent-collector = { workspace = true }
9190
solana-reward-info = { workspace = true, features = ["serde"] }
9291
solana-sha256-hasher = { workspace = true }
9392
solana-signer = { workspace = true, optional = true }
@@ -127,6 +126,7 @@ solana-logger = { workspace = true }
127126
solana-sdk-ids = { workspace = true }
128127
solana-signature = { workspace = true, features = ["rand"] }
129128
solana-slot-history = { workspace = true }
129+
solana-svm = { workspace = true }
130130
static_assertions = { workspace = true }
131131
strum = { workspace = true, features = ["derive"] }
132132
strum_macros = { workspace = true }

accounts-db/benches/bench_accounts_file.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ use {
77
append_vec::{self, AppendVec},
88
tiered_storage::{
99
file::TieredReadableFile,
10-
hot::{HotStorageReader, HotStorageWriter},
10+
hot::{HotStorageReader, HotStorageWriter, RENT_EXEMPT_RENT_EPOCH},
1111
},
1212
},
1313
solana_clock::Slot,
1414
solana_pubkey::Pubkey,
15-
solana_rent_collector::RENT_EXEMPT_RENT_EPOCH,
1615
solana_system_interface::MAX_PERMITTED_DATA_LENGTH,
1716
std::mem::ManuallyDrop,
1817
};

accounts-db/benches/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use {
99
},
1010
rand_chacha::ChaChaRng,
1111
solana_account::AccountSharedData,
12+
solana_accounts_db::tiered_storage::hot::RENT_EXEMPT_RENT_EPOCH,
1213
solana_pubkey::Pubkey,
1314
solana_rent::Rent,
14-
solana_rent_collector::RENT_EXEMPT_RENT_EPOCH,
1515
std::iter,
1616
};
1717

accounts-db/src/tiered_storage/hot.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,19 @@ use {
2424
solana_account::{AccountSharedData, ReadableAccount, WritableAccount},
2525
solana_clock::Epoch,
2626
solana_pubkey::Pubkey,
27-
solana_rent_collector::RENT_EXEMPT_RENT_EPOCH,
2827
std::{io::Write, option::Option, path::Path},
2928
};
3029

30+
/// When rent is collected from an exempt account, rent_epoch is set to this
31+
/// value. The idea is to have a fixed, consistent value for rent_epoch for all accounts that do not collect rent.
32+
/// This enables us to get rid of the field completely.
33+
pub const RENT_EXEMPT_RENT_EPOCH: Epoch = Epoch::MAX;
34+
#[cfg(test)]
35+
static_assertions::const_assert_eq!(
36+
RENT_EXEMPT_RENT_EPOCH,
37+
solana_svm::rent_calculator::RENT_EXEMPT_RENT_EPOCH
38+
);
39+
3140
pub const HOT_FORMAT: TieredStorageFormat = TieredStorageFormat {
3241
meta_entry_size: std::mem::size_of::<HotAccountMeta>(),
3342
account_meta_format: AccountMetaFormat::Hot,

accounts-db/src/tiered_storage/test_utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
//! Helper functions for TieredStorage tests
33
use {
44
super::footer::TieredStorageFooter,
5-
crate::{account_storage::stored_account_info::StoredAccountInfo, append_vec::StoredMeta},
5+
crate::{
6+
account_storage::stored_account_info::StoredAccountInfo, append_vec::StoredMeta,
7+
tiered_storage::hot::RENT_EXEMPT_RENT_EPOCH,
8+
},
69
solana_account::{Account, AccountSharedData, ReadableAccount},
710
solana_pubkey::Pubkey,
8-
solana_rent_collector::RENT_EXEMPT_RENT_EPOCH,
911
};
1012

1113
/// Create a test account based on the specified seed.

programs/sbf/Cargo.lock

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ frozen-abi = [
3737
"solana-perf/frozen-abi",
3838
"solana-program-runtime/frozen-abi",
3939
"solana-rent/frozen-abi",
40-
"solana-rent-collector/frozen-abi",
4140
"solana-stake-interface/frozen-abi",
4241
"solana-svm/frozen-abi",
4342
"solana-transaction-error/frozen-abi",
@@ -139,7 +138,6 @@ solana-program-runtime = { workspace = true, features = ["metrics"] }
139138
solana-pubkey = { workspace = true, features = ["rand"] }
140139
solana-rayon-threadlimit = { workspace = true }
141140
solana-rent = { workspace = true }
142-
solana-rent-collector = { workspace = true, features = ["serde"] }
143141
solana-reward-info = { workspace = true }
144142
solana-runtime-transaction = { workspace = true }
145143
solana-sdk-ids = { workspace = true }

runtime/src/bank.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use {
4444
epoch_stakes::{NodeVoteAccounts, VersionedEpochStakes},
4545
inflation_rewards::points::InflationPointCalculationEvent,
4646
installed_scheduler_pool::{BankWithScheduler, InstalledSchedulerRwLock},
47+
rent_collector::RentCollector,
4748
runtime_config::RuntimeConfig,
4849
snapshot_hash::SnapshotHash,
4950
stake_account::StakeAccount,
@@ -112,7 +113,6 @@ use {
112113
invoke_context::BuiltinFunctionWithContext, loaded_programs::ProgramCacheEntry,
113114
},
114115
solana_pubkey::Pubkey,
115-
solana_rent_collector::RentCollector,
116116
solana_reward_info::RewardInfo,
117117
solana_runtime_transaction::{
118118
runtime_transaction::RuntimeTransaction, transaction_with_meta::TransactionWithMeta,

0 commit comments

Comments
 (0)