diff --git a/Cargo.lock b/Cargo.lock index 64b589ab0b0f6e..5b16e42d588318 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7309,6 +7309,37 @@ dependencies = [ "tempfile", ] +[[package]] +name = "solana-genesis-config" +version = "2.2.0" +dependencies = [ + "bincode", + "chrono", + "memmap2", + "serde", + "serde_derive", + "solana-account", + "solana-clock", + "solana-cluster-type", + "solana-epoch-schedule", + "solana-fee-calculator", + "solana-frozen-abi", + "solana-frozen-abi-macro", + "solana-hash", + "solana-inflation", + "solana-keypair", + "solana-logger", + "solana-native-token", + "solana-poh-config", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-sha256-hasher", + "solana-shred-version", + "solana-signer", + "solana-time-utils", +] + [[package]] name = "solana-genesis-utils" version = "2.2.0" @@ -8859,7 +8890,6 @@ dependencies = [ "bytemuck", "bytemuck_derive", "byteorder", - "chrono", "curve25519-dalek 4.1.3", "digest 0.10.7", "ed25519-dalek", @@ -8870,7 +8900,6 @@ dependencies = [ "lazy_static", "libsecp256k1", "log", - "memmap2", "num-derive", "num-traits", "openssl", @@ -8899,6 +8928,7 @@ dependencies = [ "solana-fee-structure", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-genesis-config", "solana-hard-forks", "solana-inflation", "solana-instruction", diff --git a/Cargo.toml b/Cargo.toml index 634764903af639..0f61270cbef362 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,6 +135,7 @@ members = [ "sdk/frozen-abi", "sdk/frozen-abi/macro", "sdk/gen-headers", + "sdk/genesis-config", "sdk/hard-forks", "sdk/hash", "sdk/inflation", @@ -497,6 +498,7 @@ solana-frozen-abi-macro = { path = "sdk/frozen-abi/macro", version = "=2.2.0" } solana-tps-client = { path = "tps-client", version = "=2.2.0" } solana-file-download = { path = "sdk/file-download", version = "=2.2.0" } solana-genesis = { path = "genesis", version = "=2.2.0" } +solana-genesis-config = { path = "sdk/genesis-config", version = "=2.2.0" } solana-genesis-utils = { path = "genesis-utils", version = "=2.2.0" } agave-geyser-plugin-interface = { path = "geyser-plugin-interface", version = "=2.2.0" } solana-geyser-plugin-manager = { path = "geyser-plugin-manager", version = "=2.2.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 25f95af82414ac..2938df69ea7a64 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5799,6 +5799,35 @@ dependencies = [ "reqwest", ] +[[package]] +name = "solana-genesis-config" +version = "2.2.0" +dependencies = [ + "bincode", + "chrono", + "memmap2", + "serde", + "serde_derive", + "solana-account", + "solana-clock", + "solana-cluster-type", + "solana-epoch-schedule", + "solana-fee-calculator", + "solana-hash", + "solana-inflation", + "solana-keypair", + "solana-logger", + "solana-native-token", + "solana-poh-config", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-sha256-hasher", + "solana-shred-version", + "solana-signer", + "solana-time-utils", +] + [[package]] name = "solana-genesis-utils" version = "2.2.0" @@ -7461,7 +7490,6 @@ dependencies = [ "bytemuck", "bytemuck_derive", "byteorder 1.5.0", - "chrono", "digest 0.10.7", "ed25519-dalek", "getrandom 0.1.14", @@ -7470,7 +7498,6 @@ dependencies = [ "lazy_static", "libsecp256k1 0.6.0", "log", - "memmap2", "num-derive", "num-traits", "qualifier_attr", @@ -7496,6 +7523,7 @@ dependencies = [ "solana-epoch-rewards-hasher", "solana-feature-set", "solana-fee-structure", + "solana-genesis-config", "solana-hard-forks", "solana-inflation", "solana-instruction", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 84d662e1422fde..e137f19f3914b4 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -22,8 +22,6 @@ default = [ ] full = [ "byteorder", - "chrono", - "memmap2", "rand", "rand0-7", "serde_json", @@ -39,6 +37,7 @@ full = [ "dep:solana-cluster-type", "dep:solana-ed25519-program", "dep:solana-compute-budget-interface", + "dep:solana-genesis-config", "dep:solana-hard-forks", "dep:solana-keypair", "dep:solana-offchain-message", @@ -76,6 +75,7 @@ frozen-abi = [ "solana-fee-structure/frozen-abi", "solana-account/frozen-abi", "solana-cluster-type/frozen-abi", + "solana-genesis-config/frozen-abi", "solana-hard-forks/frozen-abi", "solana-inflation/frozen-abi", "solana-poh-config/frozen-abi", @@ -97,7 +97,6 @@ bs58 = { workspace = true } bytemuck = { workspace = true } bytemuck_derive = { workspace = true } byteorder = { workspace = true, optional = true } -chrono = { workspace = true, features = ["alloc"], optional = true } curve25519-dalek = { workspace = true, optional = true } digest = { workspace = true, optional = true } ed25519-dalek = { workspace = true, optional = true } @@ -105,7 +104,6 @@ itertools = { workspace = true } lazy_static = { workspace = true } libsecp256k1 = { workspace = true, optional = true, features = ["hmac"] } log = { workspace = true } -memmap2 = { workspace = true, optional = true } num-derive = { workspace = true } num-traits = { workspace = true } qualifier_attr = { workspace = true, optional = true } @@ -143,6 +141,7 @@ solana-frozen-abi = { workspace = true, optional = true, features = [ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } +solana-genesis-config = { workspace = true, optional = true } solana-hard-forks = { workspace = true, features = [ "serde", ], optional = true } diff --git a/sdk/genesis-config/Cargo.toml b/sdk/genesis-config/Cargo.toml new file mode 100644 index 00000000000000..21b656eda7a275 --- /dev/null +++ b/sdk/genesis-config/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "solana-genesis-config" +description = "A Solana network's genesis config." +documentation = "https://docs.rs/solana-genesis-config" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[dependencies] +bincode = { workspace = true } +chrono = { workspace = true, features = ["alloc"] } +memmap2 = { workspace = true } +serde = { workspace = true } +serde_derive = { workspace = true } +solana-account = { workspace = true, features = ["serde"] } +solana-clock = { workspace = true, features = ["serde"] } +solana-cluster-type = { workspace = true, features = ["serde"] } +solana-epoch-schedule = { workspace = true, features = ["serde"] } +solana-fee-calculator = { workspace = true, features = ["serde"] } +solana-frozen-abi = { workspace = true, optional = true } +solana-frozen-abi-macro = { workspace = true, optional = true } +solana-hash = { workspace = true } +solana-inflation = { workspace = true, features = ["serde"] } +solana-keypair = { workspace = true } +solana-logger = { workspace = true } +solana-native-token = { workspace = true } +solana-poh-config = { workspace = true, features = ["serde"] } +solana-pubkey = { workspace = true } +solana-rent = { workspace = true, features = ["serde"] } +solana-sdk-ids = { workspace = true } +solana-sha256-hasher = { workspace = true } +solana-shred-version = { workspace = true } +solana-signer = { workspace = true } +solana-time-utils = { workspace = true } + +[dev-dependencies] +solana-pubkey = { workspace = true, features = ["rand"] } + +[features] +frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[lints] +workspace = true diff --git a/sdk/src/genesis_config.rs b/sdk/genesis-config/src/lib.rs similarity index 91% rename from sdk/src/genesis_config.rs rename to sdk/genesis-config/src/lib.rs index af86e8e3005659..a407223ba95493 100644 --- a/sdk/src/genesis_config.rs +++ b/sdk/genesis-config/src/lib.rs @@ -1,32 +1,35 @@ //! The chain's genesis config. -#![cfg(feature = "full")] +#![cfg_attr(feature = "frozen-abi", feature(min_specialization))] #[deprecated( since = "2.2.0", note = "Use `solana_cluster_type::ClusterType` instead." )] pub use solana_cluster_type::ClusterType; +#[cfg(feature = "frozen-abi")] +use solana_frozen_abi_macro::{frozen_abi, AbiExample}; use { - crate::{ - clock::{UnixTimestamp, DEFAULT_TICKS_PER_SLOT}, - epoch_schedule::EpochSchedule, - fee_calculator::FeeRateGovernor, - hash::{hash, Hash}, - inflation::Inflation, - poh_config::PohConfig, - pubkey::Pubkey, - rent::Rent, - shred_version::compute_shred_version, - signature::{Keypair, Signer}, - system_program, - timing::years_as_slots, - }, bincode::{deserialize, serialize}, chrono::{TimeZone, Utc}, memmap2::Mmap, + serde_derive::{Deserialize, Serialize}, solana_account::{Account, AccountSharedData}, + solana_clock::{UnixTimestamp, DEFAULT_TICKS_PER_SLOT}, + solana_epoch_schedule::EpochSchedule, + solana_fee_calculator::FeeRateGovernor, + solana_hash::Hash, + solana_inflation::Inflation, + solana_keypair::Keypair, solana_native_token::lamports_to_sol, + solana_poh_config::PohConfig, + solana_pubkey::Pubkey, + solana_rent::Rent, + solana_sdk_ids::system_program, + solana_sha256_hasher::hash, + solana_shred_version::compute_shred_version, + solana_signer::Signer, + solana_time_utils::years_as_slots, std::{ collections::BTreeMap, fmt, @@ -49,7 +52,7 @@ pub const UNUSED_DEFAULT: u64 = 1024; derive(AbiExample), frozen_abi(digest = "D9VFRSj4fodCuKFC9omQY2zY2Uw8wo6SzJFLeMJaVigm") )] -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct GenesisConfig { /// when the network (bootstrap validator) was started relative to the UNIX Epoch pub creation_time: UnixTimestamp, @@ -275,11 +278,7 @@ impl fmt::Display for GenesisConfig { #[cfg(test)] mod tests { - use { - super::*, - crate::signature::{Keypair, Signer}, - std::path::PathBuf, - }; + use {super::*, solana_signer::Signer, std::path::PathBuf}; fn make_tmp_path(name: &str) -> PathBuf { let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()); @@ -310,10 +309,10 @@ mod tests { AccountSharedData::new(10_000, 0, &Pubkey::default()), ); config.add_account( - solana_sdk::pubkey::new_rand(), + solana_pubkey::new_rand(), AccountSharedData::new(1, 0, &Pubkey::default()), ); - config.add_native_instruction_processor("hi".to_string(), solana_sdk::pubkey::new_rand()); + config.add_native_instruction_processor("hi".to_string(), solana_pubkey::new_rand()); assert_eq!(config.accounts.len(), 2); assert!(config diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index f9d1e89ce4f305..53c7aab0c91421 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -66,7 +66,9 @@ pub mod entrypoint; pub mod entrypoint_deprecated; pub mod example_mocks; pub mod feature; -pub mod genesis_config; +#[cfg(feature = "full")] +#[deprecated(since = "2.2.0", note = "Use `solana-genesis-config` crate instead")] +pub use solana_genesis_config as genesis_config; #[cfg(feature = "full")] #[deprecated(since = "2.2.0", note = "Use `solana-hard-forks` crate instead")] pub use solana_hard_forks as hard_forks; diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 5826ad73039f6d..03d65cfdee9a27 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5630,6 +5630,35 @@ dependencies = [ "solana-native-token", ] +[[package]] +name = "solana-genesis-config" +version = "2.2.0" +dependencies = [ + "bincode", + "chrono", + "memmap2", + "serde", + "serde_derive", + "solana-account", + "solana-clock", + "solana-cluster-type", + "solana-epoch-schedule", + "solana-fee-calculator", + "solana-hash", + "solana-inflation", + "solana-keypair", + "solana-logger", + "solana-native-token", + "solana-poh-config", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-sha256-hasher", + "solana-shred-version", + "solana-signer", + "solana-time-utils", +] + [[package]] name = "solana-geyser-plugin-manager" version = "2.2.0" @@ -6781,7 +6810,6 @@ dependencies = [ "bytemuck", "bytemuck_derive", "byteorder", - "chrono", "digest 0.10.7", "ed25519-dalek", "getrandom 0.1.16", @@ -6790,7 +6818,6 @@ dependencies = [ "lazy_static", "libsecp256k1", "log", - "memmap2", "num-derive", "num-traits", "rand 0.7.3", @@ -6815,6 +6842,7 @@ dependencies = [ "solana-epoch-rewards-hasher", "solana-feature-set", "solana-fee-structure", + "solana-genesis-config", "solana-hard-forks", "solana-inflation", "solana-instruction",