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

Extract keccak-hasher crate #3408

Merged
merged 7 commits into from
Nov 20, 2024
Merged

Conversation

kevinheavey
Copy link

@kevinheavey kevinheavey commented Oct 31, 2024

Problem

solana_program::keccak imposes a solana_program dep on some SPL crates

Summary of Changes

  • Move solana_program::keccak to a new crate solana-keccak-hasher, modelled on solana-sha256-hasher (see sdk: Extract hash and hasher crates #2015)
  • This new crate should replace its Hash struct with solana_hash::Hash but it won't be able to do so without a breaking change. In the meantime I've just made it rely on solana_hash as much as possible while avoiding breakage

This branches off #3405 so that needs to be merged first (update: done)

@kevinheavey kevinheavey marked this pull request as ready for review November 13, 2024 13:41
@kevinheavey kevinheavey force-pushed the extract-keccak-crate branch 2 times, most recently from b16f644 to 8c2912d Compare November 16, 2024 07:33
Copy link

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a few small things


[dependencies]
borsh = { workspace = true, optional = true }
bs58 = { workspace = true }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is using solana-hash, I don't think this dependency is needed

solana_sanitize::Sanitize,
std::{convert::TryFrom, fmt, str::FromStr},
thiserror::Error,
std::{fmt, str::FromStr},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about making this crate no_std like the hash crate? this can use core::{fmt, str::FromStr}. It can have an std feature which pretty much just enables the std feature on solana-hash

Comment on lines +17 to +21
// TODO: replace this with `solana_hash::Hash` in the
// next breaking change.
// It's a breaking change because the field is public
// here and private in `solana_hash`, and making
// it public in `solana_hash` would break wasm-bindgen

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone tried to combine all the hashes awhile ago, and we couldn't for this exact reason 🙃

bs58 = { workspace = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
solana-atomic-u64 = { workspace = true }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency can also be removed

Copy link

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! @yihau can you accept solana-keccak-hasher?

@yihau yihau merged commit 7384eca into anza-xyz:master Nov 20, 2024
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants