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: Extract hash and hasher crates #2015

Merged
merged 50 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d5ba134
extract hash and hasher crates and re-export their contents in solana…
kevinheavey Jul 4, 2024
9154170
make bytemuck and serde optional, and activate features in solana-pro…
kevinheavey Jul 4, 2024
f1bcfa9
fix frozen-abi support
kevinheavey Jul 4, 2024
9ac2790
fix import
kevinheavey Jul 4, 2024
7c23c29
update lock file
kevinheavey Jul 4, 2024
7c807e8
cargo sort
kevinheavey Jul 4, 2024
fc8ace3
fix wasm_bindgen import
kevinheavey Jul 5, 2024
87c0099
typo
kevinheavey Jul 5, 2024
9afdabc
fmt
kevinheavey Jul 5, 2024
b475e11
make the inner field of Hash pub(crate) again because otherwise wasm_…
kevinheavey Jul 5, 2024
d4edc90
move program/src/wasm/hash.rs contents to solana-hash crate
kevinheavey Jul 5, 2024
6411058
update lock file
kevinheavey Jul 5, 2024
5679f1d
remove duplicate frozen-abi stuff
kevinheavey Jul 5, 2024
125151b
fix specialization stuff
kevinheavey Jul 6, 2024
1e63d69
delete tmp tests
kevinheavey Jul 6, 2024
be1dd02
update BlockhashQueue digest
kevinheavey Jul 6, 2024
8bd6fe6
Revert "update BlockhashQueue digest"
kevinheavey Jul 6, 2024
46f1968
update expected digests after confirming that the change is merely fr…
kevinheavey Jul 7, 2024
b09a51a
update another digest
kevinheavey Jul 7, 2024
d4a935f
update digests in sdk and program
kevinheavey Jul 7, 2024
73b4802
update digests in runtime
kevinheavey Jul 7, 2024
ae4875f
update VoteTransaction digest
kevinheavey Jul 7, 2024
a67d522
conditionally activate solana-hash/borsh in solana-program
kevinheavey Jul 17, 2024
22398bd
move js-sys dep under cfg(target_arch = "wasm32")
kevinheavey Jul 17, 2024
8ec7adb
remove thiserror from hash crate
kevinheavey Jul 17, 2024
0b293c5
remove solana-program dependency from merkle-tree
kevinheavey Jul 19, 2024
68de098
make solana-hash no_std by default
kevinheavey Jul 30, 2024
55c698f
fmt
kevinheavey Jul 31, 2024
70567ba
fmt after rebase
kevinheavey Jul 31, 2024
0c7666f
make std feature default
kevinheavey Jul 31, 2024
fdf9edc
make sha2 an optional dep when target_os = "solana", because it's unl…
kevinheavey Aug 1, 2024
ac40c2b
fmt
kevinheavey Aug 1, 2024
3034854
make rustc_version optional
kevinheavey Aug 17, 2024
0f5a144
update lock file
kevinheavey Aug 17, 2024
8240997
fix frozen-abi lint
kevinheavey Aug 19, 2024
4b75d5f
another lint fix
kevinheavey Aug 19, 2024
0afdb74
add comment about sha2 removal
kevinheavey Sep 4, 2024
db12076
avoid Vec in FromStr
kevinheavey Sep 4, 2024
aa8962b
put Hash::new_unique behind #[cfg(feature = "dev-context-only-utils")]
kevinheavey Sep 4, 2024
a981abe
move tests from solana-hasher to solana-hash
kevinheavey Sep 4, 2024
c6cc1e8
rename solana-hasher to solana-sha256-hasher
kevinheavey Sep 4, 2024
58ca2a8
fmt
kevinheavey Sep 4, 2024
d23c6b3
make conditional import more consistent
kevinheavey Sep 4, 2024
8e200b8
don't use std feature of bs58 in solana-hash
kevinheavey Sep 4, 2024
8747184
undo putting new_unique behind dev-context-only-utils
kevinheavey Sep 4, 2024
1dff01e
missing feature
kevinheavey Sep 4, 2024
4aed6b7
rename to write_as_base58 and reorder params
kevinheavey Sep 4, 2024
7d265c4
update write_as_base58 usage
kevinheavey Sep 4, 2024
2523482
fix feature activation for tests
kevinheavey Sep 4, 2024
295b66a
remove part of doc that no longer makes sense
kevinheavey Sep 4, 2024
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
34 changes: 33 additions & 1 deletion Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ members = [
"sdk/clock",
"sdk/decode-error",
"sdk/gen-headers",
"sdk/hash",
"sdk/macro",
"sdk/msg",
"sdk/package-metadata-macro",
"sdk/program",
"sdk/program-memory",
"sdk/serde-varint",
"sdk/sha256-hasher",
"send-transaction-service",
"short-vec",
"stake-accounts",
Expand Down Expand Up @@ -198,7 +200,7 @@ bincode = "1.3.3"
bitflags = { version = "2.6.0" }
blake3 = "1.5.1"
borsh = { version = "1.5.1", features = ["derive", "unstable__schema"] }
bs58 = "0.5.1"
bs58 = { version = "0.5.1", default-features = false }
bv = "0.11.1"
byte-unit = "4.0.19"
bytecount = "0.6.8"
Expand Down Expand Up @@ -390,6 +392,7 @@ solana-genesis-utils = { path = "genesis-utils", version = "=2.1.0" }
agave-geyser-plugin-interface = { path = "geyser-plugin-interface", version = "=2.1.0" }
solana-geyser-plugin-manager = { path = "geyser-plugin-manager", version = "=2.1.0" }
solana-gossip = { path = "gossip", version = "=2.1.0" }
solana-hash = { path = "sdk/hash", version = "=2.1.0" }
solana-inline-spl = { path = "inline-spl", version = "=2.1.0" }
solana-lattice-hash = { path = "lattice-hash", version = "=2.1.0" }
solana-ledger = { path = "ledger", version = "=2.1.0" }
Expand Down Expand Up @@ -418,6 +421,7 @@ solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=2.1.0" }
solana-remote-wallet = { path = "remote-wallet", version = "=2.1.0", default-features = false }
solana-sanitize = { path = "sanitize", version = "=2.1.0" }
solana-serde-varint = { path = "sdk/serde-varint", version = "=2.1.0" }
solana-sha256-hasher = { path = "sdk/sha256-hasher", version = "=2.1.0" }
solana-timings = { path = "timings", version = "=2.1.0" }
solana-unified-scheduler-logic = { path = "unified-scheduler-logic", version = "=2.1.0" }
solana-unified-scheduler-pool = { path = "unified-scheduler-pool", version = "=2.1.0" }
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/blockhash_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl HashInfo {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "HzbCqb1YtCodkx6Fu57SpzkgaLp9WSrtw8texsjBhEDH")
frozen_abi(digest = "BxykY65dC2NCcDm17rHQPjEY8wK55sKAhfhKVFGc5T1u")
)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BlockhashQueue {
Expand Down
2 changes: 1 addition & 1 deletion core/src/banking_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct BankingTracer {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "Eq6YrAFtTbtPrCEvh6Et1mZZDCARUg1gcK2qiZdqyjUz")
frozen_abi(digest = "F5GH1poHbPqipU4DB3MczhSxHZw4o27f3C7QnMVirFci")
)]
#[derive(Serialize, Deserialize, Debug)]
pub struct TimedTracedEvent(pub std::time::SystemTime, pub TracedEvent);
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub(crate) enum BlockhashStatus {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "H6T5A66kgJYANFXVrUprxV76WD5ce7Gf62q9SiBC2uYk")
frozen_abi(digest = "5BUswzvu7Qe44HbR4eBwPX4Jn9GSfhjmg8eijnBjoKUd")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower {
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus/tower1_14_11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "EqYa8kwY9Z1Zbjxgs2aBbqKyCK4f7WAG8gJ7pVSQyKzk")
frozen_abi(digest = "9P6J8ZtVLR5zbUxWT83q1iUsJMH6B7SwcomSqcoomPmg")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower1_14_11 {
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus/tower1_7_14.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "9Kc3Cpak93xdL8bCnEwMWA8ZLGCBNfqh9PLo1o5RiPyT")
frozen_abi(digest = "DJVvkk4EFFCbA37vsKcFPGuwEULh2wEvMUESsTyvABzU")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower1_7_14 {
Expand Down
4 changes: 2 additions & 2 deletions core/src/repair/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl AncestorHashesRepairType {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiEnumVisitor, AbiExample),
frozen_abi(digest = "AKpurCovzn6rsji4aQrP3hUdEHxjtXUfT7AatZXN7Rpz")
frozen_abi(digest = "98D6KvXCBxAHTxXgqiywLTugTp6WFUHSf559yy4VvKE7")
)]
#[derive(Debug, Deserialize, Serialize)]
pub enum AncestorHashesResponse {
Expand Down Expand Up @@ -224,7 +224,7 @@ pub(crate) type Ping = ping_pong::Ping<[u8; REPAIR_PING_TOKEN_SIZE]>;
#[cfg_attr(
feature = "frozen-abi",
derive(AbiEnumVisitor, AbiExample),
frozen_abi(digest = "5cmSdmXMgkpUH5ZCmYYjxUVQfULe9iJqCqqfrADfsEmK")
frozen_abi(digest = "DzofXbeBFKJpbA88nUEnDpCGKvMEcguNphyQoVr7FyLh")
)]
#[derive(Debug, Deserialize, Serialize)]
pub enum RepairProtocol {
Expand Down
2 changes: 1 addition & 1 deletion frozen-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = { workspace = true }
edition = { workspace = true }

[dependencies]
bs58 = { workspace = true }
bs58 = { workspace = true, features = ["alloc"] }
bv = { workspace = true, features = ["serde"] }
log = { workspace = true, features = ["std"] }
serde = { workspace = true, features = ["rc"] }
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample, AbiEnumVisitor),
frozen_abi(digest = "6YaMJand6tKtNLUrqvusC5QVDmVLCWYRg5LtxYNi6XN4")
frozen_abi(digest = "7jwuQ3oFEy8bMnmr5XHSR2jqivZniG8ZjxHx3YKTfR6C")
)]
#[derive(Serialize, Deserialize, Debug)]
#[allow(clippy::large_enum_variant)]
Expand Down
3 changes: 2 additions & 1 deletion merkle-tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ edition = { workspace = true }

[dependencies]
fast-math = { workspace = true }
solana-program = { workspace = true }
joncinque marked this conversation as resolved.
Show resolved Hide resolved
solana-hash = { workspace = true }
solana-sha256-hasher = { workspace = true }

[dev-dependencies]
hex = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion merkle-tree/src/merkle_tree.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use solana_program::hash::{hashv, Hash};
use {solana_hash::Hash, solana_sha256_hasher::hashv};

// We need to discern between leaf and intermediate nodes to prevent trivial second
// pre-image attacks.
Expand Down
30 changes: 29 additions & 1 deletion 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 programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample, AbiEnumVisitor),
frozen_abi(digest = "3R2hRL3FM6jovbYubq2UWeiVDEVzrhH6M1ihoCPZWLsk")
frozen_abi(digest = "3dbyMxwfCN43orGKa5YiyY1EqN2K97pTicNhKYTZSUQH")
)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum VoteTransaction {
Expand Down
2 changes: 1 addition & 1 deletion rpc-client-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = { workspace = true }
[dependencies]
anyhow = { workspace = true }
base64 = { workspace = true }
bs58 = { workspace = true }
bs58 = { workspace = true, features = ["std"] }
joncinque marked this conversation as resolved.
Show resolved Hide resolved
jsonrpc-core = { workspace = true }
reqwest = { workspace = true, features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] }
reqwest-middleware = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ struct RentMetrics {
pub type BankStatusCache = StatusCache<Result<()>>;
#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "9Pf3NTGr1AEzB4nKaVBY24uNwoQR4aJi8vc96W6kGvNk")
frozen_abi(digest = "EQwW6Ym6ECKaAREnAgkhXYisBQovuraBKSALdJ8koZzq")
)]
pub type BankSlotDelta = SlotDelta<Result<()>>;

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ mod tests {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "HQYDRuCaM5V1ggSuMPTKT5Mu2vE5HX4y4ZM1Xuorx6My")
frozen_abi(digest = "FuFBQtx7rGruVC3cyh4zvZ3uN4RUtBiwh1pXJRwUCcoS")
)]
#[derive(Serialize)]
pub struct BankAbiTestWrapper {
Expand Down
52 changes: 52 additions & 0 deletions sdk/hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[package]
name = "solana-hash"
description = "Solana wrapper for the 32-byte output of a hashing algorithm."
documentation = "https://docs.rs/solana-hash"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

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

[dependencies]
borsh = { workspace = true, optional = true }
bs58 = { workspace = true, default-features = false }
bytemuck = { workspace = true, optional = true }
bytemuck_derive = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
solana-atomic-u64 = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true }
solana-frozen-abi-macro = { workspace = true, optional = true }
solana-sanitize = { workspace = true }

[dev-dependencies]
solana-hash = { path = ".", features = ["dev-context-only-utils"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = { workspace = true }
wasm-bindgen = { workspace = true }

[build-dependencies]
rustc_version = { workspace = true, optional = true }

[features]
borsh = ["dep:borsh", "std"]
bytemuck = ["dep:bytemuck", "dep:bytemuck_derive"]
default = ["std"]
dev-context-only-utils = ["bs58/alloc"]
frozen-abi = [
"dep:rustc_version",
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
"std"
]
serde = ["dep:serde", "dep:serde_derive"]
std = []

[lints]
workspace = true
1 change: 1 addition & 0 deletions sdk/hash/build.rs
Loading