diff --git a/Cargo.lock b/Cargo.lock index cc437e886f238b..03e47cdbba4d6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6515,6 +6515,7 @@ dependencies = [ "serde", "serde_derive", "solana-clock", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", "static_assertions", @@ -6843,6 +6844,7 @@ dependencies = [ "solana-frozen-abi", "solana-frozen-abi-macro", "solana-hash", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", ] @@ -6857,6 +6859,7 @@ dependencies = [ "solana-epoch-schedule", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", "static_assertions", @@ -6889,7 +6892,6 @@ name = "solana-feature-set" version = "2.2.0" dependencies = [ "lazy_static", - "solana-clock", "solana-epoch-schedule", "solana-frozen-abi", "solana-frozen-abi-macro", @@ -7179,6 +7181,7 @@ version = "2.2.0" dependencies = [ "serde", "serde_derive", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", ] @@ -7689,6 +7692,7 @@ dependencies = [ "solana-pubkey", "solana-rent", "solana-sanitize", + "solana-sdk-ids", "solana-sdk-macro", "solana-secp256k1-recover", "solana-serde-varint", @@ -7939,11 +7943,25 @@ dependencies = [ "solana-clock", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", "static_assertions", ] +[[package]] +name = "solana-reserved-account-keys" +version = "2.2.0" +dependencies = [ + "lazy_static", + "solana-feature-set", + "solana-frozen-abi", + "solana-frozen-abi-macro", + "solana-program", + "solana-pubkey", + "solana-sdk-ids", +] + [[package]] name = "solana-reward-info" version = "2.2.0" @@ -8297,9 +8315,11 @@ dependencies = [ "solana-program", "solana-program-memory", "solana-pubkey", + "solana-reserved-account-keys", "solana-reward-info", "solana-sanitize", "solana-sdk", + "solana-sdk-ids", "solana-sdk-macro", "solana-secp256k1-recover", "solana-seed-derivable", @@ -8316,6 +8336,13 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "solana-sdk-ids" +version = "2.2.0" +dependencies = [ + "solana-pubkey", +] + [[package]] name = "solana-sdk-macro" version = "2.2.0" @@ -8457,6 +8484,7 @@ dependencies = [ "serde", "serde_derive", "solana-hash", + "solana-sdk-ids", "solana-sha256-hasher", "solana-sysvar-id", ] @@ -8468,6 +8496,7 @@ dependencies = [ "bv", "serde", "serde_derive", + "solana-sdk-ids", "solana-sysvar-id", ] @@ -8748,6 +8777,7 @@ name = "solana-sysvar-id" version = "2.2.0" dependencies = [ "solana-pubkey", + "solana-sdk-ids", ] [[package]] @@ -9245,6 +9275,7 @@ dependencies = [ "solana-instruction", "solana-pubkey", "solana-sdk", + "solana-sdk-ids", "subtle", "thiserror", "tiny-bip39", @@ -9306,6 +9337,7 @@ dependencies = [ "solana-instruction", "solana-pubkey", "solana-sdk", + "solana-sdk-ids", "subtle", "thiserror", "tiny-bip39", diff --git a/Cargo.toml b/Cargo.toml index 4481a65765ce93..01cad33e1ca027 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,7 +140,9 @@ members = [ "sdk/program-pack", "sdk/pubkey", "sdk/rent", + "sdk/reserved-account-keys", "sdk/sanitize", + "sdk/sdk-ids", "sdk/seed-derivable", "sdk/seed-phrase", "sdk/serde-varint", @@ -491,6 +493,7 @@ solana-quic-client = { path = "quic-client", version = "=2.2.0" } solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=2.2.0" } solana-remote-wallet = { path = "remote-wallet", version = "=2.2.0", default-features = false } solana-rent = { path = "sdk/rent", version = "=2.2.0", default-features = false } +solana-reserved-account-keys = { path = "sdk/reserved-account-keys", version = "=2.2.0", default-features = false } solana-reward-info = { path = "sdk/reward-info", version = "=2.2.0" } solana-sanitize = { path = "sdk/sanitize", version = "=2.2.0" } solana-seed-derivable = { path = "sdk/seed-derivable", version = "=2.2.0" } @@ -513,6 +516,7 @@ solana-rpc-client-nonce-utils = { path = "rpc-client-nonce-utils", version = "=2 solana-runtime = { path = "runtime", version = "=2.2.0" } solana-runtime-transaction = { path = "runtime-transaction", version = "=2.2.0" } solana-sdk = { path = "sdk", version = "=2.2.0" } +solana-sdk-ids = { path = "sdk/sdk-ids", version = "=2.2.0" } solana-sdk-macro = { path = "sdk/macro", version = "=2.2.0" } solana-secp256k1-recover = { path = "curves/secp256k1-recover", version = "=2.2.0", default-features = false } solana-send-transaction-service = { path = "send-transaction-service", version = "=2.2.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 498441efb8766f..71e3861b2b3d51 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5233,6 +5233,7 @@ version = "2.2.0" dependencies = [ "serde", "serde_derive", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", ] @@ -5478,6 +5479,7 @@ dependencies = [ "serde", "serde_derive", "solana-hash", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", ] @@ -5488,6 +5490,7 @@ version = "2.2.0" dependencies = [ "serde", "serde_derive", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", ] @@ -5519,7 +5522,6 @@ name = "solana-feature-set" version = "2.2.0" dependencies = [ "lazy_static", - "solana-clock", "solana-epoch-schedule", "solana-hash", "solana-pubkey", @@ -5709,6 +5711,7 @@ version = "2.2.0" dependencies = [ "serde", "serde_derive", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", ] @@ -6040,6 +6043,7 @@ dependencies = [ "solana-pubkey", "solana-rent", "solana-sanitize", + "solana-sdk-ids", "solana-sdk-macro", "solana-secp256k1-recover", "solana-serde-varint", @@ -6264,10 +6268,21 @@ version = "2.2.0" dependencies = [ "serde", "serde_derive", + "solana-sdk-ids", "solana-sdk-macro", "solana-sysvar-id", ] +[[package]] +name = "solana-reserved-account-keys" +version = "2.2.0" +dependencies = [ + "lazy_static", + "solana-feature-set", + "solana-pubkey", + "solana-sdk-ids", +] + [[package]] name = "solana-reward-info" version = "2.2.0" @@ -7033,8 +7048,10 @@ dependencies = [ "solana-program", "solana-program-memory", "solana-pubkey", + "solana-reserved-account-keys", "solana-reward-info", "solana-sanitize", + "solana-sdk-ids", "solana-sdk-macro", "solana-secp256k1-recover", "solana-seed-derivable", @@ -7049,6 +7066,13 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "solana-sdk-ids" +version = "2.2.0" +dependencies = [ + "solana-pubkey", +] + [[package]] name = "solana-sdk-macro" version = "2.2.0" @@ -7168,6 +7192,7 @@ dependencies = [ "serde", "serde_derive", "solana-hash", + "solana-sdk-ids", "solana-sysvar-id", ] @@ -7178,6 +7203,7 @@ dependencies = [ "bv", "serde", "serde_derive", + "solana-sdk-ids", "solana-sysvar-id", ] @@ -7349,6 +7375,7 @@ name = "solana-sysvar-id" version = "2.2.0" dependencies = [ "solana-pubkey", + "solana-sdk-ids", ] [[package]] @@ -7686,6 +7713,7 @@ dependencies = [ "solana-instruction", "solana-pubkey", "solana-sdk", + "solana-sdk-ids", "subtle", "thiserror", "wasm-bindgen", @@ -7732,6 +7760,7 @@ dependencies = [ "solana-instruction", "solana-pubkey", "solana-sdk", + "solana-sdk-ids", "subtle", "thiserror", "zeroize", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 4dd91e2277a944..cfef796073044f 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -116,8 +116,10 @@ solana-presigner = { workspace = true, optional = true } solana-program = { workspace = true } solana-program-memory = { workspace = true } solana-pubkey = { workspace = true, default-features = false, features = ["std"] } +solana-reserved-account-keys = { workspace = true } solana-reward-info = { workspace = true, features = ["serde"] } solana-sanitize = { workspace = true } +solana-sdk-ids = { workspace = true } solana-sdk-macro = { workspace = true } solana-secp256k1-recover = { workspace = true } solana-seed-derivable = { workspace = true, optional = true } diff --git a/sdk/clock/Cargo.toml b/sdk/clock/Cargo.toml index e9ac81b5389bc5..eea52e8db215ca 100644 --- a/sdk/clock/Cargo.toml +++ b/sdk/clock/Cargo.toml @@ -12,6 +12,7 @@ edition = { workspace = true } [dependencies] serde = { workspace = true, optional = true } serde_derive = { workspace = true, optional = true } +solana-sdk-ids = { workspace = true, optional = true } solana-sdk-macro = { workspace = true } solana-sysvar-id = { workspace = true, optional = true } @@ -21,7 +22,7 @@ static_assertions = { workspace = true } [features] serde = ["dep:serde", "dep:serde_derive"] -sysvar = ["dep:solana-sysvar-id"] +sysvar = ["dep:solana-sdk-ids", "dep:solana-sysvar-id"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/clock/src/sysvar.rs b/sdk/clock/src/sysvar.rs index 7011e8ead2d874..22c73417cd0691 100644 --- a/sdk/clock/src/sysvar.rs +++ b/sdk/clock/src/sysvar.rs @@ -1,3 +1,4 @@ -use {crate::Clock, solana_sysvar_id::declare_sysvar_id}; +pub use solana_sdk_ids::sysvar::clock::{check_id, id, ID}; +use {crate::Clock, solana_sysvar_id::impl_sysvar_id}; -declare_sysvar_id!("SysvarC1ock11111111111111111111111111111111", Clock); +impl_sysvar_id!(Clock); diff --git a/sdk/epoch-rewards/Cargo.toml b/sdk/epoch-rewards/Cargo.toml index 274e3f3a458340..800595db132fa4 100644 --- a/sdk/epoch-rewards/Cargo.toml +++ b/sdk/epoch-rewards/Cargo.toml @@ -15,6 +15,7 @@ serde_derive = { workspace = true, optional = true } solana-frozen-abi = { workspace = true, optional = true } solana-frozen-abi-macro = { workspace = true, optional = true } solana-hash = { workspace = true, default-features = false } +solana-sdk-ids = { workspace = true } solana-sdk-macro = { workspace = true } solana-sysvar-id = { workspace = true, optional = true } diff --git a/sdk/epoch-rewards/src/sysvar.rs b/sdk/epoch-rewards/src/sysvar.rs index 68564344d1312d..e8f44c741605de 100644 --- a/sdk/epoch-rewards/src/sysvar.rs +++ b/sdk/epoch-rewards/src/sysvar.rs @@ -1,3 +1,4 @@ -use {crate::EpochRewards, solana_sysvar_id::declare_sysvar_id}; +pub use solana_sdk_ids::sysvar::epoch_rewards::{check_id, id, ID}; +use {crate::EpochRewards, solana_sysvar_id::impl_sysvar_id}; -declare_sysvar_id!("SysvarEpochRewards1111111111111111111111111", EpochRewards); +impl_sysvar_id!(EpochRewards); diff --git a/sdk/epoch-schedule/Cargo.toml b/sdk/epoch-schedule/Cargo.toml index bf437b0dc88b08..f14efbd02608cd 100644 --- a/sdk/epoch-schedule/Cargo.toml +++ b/sdk/epoch-schedule/Cargo.toml @@ -14,6 +14,7 @@ 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-ids = { workspace = true, optional = true } solana-sdk-macro = { workspace = true } solana-sysvar-id = { workspace = true, optional = true } @@ -28,7 +29,7 @@ static_assertions = { workspace = true } [features] frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] serde = ["dep:serde", "dep:serde_derive"] -sysvar = ["dep:solana-sysvar-id"] +sysvar = ["dep:solana-sdk-ids", "dep:solana-sysvar-id"] [lints] workspace = true diff --git a/sdk/epoch-schedule/src/sysvar.rs b/sdk/epoch-schedule/src/sysvar.rs index ca4312ada02315..8520acebe4ef28 100644 --- a/sdk/epoch-schedule/src/sysvar.rs +++ b/sdk/epoch-schedule/src/sysvar.rs @@ -1,3 +1,4 @@ -use {crate::EpochSchedule, solana_sysvar_id::declare_sysvar_id}; +pub use solana_sdk_ids::sysvar::epoch_schedule::{check_id, id, ID}; +use {crate::EpochSchedule, solana_sysvar_id::impl_sysvar_id}; -declare_sysvar_id!("SysvarEpochSchedu1e111111111111111111111111", EpochSchedule); +impl_sysvar_id!(EpochSchedule); diff --git a/sdk/feature-set/Cargo.toml b/sdk/feature-set/Cargo.toml index 7352ff37a9680f..19b90755661a86 100644 --- a/sdk/feature-set/Cargo.toml +++ b/sdk/feature-set/Cargo.toml @@ -11,7 +11,6 @@ edition = { workspace = true } [dependencies] lazy_static = { workspace = true } -solana-clock = { workspace = true } solana-epoch-schedule = { workspace = true } solana-frozen-abi = { workspace = true, optional = true, features = [ "frozen-abi", diff --git a/sdk/feature-set/src/lib.rs b/sdk/feature-set/src/lib.rs index 8e62e812053c9e..83b556f5664a54 100644 --- a/sdk/feature-set/src/lib.rs +++ b/sdk/feature-set/src/lib.rs @@ -21,7 +21,6 @@ use { lazy_static::lazy_static, - solana_clock::{Epoch, Slot}, solana_epoch_schedule::EpochSchedule, solana_hash::Hash, solana_pubkey::Pubkey, @@ -1132,7 +1131,7 @@ lazy_static! { #[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] #[derive(Debug, Clone, Eq, PartialEq)] pub struct FeatureSet { - pub active: HashMap, + pub active: HashMap, pub inactive: HashSet, } impl Default for FeatureSet { @@ -1149,7 +1148,7 @@ impl FeatureSet { self.active.contains_key(feature_id) } - pub fn activated_slot(&self, feature_id: &Pubkey) -> Option { + pub fn activated_slot(&self, feature_id: &Pubkey) -> Option { self.active.get(feature_id).copied() } @@ -1181,7 +1180,7 @@ impl FeatureSet { } /// Activate a feature - pub fn activate(&mut self, feature_id: &Pubkey, slot: Slot) { + pub fn activate(&mut self, feature_id: &Pubkey, slot: u64) { self.inactive.remove(feature_id); self.active.insert(*feature_id, slot); } @@ -1192,7 +1191,7 @@ impl FeatureSet { self.inactive.insert(*feature_id); } - pub fn new_warmup_cooldown_rate_epoch(&self, epoch_schedule: &EpochSchedule) -> Option { + pub fn new_warmup_cooldown_rate_epoch(&self, epoch_schedule: &EpochSchedule) -> Option { self.activated_slot(&reduce_stake_warmup_cooldown::id()) .map(|slot| epoch_schedule.get_epoch(slot)) } diff --git a/sdk/last-restart-slot/Cargo.toml b/sdk/last-restart-slot/Cargo.toml index 8aa4b51bf4b350..8735fc9b214ead 100644 --- a/sdk/last-restart-slot/Cargo.toml +++ b/sdk/last-restart-slot/Cargo.toml @@ -12,12 +12,13 @@ edition = { workspace = true } [dependencies] serde = { workspace = true, optional = true } serde_derive = { workspace = true, optional = true } +solana-sdk-ids = { workspace = true, optional = true } solana-sdk-macro = { workspace = true } solana-sysvar-id = { workspace = true, optional = true } [features] serde = ["dep:serde", "dep:serde_derive"] -sysvar = ["dep:solana-sysvar-id"] +sysvar = ["dep:solana-sdk-ids", "dep:solana-sysvar-id"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/last-restart-slot/src/sysvar.rs b/sdk/last-restart-slot/src/sysvar.rs index 6d417aef8f6ed1..ded39f92f9b940 100644 --- a/sdk/last-restart-slot/src/sysvar.rs +++ b/sdk/last-restart-slot/src/sysvar.rs @@ -1,6 +1,4 @@ -use {crate::LastRestartSlot, solana_sysvar_id::declare_sysvar_id}; +pub use solana_sdk_ids::sysvar::last_restart_slot::{check_id, id, ID}; +use {crate::LastRestartSlot, solana_sysvar_id::impl_sysvar_id}; -declare_sysvar_id!( - "SysvarLastRestartS1ot1111111111111111111111", - LastRestartSlot -); +impl_sysvar_id!(LastRestartSlot); diff --git a/sdk/program/Cargo.toml b/sdk/program/Cargo.toml index 289f03e4fef09c..141773c4f789df 100644 --- a/sdk/program/Cargo.toml +++ b/sdk/program/Cargo.toml @@ -66,6 +66,7 @@ solana-program-pack = { workspace = true } solana-pubkey = { workspace = true, features = ["bytemuck", "curve25519", "serde", "std"] } solana-rent = { workspace = true, features = ["serde", "sysvar"] } solana-sanitize = { workspace = true } +solana-sdk-ids = { workspace = true } solana-sdk-macro = { workspace = true } solana-secp256k1-recover = { workspace = true } solana-serde-varint = { workspace = true } diff --git a/sdk/program/src/address_lookup_table/mod.rs b/sdk/program/src/address_lookup_table/mod.rs index 05a9f8cd1e96e1..b1d29aac360a6b 100644 --- a/sdk/program/src/address_lookup_table/mod.rs +++ b/sdk/program/src/address_lookup_table/mod.rs @@ -7,7 +7,7 @@ pub mod instruction; pub mod state; pub mod program { - crate::declare_id!("AddressLookupTab1e1111111111111111111111111"); + pub use solana_sdk_ids::address_lookup_table::{check_id, id, ID}; } /// The definition of address lookup table accounts. diff --git a/sdk/program/src/bpf_loader.rs b/sdk/program/src/bpf_loader.rs index fdfe14780f4d5c..c8cf69fe13ebf7 100644 --- a/sdk/program/src/bpf_loader.rs +++ b/sdk/program/src/bpf_loader.rs @@ -20,5 +20,4 @@ //! [`bpf_loader_deprecated`]: crate::bpf_loader_deprecated //! [`entrypoint_deprecated`]: mod@crate::entrypoint_deprecated //! [ubpfl]: crate::bpf_loader_upgradeable - -crate::declare_id!("BPFLoader2111111111111111111111111111111111"); +pub use solana_sdk_ids::bpf_loader::{check_id, id, ID}; diff --git a/sdk/program/src/bpf_loader_deprecated.rs b/sdk/program/src/bpf_loader_deprecated.rs index 1d4cea89ba6cf3..8662a5ec1a5cda 100644 --- a/sdk/program/src/bpf_loader_deprecated.rs +++ b/sdk/program/src/bpf_loader_deprecated.rs @@ -10,5 +10,4 @@ //! your program against the proper entrypoint semantics. All programs being //! deployed to this BPF loader must build against the deprecated entrypoint //! version located in `entrypoint_deprecated.rs`. - -crate::declare_id!("BPFLoader1111111111111111111111111111111111"); +pub use solana_sdk_ids::bpf_loader_deprecated::{check_id, id, ID}; diff --git a/sdk/program/src/bpf_loader_upgradeable.rs b/sdk/program/src/bpf_loader_upgradeable.rs index 82e9292fde2429..d0d7e4bca447a9 100644 --- a/sdk/program/src/bpf_loader_upgradeable.rs +++ b/sdk/program/src/bpf_loader_upgradeable.rs @@ -21,8 +21,7 @@ use crate::{ pubkey::Pubkey, system_instruction, sysvar, }; - -crate::declare_id!("BPFLoaderUpgradeab1e11111111111111111111111"); +pub use solana_sdk_ids::bpf_loader_upgradeable::{check_id, id, ID}; /// Upgradeable loader account states #[cfg_attr(feature = "frozen-abi", derive(AbiExample))] diff --git a/sdk/program/src/ed25519_program.rs b/sdk/program/src/ed25519_program.rs index 651761c869be56..a41385ad3dcbd3 100644 --- a/sdk/program/src/ed25519_program.rs +++ b/sdk/program/src/ed25519_program.rs @@ -1,5 +1,4 @@ //! The [ed25519 native program][np]. //! //! [np]: https://docs.solanalabs.com/runtime/programs#ed25519-program - -crate::declare_id!("Ed25519SigVerify111111111111111111111111111"); +pub use solana_sdk_ids::ed25519_program::{check_id, id, ID}; diff --git a/sdk/program/src/feature.rs b/sdk/program/src/feature.rs index af4ab1ad287636..2f4e8a9c9b73f3 100644 --- a/sdk/program/src/feature.rs +++ b/sdk/program/src/feature.rs @@ -11,6 +11,7 @@ //! 2. When the next epoch is entered the runtime will check for new activation requests and //! active them. When this occurs, the activation slot is recorded in the feature account +pub use solana_sdk_ids::feature::{check_id, id, ID}; use { crate::{ account_info::AccountInfo, instruction::Instruction, program_error::ProgramError, @@ -19,8 +20,6 @@ use { solana_clock::Slot, }; -crate::declare_id!("Feature111111111111111111111111111111111111"); - #[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct Feature { pub activated_at: Option, diff --git a/sdk/program/src/lib.rs b/sdk/program/src/lib.rs index 773850b2e057d3..55da6831369d8f 100644 --- a/sdk/program/src/lib.rs +++ b/sdk/program/src/lib.rs @@ -558,7 +558,7 @@ pub use { /// [np]: https://docs.solanalabs.com/runtime/programs#config-program pub mod config { pub mod program { - crate::declare_id!("Config1111111111111111111111111111111111111"); + pub use solana_sdk_ids::config::{check_id, id, ID}; } } diff --git a/sdk/program/src/loader_v4.rs b/sdk/program/src/loader_v4.rs index 4d5b0934534db7..9e26174a8f8480 100644 --- a/sdk/program/src/loader_v4.rs +++ b/sdk/program/src/loader_v4.rs @@ -8,8 +8,7 @@ use crate::{ pubkey::Pubkey, system_instruction, }; - -crate::declare_id!("LoaderV411111111111111111111111111111111111"); +pub use solana_sdk_ids::loader_v4::{check_id, id, ID}; /// Cooldown before a program can be un-/redeployed again pub const DEPLOYMENT_COOLDOWN_IN_SLOTS: u64 = 750; diff --git a/sdk/program/src/secp256k1_program.rs b/sdk/program/src/secp256k1_program.rs index fb09e7195a37ef..54a9f8365e877e 100644 --- a/sdk/program/src/secp256k1_program.rs +++ b/sdk/program/src/secp256k1_program.rs @@ -6,5 +6,4 @@ //! program's usage can be found in [`solana_sdk::secp256k1_instruction`]. //! //! [`solana_sdk::secp256k1_instruction`]: https://docs.rs/solana-sdk/latest/solana_sdk/secp256k1_instruction/index.html - -crate::declare_id!("KeccakSecp256k11111111111111111111111111111"); +pub use solana_sdk_ids::secp256k1_program::{check_id, id, ID}; diff --git a/sdk/program/src/stake/config.rs b/sdk/program/src/stake/config.rs index 6b7ddfc1ad6e0a..c5918568098b97 100644 --- a/sdk/program/src/stake/config.rs +++ b/sdk/program/src/stake/config.rs @@ -7,9 +7,8 @@ )] pub use super::state::{DEFAULT_SLASH_PENALTY, DEFAULT_WARMUP_COOLDOWN_RATE}; use serde_derive::{Deserialize, Serialize}; - // stake config ID -crate::declare_deprecated_id!("StakeConfig11111111111111111111111111111111"); +pub use solana_sdk_ids::stake::config::{check_id, id, ID}; #[deprecated( since = "1.16.7", diff --git a/sdk/program/src/stake/mod.rs b/sdk/program/src/stake/mod.rs index 31f13d4559a407..a35b98237d57b7 100644 --- a/sdk/program/src/stake/mod.rs +++ b/sdk/program/src/stake/mod.rs @@ -10,7 +10,7 @@ pub mod state; pub mod tools; pub mod program { - crate::declare_id!("Stake11111111111111111111111111111111111111"); + pub use solana_sdk_ids::stake::{check_id, id, ID}; } /// The minimum number of epochs before stake account that is delegated to a delinquent vote diff --git a/sdk/program/src/system_program.rs b/sdk/program/src/system_program.rs index e04e930540db73..d7315a63eb1cea 100644 --- a/sdk/program/src/system_program.rs +++ b/sdk/program/src/system_program.rs @@ -1,5 +1,4 @@ //! The [system native program][np]. //! //! [np]: https://docs.solanalabs.com/runtime/programs#system-program - -crate::declare_id!("11111111111111111111111111111111"); +pub use solana_sdk_ids::system_program::{check_id, id, ID}; diff --git a/sdk/program/src/sysvar/clock.rs b/sdk/program/src/sysvar/clock.rs index a91ee90d1aa9c8..9bfc179eefb347 100644 --- a/sdk/program/src/sysvar/clock.rs +++ b/sdk/program/src/sysvar/clock.rs @@ -127,9 +127,9 @@ //! ``` use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; -pub use solana_clock::{ - sysvar::{check_id, id, ID}, - Clock, +pub use { + solana_clock::Clock, + solana_sdk_ids::sysvar::clock::{check_id, id, ID}, }; impl Sysvar for Clock { diff --git a/sdk/program/src/sysvar/epoch_rewards.rs b/sdk/program/src/sysvar/epoch_rewards.rs index 13a4bc116fb02c..6d1f42d3f51c3e 100755 --- a/sdk/program/src/sysvar/epoch_rewards.rs +++ b/sdk/program/src/sysvar/epoch_rewards.rs @@ -160,9 +160,9 @@ //! ``` use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; -pub use solana_epoch_rewards::{ - sysvar::{check_id, id, ID}, - EpochRewards, +pub use { + solana_epoch_rewards::EpochRewards, + solana_sdk_ids::sysvar::epoch_rewards::{check_id, id, ID}, }; impl Sysvar for EpochRewards { diff --git a/sdk/program/src/sysvar/epoch_schedule.rs b/sdk/program/src/sysvar/epoch_schedule.rs index 96c453937b699d..97f5eede9560fe 100644 --- a/sdk/program/src/sysvar/epoch_schedule.rs +++ b/sdk/program/src/sysvar/epoch_schedule.rs @@ -126,9 +126,9 @@ //! # Ok::<(), anyhow::Error>(()) //! ``` use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; -pub use solana_epoch_schedule::{ - sysvar::{check_id, id, ID}, - EpochSchedule, +pub use { + solana_epoch_schedule::EpochSchedule, + solana_sdk_ids::sysvar::epoch_schedule::{check_id, id, ID}, }; impl Sysvar for EpochSchedule { diff --git a/sdk/program/src/sysvar/fees.rs b/sdk/program/src/sysvar/fees.rs index 4dde7b79562179..6d1473ab874259 100644 --- a/sdk/program/src/sysvar/fees.rs +++ b/sdk/program/src/sysvar/fees.rs @@ -20,15 +20,16 @@ #![allow(deprecated)] +pub use solana_sdk_ids::sysvar::fees::{check_id, id, ID}; use { crate::{ fee_calculator::FeeCalculator, impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar, }, solana_sdk_macro::CloneZeroed, - solana_sysvar_id::declare_deprecated_sysvar_id, + solana_sysvar_id::impl_deprecated_sysvar_id, }; -declare_deprecated_sysvar_id!("SysvarFees111111111111111111111111111111111", Fees); +impl_deprecated_sysvar_id!(Fees); /// Transaction fees. #[deprecated( diff --git a/sdk/program/src/sysvar/instructions.rs b/sdk/program/src/sysvar/instructions.rs index a3dc9aad23d0a3..4b6dcfa6ee17c4 100644 --- a/sdk/program/src/sysvar/instructions.rs +++ b/sdk/program/src/sysvar/instructions.rs @@ -31,6 +31,7 @@ #[cfg(feature = "dev-context-only-utils")] use qualifier_attr::qualifiers; +pub use solana_sdk_ids::sysvar::instructions::{check_id, id, ID}; #[cfg(not(target_os = "solana"))] use { crate::serialize_utils::{append_slice, append_u16, append_u8}, @@ -45,7 +46,6 @@ use { serialize_utils::{read_pubkey, read_slice, read_u16, read_u8}, }, solana_sanitize::SanitizeError, - solana_sysvar_id::declare_sysvar_id, }; /// Instructions sysvar, dummy type. @@ -60,7 +60,7 @@ use { /// Use the free functions in this module to access the instructions sysvar. pub struct Instructions(); -declare_sysvar_id!("Sysvar1nstructions1111111111111111111111111", Instructions); +solana_sysvar_id::impl_sysvar_id!(Instructions); /// Construct the account data for the instructions sysvar. /// diff --git a/sdk/program/src/sysvar/last_restart_slot.rs b/sdk/program/src/sysvar/last_restart_slot.rs index 97941786ba6a7f..efaae2f41ebfc1 100644 --- a/sdk/program/src/sysvar/last_restart_slot.rs +++ b/sdk/program/src/sysvar/last_restart_slot.rs @@ -40,9 +40,9 @@ //! use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; -pub use solana_last_restart_slot::{ - sysvar::{check_id, id, ID}, - LastRestartSlot, +pub use { + solana_last_restart_slot::LastRestartSlot, + solana_sdk_ids::sysvar::last_restart_slot::{check_id, id, ID}, }; impl Sysvar for LastRestartSlot { diff --git a/sdk/program/src/sysvar/mod.rs b/sdk/program/src/sysvar/mod.rs index 2325e0070a2348..97ec8d341d4d2d 100644 --- a/sdk/program/src/sysvar/mod.rs +++ b/sdk/program/src/sysvar/mod.rs @@ -83,11 +83,12 @@ use crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; #[deprecated(since = "2.1.0", note = "Use `solana-sysvar-id` crate instead")] -pub use solana_sysvar_id::{ - check_id, declare_deprecated_sysvar_id, declare_sysvar_id, id, SysvarId, ID, -}; +pub use solana_sysvar_id::{declare_deprecated_sysvar_id, declare_sysvar_id, SysvarId}; #[allow(deprecated)] -pub use sysvar_ids::ALL_IDS; +pub use { + solana_sdk_ids::sysvar::{check_id, id, ID}, + sysvar_ids::ALL_IDS, +}; pub mod clock; pub mod epoch_rewards; diff --git a/sdk/program/src/sysvar/recent_blockhashes.rs b/sdk/program/src/sysvar/recent_blockhashes.rs index ecbbba0e66865e..80c39179688846 100644 --- a/sdk/program/src/sysvar/recent_blockhashes.rs +++ b/sdk/program/src/sysvar/recent_blockhashes.rs @@ -18,9 +18,10 @@ #![allow(deprecated)] #![allow(clippy::arithmetic_side_effects)] +pub use solana_sdk_ids::sysvar::recent_blockhashes::{check_id, id, ID}; use { crate::{fee_calculator::FeeCalculator, hash::Hash, sysvar::Sysvar}, - solana_sysvar_id::declare_deprecated_sysvar_id, + solana_sysvar_id::impl_sysvar_id, std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref}, }; @@ -30,10 +31,7 @@ use { )] pub const MAX_ENTRIES: usize = 150; -declare_deprecated_sysvar_id!( - "SysvarRecentB1ockHashes11111111111111111111", - RecentBlockhashes -); +impl_sysvar_id!(RecentBlockhashes); #[deprecated( since = "1.9.0", diff --git a/sdk/program/src/sysvar/rent.rs b/sdk/program/src/sysvar/rent.rs index a19ccea0b4abff..9be8be38764567 100644 --- a/sdk/program/src/sysvar/rent.rs +++ b/sdk/program/src/sysvar/rent.rs @@ -127,9 +127,9 @@ //! # Ok::<(), anyhow::Error>(()) //! ``` use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; -pub use solana_rent::{ - sysvar::{check_id, id, ID}, - Rent, +pub use { + solana_rent::Rent, + solana_sdk_ids::sysvar::rent::{check_id, id, ID}, }; impl Sysvar for Rent { diff --git a/sdk/program/src/sysvar/rewards.rs b/sdk/program/src/sysvar/rewards.rs index cca44cd4582024..4727117c731819 100644 --- a/sdk/program/src/sysvar/rewards.rs +++ b/sdk/program/src/sysvar/rewards.rs @@ -1,8 +1,8 @@ //! This sysvar is deprecated and unused. +pub use solana_sdk_ids::sysvar::rewards::{check_id, id, ID}; +use {crate::sysvar::Sysvar, solana_sysvar_id::impl_sysvar_id}; -use {crate::sysvar::Sysvar, solana_sysvar_id::declare_sysvar_id}; - -declare_sysvar_id!("SysvarRewards111111111111111111111111111111", Rewards); +impl_sysvar_id!(Rewards); #[repr(C)] #[derive(Serialize, Deserialize, Debug, Default, PartialEq)] diff --git a/sdk/program/src/sysvar/slot_hashes.rs b/sdk/program/src/sysvar/slot_hashes.rs index 699be16a2ee6e0..edc629129b75d6 100644 --- a/sdk/program/src/sysvar/slot_hashes.rs +++ b/sdk/program/src/sysvar/slot_hashes.rs @@ -60,10 +60,8 @@ use { const U64_SIZE: usize = std::mem::size_of::(); pub use { - solana_slot_hashes::{ - sysvar::{check_id, id, ID}, - SlotHashes, - }, + solana_sdk_ids::sysvar::slot_hashes::{check_id, id, ID}, + solana_slot_hashes::SlotHashes, solana_sysvar_id::SysvarId, }; diff --git a/sdk/program/src/sysvar/slot_history.rs b/sdk/program/src/sysvar/slot_history.rs index 3d75b653bfec2a..df1e3a6781a86c 100644 --- a/sdk/program/src/sysvar/slot_history.rs +++ b/sdk/program/src/sysvar/slot_history.rs @@ -50,10 +50,8 @@ use crate::sysvar::Sysvar; pub use { crate::{account_info::AccountInfo, program_error::ProgramError}, - solana_slot_history::{ - sysvar::{check_id, id, ID}, - SlotHistory, - }, + solana_sdk_ids::sysvar::slot_history::{check_id, id, ID}, + solana_slot_history::SlotHistory, }; impl Sysvar for SlotHistory { diff --git a/sdk/program/src/sysvar/stake_history.rs b/sdk/program/src/sysvar/stake_history.rs index 28920cd25b0878..4407375f22f351 100644 --- a/sdk/program/src/sysvar/stake_history.rs +++ b/sdk/program/src/sysvar/stake_history.rs @@ -45,17 +45,20 @@ //! # Ok::<(), anyhow::Error>(()) //! ``` -pub use crate::stake_history::StakeHistory; +pub use { + crate::stake_history::StakeHistory, + solana_sdk_ids::sysvar::stake_history::{check_id, id, ID}, +}; use { crate::{ stake_history::{StakeHistoryEntry, StakeHistoryGetEntry, MAX_ENTRIES}, sysvar::{get_sysvar, Sysvar, SysvarId}, }, solana_clock::Epoch, - solana_sysvar_id::declare_sysvar_id, + solana_sysvar_id::impl_sysvar_id, }; -declare_sysvar_id!("SysvarStakeHistory1111111111111111111111111", StakeHistory); +impl_sysvar_id!(StakeHistory); impl Sysvar for StakeHistory { // override diff --git a/sdk/program/src/vote/mod.rs b/sdk/program/src/vote/mod.rs index c26134c1a42450..b1417990321b36 100644 --- a/sdk/program/src/vote/mod.rs +++ b/sdk/program/src/vote/mod.rs @@ -8,5 +8,5 @@ pub mod instruction; pub mod state; pub mod program { - crate::declare_id!("Vote111111111111111111111111111111111111111"); + pub use solana_sdk_ids::vote::{check_id, id, ID}; } diff --git a/sdk/rent/Cargo.toml b/sdk/rent/Cargo.toml index 50d41d1a0cbd96..44a53b8697620c 100644 --- a/sdk/rent/Cargo.toml +++ b/sdk/rent/Cargo.toml @@ -14,6 +14,7 @@ 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-ids = { workspace = true, optional = true } solana-sdk-macro = { workspace = true } solana-sysvar-id = { workspace = true, optional = true } @@ -24,7 +25,7 @@ static_assertions = { workspace = true } [features] frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] serde = ["dep:serde", "dep:serde_derive"] -sysvar = ["dep:solana-sysvar-id"] +sysvar = ["dep:solana-sdk-ids", "dep:solana-sysvar-id"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/rent/src/sysvar.rs b/sdk/rent/src/sysvar.rs index 975ccfff814fb9..81a7cda893304b 100644 --- a/sdk/rent/src/sysvar.rs +++ b/sdk/rent/src/sysvar.rs @@ -1,3 +1,4 @@ -use {crate::Rent, solana_sysvar_id::declare_sysvar_id}; +pub use solana_sdk_ids::sysvar::rent::{check_id, id, ID}; +use {crate::Rent, solana_sysvar_id::impl_sysvar_id}; -declare_sysvar_id!("SysvarRent111111111111111111111111111111111", Rent); +impl_sysvar_id!(Rent); diff --git a/sdk/reserved-account-keys/Cargo.toml b/sdk/reserved-account-keys/Cargo.toml new file mode 100644 index 00000000000000..d42aaa74c2780b --- /dev/null +++ b/sdk/reserved-account-keys/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "solana-reserved-account-keys" +description = "Reserved Solana account keys" +documentation = "https://docs.rs/solana-reserved-account-keys" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[dependencies] +lazy_static = { workspace = true } +solana-feature-set = { workspace = true } +solana-frozen-abi = { workspace = true, optional = true, features = [ + "frozen-abi", +] } +solana-frozen-abi-macro = { workspace = true, optional = true, features = [ + "frozen-abi", +] } +solana-pubkey = { workspace = true, default-features = false } +solana-sdk-ids = { workspace = true } + +[dev-dependencies] +solana-program = { path = "../program" } + +[features] +frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] +all-features = true +rustdoc-args = ["--cfg=docsrs"] + +[lints] +workspace = true diff --git a/sdk/src/reserved_account_keys.rs b/sdk/reserved-account-keys/src/lib.rs similarity index 93% rename from sdk/src/reserved_account_keys.rs rename to sdk/reserved-account-keys/src/lib.rs index 49cde7fd9bcd79..2f7a55c83c2ea7 100644 --- a/sdk/src/reserved_account_keys.rs +++ b/sdk/reserved-account-keys/src/lib.rs @@ -1,30 +1,21 @@ //! Collection of reserved account keys that cannot be write-locked by transactions. //! New reserved account keys may be added as long as they specify a feature //! gate that transitions the key into read-only at an epoch boundary. - -#![cfg(feature = "full")] - +#![cfg_attr(feature = "frozen-abi", feature(min_specialization))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] use { - crate::{ - address_lookup_table, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, - compute_budget, config, ed25519_program, feature, loader_v4, native_loader, pubkey::Pubkey, - secp256k1_program, stake, system_program, sysvar, vote, - }, lazy_static::lazy_static, solana_feature_set::{self as feature_set, FeatureSet}, + solana_pubkey::Pubkey, + solana_sdk_ids::{ + address_lookup_table, bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, + compute_budget, config, ed25519_program, feature, loader_v4, native_loader, + secp256k1_program, stake, system_program, sysvar, vote, zk_elgamal_proof_program, + zk_token_proof_program, + }, std::collections::{HashMap, HashSet}, }; -// Inline zk token program id since it isn't available in the sdk -mod zk_token_proof_program { - solana_sdk::declare_id!("ZkTokenProof1111111111111111111111111111111"); -} - -// Inline zk-elgamal-proof program id since it isn't available in the sdk -mod zk_elgamal_proof_program { - solana_sdk::declare_id!("ZkE1Gama1Proof11111111111111111111111111111"); -} - // ReservedAccountKeys is not serialized into or deserialized from bank // snapshots but the bank requires this trait to be implemented anyways. #[cfg(feature = "frozen-abi")] @@ -150,21 +141,21 @@ impl ReservedAccount { lazy_static! { static ref RESERVED_ACCOUNTS: Vec = [ // builtin programs - ReservedAccount::new_pending(address_lookup_table::program::id(), feature_set::add_new_reserved_account_keys::id()), + ReservedAccount::new_pending(address_lookup_table::id(), feature_set::add_new_reserved_account_keys::id()), ReservedAccount::new_active(bpf_loader::id()), ReservedAccount::new_active(bpf_loader_deprecated::id()), ReservedAccount::new_active(bpf_loader_upgradeable::id()), ReservedAccount::new_pending(compute_budget::id(), feature_set::add_new_reserved_account_keys::id()), - ReservedAccount::new_active(config::program::id()), + ReservedAccount::new_active(config::id()), ReservedAccount::new_pending(ed25519_program::id(), feature_set::add_new_reserved_account_keys::id()), ReservedAccount::new_active(feature::id()), ReservedAccount::new_pending(loader_v4::id(), feature_set::add_new_reserved_account_keys::id()), ReservedAccount::new_pending(secp256k1_program::id(), feature_set::add_new_reserved_account_keys::id()), #[allow(deprecated)] ReservedAccount::new_active(stake::config::id()), - ReservedAccount::new_active(stake::program::id()), + ReservedAccount::new_active(stake::id()), ReservedAccount::new_active(system_program::id()), - ReservedAccount::new_active(vote::program::id()), + ReservedAccount::new_active(vote::id()), ReservedAccount::new_pending(zk_elgamal_proof_program::id(), feature_set::add_new_reserved_account_keys::id()), ReservedAccount::new_pending(zk_token_proof_program::id(), feature_set::add_new_reserved_account_keys::id()), diff --git a/sdk/sdk-ids/Cargo.toml b/sdk/sdk-ids/Cargo.toml new file mode 100644 index 00000000000000..adb61e6411c080 --- /dev/null +++ b/sdk/sdk-ids/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "solana-sdk-ids" +description = "Solana SDK IDs" +documentation = "https://docs.rs/solana-sdk-ids" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[dependencies] +solana-pubkey = { workspace = true, default-features = false } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[lints] +workspace = true diff --git a/sdk/sdk-ids/src/lib.rs b/sdk/sdk-ids/src/lib.rs new file mode 100644 index 00000000000000..b63265b61af20c --- /dev/null +++ b/sdk/sdk-ids/src/lib.rs @@ -0,0 +1,109 @@ +#![no_std] + +pub mod address_lookup_table { + solana_pubkey::declare_id!("AddressLookupTab1e1111111111111111111111111"); +} + +pub mod bpf_loader { + solana_pubkey::declare_id!("BPFLoader2111111111111111111111111111111111"); +} + +pub mod bpf_loader_deprecated { + solana_pubkey::declare_id!("BPFLoader1111111111111111111111111111111111"); +} + +pub mod bpf_loader_upgradeable { + solana_pubkey::declare_id!("BPFLoaderUpgradeab1e11111111111111111111111"); +} + +pub mod compute_budget { + solana_pubkey::declare_id!("ComputeBudget111111111111111111111111111111"); +} + +pub mod config { + solana_pubkey::declare_id!("Config1111111111111111111111111111111111111"); +} + +pub mod ed25519_program { + solana_pubkey::declare_id!("Ed25519SigVerify111111111111111111111111111"); +} + +pub mod feature { + solana_pubkey::declare_id!("Feature111111111111111111111111111111111111"); +} + +pub mod loader_v4 { + solana_pubkey::declare_id!("LoaderV411111111111111111111111111111111111"); +} + +pub mod native_loader { + solana_pubkey::declare_id!("NativeLoader1111111111111111111111111111111"); +} + +pub mod secp256k1_program { + solana_pubkey::declare_id!("KeccakSecp256k11111111111111111111111111111"); +} + +pub mod stake { + pub mod config { + solana_pubkey::declare_deprecated_id!("StakeConfig11111111111111111111111111111111"); + } + solana_pubkey::declare_id!("Stake11111111111111111111111111111111111111"); +} + +pub mod system_program { + solana_pubkey::declare_id!("11111111111111111111111111111111"); +} + +pub mod vote { + solana_pubkey::declare_id!("Vote111111111111111111111111111111111111111"); +} + +pub mod sysvar { + // Owner pubkey for sysvar accounts + solana_pubkey::declare_id!("Sysvar1111111111111111111111111111111111111"); + pub mod clock { + solana_pubkey::declare_id!("SysvarC1ock11111111111111111111111111111111"); + } + pub mod epoch_rewards { + solana_pubkey::declare_id!("SysvarEpochRewards1111111111111111111111111"); + } + pub mod epoch_schedule { + solana_pubkey::declare_id!("SysvarEpochSchedu1e111111111111111111111111"); + } + pub mod fees { + solana_pubkey::declare_id!("SysvarFees111111111111111111111111111111111"); + } + pub mod instructions { + solana_pubkey::declare_id!("Sysvar1nstructions1111111111111111111111111"); + } + pub mod last_restart_slot { + solana_pubkey::declare_id!("SysvarLastRestartS1ot1111111111111111111111"); + } + pub mod recent_blockhashes { + solana_pubkey::declare_id!("SysvarRecentB1ockHashes11111111111111111111"); + } + pub mod rent { + solana_pubkey::declare_id!("SysvarRent111111111111111111111111111111111"); + } + pub mod rewards { + solana_pubkey::declare_id!("SysvarRewards111111111111111111111111111111"); + } + pub mod slot_hashes { + solana_pubkey::declare_id!("SysvarS1otHashes111111111111111111111111111"); + } + pub mod slot_history { + solana_pubkey::declare_id!("SysvarS1otHistory11111111111111111111111111"); + } + pub mod stake_history { + solana_pubkey::declare_id!("SysvarStakeHistory1111111111111111111111111"); + } +} + +pub mod zk_token_proof_program { + solana_pubkey::declare_id!("ZkTokenProof1111111111111111111111111111111"); +} + +pub mod zk_elgamal_proof_program { + solana_pubkey::declare_id!("ZkE1Gama1Proof11111111111111111111111111111"); +} diff --git a/sdk/slot-hashes/Cargo.toml b/sdk/slot-hashes/Cargo.toml index 9dcaaae7f53a64..d26ad580971d48 100644 --- a/sdk/slot-hashes/Cargo.toml +++ b/sdk/slot-hashes/Cargo.toml @@ -13,6 +13,7 @@ edition = { workspace = true } serde = { workspace = true, optional = true } serde_derive = { workspace = true, optional = true } solana-hash = { workspace = true, default-features = false } +solana-sdk-ids = { workspace = true, optional = true } solana-sysvar-id = { workspace = true, optional = true } [dev-dependencies] @@ -20,7 +21,7 @@ solana-sha256-hasher = { workspace = true } [features] serde = ["dep:serde", "dep:serde_derive", "solana-hash/serde"] -sysvar = ["dep:solana-sysvar-id"] +sysvar = ["dep:solana-sdk-ids", "dep:solana-sysvar-id"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/slot-hashes/src/sysvar.rs b/sdk/slot-hashes/src/sysvar.rs index dc1ab435c472ca..2760c419a267b8 100644 --- a/sdk/slot-hashes/src/sysvar.rs +++ b/sdk/slot-hashes/src/sysvar.rs @@ -1,3 +1,4 @@ -use {crate::SlotHashes, solana_sysvar_id::declare_sysvar_id}; +pub use solana_sdk_ids::sysvar::slot_hashes::{check_id, id, ID}; +use {crate::SlotHashes, solana_sysvar_id::impl_sysvar_id}; -declare_sysvar_id!("SysvarS1otHashes111111111111111111111111111", SlotHashes); +impl_sysvar_id!(SlotHashes); diff --git a/sdk/slot-history/Cargo.toml b/sdk/slot-history/Cargo.toml index 7c37333cfdeec2..aa74231e7649dd 100644 --- a/sdk/slot-history/Cargo.toml +++ b/sdk/slot-history/Cargo.toml @@ -13,11 +13,12 @@ edition = { workspace = true } bv = { workspace = true } serde = { workspace = true, optional = true } serde_derive = { workspace = true, optional = true } +solana-sdk-ids = { workspace = true, optional = true } solana-sysvar-id = { workspace = true, optional = true } [features] serde = ["dep:serde", "dep:serde_derive", "bv/serde"] -sysvar = ["dep:solana-sysvar-id"] +sysvar = ["dep:solana-sdk-ids", "dep:solana-sysvar-id"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/slot-history/src/sysvar.rs b/sdk/slot-history/src/sysvar.rs index e5f675d51d8a7a..807591f9fd6a5a 100644 --- a/sdk/slot-history/src/sysvar.rs +++ b/sdk/slot-history/src/sysvar.rs @@ -1,3 +1,4 @@ -use {crate::SlotHistory, solana_sysvar_id::declare_sysvar_id}; +pub use solana_sdk_ids::sysvar::slot_history::{check_id, id, ID}; +use {crate::SlotHistory, solana_sysvar_id::impl_sysvar_id}; -declare_sysvar_id!("SysvarS1otHistory11111111111111111111111111", SlotHistory); +impl_sysvar_id!(SlotHistory); diff --git a/sdk/src/compute_budget.rs b/sdk/src/compute_budget.rs index 8a3614f07e8f93..97408105636625 100644 --- a/sdk/src/compute_budget.rs +++ b/sdk/src/compute_budget.rs @@ -2,14 +2,13 @@ #![cfg(feature = "full")] +pub use solana_sdk_ids::compute_budget::{check_id, id, ID}; #[cfg(feature = "borsh")] use { crate::instruction::Instruction, borsh::{BorshDeserialize, BorshSerialize}, }; -crate::declare_id!("ComputeBudget111111111111111111111111111111"); - /// Compute Budget Instructions #[cfg_attr(feature = "frozen-abi", derive(AbiExample, AbiEnumVisitor))] #[cfg_attr(feature = "borsh", derive(BorshSerialize, BorshDeserialize))] diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 7a67f719523cbd..8b52dfa8704d8c 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -88,7 +88,6 @@ pub mod pubkey; pub mod quic; pub mod rent_collector; pub mod rent_debits; -pub mod reserved_account_keys; #[deprecated(since = "2.2.0", note = "Use `solana-reward-info` crate instead")] pub mod reward_info { pub use solana_reward_info::RewardInfo; @@ -149,6 +148,12 @@ pub use solana_program_memory as program_memory; /// assert_eq!(ID, my_id); /// ``` pub use solana_pubkey::pubkey; +#[cfg(feature = "full")] +#[deprecated( + since = "2.2.0", + note = "Use `solana-reserved-account-keys` crate instead" +)] +pub use solana_reserved_account_keys as reserved_account_keys; #[deprecated(since = "2.1.0", note = "Use `solana-sanitize` crate instead")] pub use solana_sanitize as sanitize; /// Same as `declare_id` except report that this id has been deprecated. diff --git a/sdk/src/native_loader.rs b/sdk/src/native_loader.rs index 1f32d3988fcf58..976a758b20e90d 100644 --- a/sdk/src/native_loader.rs +++ b/sdk/src/native_loader.rs @@ -3,8 +3,7 @@ use solana_account::{ Account, AccountSharedData, InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS, }; - -crate::declare_id!("NativeLoader1111111111111111111111111111111"); +pub use solana_sdk_ids::native_loader::{check_id, id, ID}; /// Create an executable account with the given shared object name. pub fn create_loadable_account_with_fields( diff --git a/sdk/sysvar-id/Cargo.toml b/sdk/sysvar-id/Cargo.toml index 93996fa991dd44..a934b10f898181 100644 --- a/sdk/sysvar-id/Cargo.toml +++ b/sdk/sysvar-id/Cargo.toml @@ -11,6 +11,7 @@ edition = { workspace = true } [dependencies] solana-pubkey = { workspace = true, default-features = false } +solana-sdk-ids = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/sysvar-id/src/lib.rs b/sdk/sysvar-id/src/lib.rs index c67c68a72813b4..aa6c7d4cb3a036 100644 --- a/sdk/sysvar-id/src/lib.rs +++ b/sdk/sysvar-id/src/lib.rs @@ -19,7 +19,10 @@ //! [sysvardoc]: https://docs.solanalabs.com/runtime/sysvars /// Re-export types required for macros -pub use solana_pubkey::{declare_deprecated_id, declare_id, Pubkey}; +pub use { + solana_pubkey::{declare_deprecated_id, declare_id, Pubkey}, + solana_sdk_ids::sysvar::{check_id, id, ID}, +}; /// A type that holds sysvar data and has an associated sysvar `Pubkey`. pub trait SysvarId { @@ -30,12 +33,11 @@ pub trait SysvarId { fn check_id(pubkey: &Pubkey) -> bool; } -/// Declares an ID that implements [`SysvarId`]. +/// Implements [`SysvarId`] for a module that already uses +/// `declare_id`` #[macro_export] -macro_rules! declare_sysvar_id( - ($name:expr, $type:ty) => ( - $crate::declare_id!($name); - +macro_rules! impl_sysvar_id( + ($type:ty) => { impl $crate::SysvarId for $type { fn id() -> $crate::Pubkey { id() @@ -45,15 +47,14 @@ macro_rules! declare_sysvar_id( check_id(pubkey) } } - ) + } ); -/// Same as [`declare_sysvar_id`] except that it reports that this ID has been deprecated. +/// Implements [`SysvarId`] for a module that already uses +/// `declare_deprecated_id`` #[macro_export] -macro_rules! declare_deprecated_sysvar_id( - ($name:expr, $type:ty) => ( - $crate::declare_deprecated_id!($name); - +macro_rules! impl_deprecated_sysvar_id( + ($type:ty) => { impl $crate::SysvarId for $type { fn id() -> $crate::Pubkey { #[allow(deprecated)] @@ -65,8 +66,23 @@ macro_rules! declare_deprecated_sysvar_id( check_id(pubkey) } } + } +); + +/// Declares an ID that implements [`SysvarId`]. +#[macro_export] +macro_rules! declare_sysvar_id( + ($name:expr, $type:ty) => ( + $crate::declare_id!($name); + impl_sysvar_id!($type); ) ); -// Owner pubkey for sysvar accounts -solana_pubkey::declare_id!("Sysvar1111111111111111111111111111111111111"); +/// Same as [`declare_sysvar_id`] except that it reports that this ID has been deprecated. +#[macro_export] +macro_rules! declare_deprecated_sysvar_id( + ($name:expr, $type:ty) => ( + $crate::declare_deprecated_id!($name); + impl_deprecated_sysvar_id!($type); + ) +); diff --git a/zk-sdk/Cargo.toml b/zk-sdk/Cargo.toml index 878d5dafb7d912..ef68ca0b03a433 100644 --- a/zk-sdk/Cargo.toml +++ b/zk-sdk/Cargo.toml @@ -18,6 +18,7 @@ num-derive = { workspace = true } num-traits = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } solana-pubkey = { workspace = true } +solana-sdk-ids = { workspace = true } thiserror = { workspace = true } [dev-dependencies] diff --git a/zk-sdk/src/zk_elgamal_proof_program/mod.rs b/zk-sdk/src/zk_elgamal_proof_program/mod.rs index b5ad2e6a9ebf75..dd1d9a09a6f94e 100644 --- a/zk-sdk/src/zk_elgamal_proof_program/mod.rs +++ b/zk-sdk/src/zk_elgamal_proof_program/mod.rs @@ -13,4 +13,4 @@ pub mod proof_data; pub mod state; // Program Id of the ZK ElGamal Proof program -solana_pubkey::declare_id!("ZkE1Gama1Proof11111111111111111111111111111"); +pub use solana_sdk_ids::zk_elgamal_proof_program::{check_id, id, ID}; diff --git a/zk-token-sdk/Cargo.toml b/zk-token-sdk/Cargo.toml index f5e431f54c94ae..00b13ef25e4a85 100644 --- a/zk-token-sdk/Cargo.toml +++ b/zk-token-sdk/Cargo.toml @@ -18,6 +18,7 @@ num-traits = { workspace = true } solana-curve25519 = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } solana-pubkey = { workspace = true } +solana-sdk-ids = { workspace = true } thiserror = { workspace = true } [dev-dependencies] diff --git a/zk-token-sdk/src/zk_token_proof_program.rs b/zk-token-sdk/src/zk_token_proof_program.rs index 6b8e5cfa39026a..1a2cdc29d1b7f9 100644 --- a/zk-token-sdk/src/zk_token_proof_program.rs +++ b/zk-token-sdk/src/zk_token_proof_program.rs @@ -8,4 +8,4 @@ //! [`ZK Token proof`]: https://docs.solanalabs.com/runtime/zk-token-proof // Program Id of the ZkToken Proof program -solana_pubkey::declare_id!("ZkTokenProof1111111111111111111111111111111"); +pub use solana_sdk_ids::zk_token_proof_program::{check_id, id, ID};