From e16403dfccc7b2a127dc97fe0df186caf37fc432 Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Mon, 9 Dec 2024 16:06:44 +0400 Subject: [PATCH] extract epoch-rewards-hasher crate (#3896) --- Cargo.lock | 11 +++++++++- Cargo.toml | 2 ++ programs/sbf/Cargo.lock | 11 +++++++++- sdk/Cargo.toml | 2 +- sdk/epoch-rewards-hasher/Cargo.toml | 21 +++++++++++++++++++ .../src/lib.rs} | 6 +----- sdk/src/lib.rs | 6 +++++- svm/examples/Cargo.lock | 11 +++++++++- 8 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 sdk/epoch-rewards-hasher/Cargo.toml rename sdk/{src/epoch_rewards_hasher.rs => epoch-rewards-hasher/src/lib.rs} (98%) diff --git a/Cargo.lock b/Cargo.lock index dc07b925e9e381..7ad7dd12cb16e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6978,6 +6978,15 @@ dependencies = [ "solana-sysvar-id", ] +[[package]] +name = "solana-epoch-rewards-hasher" +version = "2.2.0" +dependencies = [ + "siphasher", + "solana-hash", + "solana-pubkey", +] + [[package]] name = "solana-epoch-schedule" version = "2.2.0" @@ -8620,7 +8629,6 @@ dependencies = [ "serde_with", "sha2 0.10.8", "sha3", - "siphasher", "solana-account", "solana-bn254", "solana-client-traits", @@ -8631,6 +8639,7 @@ dependencies = [ "solana-derivation-path", "solana-ed25519-program", "solana-epoch-info", + "solana-epoch-rewards-hasher", "solana-feature-set", "solana-fee-structure", "solana-frozen-abi", diff --git a/Cargo.toml b/Cargo.toml index 8fb1add92b9cf3..83f82ffbfc92a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,6 +121,7 @@ members = [ "sdk/ed25519-program", "sdk/epoch-info", "sdk/epoch-rewards", + "sdk/epoch-rewards-hasher", "sdk/epoch-schedule", "sdk/feature-gate-interface", "sdk/feature-set", @@ -471,6 +472,7 @@ solana-entry = { path = "entry", version = "=2.2.0" } solana-program-entrypoint = { path = "sdk/program-entrypoint", version = "=2.2.0" } solana-epoch-info = { path = "sdk/epoch-info", version = "=2.2.0" } solana-epoch-rewards = { path = "sdk/epoch-rewards", version = "=2.2.0" } +solana-epoch-rewards-hasher = { path = "sdk/epoch-rewards-hasher", version = "=2.2.0" } solana-epoch-schedule = { path = "sdk/epoch-schedule", version = "=2.2.0" } solana-faucet = { path = "faucet", version = "=2.2.0" } solana-feature-gate-interface = { path = "sdk/feature-gate-interface", version = "=2.2.0" } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index c8ff78a474d51f..205717124644bd 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5593,6 +5593,15 @@ dependencies = [ "solana-sysvar-id", ] +[[package]] +name = "solana-epoch-rewards-hasher" +version = "2.2.0" +dependencies = [ + "siphasher", + "solana-hash", + "solana-pubkey", +] + [[package]] name = "solana-epoch-schedule" version = "2.2.0" @@ -7306,7 +7315,6 @@ dependencies = [ "serde_with", "sha2 0.10.8", "sha3", - "siphasher", "solana-account", "solana-bn254", "solana-client-traits", @@ -7317,6 +7325,7 @@ dependencies = [ "solana-derivation-path", "solana-ed25519-program", "solana-epoch-info", + "solana-epoch-rewards-hasher", "solana-feature-set", "solana-fee-structure", "solana-inflation", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 56c09d745d4364..05d955899eb461 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -115,7 +115,6 @@ serde_json = { workspace = true, optional = true } serde_with = { workspace = true, features = ["macros"] } sha2 = { workspace = true } sha3 = { workspace = true, optional = true } -siphasher = { workspace = true } solana-account = { workspace = true, features = ["bincode"] } solana-bn254 = { workspace = true } solana-client-traits = { workspace = true, optional = true } @@ -132,6 +131,7 @@ solana-decode-error = { workspace = true } solana-derivation-path = { workspace = true } solana-ed25519-program = { workspace = true, optional = true } solana-epoch-info = { workspace = true, features = ["serde"] } +solana-epoch-rewards-hasher = { workspace = true } solana-feature-set = { workspace = true } solana-fee-structure = { workspace = true, features = ["serde"] } solana-frozen-abi = { workspace = true, optional = true, features = [ diff --git a/sdk/epoch-rewards-hasher/Cargo.toml b/sdk/epoch-rewards-hasher/Cargo.toml new file mode 100644 index 00000000000000..7e6d3677c11c14 --- /dev/null +++ b/sdk/epoch-rewards-hasher/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "solana-epoch-rewards-hasher" +description = "Solana epoch rewards hasher." +documentation = "https://docs.rs/solana-epoch-rewards-hasher" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[dependencies] +siphasher = { workspace = true } +solana-hash = { workspace = true } +solana-pubkey = { workspace = true } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[lints] +workspace = true diff --git a/sdk/src/epoch_rewards_hasher.rs b/sdk/epoch-rewards-hasher/src/lib.rs similarity index 98% rename from sdk/src/epoch_rewards_hasher.rs rename to sdk/epoch-rewards-hasher/src/lib.rs index 6a5d315f0370ba..a9e910058856c7 100644 --- a/sdk/src/epoch_rewards_hasher.rs +++ b/sdk/epoch-rewards-hasher/src/lib.rs @@ -1,8 +1,4 @@ -use { - siphasher::sip::SipHasher13, - solana_sdk::{hash::Hash, pubkey::Pubkey}, - std::hash::Hasher, -}; +use {siphasher::sip::SipHasher13, solana_hash::Hash, solana_pubkey::Pubkey, std::hash::Hasher}; #[derive(Debug, Clone)] pub struct EpochRewardsHasher { diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index ac7f74fd95a9e2..ec09dffb703dca 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -64,7 +64,6 @@ pub use solana_program::{borsh, borsh0_10, borsh1}; pub use solana_signer::signers; pub mod entrypoint; pub mod entrypoint_deprecated; -pub mod epoch_rewards_hasher; pub mod example_mocks; pub mod exit; pub mod feature; @@ -123,6 +122,11 @@ pub use solana_derivation_path as derivation_path; pub use solana_ed25519_program as ed25519_instruction; #[deprecated(since = "2.2.0", note = "Use `solana-epoch-info` crate instead")] pub use solana_epoch_info as epoch_info; +#[deprecated( + since = "2.2.0", + note = "Use `solana-epoch-rewards-hasher` crate instead" +)] +pub use solana_epoch_rewards_hasher as epoch_rewards_hasher; #[deprecated(since = "2.1.0", note = "Use `solana-feature-set` crate instead")] pub use solana_feature_set as feature_set; #[deprecated(since = "2.2.0", note = "Use `solana-fee-structure` crate instead")] diff --git a/svm/examples/Cargo.lock b/svm/examples/Cargo.lock index 9bd317e4e8ddc8..d58d5b31e561c3 100644 --- a/svm/examples/Cargo.lock +++ b/svm/examples/Cargo.lock @@ -5434,6 +5434,15 @@ dependencies = [ "solana-sysvar-id", ] +[[package]] +name = "solana-epoch-rewards-hasher" +version = "2.2.0" +dependencies = [ + "siphasher", + "solana-hash", + "solana-pubkey", +] + [[package]] name = "solana-epoch-schedule" version = "2.2.0" @@ -6627,7 +6636,6 @@ dependencies = [ "serde_with", "sha2 0.10.8", "sha3", - "siphasher", "solana-account", "solana-bn254", "solana-client-traits", @@ -6638,6 +6646,7 @@ dependencies = [ "solana-derivation-path", "solana-ed25519-program", "solana-epoch-info", + "solana-epoch-rewards-hasher", "solana-feature-set", "solana-fee-structure", "solana-inflation",