Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
744 changes: 414 additions & 330 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ members = [
"program-tests/system-cpi-test",
"program-tests/system-cpi-v2-test",
"program-tests/system-test",
"program-tests/sdk-anchor-test/programs/sdk-anchor-test",
"program-tests/sdk-test",
"program-tests/sdk-pinocchio-test",
"sdk-tests/sdk-anchor-test/programs/sdk-anchor-test",
"sdk-tests/sdk-test",
"sdk-tests/sdk-pinocchio-test",
"program-tests/create-address-test-program",
"program-tests/utils",
"program-tests/merkle-tree",
"program-tests/client-test",
"sdk-tests/client-test",
"forester-utils",
"forester",
"sparse-merkle-tree",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions sdk-tests/sdk-anchor-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"scripts": {
"test": "cargo test-sbf -p sdk-test"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0"
},
"devDependencies": {
"@lightprotocol/zk-compression-cli": "workspace:*",
"chai": "^5.2.0",
"mocha": "^11.7.1",
"ts-mocha": "^11.1.0",
"@types/bn.js": "^5.2.0",
"@types/chai": "^5.2.2",
"@types/mocha": "^10.0.10",
"typescript": "^5.9.2",
"prettier": "^3.6.2"
}
}
Comment on lines +1 to +19
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add required package metadata for workspace compatibility (name/private/version).

This package references a workspace dependency ("workspace:") but lacks "name", "private", and "version". Most workspace managers (npm/yarn/pnpm) require at least "name" (and often "version" + "private": true) for the package to be recognized as a workspace member. Without these, resolution of "workspace:" can fail or behave unexpectedly.

Apply this diff to add minimal, safe metadata:

 {
+  "name": "@lightprotocol/sdk-anchor-test",
+  "private": true,
+  "version": "0.0.0",
   "scripts": {
     "test": "cargo test-sbf -p sdk-test"
   },
   "dependencies": {
     "@coral-xyz/anchor": "^0.29.0"
   },
   "devDependencies": {
     "@lightprotocol/zk-compression-cli": "workspace:*",
     "chai": "^5.2.0",
     "mocha": "^11.7.1",
     "ts-mocha": "^11.1.0",
     "@types/bn.js": "^5.2.0",
     "@types/chai": "^5.2.2",
     "@types/mocha": "^10.0.10",
     "typescript": "^5.9.2",
     "prettier": "^3.6.2"
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"scripts": {
"test": "cargo test-sbf -p sdk-test"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0"
},
"devDependencies": {
"@lightprotocol/zk-compression-cli": "workspace:*",
"chai": "^5.2.0",
"mocha": "^11.7.1",
"ts-mocha": "^11.1.0",
"@types/bn.js": "^5.2.0",
"@types/chai": "^5.2.2",
"@types/mocha": "^10.0.10",
"typescript": "^5.9.2",
"prettier": "^3.6.2"
}
}
{
"name": "@lightprotocol/sdk-anchor-test",
"private": true,
"version": "0.0.0",
"scripts": {
"test": "cargo test-sbf -p sdk-test"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0"
},
"devDependencies": {
"@lightprotocol/zk-compression-cli": "workspace:*",
"chai": "^5.2.0",
"mocha": "^11.7.1",
"ts-mocha": "^11.1.0",
"@types/bn.js": "^5.2.0",
"@types/chai": "^5.2.2",
"@types/mocha": "^10.0.10",
"typescript": "^5.9.2",
"prettier": "^3.6.2"
}
}
🤖 Prompt for AI Agents
In sdk-tests/sdk-anchor-test/package.json around lines 1 to 19, the package.json
is missing required workspace metadata (name, version, private) which prevents
resolving "workspace:*"; add a valid "name" (unique, npm-safe), a "version"
(e.g., "1.0.0"), and "private": true at the top level of the JSON so the package
is recognized as a workspace member while keeping the existing
scripts/dependencies unchanged.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ solana-program = { workspace = true }
light-macros = { workspace = true, features = ["solana"] }
borsh = { workspace = true }
light-compressed-account = { workspace = true, features = ["solana"] }
light-zero-copy = { workspace = true }

[dev-dependencies]
light-program-test = { workspace = true, features = ["devenv"] }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use light_sdk::{
light_hasher::hash_to_field_size::hashv_to_bn254_field_size_be_const_array,
LightDiscriminator, LightHasher,
};
use solana_program::account_info::AccountInfo;
use solana_program::{account_info::AccountInfo, msg};

use crate::ARRAY_LEN;

/// TODO: write test program with A8JgviaEAByMVLBhcebpDQ7NMuZpqBTBigC1b83imEsd (inconvenient program id)
/// CU usage:
Expand All @@ -17,9 +19,11 @@ pub fn create_pda<const BATCHED: bool>(
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> Result<(), LightSdkError> {
msg!("pre instruction_data");
let mut instruction_data = instruction_data;
let instruction_data = CreatePdaInstructionData::deserialize(&mut instruction_data)
.map_err(|_| LightSdkError::Borsh)?;
msg!("pre config");
let config = CpiAccountsConfig::new(crate::LIGHT_CPI_SIGNER);
let cpi_accounts = CpiAccounts::try_new_with_config(
&accounts[0],
Expand Down Expand Up @@ -51,7 +55,7 @@ pub fn create_pda<const BATCHED: bool>(
)
};
let new_address_params = address_tree_info.into_new_address_params_packed(address_seed);

msg!("pre account");
let mut my_compressed_account = LightAccount::<'_, MyCompressedAccount>::new_init(
&crate::ID,
Some(address),
Expand All @@ -69,19 +73,27 @@ pub fn create_pda<const BATCHED: bool>(
Ok(())
}

#[derive(
Clone, Debug, Default, LightHasher, LightDiscriminator, BorshDeserialize, BorshSerialize,
)]
#[derive(Clone, Debug, LightHasher, LightDiscriminator, BorshDeserialize, BorshSerialize)]
pub struct MyCompressedAccount {
pub data: [u8; 31],
#[hash]
pub data: [u8; ARRAY_LEN],
}

impl Default for MyCompressedAccount {
fn default() -> Self {
Self {
data: [0u8; ARRAY_LEN],
}
}
}

#[derive(Clone, Debug, Default, BorshDeserialize, BorshSerialize)]
#[derive(Clone, Debug, BorshDeserialize, BorshSerialize)]
#[repr(C)]
pub struct CreatePdaInstructionData {
pub proof: ValidityProof,
pub address_tree_info: PackedAddressTreeInfo,
pub output_merkle_tree_index: u8,
pub data: [u8; 31],
pub data: [u8; ARRAY_LEN],
pub system_accounts_offset: u8,
pub tree_accounts_offset: u8,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use solana_program::{
pub mod create_pda;
pub mod update_pda;

pub const ARRAY_LEN: usize = 2200;

pub const ID: Pubkey = pubkey!("FNt7byTHev1k5x2cXZLBr8TdWiC3zoP5vcnZR4P682Uy");
pub const LIGHT_CPI_SIGNER: CpiSigner =
derive_light_cpi_signer!("FNt7byTHev1k5x2cXZLBr8TdWiC3zoP5vcnZR4P682Uy");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use light_sdk::{
};
use solana_program::{account_info::AccountInfo, log::sol_log_compute_units};

use crate::create_pda::MyCompressedAccount;
use crate::{create_pda::MyCompressedAccount, ARRAY_LEN};

/// CU usage:
/// - sdk pre system program 9,183k CU
Expand Down Expand Up @@ -50,16 +50,35 @@ pub fn update_pda<const BATCHED: bool>(
Ok(())
}

#[derive(Clone, Debug, Default, BorshDeserialize, BorshSerialize)]
#[derive(Clone, Debug, BorshDeserialize, BorshSerialize)]
pub struct UpdatePdaInstructionData {
pub proof: ValidityProof,
pub my_compressed_account: UpdateMyCompressedAccount,
pub new_data: [u8; 31],
pub new_data: [u8; ARRAY_LEN],
pub system_accounts_offset: u8,
}
impl Default for UpdatePdaInstructionData {
fn default() -> Self {
Self {
new_data: [0u8; ARRAY_LEN],
my_compressed_account: UpdateMyCompressedAccount::default(),
system_accounts_offset: 0,
proof: ValidityProof::default(),
}
}
}

#[derive(Clone, Debug, Default, BorshDeserialize, BorshSerialize)]
#[derive(Clone, Debug, BorshDeserialize, BorshSerialize)]
pub struct UpdateMyCompressedAccount {
pub meta: CompressedAccountMeta,
pub data: [u8; 31],
pub data: [u8; ARRAY_LEN],
}

impl Default for UpdateMyCompressedAccount {
fn default() -> Self {
Self {
meta: CompressedAccountMeta::default(),
data: [0u8; ARRAY_LEN],
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "test-sbf")]
//#![cfg(feature = "test-sbf")]

use borsh::BorshSerialize;
use light_compressed_account::{
Expand All @@ -14,6 +14,7 @@ use light_sdk::instruction::{
use sdk_test::{
create_pda::CreatePdaInstructionData,
update_pda::{UpdateMyCompressedAccount, UpdatePdaInstructionData},
ARRAY_LEN,
};
use solana_sdk::{
instruction::Instruction,
Expand All @@ -28,7 +29,7 @@ async fn test_sdk_test() {
let payer = rpc.get_payer().insecure_clone();

let address_tree_pubkey = rpc.get_address_merkle_tree_v2();
let account_data = [1u8; 31];
let account_data = [1u8; ARRAY_LEN];

// // V1 trees
// let (address, _) = light_sdk::address::derive_address(
Expand Down Expand Up @@ -65,7 +66,7 @@ async fn test_sdk_test() {
.clone();
assert_eq!(compressed_pda.address.unwrap(), address);

update_pda(&payer, &mut rpc, [2u8; 31], compressed_pda.into())
update_pda(&payer, &mut rpc, [2u8; ARRAY_LEN], compressed_pda.into())
.await
.unwrap();
}
Expand All @@ -74,7 +75,7 @@ pub async fn create_pda(
payer: &Keypair,
rpc: &mut LightProgramTest,
merkle_tree_pubkey: &Pubkey,
account_data: [u8; 31],
account_data: [u8; ARRAY_LEN],
address_tree_pubkey: Pubkey,
address: [u8; 32],
) -> Result<(), RpcError> {
Expand Down Expand Up @@ -123,7 +124,7 @@ pub async fn create_pda(
pub async fn update_pda(
payer: &Keypair,
rpc: &mut LightProgramTest,
new_account_data: [u8; 31],
new_account_data: [u8; ARRAY_LEN],
compressed_account: CompressedAccountWithMerkleContext,
) -> Result<(), RpcError> {
let system_account_meta_config = SystemAccountMetaConfig::new(sdk_test::ID);
Expand Down