diff --git a/Cargo.lock b/Cargo.lock index 58b4f45f4ed579..55c24db2d3f580 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1320,7 +1320,7 @@ checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.85", ] [[package]] @@ -6641,15 +6641,21 @@ dependencies = [ ] [[package]] -name = "solana-ed25519-instruction" +name = "solana-ed25519-instructions" version = "2.1.0" dependencies = [ "bytemuck", "bytemuck_derive", "ed25519-dalek", + "hex", + "rand 0.7.3", "solana-feature-set", + "solana-hash", "solana-instruction", + "solana-logger", "solana-precompile-error", + "solana-pubkey", + "solana-sdk", ] [[package]] @@ -8020,6 +8026,7 @@ dependencies = [ "solana-bn254", "solana-decode-error", "solana-derivation-path", + "solana-ed25519-instructions", "solana-feature-set", "solana-frozen-abi", "solana-frozen-abi-macro", diff --git a/Cargo.toml b/Cargo.toml index 4566f364d33929..2da34e000bde1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -352,6 +352,7 @@ quinn = "0.11.4" quinn-proto = "0.11.7" quote = "1.0" rand = "0.8.5" +rand0-7 = { package = "rand", version = "0.7" } rand_chacha = "0.3.1" rayon = "1.10.0" reed-solomon-erasure = "6.0.0" diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index d008570ef79fd0..6be99b593bf09e 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -969,7 +969,7 @@ checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.85", ] [[package]] @@ -5293,6 +5293,19 @@ dependencies = [ "solana-sdk", ] +[[package]] +name = "solana-ed25519-instructions" +version = "2.1.0" +dependencies = [ + "bytemuck", + "bytemuck_derive", + "ed25519-dalek", + "solana-feature-set", + "solana-instruction", + "solana-precompile-error", + "solana-pubkey", +] + [[package]] name = "solana-entry" version = "2.1.0" @@ -6767,6 +6780,7 @@ dependencies = [ "solana-bn254", "solana-decode-error", "solana-derivation-path", + "solana-ed25519-instructions", "solana-feature-set", "solana-instruction", "solana-native-token", diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 98000e4ee968af..333859968c6ed9 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -34,6 +34,7 @@ full = [ "sha3", "digest", "solana-pubkey/rand", + "dep:solana-ed25519-instructions", "dep:solana-precompile-error", "dep:solana-transaction-error" ] @@ -79,7 +80,7 @@ num_enum = { workspace = true } pbkdf2 = { workspace = true } qualifier_attr = { workspace = true, optional = true } rand = { workspace = true, optional = true } -rand0-7 = { package = "rand", version = "0.7", optional = true } +rand0-7 = { workspace = true, optional = true } serde = { workspace = true } serde_bytes = { workspace = true } serde_derive = { workspace = true } @@ -92,6 +93,7 @@ solana-account = { workspace = true, features = ["bincode"] } solana-bn254 = { workspace = true } solana-decode-error = { workspace = true } solana-derivation-path = { workspace = true } +solana-ed25519-instructions = { workspace = true, optional = true } solana-feature-set = { workspace = true } solana-frozen-abi = { workspace = true, optional = true, features = [ "frozen-abi", diff --git a/sdk/ed25519-instructions/Cargo.toml b/sdk/ed25519-instructions/Cargo.toml index 312b197d270ea0..d628183664e9fe 100644 --- a/sdk/ed25519-instructions/Cargo.toml +++ b/sdk/ed25519-instructions/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "solana-ed25519-instruction" +name = "solana-ed25519-instructions" description = "Instructions for the Solana ed25519 native program" -documentation = "https://docs.rs/solana-ed25519-instruction" +documentation = "https://docs.rs/solana-ed25519-instructions" version = { workspace = true } authors = { workspace = true } repository = { workspace = true } @@ -16,6 +16,14 @@ ed25519-dalek = { workspace = true } solana-feature-set = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } solana-precompile-error = { workspace = true } +solana-pubkey = { workspace = true } + +[dev-dependencies] +hex = { workspace = true } +rand0-7 = { workspace = true } +solana-hash = { workspace = true } +solana-logger = { workspace = true } +solana-sdk = { path = ".." } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/ed25519-instructions/src/lib.rs b/sdk/ed25519-instructions/src/lib.rs index 85a691a7755e4f..0c8bedb071cfd6 100644 --- a/sdk/ed25519-instructions/src/lib.rs +++ b/sdk/ed25519-instructions/src/lib.rs @@ -9,6 +9,7 @@ use { solana_feature_set::{ed25519_precompile_verify_strict, FeatureSet}, solana_instruction::Instruction, solana_precompile_error::PrecompileError, + solana_pubkey::{pubkey, Pubkey}, }; pub const PUBKEY_SERIALIZED_SIZE: usize = 32; @@ -17,6 +18,8 @@ pub const SIGNATURE_OFFSETS_SERIALIZED_SIZE: usize = 14; // bytemuck requires structures to be aligned pub const SIGNATURE_OFFSETS_START: usize = 2; pub const DATA_START: usize = SIGNATURE_OFFSETS_SERIALIZED_SIZE + SIGNATURE_OFFSETS_START; +// copied from solana_sdk::ed25519_program to avoid solana_sdk dependency +const ED25519_PROGRAM_ID: Pubkey = pubkey!("Ed25519SigVerify111111111111111111111111111"); #[derive(Default, Debug, Copy, Clone, Zeroable, Pod, Eq, PartialEq)] #[repr(C)] @@ -77,7 +80,7 @@ pub fn new_ed25519_instruction(keypair: &ed25519_dalek::Keypair, message: &[u8]) instruction_data.extend_from_slice(message); Instruction { - program_id: solana_sdk::ed25519_program::id(), + program_id: ED25519_PROGRAM_ID, accounts: vec![], data: instruction_data, } @@ -188,15 +191,14 @@ fn get_data_slice<'a>( pub mod test { use { super::*, - crate::{ - ed25519_instruction::new_ed25519_instruction, - hash::Hash, - signature::{Keypair, Signer}, - transaction::Transaction, - }, hex, rand0_7::{thread_rng, Rng}, solana_feature_set::FeatureSet, + solana_hash::Hash, + solana_sdk::{ + signer::{keypair::Keypair, Signer}, + transaction::Transaction, + }, }; pub fn new_ed25519_instruction_raw( @@ -247,7 +249,7 @@ pub mod test { instruction_data.extend_from_slice(message); Instruction { - program_id: solana_sdk::ed25519_program::id(), + program_id: ED25519_PROGRAM_ID, accounts: vec![], data: instruction_data, } @@ -487,4 +489,9 @@ pub mod test { let feature_set = FeatureSet::all_enabled(); assert!(tx.verify_precompiles(&feature_set).is_err()); // verify_strict does NOT pass } + + #[test] + fn test_inlined_program_id() { + assert_eq!(ED25519_PROGRAM_ID, solana_sdk::ed25519_program::id()) + } }