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 signer crates #3087

Merged
merged 28 commits into from
Nov 6, 2024
Merged

Conversation

kevinheavey
Copy link

@kevinheavey kevinheavey commented Oct 6, 2024

Problem

solana_sdk::signer needs to be made available outside solana_sdk

Summary of Changes

  • Rip out the following crates (not putting them in one crate because each one has quite significant dependencies): solana-presigner, solana-seed-derivable, solana-seed-phrase, solana-signer
  • Make the keypair module optional in solana-signer. This didn't go in its own crate because it seems it's not possible to do so without breaking the Signers trait
  • replace serde_json usage in keypair.rs with a simple inline parser
  • remove itertools from the unique_signers function

This branches off #2295 so that needs to be merged first

@joncinque
Copy link

Make the keypair module optional in solana-signer. This didn't go in its own crate because it seems it's not possible to do so without breaking the Signers trait

I took a look at the PR and managed to extract solana-keypair without any issues on the Signers trait. I think it would be much better to extract Keypair too if it's possible -- do you mind if I push my changes to your branch so you can check it out? I also removed the keypair feature from solana-seed-phrase and just implemented it in solana-keypair.

I'm still looking through the changes, but it all looks good so far

@kevinheavey
Copy link
Author

Go for it!

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.

Ok I've pushed my changes -- let me know what you think! Also tagging @febo for another set of eyes

Comment on lines 23 to 41
impl SeedDerivable for Keypair {
fn from_seed(seed: &[u8]) -> Result<Self, Box<dyn error::Error>> {
keypair_from_seed(seed)
}

fn from_seed_and_derivation_path(
seed: &[u8],
derivation_path: Option<DerivationPath>,
) -> Result<Self, Box<dyn error::Error>> {
keypair_from_seed_and_derivation_path(seed, derivation_path)
}

fn from_seed_phrase_and_passphrase(
seed_phrase: &str,
passphrase: &str,
) -> Result<Self, Box<dyn error::Error>> {
keypair_from_seed_phrase_and_passphrase(seed_phrase, passphrase)
}
}

Choose a reason for hiding this comment

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

note: I typically prefer to have the trait implementation in the crate with the concrete type, but I think it makes sense here since there isn't too much else here, and it's the only crate with the ed25519-dalek-bip32 dependency

Copy link

Choose a reason for hiding this comment

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

Hmmm, I found this a bit unexpected to be here. Is there a scenario where you would want only the trait and using this crate will incur you getting a ed25519-dalek-bip32 dependency?

Copy link

Choose a reason for hiding this comment

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

If it does not make sense to move it to the keypair crate, perhaps we can put this behind a feature flag?

Choose a reason for hiding this comment

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

Hm, this is a good point. The only other impls of SeedDerivable exist in the zk-sdk and zk-token-sdk crates, and they explicitly just return an error for from_seed_and_derivation_path, which means they don't use the bip32 dependency at all.

We could implement the trait and extra functions under a feature flag like seed-derivable in solana-keypair. What do you think @kevinheavey ?

Copy link
Author

Choose a reason for hiding this comment

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

yeah feature flag sounds good to me, you wanna take it?

Choose a reason for hiding this comment

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

Yep! Done with 1720552 -- let me know how it looks

Copy link
Author

Choose a reason for hiding this comment

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

lgtm!

@joncinque joncinque requested a review from febo November 4, 2024 22:52
@kevinheavey
Copy link
Author

lgtm

@kevinheavey
Copy link
Author

@yihau I've sent anza-team invites for the following crates:

  • solana-keypair
  • solana-presigner
  • solana-seed-derivable
  • solana-seed-phrase
  • solana-signer

@yihau
Copy link
Member

yihau commented Nov 5, 2024

sdk/src/signer/keypair.rs Outdated Show resolved Hide resolved
sdk/src/signer/mod.rs Outdated Show resolved Hide resolved
Copy link

@febo febo left a comment

Choose a reason for hiding this comment

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

Just a couple of comments. Also, some of the crates have the "` ... `" formatting on the description field in the Cargo.toml file – wodering whether that is going to render properly or should be removed.

@kevinheavey
Copy link
Author

Just a couple of comments. Also, some of the crate have the "..." formatting on the description field in the Cargo.toml file – wodering whether that is going to render properly or should be removed.

Confirming that crates.io does not give them proper rendering in the description field https://crates.io/crates/backtick-description-example

@joncinque joncinque requested a review from febo November 6, 2024 15:46
Copy link

@febo febo 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!

@kevinheavey kevinheavey added the automerge automerge Merge this Pull Request automatically once CI passes label Nov 6, 2024
@mergify mergify bot merged commit e752b38 into anza-xyz:master Nov 6, 2024
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge automerge Merge this Pull Request automatically once CI passes need:merge-assist
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants