From 921b7e61a1c0be506dca5c64fed57ce8ec682cdc Mon Sep 17 00:00:00 2001 From: kevinheavey Date: Mon, 28 Oct 2024 14:24:11 +0400 Subject: [PATCH] fix imports and dependencies --- Cargo.lock | 9 +++++++++ sdk/secp256k1-instruction/Cargo.toml | 12 +++++++++++- sdk/secp256k1-instruction/src/lib.rs | 24 ++++++++++++++++-------- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ad4b3ec4bcc30..373bfad7caf5ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8331,15 +8331,24 @@ dependencies = [ name = "solana-secp256k1-instruction" version = "2.2.0" dependencies = [ + "anyhow", "bincode", "digest 0.10.7", + "hex", "libsecp256k1", + "rand 0.7.3", "serde", "serde_derive", "sha3", "solana-feature-set", + "solana-hash", "solana-instruction", + "solana-logger", "solana-precompile-error", + "solana-program", + "solana-pubkey", + "solana-sdk", + "solana-secp256k1-instruction", ] [[package]] diff --git a/sdk/secp256k1-instruction/Cargo.toml b/sdk/secp256k1-instruction/Cargo.toml index 2868a3a18603c5..404c083d20dea7 100644 --- a/sdk/secp256k1-instruction/Cargo.toml +++ b/sdk/secp256k1-instruction/Cargo.toml @@ -19,11 +19,21 @@ sha3 = { workspace = true } solana-feature-set = { workspace = true } solana-instruction = { workspace = true, features = ["std"] } solana-precompile-error = { workspace = true } +solana-pubkey = { workspace = true, optional = true } [dev-dependencies] +anyhow = { workspace = true } +hex = { workspace = true } +rand0-7 = { workspace = true } +solana-hash = { workspace = true } +solana-logger = { workspace = true } +solana-program = { path = "../program" } +solana-sdk = { path = ".." } +solana-secp256k1-instruction = { path = ".", features = ["dev-context-only-utils"] } [features] -bincode = ["dep:bincode", "serde"] +bincode = ["dep:bincode", "dep:solana-pubkey", "serde"] +dev-context-only-utils = ["bincode"] serde = ["dep:serde", "dep:serde_derive"] [package.metadata.docs.rs] diff --git a/sdk/secp256k1-instruction/src/lib.rs b/sdk/secp256k1-instruction/src/lib.rs index 19b97d1e7e3997..18d0845636e720 100644 --- a/sdk/secp256k1-instruction/src/lib.rs +++ b/sdk/secp256k1-instruction/src/lib.rs @@ -796,6 +796,11 @@ pub const SIGNATURE_SERIALIZED_SIZE: usize = 64; pub const SIGNATURE_OFFSETS_SERIALIZED_SIZE: usize = 11; pub const DATA_START: usize = SIGNATURE_OFFSETS_SERIALIZED_SIZE + 1; +// inline from solana_sdk::secp256k1_program to avoid solana_sdk dependency +#[cfg(feature = "bincode")] +const SECP256K1_PROGRAM_ID: solana_pubkey::Pubkey = + solana_pubkey::pubkey!("KeccakSecp256k11111111111111111111111111111"); + /// Offsets of signature data within a secp256k1 instruction. /// /// See the [module documentation][md] for a complete description. @@ -891,7 +896,7 @@ pub fn new_secp256k1_instruction( bincode::serialize_into(writer, &offsets).unwrap(); Instruction { - program_id: solana_sdk::secp256k1_program::id(), + program_id: SECP256K1_PROGRAM_ID, accounts: vec![], data: instruction_data, } @@ -1031,16 +1036,14 @@ fn get_data_slice<'a>( pub mod test { use { super::*, - crate::{ - hash::Hash, + rand0_7::{thread_rng, Rng}, + solana_feature_set::FeatureSet, + solana_hash::Hash, + solana_sdk::{ keccak, - secp256k1_instruction::{ - new_secp256k1_instruction, SecpSignatureOffsets, SIGNATURE_OFFSETS_SERIALIZED_SIZE, - }, - signature::{Keypair, Signer}, + signer::{keypair::Keypair, Signer}, transaction::Transaction, }, - rand0_7::{thread_rng, Rng}, }; fn test_case( @@ -1306,4 +1309,9 @@ pub mod test { ) .unwrap(); } + + #[test] + fn test_inlined_program_id() { + assert_eq!(SECP256K1_PROGRAM_ID, solana_sdk::secp256k1_program::id()); + } }