Skip to content

Commit 5574dec

Browse files
committed
sdk: evict rent_collector
1 parent 11a84a4 commit 5574dec

File tree

10 files changed

+132
-22
lines changed

10 files changed

+132
-22
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ members = [
168168
"sdk/pubkey",
169169
"sdk/quic-definitions",
170170
"sdk/rent",
171+
"sdk/rent-collector",
171172
"sdk/rent-debits",
172173
"sdk/reserved-account-keys",
173174
"sdk/reward-info",
@@ -556,6 +557,7 @@ solana-quic-definitions = { path = "sdk/quic-definitions", version = "=2.2.0" }
556557
solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=2.2.0" }
557558
solana-remote-wallet = { path = "remote-wallet", version = "=2.2.0", default-features = false }
558559
solana-rent = { path = "sdk/rent", version = "=2.2.0", default-features = false }
560+
solana-rent-collector = { path = "sdk/rent-collector", version = "=2.2.0" }
559561
solana-rent-debits = { path = "sdk/rent-debits", version = "=2.2.0" }
560562
solana-reserved-account-keys = { path = "sdk/reserved-account-keys", version = "=2.2.0", default-features = false }
561563
solana-reward-info = { path = "sdk/reward-info", version = "=2.2.0" }

programs/sbf/Cargo.lock

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

runtime/src/bank/serde_snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ mod tests {
570570
#[cfg_attr(
571571
feature = "frozen-abi",
572572
derive(AbiExample),
573-
frozen_abi(digest = "9NABbrKjv1mmcPAmvtav1tVq4cJ7tTwKpHbYj6RDp3hi")
573+
frozen_abi(digest = "CiLUqUypBaGKz24XoQbv8EhpyeRD8jwwSFfosYWUrFL4")
574574
)]
575575
#[derive(Serialize)]
576576
pub struct BankAbiTestWrapper {

sdk/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ full = [
4545
"dep:solana-precompiles",
4646
"dep:solana-presigner",
4747
"dep:solana-quic-definitions",
48+
"dep:solana-rent-collector",
4849
"dep:solana-secp256k1-program",
4950
"dep:solana-seed-derivable",
5051
"dep:solana-seed-phrase",
@@ -80,6 +81,7 @@ frozen-abi = [
8081
"solana-inflation/frozen-abi",
8182
"solana-poh-config/frozen-abi",
8283
"solana-program/frozen-abi",
84+
"solana-rent-collector/frozen-abi",
8385
"solana-reward-info/frozen-abi",
8486
"solana-short-vec/frozen-abi",
8587
"solana-signature/frozen-abi",
@@ -167,6 +169,9 @@ solana-pubkey = { workspace = true, default-features = false, features = [
167169
"std",
168170
] }
169171
solana-quic-definitions = { workspace = true, optional = true }
172+
solana-rent-collector = { workspace = true, features = [
173+
"serde"
174+
], optional = true }
170175
solana-rent-debits = { workspace = true }
171176
solana-reserved-account-keys = { workspace = true }
172177
solana-reward-info = { workspace = true, features = ["serde"] }

sdk/rent-collector/Cargo.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[package]
2+
name = "solana-rent-collector"
3+
description = "Calculate and collect rent from accounts."
4+
documentation = "https://docs.rs/solana-rent-collector"
5+
version = { workspace = true }
6+
authors = { workspace = true }
7+
repository = { workspace = true }
8+
homepage = { workspace = true }
9+
license = { workspace = true }
10+
edition = { workspace = true }
11+
12+
[dependencies]
13+
serde = { workspace = true, optional = true }
14+
serde_derive = { workspace = true, optional = true }
15+
solana-account = { workspace = true }
16+
solana-clock = { workspace = true }
17+
solana-epoch-schedule = { workspace = true }
18+
solana-frozen-abi = { workspace = true, optional = true }
19+
solana-frozen-abi-macro = { workspace = true, optional = true }
20+
solana-genesis-config = { workspace = true }
21+
solana-pubkey = { workspace = true }
22+
solana-rent = { workspace = true }
23+
solana-sdk-ids = { workspace = true }
24+
25+
[dev-dependencies]
26+
assert_matches = { workspace = true }
27+
solana-logger = { workspace = true }
28+
solana-pubkey = { workspace = true, features = ["rand"] }
29+
solana-rent-collector = { path = ".", features = ["serde"] }
30+
31+
[features]
32+
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"]
33+
serde = [
34+
"dep:serde",
35+
"dep:serde_derive",
36+
"solana-epoch-schedule/serde",
37+
"solana-rent/serde",
38+
]
39+
40+
[package.metadata.docs.rs]
41+
targets = ["x86_64-unknown-linux-gnu"]
42+
all-features = true
43+
rustdoc-args = ["--cfg=docsrs"]
44+
45+
[lints]
46+
workspace = true

sdk/src/rent_collector.rs renamed to sdk/rent-collector/src/lib.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
#![cfg(feature = "full")]
1+
//! Calculate and collect rent from accounts.
2+
3+
#![cfg_attr(feature = "frozen-abi", feature(min_specialization))]
24

3-
//! calculate and collect rent from Accounts
45
use {
56
solana_account::{AccountSharedData, ReadableAccount, WritableAccount},
6-
solana_sdk::{
7-
clock::Epoch,
8-
epoch_schedule::EpochSchedule,
9-
genesis_config::GenesisConfig,
10-
incinerator,
11-
pubkey::Pubkey,
12-
rent::{Rent, RentDue},
13-
},
7+
solana_clock::Epoch,
8+
solana_epoch_schedule::EpochSchedule,
9+
solana_genesis_config::GenesisConfig,
10+
solana_pubkey::Pubkey,
11+
solana_rent::{Rent, RentDue},
12+
solana_sdk_ids::incinerator,
1413
};
1514

16-
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
17-
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
15+
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))]
16+
#[cfg_attr(
17+
feature = "serde",
18+
derive(serde_derive::Deserialize, serde_derive::Serialize)
19+
)]
20+
#[derive(Clone, Debug, PartialEq)]
1821
pub struct RentCollector {
1922
pub epoch: Epoch,
2023
pub epoch_schedule: EpochSchedule,
@@ -215,7 +218,9 @@ impl std::ops::AddAssign for CollectedInfo {
215218

216219
#[cfg(test)]
217220
mod tests {
218-
use {super::*, assert_matches::assert_matches, solana_account::Account, solana_sdk::sysvar};
221+
use {
222+
super::*, assert_matches::assert_matches, solana_account::Account, solana_sdk_ids::sysvar,
223+
};
219224

220225
fn default_rent_collector_clone_with_epoch(epoch: Epoch) -> RentCollector {
221226
RentCollector::default().clone_with_epoch(epoch)
@@ -374,7 +379,7 @@ mod tests {
374379

375380
// collect rent on a newly-created account
376381
let collected = rent_collector
377-
.collect_from_created_account(&solana_sdk::pubkey::new_rand(), &mut created_account);
382+
.collect_from_created_account(&solana_pubkey::new_rand(), &mut created_account);
378383
assert!(created_account.lamports() < old_lamports);
379384
assert_eq!(
380385
created_account.lamports() + collected.rent_amount,
@@ -385,7 +390,7 @@ mod tests {
385390

386391
// collect rent on a already-existing account
387392
let collected = rent_collector
388-
.collect_from_existing_account(&solana_sdk::pubkey::new_rand(), &mut existing_account);
393+
.collect_from_existing_account(&solana_pubkey::new_rand(), &mut existing_account);
389394
assert!(existing_account.lamports() < old_lamports);
390395
assert_eq!(
391396
existing_account.lamports() + collected.rent_amount,
@@ -406,7 +411,7 @@ mod tests {
406411
let epoch = 3;
407412
let huge_lamports = 123_456_789_012;
408413
let tiny_lamports = 789_012;
409-
let pubkey = solana_sdk::pubkey::new_rand();
414+
let pubkey = solana_pubkey::new_rand();
410415

411416
assert_eq!(account.rent_epoch(), 0);
412417

@@ -441,7 +446,7 @@ mod tests {
441446
account.set_owner(sysvar::id());
442447
account.set_lamports(tiny_lamports);
443448

444-
let pubkey = solana_sdk::pubkey::new_rand();
449+
let pubkey = solana_pubkey::new_rand();
445450

446451
assert_eq!(account.rent_epoch(), 0);
447452

sdk/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ pub mod net;
7979
pub mod precompiles;
8080
pub mod program_utils;
8181
pub mod pubkey;
82-
pub mod rent_collector;
82+
#[deprecated(since = "2.2.0", note = "Use `solana_rent_collector` crate instead")]
83+
pub use solana_rent_collector as rent_collector;
8384
#[deprecated(since = "2.2.0", note = "Use `solana-reward-info` crate instead")]
8485
pub mod reward_info {
8586
pub use solana_reward_info::RewardInfo;
@@ -252,10 +253,8 @@ macro_rules! saturating_add_assign {
252253

253254
pub extern crate bs58;
254255
extern crate log as logger;
255-
#[cfg_attr(not(target_os = "solana"), macro_use)]
256256
extern crate serde_derive;
257257

258-
#[cfg_attr(feature = "frozen-abi", macro_use)]
259258
#[cfg(feature = "frozen-abi")]
260259
extern crate solana_frozen_abi_macro;
261260

sdk/src/program_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub mod tests {
2222

2323
#[test]
2424
fn test_limited_deserialize() {
25-
#[derive(Deserialize, Serialize)]
25+
#[derive(serde_derive::Deserialize, serde_derive::Serialize)]
2626
enum Foo {
2727
Bar(Vec<u8>),
2828
}

svm/examples/Cargo.lock

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

0 commit comments

Comments
 (0)