Skip to content

Commit

Permalink
Extract solana-rent crate (solana-labs#3022)
Browse files Browse the repository at this point in the history
* extract rent crate

* add #![no_std] to rent crate

* missing dev deps

* update digest

* update digest
  • Loading branch information
kevinheavey authored Oct 7, 2024
1 parent ed51e70 commit 0f38e03
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 7 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ members = [
"sdk/program-option",
"sdk/program-pack",
"sdk/pubkey",
"sdk/rent",
"sdk/serde-varint",
"sdk/serialize-utils",
"sdk/sha256-hasher",
Expand Down Expand Up @@ -440,6 +441,7 @@ solana-pubsub-client = { path = "pubsub-client", version = "=2.1.0" }
solana-quic-client = { path = "quic-client", version = "=2.1.0" }
solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=2.1.0" }
solana-remote-wallet = { path = "remote-wallet", version = "=2.1.0", default-features = false }
solana-rent = { path = "sdk/rent", version = "=2.1.0", default-features = false }
solana-sanitize = { path = "sanitize", version = "=2.1.0" }
solana-serde-varint = { path = "sdk/serde-varint", version = "=2.1.0" }
solana-serialize-utils = { path = "sdk/serialize-utils", version = "=2.1.0" }
Expand Down
10 changes: 10 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion runtime/src/bank/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ mod tests {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "6d4H7gw1hSrspdTew8dAXZ5dZT1mwFc6VZdXnkuggJ8E")
frozen_abi(digest = "8hwm4YsQXJWGZdp762SkJnDok29LXKwFtmW9oQ2KSzrN")
)]
#[derive(Serialize)]
pub struct BankAbiTestWrapper {
Expand Down
2 changes: 2 additions & 0 deletions sdk/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ solana-program-memory = { workspace = true }
solana-program-option = { workspace = true }
solana-program-pack = { workspace = true }
solana-pubkey = { workspace = true, features = ["bytemuck", "curve25519", "serde", "std"] }
solana-rent = { workspace = true, features = ["serde"] }
solana-sanitize = { workspace = true }
solana-sdk-macro = { workspace = true }
solana-secp256k1-recover = { workspace = true }
Expand Down Expand Up @@ -128,6 +129,7 @@ frozen-abi = [
"solana-hash/frozen-abi",
"solana-instruction/frozen-abi",
"solana-pubkey/frozen-abi",
"solana-rent/frozen-abi",
"solana-short-vec/frozen-abi"
]

Expand Down
3 changes: 1 addition & 2 deletions sdk/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ pub mod program;
pub mod program_error;
pub mod program_stubs;
pub mod program_utils;
pub mod rent;
pub mod secp256k1_program;
pub mod slot_hashes;
pub mod slot_history;
Expand Down Expand Up @@ -542,7 +541,7 @@ pub use {
solana_account_info::{self as account_info, debug_account_data},
solana_clock as clock,
solana_msg::msg,
solana_program_option as program_option, solana_pubkey as pubkey,
solana_program_option as program_option, solana_pubkey as pubkey, solana_rent as rent,
};

/// The [config native program][np].
Expand Down
31 changes: 31 additions & 0 deletions sdk/rent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "solana-rent"
description = "Configuration for Solana network rent."
documentation = "https://docs.rs/solana-rent"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
solana-frozen-abi = { workspace = true, optional = true }
solana-frozen-abi-macro = { workspace = true, optional = true }
solana-sdk-macro = { workspace = true }

[dev-dependencies]
solana-clock = { workspace = true }
static_assertions = { workspace = true }

[features]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"]
serde = ["dep:serde", "dep:serde_derive"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[lints]
workspace = true
22 changes: 19 additions & 3 deletions sdk/program/src/rent.rs → sdk/rent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,29 @@
//! [rent]: https://docs.solanalabs.com/implemented-proposals/rent
#![allow(clippy::arithmetic_side_effects)]
#![no_std]
#![cfg_attr(feature = "frozen-abi", feature(min_specialization))]
#[cfg(feature = "frozen-abi")]
extern crate std;

use {solana_clock::DEFAULT_SLOTS_PER_EPOCH, solana_sdk_macro::CloneZeroed};
use solana_sdk_macro::CloneZeroed;

// inlined to avoid solana_clock dep
const DEFAULT_SLOTS_PER_EPOCH: u64 = 432_000;
#[cfg(test)]
static_assertions::const_assert_eq!(
DEFAULT_SLOTS_PER_EPOCH,
solana_clock::DEFAULT_SLOTS_PER_EPOCH
);

/// Configuration of network rent.
#[repr(C)]
#[cfg_attr(feature = "frozen-abi", derive(AbiExample))]
#[derive(Serialize, Deserialize, PartialEq, CloneZeroed, Debug)]
#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))]
#[cfg_attr(
feature = "serde",
derive(serde_derive::Deserialize, serde_derive::Serialize)
)]
#[derive(PartialEq, CloneZeroed, Debug)]
pub struct Rent {
/// Rental rate in lamports/byte-year.
pub lamports_per_byte_year: u64,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl FromStr for ClusterType {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "z6vuQfrTaknTiRs1giPFzG1Jcw8eReidFTNDTmaX6GN")
frozen_abi(digest = "GDkrvVXezJYuGHcKSK19wvPBUMfKsifKQtoBxH1RpriL")
)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct GenesisConfig {
Expand Down

0 comments on commit 0f38e03

Please sign in to comment.