diff --git a/Cargo.lock b/Cargo.lock index 7e7b47971b..e18aca859e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3281,6 +3281,7 @@ dependencies = [ "core_affinity 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3312,7 +3313,6 @@ dependencies = [ "solana-chacha-sys 0.21.0", "solana-client 0.21.0", "solana-drone 0.21.0", - "solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-ledger 0.21.0", "solana-logger 0.21.0", "solana-measure 0.21.0", @@ -3347,6 +3347,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3355,7 +3356,6 @@ dependencies = [ "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.22 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3380,19 +3380,6 @@ dependencies = [ "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "solana-ed25519-dalek" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "solana-exchange-api" version = "0.21.0" @@ -3549,6 +3536,7 @@ dependencies = [ "dir-diff 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "dlopen 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "dlopen_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3563,7 +3551,6 @@ dependencies = [ "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-budget-api 0.21.0", - "solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-genesis-programs 0.21.0", "solana-logger 0.21.0", "solana-measure 0.21.0", @@ -3849,6 +3836,7 @@ dependencies = [ "bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3865,7 +3853,6 @@ dependencies = [ "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-crate-features 0.21.0", - "solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-logger 0.21.0", "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3877,10 +3864,11 @@ dependencies = [ "bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cbindgen 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "solana-sdk 0.21.0", ] @@ -5716,7 +5704,6 @@ dependencies = [ "checksum slog-term 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cb9b3fd9a3c2c86580fce3558a98ed7c69039da0288b08a3f15b371635254e08" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" -"checksum solana-ed25519-dalek 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1c21f9d5aa62959872194dfd086feb4e8efec1c2589d27e6a0339904759e99fc" "checksum solana-reed-solomon-erasure 4.0.1-3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5b3ab3f4dd12af687a7d0d0ee73299cbc06ed3aada42dccac26fe243e73399e" "checksum solana_libra_bytecode_verifier 0.0.1-sol4 (registry+https://github.com/rust-lang/crates.io-index)" = "79c3b7e9555da6f04a3f542a40e92bbbd46d0f05bd270ae3ff8c0283c329a179" "checksum solana_libra_canonical_serialization 0.0.1-sol4 (registry+https://github.com/rust-lang/crates.io-index)" = "c674689dd2d17b0bab49501f0d63ec71b3e1f8fab2eae86174e37768435a54aa" diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 4fe3b58162..c276cbaae5 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -43,6 +43,28 @@ use std::{ const USERDATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE +#[derive(Debug)] +pub struct KeypairEq(Keypair); + +impl From for KeypairEq { + fn from(keypair: Keypair) -> Self { + Self(keypair) + } +} + +impl PartialEq for KeypairEq { + fn eq(&self, other: &Self) -> bool { + self.pubkey() == other.pubkey() + } +} + +impl std::ops::Deref for KeypairEq { + type Target = Keypair; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + #[derive(Debug, PartialEq)] #[allow(clippy::large_enum_variant)] pub enum CliCommand { @@ -66,7 +88,7 @@ pub enum CliCommand { Deploy(String), // Stake Commands CreateStakeAccount { - stake_account: Keypair, + stake_account: KeypairEq, staker: Option, withdrawer: Option, lockup: Lockup, @@ -87,7 +109,7 @@ pub enum CliCommand { // Storage Commands CreateStorageAccount { account_owner: Pubkey, - storage_account: Keypair, + storage_account: KeypairEq, account_type: StorageAccountType, }, ClaimStorageReward { @@ -104,7 +126,7 @@ pub enum CliCommand { }, // Vote Commands CreateVoteAccount { - vote_account: Keypair, + vote_account: KeypairEq, node_pubkey: Pubkey, authorized_voter: Option, authorized_withdrawer: Option, @@ -1796,7 +1818,7 @@ mod tests { let bob_pubkey = bob_keypair.pubkey(); let node_pubkey = Pubkey::new_rand(); config.command = CliCommand::CreateVoteAccount { - vote_account: bob_keypair, + vote_account: bob_keypair.into(), node_pubkey, authorized_voter: Some(bob_pubkey), authorized_withdrawer: Some(bob_pubkey), @@ -1815,7 +1837,7 @@ mod tests { let bob_pubkey = bob_keypair.pubkey(); let custodian = Pubkey::new_rand(); config.command = CliCommand::CreateStakeAccount { - stake_account: bob_keypair, + stake_account: bob_keypair.into(), staker: None, withdrawer: None, lockup: Lockup { slot: 0, custodian }, @@ -1961,7 +1983,7 @@ mod tests { let bob_keypair = Keypair::new(); config.command = CliCommand::CreateVoteAccount { - vote_account: bob_keypair, + vote_account: bob_keypair.into(), node_pubkey, authorized_voter: Some(bob_pubkey), authorized_withdrawer: Some(bob_pubkey), diff --git a/cli/src/input_parsers.rs b/cli/src/input_parsers.rs index 1cf23abcb7..9356030b3e 100644 --- a/cli/src/input_parsers.rs +++ b/cli/src/input_parsers.rs @@ -125,14 +125,17 @@ mod tests { let matches = app() .clone() .get_matches_from(vec!["test", "--single", &outfile]); - assert_eq!(keypair_of(&matches, "single"), Some(keypair)); - assert_eq!(keypair_of(&matches, "multiple"), None); + assert_eq!( + keypair_of(&matches, "single").unwrap().pubkey(), + keypair.pubkey() + ); + assert!(keypair_of(&matches, "multiple").is_none()); let matches = app() .clone() .get_matches_from(vec!["test", "--single", "random_keypair_file.json"]); - assert_eq!(keypair_of(&matches, "single"), None); + assert!(keypair_of(&matches, "single").is_none()); fs::remove_file(&outfile).unwrap(); } diff --git a/cli/src/stake.rs b/cli/src/stake.rs index 37f4daf9a7..4d97f5aa25 100644 --- a/cli/src/stake.rs +++ b/cli/src/stake.rs @@ -283,7 +283,7 @@ pub fn parse_stake_create_account(matches: &ArgMatches<'_>) -> Result) -> Result = RefCell::new(rayon::ThreadPoolBuilder::new() .num_threads(get_thread_count()) diff --git a/sdk-c/Cargo.toml b/sdk-c/Cargo.toml index 735d31386f..24892c0063 100644 --- a/sdk-c/Cargo.toml +++ b/sdk-c/Cargo.toml @@ -19,7 +19,8 @@ libc = "0.2.65" rand_chacha = "0.1.1" rand_core = { version = ">=0.2, <0.4", default-features = false } solana-sdk = { path = "../sdk", version = "0.21.0" } -solana-ed25519-dalek = "0.2.0" +ed25519-dalek = "1.0.0-pre.1" +sha2 = "0.8.0" [build-dependencies] cbindgen = "0.9.1" \ No newline at end of file diff --git a/sdk-c/src/lib.rs b/sdk-c/src/lib.rs index 09162da1a3..d74a6214cb 100644 --- a/sdk-c/src/lib.rs +++ b/sdk-c/src/lib.rs @@ -1,21 +1,23 @@ use bincode::{deserialize, serialize}; +use ed25519_dalek::{SignatureError, KEYPAIR_LENGTH, PUBLIC_KEY_LENGTH}; use libc::{c_int, size_t}; use rand_chacha::ChaChaRng; use rand_core::SeedableRng; -use solana_ed25519_dalek::{SignatureError, KEYPAIR_LENGTH, PUBLIC_KEY_LENGTH}; -use solana_sdk::hash::Hash; -use solana_sdk::instruction::CompiledInstruction as CompiledInstructionNative; -use solana_sdk::message::Message as MessageNative; -use solana_sdk::message::MessageHeader as MessageHeaderNative; -use solana_sdk::pubkey::Pubkey; -use solana_sdk::signature::Signature as SignatureNative; -use solana_sdk::signature::{Keypair as KeypairNative, KeypairUtil}; -use solana_sdk::transaction::Transaction as TransactionNative; -use std::convert::TryInto; -use std::ffi::CString; -use std::os::raw::c_char; -use std::vec::Vec; -use std::{fmt, mem, ptr, slice}; +use solana_sdk::{ + hash::Hash, + instruction::CompiledInstruction as CompiledInstructionNative, + message::{Message as MessageNative, MessageHeader as MessageHeaderNative}, + pubkey::Pubkey, + signature::{Keypair as KeypairNative, KeypairUtil, Signature as SignatureNative}, + transaction::Transaction as TransactionNative, +}; +use std::{ + convert::TryInto, + ffi::CString, + os::raw::c_char, + vec::Vec, + {fmt, mem, ptr, slice}, +}; #[repr(C)] #[derive(Debug)] @@ -481,7 +483,7 @@ mod tests { let mut rng = ChaChaRng::from_seed(seed); let keypair = KeypairNative::generate(&mut rng); let c_keypair = unsafe { Box::from_raw(generate_keypair(seed.as_ptr())) }; - assert_eq!(c_keypair.new_native(), Ok(keypair)); + assert_eq!(c_keypair.new_native().unwrap().pubkey(), keypair.pubkey()); } #[test] diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index ce1910e7b0..b68b680cdf 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -21,7 +21,7 @@ default = [ "rand_chacha", "rayon", "serde_json", - "solana-ed25519-dalek", + "ed25519-dalek", "solana-logger", "untrusted", "solana-crate-features" @@ -48,7 +48,7 @@ serde_bytes = "0.11" serde_derive = "1.0.102" serde_json = { version = "1.0.41", optional = true } sha2 = "0.8.0" -solana-ed25519-dalek = { version = "0.2.0", optional = true } +ed25519-dalek = { version = "1.0.0-pre.1", optional = true } solana-logger = { path = "../logger", version = "0.21.0", optional = true } untrusted = { version = "0.7.0", optional = true } solana-crate-features = { path = "../crate-features", version = "0.21.0", optional = true } diff --git a/sdk/src/signature.rs b/sdk/src/signature.rs index bcbfd30444..da2394528e 100644 --- a/sdk/src/signature.rs +++ b/sdk/src/signature.rs @@ -2,20 +2,19 @@ use crate::pubkey::Pubkey; use bs58; -use generic_array::typenum::U64; -use generic_array::GenericArray; +use ed25519_dalek; +use generic_array::{typenum::U64, GenericArray}; use rand::rngs::OsRng; use serde_json; -use solana_ed25519_dalek as ed25519_dalek; -use std::borrow::Borrow; -use std::borrow::Cow; -use std::error; -use std::fmt; -use std::fs::{self, File}; -use std::io::{Read, Write}; -use std::mem; -use std::path::Path; -use std::str::FromStr; +use std::{ + borrow::{Borrow, Cow}, + error, fmt, + fs::{self, File}, + io::{Read, Write}, + mem, + path::Path, + str::FromStr, +}; pub type Keypair = ed25519_dalek::Keypair; @@ -117,7 +116,7 @@ impl KeypairUtil for Keypair { /// Return the public key for the given keypair fn pubkey(&self) -> Pubkey { - Pubkey::new(&self.public.as_ref()) + Pubkey::new(self.public.as_ref()) } fn sign_message(&self, message: &[u8]) -> Signature {