From 04bccc882f083bd5d428d13dec3dcfba1f88a18f Mon Sep 17 00:00:00 2001 From: ananas Date: Thu, 23 Oct 2025 03:08:48 +0100 Subject: [PATCH] refactor: pinocchio sdk + small fixes --- Cargo.lock | 16 +++--- Cargo.toml | 16 +++--- cli/package.json | 2 +- js/compressed-token/package.json | 2 +- js/stateless.js/package.json | 2 +- program-libs/compressed-account/Cargo.toml | 2 +- .../src/instruction_data/compressed_proof.rs | 49 +++++++++++++++++ program-libs/compressed-account/src/lib.rs | 3 ++ .../src/mint_action/actions/mint_to.rs | 2 +- prover/client/Cargo.toml | 2 +- sdk-libs/client/Cargo.toml | 2 +- sdk-libs/macros/Cargo.toml | 2 +- sdk-libs/program-test/Cargo.toml | 2 +- sdk-libs/sdk-pinocchio/Cargo.toml | 2 +- sdk-libs/sdk-pinocchio/src/address.rs | 30 ++--------- sdk-libs/sdk-pinocchio/src/cpi/account.rs | 25 +++++++++ sdk-libs/sdk-pinocchio/src/cpi/instruction.rs | 22 ++++++++ .../src/cpi/{traits.rs => invoke.rs} | 53 +++---------------- sdk-libs/sdk-pinocchio/src/cpi/mod.rs | 14 +++-- sdk-libs/sdk-pinocchio/src/cpi/v1/invoke.rs | 5 +- sdk-libs/sdk-pinocchio/src/instruction/mod.rs | 4 ++ sdk-libs/sdk-pinocchio/src/lib.rs | 12 ++--- sdk-libs/sdk-types/Cargo.toml | 2 +- sdk-libs/sdk/Cargo.toml | 2 +- sdk-libs/sdk/src/lib.rs | 2 +- .../sdk-pinocchio-v1-test/src/create_pda.rs | 4 +- .../sdk-pinocchio-v1-test/src/update_pda.rs | 4 +- .../sdk-pinocchio-v2-test/src/create_pda.rs | 4 +- .../sdk-pinocchio-v2-test/src/update_pda.rs | 4 +- sdk-tests/sdk-pinocchio-v2-test/tests/test.rs | 2 +- 30 files changed, 170 insertions(+), 123 deletions(-) create mode 100644 sdk-libs/sdk-pinocchio/src/cpi/account.rs create mode 100644 sdk-libs/sdk-pinocchio/src/cpi/instruction.rs rename sdk-libs/sdk-pinocchio/src/cpi/{traits.rs => invoke.rs} (70%) diff --git a/Cargo.lock b/Cargo.lock index ba2bf99c3a..6c1de65ddf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3427,7 +3427,7 @@ dependencies = [ [[package]] name = "light-client" -version = "0.15.0" +version = "0.16.0" dependencies = [ "async-trait", "base64 0.13.1", @@ -3474,7 +3474,7 @@ dependencies = [ [[package]] name = "light-compressed-account" -version = "0.5.0" +version = "0.6.0" dependencies = [ "anchor-lang", "ark-bn254 0.5.0", @@ -3829,7 +3829,7 @@ dependencies = [ [[package]] name = "light-program-test" -version = "0.15.0" +version = "0.16.0" dependencies = [ "account-compression", "anchor-lang", @@ -3884,7 +3884,7 @@ dependencies = [ [[package]] name = "light-prover-client" -version = "3.0.0" +version = "4.0.0" dependencies = [ "ark-bn254 0.5.0", "ark-serialize 0.5.0", @@ -3925,7 +3925,7 @@ dependencies = [ [[package]] name = "light-sdk" -version = "0.15.0" +version = "0.16.0" dependencies = [ "anchor-lang", "borsh 0.10.4", @@ -3949,7 +3949,7 @@ dependencies = [ [[package]] name = "light-sdk-macros" -version = "0.15.0" +version = "0.16.0" dependencies = [ "borsh 0.10.4", "light-account-checks", @@ -3967,7 +3967,7 @@ dependencies = [ [[package]] name = "light-sdk-pinocchio" -version = "0.13.0" +version = "0.14.0" dependencies = [ "borsh 0.10.4", "light-account-checks", @@ -3983,7 +3983,7 @@ dependencies = [ [[package]] name = "light-sdk-types" -version = "0.15.0" +version = "0.16.0" dependencies = [ "anchor-lang", "borsh 0.10.4", diff --git a/Cargo.toml b/Cargo.toml index 3ee033b374..6c1ca5e59f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,18 +167,18 @@ light-hash-set = { version = "3.0.0", path = "program-libs/hash-set" } light-indexed-merkle-tree = { version = "3.0.0", path = "program-libs/indexed-merkle-tree" } light-concurrent-merkle-tree = { version = "3.0.0", path = "program-libs/concurrent-merkle-tree" } light-sparse-merkle-tree = { version = "0.2.0", path = "sparse-merkle-tree" } -light-client = { path = "sdk-libs/client", version = "0.15.0" } +light-client = { path = "sdk-libs/client", version = "0.16.0" } light-event = { path = "sdk-libs/event", version = "0.1.0" } light-hasher = { path = "program-libs/hasher", version = "4.0.0", default-features = false } light-macros = { path = "program-libs/macros", version = "2.1.0" } light-merkle-tree-reference = { path = "program-tests/merkle-tree", version = "3.0.1" } light-heap = { path = "program-libs/heap", version = "2.0.0" } -light-prover-client = { path = "prover/client", version = "3.0.0" } -light-sdk = { path = "sdk-libs/sdk", version = "0.15.0" } -light-sdk-pinocchio = { path = "sdk-libs/sdk-pinocchio", version = "0.13.0" } -light-sdk-macros = { path = "sdk-libs/macros", version = "0.15.0" } -light-sdk-types = { path = "sdk-libs/sdk-types", version = "0.15.0", default-features = false } -light-compressed-account = { path = "program-libs/compressed-account", version = "0.5.0", default-features = false } +light-prover-client = { path = "prover/client", version = "4.0.0" } +light-sdk = { path = "sdk-libs/sdk", version = "0.16.0" } +light-sdk-pinocchio = { path = "sdk-libs/sdk-pinocchio", version = "0.14.0" } +light-sdk-macros = { path = "sdk-libs/macros", version = "0.16.0" } +light-sdk-types = { path = "sdk-libs/sdk-types", version = "0.16.0", default-features = false } +light-compressed-account = { path = "program-libs/compressed-account", version = "0.6.0", default-features = false } light-compressible = { path = "program-libs/compressible", version = "0.1.0" } light-ctoken-types = { path = "program-libs/ctoken-types", version = "0.1.0" } light-account-checks = { path = "program-libs/account-checks", version = "0.4.0", default-features = false } @@ -205,7 +205,7 @@ light-registry = { path = "programs/registry", version = "2.0.0", features = [ create-address-test-program = { path = "program-tests/create-address-test-program", version = "1.0.0", features = [ "cpi", ] } -light-program-test = { path = "sdk-libs/program-test", version = "0.15.0" } +light-program-test = { path = "sdk-libs/program-test", version = "0.16.0" } light-batched-merkle-tree = { path = "program-libs/batched-merkle-tree", version = "0.5.0" } light-merkle-tree-metadata = { path = "program-libs/merkle-tree-metadata", version = "0.5.0" } aligned-sized = { path = "program-libs/aligned-sized", version = "1.1.0" } diff --git a/cli/package.json b/cli/package.json index c66d143ba6..57a1e2518f 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@lightprotocol/zk-compression-cli", - "version": "0.27.0", + "version": "0.27.1-alpha.2", "description": "ZK Compression: Secure Scaling on Solana", "maintainers": [ { diff --git a/js/compressed-token/package.json b/js/compressed-token/package.json index 77834ab3f6..fdf9075985 100644 --- a/js/compressed-token/package.json +++ b/js/compressed-token/package.json @@ -1,6 +1,6 @@ { "name": "@lightprotocol/compressed-token", - "version": "0.22.0", + "version": "0.22.1-alpha.2", "description": "JS client to interact with the compressed-token program", "sideEffects": false, "main": "dist/cjs/node/index.cjs", diff --git a/js/stateless.js/package.json b/js/stateless.js/package.json index 7202b6bfec..798a2cc7fd 100644 --- a/js/stateless.js/package.json +++ b/js/stateless.js/package.json @@ -1,6 +1,6 @@ { "name": "@lightprotocol/stateless.js", - "version": "0.22.0", + "version": "0.22.1-alpha.1", "description": "JavaScript API for Light & ZK Compression", "sideEffects": false, "main": "dist/cjs/node/index.cjs", diff --git a/program-libs/compressed-account/Cargo.toml b/program-libs/compressed-account/Cargo.toml index fe21b4e1e4..8bdbd90ff8 100644 --- a/program-libs/compressed-account/Cargo.toml +++ b/program-libs/compressed-account/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-compressed-account" -version = "0.5.0" +version = "0.6.0" description = "Compressed account struct and common utility functions used in Light Protocol." repository = "https://github.com/Lightprotocol/light-protocol" license = "Apache-2.0" diff --git a/program-libs/compressed-account/src/instruction_data/compressed_proof.rs b/program-libs/compressed-account/src/instruction_data/compressed_proof.rs index 7507bbf477..de6c7c6a15 100644 --- a/program-libs/compressed-account/src/instruction_data/compressed_proof.rs +++ b/program-libs/compressed-account/src/instruction_data/compressed_proof.rs @@ -39,6 +39,34 @@ impl Default for CompressedProof { } } +impl CompressedProof { + /// Convert the proof to a fixed-size byte array [u8; 128] + pub fn to_array(&self) -> [u8; 128] { + let mut result = [0u8; 128]; + result[0..32].copy_from_slice(&self.a); + result[32..96].copy_from_slice(&self.b); + result[96..128].copy_from_slice(&self.c); + result + } +} + +impl TryFrom<&[u8]> for CompressedProof { + type Error = crate::CompressedAccountError; + + fn try_from(bytes: &[u8]) -> Result { + if bytes.len() < 128 { + return Err(crate::CompressedAccountError::InvalidProofSize(bytes.len())); + } + let mut a = [0u8; 32]; + let mut b = [0u8; 64]; + let mut c = [0u8; 32]; + a.copy_from_slice(&bytes[0..32]); + b.copy_from_slice(&bytes[32..96]); + c.copy_from_slice(&bytes[96..128]); + Ok(Self { a, b, c }) + } +} + impl<'a> ZeroCopyAt<'a> for CompressedProof { type ZeroCopyAt = Ref<&'a [u8], Self>; fn zero_copy_at(bytes: &'a [u8]) -> Result<(Self::ZeroCopyAt, &'a [u8]), ZeroCopyError> { @@ -61,6 +89,12 @@ impl ValidityProof { pub fn new(proof: Option) -> Self { Self(proof) } + + /// Convert the validity proof to a fixed-size byte array [u8; 128] + /// Returns None if the proof is None + pub fn to_array(&self) -> Option<[u8; 128]> { + self.0.as_ref().map(|proof| proof.to_array()) + } } impl From for ValidityProof { @@ -86,6 +120,21 @@ impl From<&Option> for ValidityProof { } } +impl TryFrom<&[u8]> for ValidityProof { + type Error = crate::CompressedAccountError; + + /// Convert bytes to ValidityProof. + /// Empty slice returns None, otherwise attempts to parse as CompressedProof and returns Some. + fn try_from(bytes: &[u8]) -> Result { + if bytes.is_empty() { + Ok(Self(None)) + } else { + let proof = CompressedProof::try_from(bytes)?; + Ok(Self(Some(proof))) + } + } +} + #[allow(clippy::from_over_into)] impl Into> for ValidityProof { fn into(self) -> Option { diff --git a/program-libs/compressed-account/src/lib.rs b/program-libs/compressed-account/src/lib.rs index f30a29d165..10da835ccf 100644 --- a/program-libs/compressed-account/src/lib.rs +++ b/program-libs/compressed-account/src/lib.rs @@ -76,6 +76,8 @@ pub enum CompressedAccountError { InstructionDataExpectedProof, #[error("Expected proof for compressed account got None.")] ZeroCopyExpectedProof, + #[error("Invalid proof size: expected 128 bytes, got {0}")] + InvalidProofSize(usize), } // NOTE(vadorovsky): Unfortunately, we need to do it by hand. @@ -103,6 +105,7 @@ impl From for u32 { CompressedAccountError::ZeroCopyExpectedProof => 12022, CompressedAccountError::ExpectedDataHash => 12023, CompressedAccountError::InvalidCpiContext => 12024, + CompressedAccountError::InvalidProofSize(_) => 12025, CompressedAccountError::HasherError(e) => u32::from(e), } } diff --git a/programs/compressed-token/program/src/mint_action/actions/mint_to.rs b/programs/compressed-token/program/src/mint_action/actions/mint_to.rs index 027197432f..b0b4679884 100644 --- a/programs/compressed-token/program/src/mint_action/actions/mint_to.rs +++ b/programs/compressed-token/program/src/mint_action/actions/mint_to.rs @@ -6,7 +6,7 @@ use light_ctoken_types::{ state::CompressedMint, }; use light_program_profiler::profile; -use light_sdk_pinocchio::ZOutputCompressedAccountWithPackedContextMut; +use light_sdk_pinocchio::instruction::ZOutputCompressedAccountWithPackedContextMut; use crate::{ mint_action::{ diff --git a/prover/client/Cargo.toml b/prover/client/Cargo.toml index 0579cde9a5..0123c73582 100644 --- a/prover/client/Cargo.toml +++ b/prover/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-prover-client" -version = "3.0.0" +version = "4.0.0" description = "Crate for interacting with Light Protocol circuits" repository = "https://github.com/Lightprotocol/light-protocol" license = "Apache-2.0" diff --git a/sdk-libs/client/Cargo.toml b/sdk-libs/client/Cargo.toml index 6b1fed932e..ea89387e43 100644 --- a/sdk-libs/client/Cargo.toml +++ b/sdk-libs/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-client" -version = "0.15.0" +version = "0.16.0" edition = "2021" license = "Apache-2.0" repository = "https://github.com/lightprotocol/light-protocol" diff --git a/sdk-libs/macros/Cargo.toml b/sdk-libs/macros/Cargo.toml index 8f43ea4ffd..124d3e1e0c 100644 --- a/sdk-libs/macros/Cargo.toml +++ b/sdk-libs/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-sdk-macros" -version = "0.15.0" +version = "0.16.0" description = "Macros for Programs using the Light SDK for ZK Compression " repository = "https://github.com/Lightprotocol/light-protocol" license = "Apache-2.0" diff --git a/sdk-libs/program-test/Cargo.toml b/sdk-libs/program-test/Cargo.toml index 0317748aca..ee75a7fd74 100644 --- a/sdk-libs/program-test/Cargo.toml +++ b/sdk-libs/program-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-program-test" -version = "0.15.0" +version = "0.16.0" description = "A fast local test environment for Solana programs using compressed accounts and tokens." license = "MIT" edition = "2021" diff --git a/sdk-libs/sdk-pinocchio/Cargo.toml b/sdk-libs/sdk-pinocchio/Cargo.toml index 4d20e3e46e..52522780f1 100644 --- a/sdk-libs/sdk-pinocchio/Cargo.toml +++ b/sdk-libs/sdk-pinocchio/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-sdk-pinocchio" -version = "0.13.0" +version = "0.14.0" description = "Rust SDK for ZK Compression on Solana with Pinocchio features" repository = "https://github.com/Lightprotocol/light-protocol" license = "Apache-2.0" diff --git a/sdk-libs/sdk-pinocchio/src/address.rs b/sdk-libs/sdk-pinocchio/src/address.rs index 179a8e4d7d..674dfe15fd 100644 --- a/sdk-libs/sdk-pinocchio/src/address.rs +++ b/sdk-libs/sdk-pinocchio/src/address.rs @@ -1,30 +1,6 @@ -use pinocchio::{account_info::AccountInfo, pubkey::Pubkey}; - -// Define data structures needed -#[derive(Clone, Debug, Default)] -pub struct NewAddressParams { - pub seed: [u8; 32], - pub address_queue_pubkey: [u8; 32], - pub address_merkle_tree_pubkey: [u8; 32], - pub address_merkle_tree_root_index: u16, -} - -pub fn unpack_new_address_params( - address_params: &crate::NewAddressParamsPacked, - remaining_accounts: &[AccountInfo], -) -> NewAddressParams { - let address_merkle_tree_pubkey = - remaining_accounts[address_params.address_merkle_tree_account_index as usize].key(); - let address_queue_pubkey = - remaining_accounts[address_params.address_queue_account_index as usize].key(); - - NewAddressParams { - seed: address_params.seed, - address_queue_pubkey: *address_queue_pubkey, - address_merkle_tree_pubkey: *address_merkle_tree_pubkey, - address_merkle_tree_root_index: address_params.address_merkle_tree_root_index, - } -} +pub use light_compressed_account::instruction_data::data::NewAddressParamsPacked; +pub use light_sdk_types::address::AddressSeed; +use pinocchio::pubkey::Pubkey; pub mod v1 { use light_sdk_types::address::AddressSeed; diff --git a/sdk-libs/sdk-pinocchio/src/cpi/account.rs b/sdk-libs/sdk-pinocchio/src/cpi/account.rs new file mode 100644 index 0000000000..4e5216481f --- /dev/null +++ b/sdk-libs/sdk-pinocchio/src/cpi/account.rs @@ -0,0 +1,25 @@ +#[cfg(all(not(feature = "std"), feature = "alloc"))] +extern crate alloc; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::vec::Vec; +#[cfg(feature = "std")] +use std::vec::Vec; + +use pinocchio::instruction::AccountMeta; + +/// Trait for types that can provide account information for CPI calls +pub trait CpiAccountsTrait { + /// Convert to a vector of AccountMeta references for instruction + fn to_account_metas(&self) -> crate::error::Result>>; + + /// Convert to account infos for invoke + fn to_account_infos_for_invoke( + &self, + ) -> crate::error::Result>; + + /// Get the CPI signer bump + fn bump(&self) -> u8; + + /// Get the mode for the instruction (0 for v1, 1 for v2) + fn get_mode(&self) -> u8; +} diff --git a/sdk-libs/sdk-pinocchio/src/cpi/instruction.rs b/sdk-libs/sdk-pinocchio/src/cpi/instruction.rs new file mode 100644 index 0000000000..aa0f993683 --- /dev/null +++ b/sdk-libs/sdk-pinocchio/src/cpi/instruction.rs @@ -0,0 +1,22 @@ +use light_compressed_account::instruction_data::compressed_proof::ValidityProof; +pub use light_compressed_account::LightInstructionData; + +/// Trait for Light CPI instruction types +pub trait LightCpiInstruction: Sized { + fn new_cpi(cpi_signer: light_sdk_types::CpiSigner, proof: ValidityProof) -> Self; + + #[cfg(feature = "light-account")] + fn with_light_account( + self, + account: crate::LightAccount<'_, A>, + ) -> Result + where + A: borsh::BorshSerialize + + borsh::BorshDeserialize + + crate::LightDiscriminator + + light_hasher::DataHasher + + Default; + + fn get_mode(&self) -> u8; + fn get_bump(&self) -> u8; +} diff --git a/sdk-libs/sdk-pinocchio/src/cpi/traits.rs b/sdk-libs/sdk-pinocchio/src/cpi/invoke.rs similarity index 70% rename from sdk-libs/sdk-pinocchio/src/cpi/traits.rs rename to sdk-libs/sdk-pinocchio/src/cpi/invoke.rs index 880f87b4c4..2abd6425c2 100644 --- a/sdk-libs/sdk-pinocchio/src/cpi/traits.rs +++ b/sdk-libs/sdk-pinocchio/src/cpi/invoke.rs @@ -1,61 +1,17 @@ -#[cfg(all(not(feature = "std"), feature = "alloc"))] -extern crate alloc; -#[cfg(all(not(feature = "std"), feature = "alloc"))] -use alloc::vec::Vec; -#[cfg(feature = "std")] -use std::vec::Vec; - -use light_compressed_account::instruction_data::compressed_proof::ValidityProof; pub use light_compressed_account::LightInstructionData; use light_sdk_types::constants::{CPI_AUTHORITY_PDA_SEED, LIGHT_SYSTEM_PROGRAM_ID}; #[cfg(any(feature = "std", feature = "alloc"))] use pinocchio::pubkey::Pubkey; use pinocchio::{ cpi::slice_invoke_signed, - instruction::{AccountMeta, Instruction, Seed, Signer}, + instruction::{Instruction, Seed, Signer}, program_error::ProgramError, }; +use super::{account::CpiAccountsTrait, instruction::LightCpiInstruction}; #[cfg(any(feature = "std", feature = "alloc"))] use crate::error::LightSdkError; -/// Trait for types that can provide account information for CPI calls -pub trait CpiAccountsTrait { - /// Convert to a vector of AccountMeta references for instruction - fn to_account_metas(&self) -> crate::error::Result>>; - - /// Convert to account infos for invoke - fn to_account_infos_for_invoke( - &self, - ) -> crate::error::Result>; - - /// Get the CPI signer bump - fn bump(&self) -> u8; - - /// Get the mode for the instruction (0 for v1, 1 for v2) - fn get_mode(&self) -> u8; -} - -/// Trait for Light CPI instruction types -pub trait LightCpiInstruction: Sized { - fn new_cpi(cpi_signer: light_sdk_types::CpiSigner, proof: ValidityProof) -> Self; - - #[cfg(feature = "light-account")] - fn with_light_account( - self, - account: crate::LightAccount<'_, A>, - ) -> Result - where - A: borsh::BorshSerialize - + borsh::BorshDeserialize - + crate::LightDiscriminator - + light_hasher::DataHasher - + Default; - - fn get_mode(&self) -> u8; - fn get_bump(&self) -> u8; -} - pub trait InvokeLightSystemProgram { #[cfg(any(feature = "std", feature = "alloc"))] fn invoke(self, accounts: impl CpiAccountsTrait) -> Result<(), ProgramError>; @@ -130,6 +86,11 @@ where } } +/// Low-level function to invoke the Light system program with a PDA signer. +/// +/// **Note**: This is a low-level function. In most cases, you should use the +/// [`InvokeLightSystemProgram`] trait methods instead, which provide a higher-level +/// interface with better type safety and ergonomics. #[inline(always)] pub fn invoke_light_system_program( account_infos: &[&pinocchio::account_info::AccountInfo], diff --git a/sdk-libs/sdk-pinocchio/src/cpi/mod.rs b/sdk-libs/sdk-pinocchio/src/cpi/mod.rs index 40851e4295..a279a9b216 100644 --- a/sdk-libs/sdk-pinocchio/src/cpi/mod.rs +++ b/sdk-libs/sdk-pinocchio/src/cpi/mod.rs @@ -1,7 +1,15 @@ -mod traits; +mod account; +mod instruction; +pub mod invoke; + pub mod v1; #[cfg(feature = "v2")] pub mod v2; -pub use light_sdk_types::cpi_accounts::CpiAccountsConfig; -pub use traits::*; +pub use account::*; +pub use instruction::*; +pub use invoke::InvokeLightSystemProgram; +/// Derives cpi signer and bump to invoke the light system program at compile time. +pub use light_macros::derive_light_cpi_signer; +/// Contains program id, derived cpi signer, and bump. +pub use light_sdk_types::{cpi_accounts::CpiAccountsConfig, CpiSigner}; diff --git a/sdk-libs/sdk-pinocchio/src/cpi/v1/invoke.rs b/sdk-libs/sdk-pinocchio/src/cpi/v1/invoke.rs index 6c894bd48b..e2486b9ebc 100644 --- a/sdk-libs/sdk-pinocchio/src/cpi/v1/invoke.rs +++ b/sdk-libs/sdk-pinocchio/src/cpi/v1/invoke.rs @@ -3,10 +3,11 @@ use light_compressed_account::instruction_data::{ }; #[cfg(feature = "light-account")] use light_sdk_types::instruction::account_info::CompressedAccountInfoTrait; +use light_sdk_types::CpiSigner; use crate::{ - cpi::traits::{LightCpiInstruction, LightInstructionData}, - BorshSerialize, CpiSigner, + cpi::{LightCpiInstruction, LightInstructionData}, + BorshSerialize, }; /// V1 wrapper struct for InstructionDataInvokeCpi with CpiSigner diff --git a/sdk-libs/sdk-pinocchio/src/instruction/mod.rs b/sdk-libs/sdk-pinocchio/src/instruction/mod.rs index b28b45fcba..91f2989e45 100644 --- a/sdk-libs/sdk-pinocchio/src/instruction/mod.rs +++ b/sdk-libs/sdk-pinocchio/src/instruction/mod.rs @@ -1 +1,5 @@ +pub use light_compressed_account::instruction_data::{ + compressed_proof::{CompressedProof, ValidityProof}, + data::*, +}; pub use light_sdk_types::instruction::*; diff --git a/sdk-libs/sdk-pinocchio/src/lib.rs b/sdk-libs/sdk-pinocchio/src/lib.rs index 6326ffd54d..551ccd9064 100644 --- a/sdk-libs/sdk-pinocchio/src/lib.rs +++ b/sdk-libs/sdk-pinocchio/src/lib.rs @@ -2,20 +2,18 @@ pub mod address; pub mod cpi; pub mod error; pub mod instruction; +// TODO: Add tree_info module with helpers for packing/unpacking address tree info +// Similar to light-sdk's tree_info.rs but adapted for pinocchio (no Anchor dependencies) +// Should include: pack_address_tree_info, unpack_address_tree_info, AddressTreeInfo struct #[cfg(feature = "light-account")] pub(crate) use borsh::BorshDeserialize; pub(crate) use borsh::BorshSerialize; -pub use cpi::{v1::CpiAccounts, CpiAccountsConfig}; pub use light_account_checks::discriminator::Discriminator as LightDiscriminator; -pub use light_compressed_account::{ - self, - instruction_data::{compressed_proof::ValidityProof, data::*}, -}; pub use light_hasher; -pub use light_macros::derive_light_cpi_signer; +pub use light_macros::{derive_light_cpi_signer, derive_light_cpi_signer_pda}; #[cfg(feature = "light-account")] pub use light_sdk::LightAccount; #[cfg(feature = "light-account")] pub use light_sdk_macros::{LightDiscriminator, LightHasher}; -pub use light_sdk_types::{self, constants, CpiSigner}; +pub use light_sdk_types::{constants, CpiSigner}; diff --git a/sdk-libs/sdk-types/Cargo.toml b/sdk-libs/sdk-types/Cargo.toml index df90c0231e..89e749c568 100644 --- a/sdk-libs/sdk-types/Cargo.toml +++ b/sdk-libs/sdk-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-sdk-types" -version = "0.15.0" +version = "0.16.0" edition = "2021" license = "Apache-2.0" repository = "https://github.com/lightprotocol/light-protocol" diff --git a/sdk-libs/sdk/Cargo.toml b/sdk-libs/sdk/Cargo.toml index 2e8d915b79..8f15ff961d 100644 --- a/sdk-libs/sdk/Cargo.toml +++ b/sdk-libs/sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "light-sdk" -version = "0.15.0" +version = "0.16.0" description = "Rust SDK for ZK Compression on Solana" repository = "https://github.com/Lightprotocol/light-protocol" license = "Apache-2.0" diff --git a/sdk-libs/sdk/src/lib.rs b/sdk-libs/sdk/src/lib.rs index f32f6a3a4f..b5f6f577a3 100644 --- a/sdk-libs/sdk/src/lib.rs +++ b/sdk-libs/sdk/src/lib.rs @@ -167,7 +167,7 @@ pub use light_macros::{derive_light_cpi_signer, derive_light_cpi_signer_pda}; pub use light_sdk_macros::{ light_system_accounts, LightDiscriminator, LightHasher, LightHasherSha, LightTraits, }; -pub use light_sdk_types::constants; +pub use light_sdk_types::{constants, CpiSigner}; use solana_account_info::AccountInfo; use solana_cpi::invoke_signed; use solana_instruction::{AccountMeta, Instruction}; diff --git a/sdk-tests/sdk-pinocchio-v1-test/src/create_pda.rs b/sdk-tests/sdk-pinocchio-v1-test/src/create_pda.rs index f69085a9e1..2588617dcc 100644 --- a/sdk-tests/sdk-pinocchio-v1-test/src/create_pda.rs +++ b/sdk-tests/sdk-pinocchio-v1-test/src/create_pda.rs @@ -5,8 +5,8 @@ use light_sdk_pinocchio::{ InvokeLightSystemProgram, LightCpiInstruction, }, error::LightSdkError, - instruction::PackedAddressTreeInfo, - LightAccount, LightDiscriminator, LightHasher, ValidityProof, + instruction::{PackedAddressTreeInfo, ValidityProof}, + LightAccount, LightDiscriminator, LightHasher, }; use pinocchio::account_info::AccountInfo; diff --git a/sdk-tests/sdk-pinocchio-v1-test/src/update_pda.rs b/sdk-tests/sdk-pinocchio-v1-test/src/update_pda.rs index 77b360fb53..0c844141ab 100644 --- a/sdk-tests/sdk-pinocchio-v1-test/src/update_pda.rs +++ b/sdk-tests/sdk-pinocchio-v1-test/src/update_pda.rs @@ -5,8 +5,8 @@ use light_sdk_pinocchio::{ InvokeLightSystemProgram, LightCpiInstruction, }, error::LightSdkError, - instruction::account_meta::CompressedAccountMeta, - LightAccount, ValidityProof, + instruction::{account_meta::CompressedAccountMeta, ValidityProof}, + LightAccount, }; use pinocchio::{ account_info::AccountInfo, log::sol_log_compute_units, program_error::ProgramError, diff --git a/sdk-tests/sdk-pinocchio-v2-test/src/create_pda.rs b/sdk-tests/sdk-pinocchio-v2-test/src/create_pda.rs index 4170b8d616..77648edcbf 100644 --- a/sdk-tests/sdk-pinocchio-v2-test/src/create_pda.rs +++ b/sdk-tests/sdk-pinocchio-v2-test/src/create_pda.rs @@ -6,8 +6,8 @@ use light_sdk_pinocchio::{ InvokeLightSystemProgram, LightCpiInstruction, }, error::LightSdkError, - instruction::PackedAddressTreeInfo, - LightAccount, LightDiscriminator, LightHasher, ValidityProof, + instruction::{PackedAddressTreeInfo, ValidityProof}, + LightAccount, LightDiscriminator, LightHasher, }; use pinocchio::{account_info::AccountInfo, program_error::ProgramError}; diff --git a/sdk-tests/sdk-pinocchio-v2-test/src/update_pda.rs b/sdk-tests/sdk-pinocchio-v2-test/src/update_pda.rs index af0119e7a0..f0b2430172 100644 --- a/sdk-tests/sdk-pinocchio-v2-test/src/update_pda.rs +++ b/sdk-tests/sdk-pinocchio-v2-test/src/update_pda.rs @@ -5,8 +5,8 @@ use light_sdk_pinocchio::{ v2::{CpiAccounts, LightSystemProgramCpi}, InvokeLightSystemProgram, LightCpiInstruction, }, - instruction::account_meta::CompressedAccountMeta, - LightAccount, ValidityProof, + instruction::{account_meta::CompressedAccountMeta, ValidityProof}, + LightAccount, }; use pinocchio::{account_info::AccountInfo, program_error::ProgramError}; diff --git a/sdk-tests/sdk-pinocchio-v2-test/tests/test.rs b/sdk-tests/sdk-pinocchio-v2-test/tests/test.rs index 93f0938fbc..59a0562c63 100644 --- a/sdk-tests/sdk-pinocchio-v2-test/tests/test.rs +++ b/sdk-tests/sdk-pinocchio-v2-test/tests/test.rs @@ -189,7 +189,7 @@ pub async fn update_pda( .try_into() .unwrap(), }, - proof: light_sdk_pinocchio::ValidityProof(None), + proof: light_sdk_pinocchio::instruction::ValidityProof(None), new_data: new_account_data, system_accounts_offset: system_accounts_offset as u8, };