Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk: evict hard_forks #3962

Merged
merged 7 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 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 @@ -132,6 +132,7 @@ members = [
"sdk/frozen-abi",
"sdk/frozen-abi/macro",
"sdk/gen-headers",
"sdk/hard-forks",
"sdk/hash",
"sdk/inflation",
"sdk/instruction",
Expand Down Expand Up @@ -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" }
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 @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -74,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",
Expand Down Expand Up @@ -140,6 +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",
], optional = true }
buffalojoec marked this conversation as resolved.
Show resolved Hide resolved
solana-inflation = { workspace = true, features = ["serde"] }
solana-instruction = { workspace = true }
solana-keypair = { workspace = true, optional = true, features = [
Expand Down
27 changes: 27 additions & 0 deletions sdk/hard-forks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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, 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"]
serde = ["dep:serde", "dep:serde_derive"]

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

[lints]
workspace = true
23 changes: 12 additions & 11 deletions sdk/src/hard_forks.rs → sdk/hard-forks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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()
}

Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
buffalojoec marked this conversation as resolved.
Show resolved Hide resolved
pub use solana_hard_forks as hard_forks;
pub mod hash;
pub mod inner_instruction;
pub mod log;
Expand Down
10 changes: 10 additions & 0 deletions svm/examples/Cargo.lock

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

Loading