From bbaf86001d7821c926147bc468745fdf9d73b3ea Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Thu, 5 Dec 2024 11:48:25 +0900 Subject: [PATCH 1/7] sdk: evict hard_forks --- Cargo.lock | 12 +++++++++ Cargo.toml | 2 ++ programs/sbf/Cargo.lock | 10 +++++++ sdk/Cargo.toml | 4 +++ sdk/hard-forks/Cargo.toml | 27 +++++++++++++++++++ .../hard_forks.rs => hard-forks/src/lib.rs} | 23 ++++++++-------- sdk/src/lib.rs | 4 ++- svm/examples/Cargo.lock | 10 +++++++ 8 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 sdk/hard-forks/Cargo.toml rename sdk/{src/hard_forks.rs => hard-forks/src/lib.rs} (82%) diff --git a/Cargo.lock b/Cargo.lock index ffb1e84cb93d48..e53d5ab297994b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7309,6 +7309,17 @@ dependencies = [ "thiserror 2.0.6", ] +[[package]] +name = "solana-hard-forks" +version = "2.2.0" +dependencies = [ + "byteorder", + "serde", + "serde_derive", + "solana-frozen-abi", + "solana-frozen-abi-macro", +] + [[package]] name = "solana-hash" version = "2.2.0" @@ -8705,6 +8716,7 @@ dependencies = [ "solana-fee-structure", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-hard-forks", "solana-inflation", "solana-instruction", "solana-keypair", diff --git a/Cargo.toml b/Cargo.toml index f523b220afa0a6..d87e45fd9fe75b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,6 +132,7 @@ members = [ "sdk/frozen-abi", "sdk/frozen-abi/macro", "sdk/gen-headers", + "sdk/hard-forks", "sdk/hash", "sdk/inflation", "sdk/instruction", @@ -491,6 +492,7 @@ 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" } solana-gossip = { path = "gossip", version = "=2.2.0" } +solana-hard-forks = { path = "sdk/hard-forks", version = "=2.2.0", default-features = false } solana-hash = { path = "sdk/hash", version = "=2.2.0", default-features = false } solana-inflation = { path = "sdk/inflation", version = "=2.2.0" } solana-inline-spl = { path = "inline-spl", version = "=2.2.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 4413415c55e15f..caf88f47b683de 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5833,6 +5833,15 @@ dependencies = [ "thiserror 2.0.6", ] +[[package]] +name = "solana-hard-forks" +version = "2.2.0" +dependencies = [ + "byteorder 1.5.0", + "serde", + "serde_derive", +] + [[package]] name = "solana-hash" version = "2.2.0" @@ -7370,6 +7379,7 @@ dependencies = [ "solana-epoch-rewards-hasher", "solana-feature-set", "solana-fee-structure", + "solana-hard-forks", "solana-inflation", "solana-instruction", "solana-keypair", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 05d955899eb461..f6975339e141ed 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -39,6 +39,7 @@ full = [ "dep:solana-cluster-type", "dep:solana-ed25519-program", "dep:solana-compute-budget-interface", + "dep:solana-hard-forks", "dep:solana-keypair", "dep:solana-offchain-message", "dep:solana-precompile-error", @@ -140,6 +141,9 @@ solana-frozen-abi = { workspace = true, optional = true, features = [ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } +solana-hard-forks = { workspace = true, features = [ + "serde", +], optional = true } solana-inflation = { workspace = true, features = ["serde"] } solana-instruction = { workspace = true } solana-keypair = { workspace = true, optional = true, features = [ diff --git a/sdk/hard-forks/Cargo.toml b/sdk/hard-forks/Cargo.toml new file mode 100644 index 00000000000000..51f4a7f37fc4c9 --- /dev/null +++ b/sdk/hard-forks/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "solana-hard-forks" +description = "The list of slot boundaries at which a hard fork should occur." +documentation = "https://docs.rs/solana-hard-forks" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[dependencies] +byteorder = { workspace = true } +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 } + +[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 diff --git a/sdk/src/hard_forks.rs b/sdk/hard-forks/src/lib.rs similarity index 82% rename from sdk/src/hard_forks.rs rename to sdk/hard-forks/src/lib.rs index dda66a2949138d..56348ae1b2a73b 100644 --- a/sdk/src/hard_forks.rs +++ b/sdk/hard-forks/src/lib.rs @@ -1,21 +1,22 @@ //! The list of slot boundaries at which a hard fork should //! occur. -#![cfg(feature = "full")] +#![cfg_attr(feature = "frozen-abi", feature(min_specialization))] -use { - byteorder::{ByteOrder, LittleEndian}, - solana_sdk::clock::Slot, -}; +use byteorder::{ByteOrder, LittleEndian}; -#[cfg_attr(feature = "frozen-abi", derive(AbiExample))] -#[derive(Default, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +#[cfg_attr(feature = "frozen-abi", derive(solana_frozen_abi_macro::AbiExample))] +#[cfg_attr( + feature = "serde", + derive(serde_derive::Deserialize, serde_derive::Serialize) +)] +#[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct HardForks { - hard_forks: Vec<(Slot, usize)>, + hard_forks: Vec<(u64, usize)>, } impl HardForks { // Register a fork to occur at all slots >= `slot` with a parent slot < `slot` - pub fn register(&mut self, new_slot: Slot) { + pub fn register(&mut self, new_slot: u64) { if let Some(i) = self .hard_forks .iter() @@ -30,7 +31,7 @@ impl HardForks { } // Returns a sorted-by-slot iterator over the registered hark forks - pub fn iter(&self) -> std::slice::Iter<(Slot, usize)> { + pub fn iter(&self) -> std::slice::Iter<(u64, usize)> { self.hard_forks.iter() } @@ -40,7 +41,7 @@ impl HardForks { } // Returns data to include in the bank hash for the given slot if a hard fork is scheduled - pub fn get_hash_data(&self, slot: Slot, parent_slot: Slot) -> Option<[u8; 8]> { + pub fn get_hash_data(&self, slot: u64, parent_slot: u64) -> Option<[u8; 8]> { // The expected number of hard forks in a cluster is small. // If this turns out to be false then a more efficient data // structure may be needed here to avoid this linear search diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index ec09dffb703dca..5b269aa286948f 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -68,7 +68,9 @@ pub mod example_mocks; pub mod exit; pub mod feature; pub mod genesis_config; -pub mod hard_forks; +#[cfg(feature = "full")] +#[deprecated(since = "2.2.0", note = "Use `solana_hard_forks` crate instead")] +pub use solana_hard_forks as hard_forks; pub mod hash; pub mod inner_instruction; pub mod log; diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index e326abd8a08870..e5a11e08cb2c4f 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5653,6 +5653,15 @@ dependencies = [ "thiserror 2.0.6", ] +[[package]] +name = "solana-hard-forks" +version = "2.2.0" +dependencies = [ + "byteorder", + "serde", + "serde_derive", +] + [[package]] name = "solana-hash" version = "2.2.0" @@ -6690,6 +6699,7 @@ dependencies = [ "solana-epoch-rewards-hasher", "solana-feature-set", "solana-fee-structure", + "solana-hard-forks", "solana-inflation", "solana-instruction", "solana-keypair", From fbf9751b9e3bc8ab401012faa460fc79281be18d Mon Sep 17 00:00:00 2001 From: Joe C Date: Fri, 6 Dec 2024 11:12:11 +0900 Subject: [PATCH 2/7] Update sdk/src/lib.rs Co-authored-by: Jon C --- sdk/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 5b269aa286948f..4e4c905933793f 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -69,7 +69,7 @@ pub mod exit; pub mod feature; pub mod genesis_config; #[cfg(feature = "full")] -#[deprecated(since = "2.2.0", note = "Use `solana_hard_forks` crate instead")] +#[deprecated(since = "2.2.0", note = "Use `solana-hard-forks` crate instead")] pub use solana_hard_forks as hard_forks; pub mod hash; pub mod inner_instruction; From 9e2c1228dcefea5d24576136adc25676a2bf9120 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Fri, 6 Dec 2024 11:14:05 +0900 Subject: [PATCH 3/7] enable frozen-abi dep --- sdk/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index f6975339e141ed..84265ef0a660b9 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -75,6 +75,7 @@ frozen-abi = [ "solana-fee-structure/frozen-abi", "solana-account/frozen-abi", "solana-cluster-type/frozen-abi", + "solana-hard-forks/frozen-abi", "solana-inflation/frozen-abi", "solana-poh-config/frozen-abi", "solana-program/frozen-abi", From 95fdb498ab5992627d590fb3780d75e82e58df5c Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Fri, 6 Dec 2024 18:02:12 +0900 Subject: [PATCH 4/7] dont use under full feature --- sdk/Cargo.toml | 5 +---- sdk/src/lib.rs | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 84265ef0a660b9..03e4413a419d7c 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -39,7 +39,6 @@ full = [ "dep:solana-cluster-type", "dep:solana-ed25519-program", "dep:solana-compute-budget-interface", - "dep:solana-hard-forks", "dep:solana-keypair", "dep:solana-offchain-message", "dep:solana-precompile-error", @@ -142,9 +141,7 @@ solana-frozen-abi = { workspace = true, optional = true, features = [ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } -solana-hard-forks = { workspace = true, features = [ - "serde", -], optional = true } +solana-hard-forks = { workspace = true, features = ["serde"] } solana-inflation = { workspace = true, features = ["serde"] } solana-instruction = { workspace = true } solana-keypair = { workspace = true, optional = true, features = [ diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 4e4c905933793f..871663bab6e9cf 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -68,7 +68,6 @@ pub mod example_mocks; pub mod exit; pub mod feature; pub mod 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; pub mod hash; From c28b9340238e39d2f02c11be0eeb05f19dee47d7 Mon Sep 17 00:00:00 2001 From: Joe C Date: Mon, 9 Dec 2024 15:01:24 +0900 Subject: [PATCH 5/7] Update sdk/hard-forks/Cargo.toml Co-authored-by: Jon C --- sdk/hard-forks/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/hard-forks/Cargo.toml b/sdk/hard-forks/Cargo.toml index 51f4a7f37fc4c9..f22976064d9ab9 100644 --- a/sdk/hard-forks/Cargo.toml +++ b/sdk/hard-forks/Cargo.toml @@ -13,8 +13,8 @@ edition = { workspace = true } byteorder = { workspace = true } 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-frozen-abi = { workspace = true, optional = true, features = ["frozen-abi"] } +solana-frozen-abi-macro = { workspace = true, optional = true, features = ["frozen-abi"] } [features] frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"] From 0f5aa14359da5ec58ff4b15bf5172666010b5f3e Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Tue, 10 Dec 2024 10:22:38 +0900 Subject: [PATCH 6/7] fix frozen-abi digest --- runtime/src/bank/serde_snapshot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/bank/serde_snapshot.rs b/runtime/src/bank/serde_snapshot.rs index 9078ef9edbbe19..da8a97c0b600da 100644 --- a/runtime/src/bank/serde_snapshot.rs +++ b/runtime/src/bank/serde_snapshot.rs @@ -570,7 +570,7 @@ mod tests { #[cfg_attr( feature = "frozen-abi", derive(AbiExample), - frozen_abi(digest = "2bWtYJSWVVvCEnBw6W2PsYZaR7RVs2V7CthFcHArdbUR") + frozen_abi(digest = "9NABbrKjv1mmcPAmvtav1tVq4cJ7tTwKpHbYj6RDp3hi") )] #[derive(Serialize)] pub struct BankAbiTestWrapper { From 5bbb24cd9f3c500570079e2687c65a111007edf1 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Tue, 10 Dec 2024 22:11:37 +0900 Subject: [PATCH 7/7] add back to full feature --- sdk/Cargo.toml | 5 ++++- sdk/src/lib.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 03e4413a419d7c..84265ef0a660b9 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -39,6 +39,7 @@ full = [ "dep:solana-cluster-type", "dep:solana-ed25519-program", "dep:solana-compute-budget-interface", + "dep:solana-hard-forks", "dep:solana-keypair", "dep:solana-offchain-message", "dep:solana-precompile-error", @@ -141,7 +142,9 @@ solana-frozen-abi = { workspace = true, optional = true, features = [ solana-frozen-abi-macro = { workspace = true, optional = true, features = [ "frozen-abi", ] } -solana-hard-forks = { workspace = true, features = ["serde"] } +solana-hard-forks = { workspace = true, features = [ + "serde", +], optional = true } solana-inflation = { workspace = true, features = ["serde"] } solana-instruction = { workspace = true } solana-keypair = { workspace = true, optional = true, features = [ diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 871663bab6e9cf..4e4c905933793f 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -68,6 +68,7 @@ pub mod example_mocks; pub mod exit; pub mod feature; pub mod 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; pub mod hash;