Skip to content

chore: csdk#2020

Merged
ananas-block merged 4 commits intomainfrom
swen/csdk
Nov 18, 2025
Merged

chore: csdk#2020
ananas-block merged 4 commits intomainfrom
swen/csdk

Conversation

@SwenSchaeferjohann
Copy link
Contributor

@SwenSchaeferjohann SwenSchaeferjohann commented Oct 28, 2025

  • csdk anchor test program in sdk-tests
  • compressible features, compressible_client rust
  • patch in cli/scripts/copyLocalProgramBinaries.sh (todo: investigate)
  • borsh_compat validityProof (todo: check if we can remove already)

Summary by CodeRabbit

  • New Features

    • Cross-type transfers between SPL and compressed tokens; signed CPI variants supported.
    • End-to-end compressible account management: config, compression/decompression, and idempotent batch operations.
    • New client helpers for loading/deserializing compressible accounts and lookup-table support.
  • Refactor

    • API and naming consistency improvements across token/ctoken operations and SDK modules.
    • Reorganized SDK exports to surface compressible/ctoken primitives.
  • Tests

    • Expanded tests and tooling for packing, transfers, compression flows, and simulation utilities.
  • Chores

    • CI workflow and cache enhancements for SDK test coverage.

@SwenSchaeferjohann SwenSchaeferjohann changed the title chore: wip csdk chore: csdk rebase [wip] Oct 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Caution

Review failed

The head commit changed during the review from fe297ce to d9f4796.

Walkthrough

Introduces a compressible account framework, moves token data compatibility into compressed-token-sdk, adds cross-type transfer and signed CPI helpers, introduces a compressible-client crate, updates program-test automation and CI for SDK tests, and applies many API renames/PDAs and dependency updates across SDK crates.

Changes

Cohort / File(s) Summary
CI / Workflows
.github/actions/setup-and-build/action.yml, .github/workflows/cli-v1.yml, .github/workflows/sdk-tests.yml
Expanded cache artifact/key to include SDK test artifacts (csdk_anchor_test.so, sdk-tests Cargo manifests & .rs); changed CLI build step to nx run ...:build-ci; added pre-build cargo build-sbf steps for anchor test paths in sdk-tests matrix.
Workspace & Manifests
Cargo.toml, sdk-libs/*/Cargo.toml, program-libs/*/Cargo.toml, forester/Cargo.toml
Added workspace member sdk-libs/compressible-client / crate light-compressible-client; added/adjusted many workspace dependencies (light-compressible, light-compressible-client, light-compressed-token-sdk, solana-* entries, keccak features in batched-merkle-tree, etc.); toggled optional flags and feature lists.
Compressed-token SDK: core API & modules
sdk-libs/compressed-token-sdk/src/{lib.rs,ctoken.rs,pack.rs,account2.rs,token_pool.rs,token_pool.rs,...}
New ctoken module, pack/compat layer and TokenData compat types; added CTokenAccount2 refactor; added pack/unpack traits and packing tests; token pool PDA helpers and derive_token_pool; many public re-exports and API surface changes.
Transfer / Transfer Interface
sdk-libs/compressed-token-sdk/src/instructions/{transfer_ctoken.rs,transfer_interface.rs}, sdk-libs/token-client/src/actions/**, program-tests/.../transfer2/*
Added transfer_ctoken and signed variant; added transfer_interface and signed routing (SPL <-> ctoken) with bridge validation; renamed and expanded client helpers (ctoken_transfer → transfer_ctoken, ctoken_to_spl_transfer → transfer_ctoken_to_spl) and updated call sites.
Create / ATA / CPI helpers
sdk-libs/compressed-token-sdk/src/instructions/create_token_account/*, create_associated_token_account.rs, program-tests/.../ctoken/*
Renamed create_compressible_token_accountcreate_compressible_token_account_instruction; added create_ctoken_account_signed; added create_associated_ctoken_account and idempotent variant; updated tests to new names.
Mint utilities / renames
sdk-libs/compressed-token-sdk/src/instructions/create_compressed_mint/*, sdk-libs/token-client/src/instructions/mint_to_compressed.rs, program-tests/utils/*
Renamed derive_compressed_mint_from_spl_mint → derive_cmint_from_spl_mint; added create_compressed_mint_cpi_write export; updated import sites and tests.
Compression framework (sdk-libs/sdk)
sdk-libs/sdk/src/compressible/{mod.rs,compression_info.rs,config.rs,compress_account.rs,compress_account_on_init.rs,decompress_idempotent.rs,close.rs}
New compressible public surface: CompressionInfo, HasCompressionInfo, Pack/Unpack, CompressAs traits; CompressibleConfig PDA management & authority checks; prepare/close/decompress helper functions and feature-gated v2 flows.
Client & RPC utilities
sdk-libs/client/src/{constants.rs,rpc/mod.rs,rpc/lut.rs}, sdk-libs/sdk/src/address.rs, sdk-libs/sdk/src/account.rs
Added LIGHT_PROTOCOL_LOOKUP_TABLE_ADDRESS constant; added load_lookup_table and lut module; derived compressed address helper; added LightAccountInner.size() and remove_data() methods.
Compressible client crate
sdk-libs/compressible-client/{Cargo.toml,src/lib.rs,src/get_compressible_account.rs}
New crate light-compressible-client: get_account_info_interface, deserialize_account with Anchor/Borsh variants, MerkleContext/AccountInfoInterface types, and compressible instruction builders (CompressibleInstruction).
Program-test & devenv
sdk-libs/program-test/src/{program_test/*,compressible.rs,utils/*}, sdk-libs/program-test/Cargo.toml
Added auto_compress_programs, config flags, register_auto_compression(), simulate_cu, compressible_setup helpers, auto_compress_program_pdas and try_compress_chunk flows; updated Cargo features and dependencies.
Errors & signer handling
sdk-libs/compressed-token-sdk/src/error.rs, sdk-libs/compressed-token-sdk/src/instructions/decompress_full.rs, compress_and_close.rs
Added TokenSdkError variants for bridge/dispatch errors; improved signer flag handling in decompress_full; added signed CPI wrappers (compress_and_close_ctoken_accounts_signed).
Tests, small fixes & imports
sdk-libs/compressed-token-sdk/tests/pack_test.rs, program-tests/*, cli/src/commands/token-balance/index.ts, forester/tests/*, various import updates
Added pack tests; updated many tests to new API names and compat imports; added type annotations in CLI; adjusted imports in forester and program-test to use compat TokenData types; minor comment removal.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant TransferInterface
    participant TransferCToken
    participant TokenProgram
    participant CTokenProgram

    Client->>TransferInterface: transfer_interface(src,dst,amount)
    alt both ctoken
        TransferInterface->>TransferCToken: transfer_ctoken(...)
        TransferCToken->>CTokenProgram: invoke / invoke_signed
        CTokenProgram-->>TransferCToken: result
    else SPL -> ctoken
        TransferInterface->>TransferInterface: verify bridge config
        TransferInterface->>TokenProgram: invoke SPL transfer
        TokenProgram-->>TransferInterface: result
        TransferInterface->>CTokenProgram: invoke decompress/compress as needed
        CTokenProgram-->>TransferInterface: result
    else ctoken -> SPL
        TransferInterface->>TransferCToken: transfer_ctoken_to_spl(...)
        TransferCToken->>CTokenProgram: compress/decompress
        TransferCToken->>TokenProgram: invoke SPL transfer
        TokenProgram-->>TransferCToken: result
    else SPL -> SPL
        TransferInterface-->>Client: Error (UseRegularSplTransfer)
    end
    TransferInterface-->>Client: Result
Loading
sequenceDiagram
    participant ProgramTest
    participant AutoCompress
    participant Indexer
    participant RPC

    ProgramTest->>AutoCompress: auto_compress_program_pdas(program_id)
    AutoCompress->>Indexer: fetch program accounts & state tree
    Indexer-->>AutoCompress: accounts + proofs
    AutoCompress->>RPC: compress_accounts_idempotent(...) -> maybe Instruction
    alt instruction returned
        AutoCompress->>ProgramTest: sign & send tx
        ProgramTest-->>RPC: send transaction
    else none
        AutoCompress-->>ProgramTest: nothing to do
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Areas needing focused review:
    • sdk-libs/sdk/src/compressible/* (traits, generics, feature-gated behavior)
    • transfer routing and signed CPI handling (transfer_interface, transfer_ctoken, create_ctoken_account_signed)
    • widespread import/type migration to compat TokenData (ensure conversions and serde/borh boundaries)
    • CompressibleConfig PDA derivation and authority checks (rent, seeds, find_program_address)
    • New crate boundaries and Cargo feature interactions (anchor, v2, devenv)

Possibly related PRs

Suggested reviewers

  • sergeytimoshin

"A crate was born, PDAs traced with care,
Pack and Unpack now dance in the air.
CPI signed, tests pre-built and run,
Tokens migrate, new features spun.
🧩✨"

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'chore: csdk' is vague and does not clearly convey the main scope of changes. While csdk relates to the compressed SDK components added, the title lacks specificity about what 'csdk' encompasses or why these changes matter. Consider a more descriptive title such as 'feat: add compressible account support and compressed token transfer interfaces' or 'feat: introduce csdk with compressible client and account compression helpers' to better communicate the primary changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 18

🧹 Nitpick comments (13)
sdk-libs/compressible-client/tests/pack_test.rs (1)

1-120: Consider additional edge case coverage.

The current tests provide solid coverage of the main packing scenarios. For completeness, you might consider adding:

  • Tests with tlv data populated
  • Tests with different state values
  • Round-trip tests (pack then unpack) to verify bidirectional correctness

These are nice-to-have enhancements rather than immediate requirements.

Based on learnings

sdk-libs/sdk/src/address.rs (2)

137-137: Expand the documentation comment.

The doc comment should explain:

  • The specific use case (deriving compressed addresses from account addresses/PDAs)
  • When to use this function vs. the more general derive_address
  • A usage example similar to other functions in the module

Consider expanding the documentation:

-    /// Derive address from PDA using Pubkey types.
+    /// Derives a compressed address from an account address (typically a PDA).
+    ///
+    /// This is a convenience function for the common pattern of deriving a compressed
+    /// address when the seed is a single Pubkey (e.g., a PDA).
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// use light_sdk::address::v2::derive_compressed_address;
+    /// use solana_pubkey::pubkey;
+    ///
+    /// let account_pda = pubkey!("...");
+    /// let address_tree_pubkey = pubkey!("amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx");
+    /// let program_id = pubkey!("GRLu2hKaAiMbxpkAM1HeXzks9YeGuz18SEgXEizVvPqX");
+    ///
+    /// let address = derive_compressed_address(&account_pda, &address_tree_pubkey, &program_id);
+    /// ```
     pub fn derive_compressed_address(

137-149: Consider adding test coverage for the new function.

The new derive_compressed_address function has no test coverage. Adding tests would verify the behavior and prevent regressions.

Consider adding a test in the test module:

#[cfg(feature = "v2")]
mod test_v2 {
    use solana_pubkey::pubkey;
    use super::v2::*;

    #[test]
    fn test_derive_compressed_address() {
        let account_address = pubkey!("7yucc7fL3JGbyMwg4neUaenNSdySS39hbAk89Ao3t1Hz");
        let address_tree_pubkey = pubkey!("amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx");
        let program_id = pubkey!("GRLu2hKaAiMbxpkAM1HeXzks9YeGuz18SEgXEizVvPqX");

        let compressed_address = derive_compressed_address(
            &account_address,
            &address_tree_pubkey,
            &program_id,
        );

        // Verify it matches derive_address with account_address as seed
        let (expected_address, _) = derive_address(
            &[account_address.to_bytes().as_ref()],
            &address_tree_pubkey,
            &program_id,
        );
        
        assert_eq!(compressed_address, expected_address);
    }
}
sdk-libs/token-client/src/lib.rs (2)

32-45: Eliminate code duplication between address derivation functions.

Both get_associated_ctoken_address and get_associated_ctoken_address_and_bump contain identical PDA derivation logic. Refactor to call the _and_bump variant and discard the bump when not needed.

Apply this diff to eliminate duplication:

-    pub fn get_associated_ctoken_address(owner: &Pubkey, mint: &Pubkey) -> Pubkey {
-        Pubkey::find_program_address(
-            &[&owner.to_bytes(), &id().to_bytes(), &mint.to_bytes()],
-            &id(),
-        )
-        .0
-    }
+    pub fn get_associated_ctoken_address(owner: &Pubkey, mint: &Pubkey) -> Pubkey {
+        get_associated_ctoken_address_and_bump(owner, mint).0
+    }

51-83: Consider extracting hardcoded program IDs to module-level constants.

The registry program ID Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX is hardcoded in multiple locations (lines 54, 74), and the ctoken program ID is duplicated on line 68. Extracting these to constants would improve maintainability and reduce the risk of inconsistencies.

Consider applying this refactor:

const REGISTRY_PROGRAM_ID: Pubkey = pubkey!("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX");

pub fn derive_ctoken_program_config(_version: Option<u64>) -> (Pubkey, u8) {
    let version = _version.unwrap_or(1) as u16;
    let (compressible_config_pda, config_bump) = Pubkey::find_program_address(
        &[b"compressible_config", &version.to_le_bytes()],
        &REGISTRY_PROGRAM_ID,
    );
    (compressible_config_pda, config_bump)
}

pub fn derive_ctoken_rent_sponsor(_version: Option<u64>) -> (Pubkey, u8) {
    let version = _version.unwrap_or(1) as u16;
    Pubkey::find_program_address(
        &[b"rent_sponsor".as_slice(), version.to_le_bytes().as_slice()],
        &CTOKEN_PROGRAM_ID,
    )
}

pub fn derive_ctoken_compression_authority(version: Option<u64>) -> (Pubkey, u8) {
    let (compression_authority, compression_authority_bump) = Pubkey::find_program_address(
        &[
            b"compression_authority".as_slice(),
            version.unwrap_or(1).to_le_bytes().as_slice(),
        ],
        &REGISTRY_PROGRAM_ID,
    );
    (compression_authority, compression_authority_bump)
}
sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs (1)

448-455: Consider extracting seed construction to a helper function.

The seed transformation pattern (owned Vec → borrowed slices → slice of slices) is correct but complex. While this pattern appears elsewhere in the codebase, extracting it to a reusable helper would improve readability.

Example helper:

fn prepare_signer_seeds<'a, 'info>(
    accounts: &'a [AccountInfoToCompress<'info>]
) -> (Vec<Vec<&'a [u8]>>, Vec<&'a [&'a [u8]]>) {
    let token_seeds_refs: Vec<Vec<&[u8]>> = accounts
        .iter()
        .map(|t| t.signer_seeds.iter().map(|v| v.as_slice()).collect())
        .collect();
    let all_signer_seeds: Vec<&[&[u8]]> = token_seeds_refs
        .iter()
        .map(|seeds| seeds.as_slice())
        .collect();
    (token_seeds_refs, all_signer_seeds)
}
sdk-libs/compressible-client/src/lib.rs (1)

297-300: Remove leftover debug println!

This println! leaks internal state to stdout for every call and can’t be controlled by callers. Please drop it (or replace it with gated tracing/logging if needed).

Apply this diff:

-        println!(
-            "compress_accounts_idempotent - account_pubkeys: {:?}",
-            account_pubkeys
-        );
sdk-libs/program-test/src/utils/simulation.rs (1)

30-35: Guard against simulations that return a runtime error.

simulate_transaction will happily return a payload even when the inner execution failed, stashing the failure in the returned meta/value. As written we still hand back a CU total, which can mask the failure for callers that only preflight. Please bail out when simulate_result.meta.err (or the equivalent field on this response type) is Some(_) before reporting the compute units.

.github/workflows/cli-v1.yml (1)

52-60: Verify: Are these explicit build steps necessary?

The workflow now explicitly builds js/stateless.js and js/compressed-token before building the CLI. Please confirm:

  • Are these steps required in the CI environment, or does the CLI build (line 64) already handle these dependencies via nx/pnpm?
  • If they're workarounds for dependency resolution issues, consider adding a comment explaining why they're needed.
cli/package.json (1)

135-137: Verify: Is explicit build dependency the intended approach?

The CLI build now explicitly depends on @lightprotocol/programs:build. Please confirm:

  • Is this the preferred approach for build ordering in your nx workspace?
  • Or would declaring the programs as package dependencies be more appropriate?

This change ensures correct build order but might indicate missing dependency declarations elsewhere.

sdk-libs/sdk/Cargo.toml (1)

28-28: LGTM! Clean feature and dependency additions.

The new anchor-discriminator feature properly delegates to the macros crate, and the Solana dependencies correctly use workspace versions for consistency. The bincode = "1" dependency uses a major version constraint which is acceptable, though using a workspace dependency would provide more consistency.

Consider moving bincode to a workspace dependency in the root Cargo.toml for version consistency across the workspace, similar to other dependencies:

Root Cargo.toml:

bincode = "1.3"

This file:

-bincode = "1"
+bincode = { workspace = true }

Also applies to: 37-40, 47-47

sdk-libs/client/Cargo.toml (1)

39-41: Consider using workspace version for solana-message and clarify anchor-lang TODO.

Line 39 uses an explicit version "2.2" for solana-message, which differs from the workspace version pattern used by other Solana dependencies in this file. For consistency, consider using { workspace = true }.

The TODO comment on line 40 suggests uncertainty about whether anchor-lang should remain in this crate. If this is temporary, consider documenting the intended destination or creating a tracking issue.

-solana-message = "2.2"
+solana-message = { workspace = true }
sdk-libs/client/src/rpc/lut.rs (1)

24-36: Guard against non-LUT owners before deserializing

Please reject accounts that aren’t owned by the address-lookup-table program so callers get a deterministic error instead of confusing deserialize failures later.

@@
-    let raw_account = client.get_account(lookup_table_address)?;
+    let raw_account = client.get_account(lookup_table_address)?;
+    if raw_account.owner != program::ID {
+        return Err(RpcError::CustomError(format!(
+            "Account {} is not an address lookup table (owner={})",
+            lookup_table_address,
+            raw_account.owner
+        )));
+    }

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

♻️ Duplicate comments (9)
cli/src/commands/token-balance/index.ts (1)

59-62: Same typing suggestion applies here.

As with the filter callback above, defining a proper type interface would improve type safety here as well.

sdk-libs/compressed-token-sdk/src/instructions/create_associated_token_account.rs (1)

408-449: Fix parameter type and remove authority from accounts list.

Two critical issues remain from the previous review:

  1. Line 414: The authority parameter should be Pubkey, not AccountInfo<'info>, to match the idempotent variant (line 460) and because the owner is serialized into instruction data (line 191), not passed as an account.

  2. Line 446: The authority account must be removed from the invoke accounts list. The instruction expects exactly 5 accounts for a compressible ATA: [payer, associated_token_account, system_program, compressible_config, rent_sponsor]. Including authority creates a 6-account list that will cause the CPI to fail with an account count mismatch.

Apply this diff to fix both issues:

 pub fn create_associated_ctoken_account<'info>(
     payer: AccountInfo<'info>,
     associated_token_account: AccountInfo<'info>,
     system_program: AccountInfo<'info>,
     compressible_config: AccountInfo<'info>,
     rent_sponsor: AccountInfo<'info>,
-    authority: AccountInfo<'info>,
+    authority: Pubkey,
     mint: Pubkey,
     bump: u8,
     pre_pay_num_epochs: Option<u8>,
     lamports_per_write: Option<u32>,
 ) -> std::result::Result<(), solana_program_error::ProgramError> {
     let inputs = CreateCompressibleAssociatedTokenAccountInputs {
         payer: *payer.key,
-        owner: *authority.key,
+        owner: authority,
         mint,
         compressible_config: *compressible_config.key,
         rent_sponsor: *rent_sponsor.key,
         pre_pay_num_epochs: pre_pay_num_epochs.unwrap_or(1),
         lamports_per_write,
         token_account_version: TokenDataVersion::ShaFlat,
     };

     // TODO: switch to wrapper ixn using accounts instead of ixdata.
     let ix = create_compressible_associated_token_account_with_bump(
         inputs,
         *associated_token_account.key,
         bump,
     )?;

     solana_cpi::invoke(
         &ix,
         &[
             payer,
             associated_token_account,
             system_program,
             compressible_config,
             rent_sponsor,
-            authority,
         ],
     )
 }
sdk-libs/token-client/src/lib.rs (2)

51-60: Unused _version parameter contradicts function signature.

This issue was previously identified: the function accepts a _version parameter but hardcodes version = 1u16 instead. The function should use the version parameter consistently with derive_ctoken_compression_authority (line 71).


62-69: Unused _version parameter and unresolved TODO.

This issue was previously identified: the function ignores its _version parameter and hardcodes the version. Like the other derive functions, it should properly handle the version parameter.

sdk-libs/sdk/src/compressible/config.rs (1)

340-344: Fix deserialization to handle ProgramData trailing bytes.

ProgramData accounts contain an UpgradeableLoaderState header followed by program bytes. Using bincode::deserialize(&data) on the entire buffer fails because bincode expects exact length. The loader provides UpgradeableLoaderState::deserialize which reads only the header and ignores trailing bytes.

Apply this diff:

     let data = program_data_account.try_borrow_data()?;
-    let program_state: UpgradeableLoaderState = bincode::deserialize(&data).map_err(|_| {
+    let program_state = UpgradeableLoaderState::deserialize(&mut &data[..]).map_err(|_| {
         msg!("Failed to deserialize program data account");
         LightSdkError::ConstraintViolation
     })?;

Based on learnings

sdk-libs/program-test/src/compressible.rs (1)

188-188: Guard against empty address_space to prevent panic.

Direct indexing cfg.address_space[0] will panic if the vec is empty, even though config validation checks the length. If deserialization produces a malformed config or the validation is bypassed, this crashes.

Apply this diff to safely extract the address tree:

-    let address_tree = cfg.address_space[0];
+    let address_tree = cfg
+        .address_space
+        .first()
+        .copied()
+        .ok_or_else(|| RpcError::CustomError("compressible config has empty address space".into()))?;
sdk-libs/compressed-token-sdk/src/instructions/transfer_ctoken.rs (1)

31-37: Fix duplicated transfer discriminator byte.

The payload currently emits [3, 3, <amount bytes>], but the c-token program expects a single discriminator byte (3) followed immediately by the u64 amount. The extra data.push(3u8) at line 34 will cause the CPI to fail with InvalidInstructionData.

Apply this diff to remove the duplicate discriminator:

 data: {
     let mut data = vec![3u8];
-    data.push(3u8);
     data.extend_from_slice(&amount.to_le_bytes());
     data
 },
sdk-libs/compressed-token-sdk/src/instructions/create_token_account/instruction.rs (1)

159-171: Fix account ordering and add missing accounts in invoke_signed.

The instruction expects accounts in order [token_account, mint, payer, compressible_config, system_program, rent_sponsor] (as defined in lines 76-83), but invoke_signed receives them in the wrong order and is missing the system_program account entirely. This will cause NotEnoughAccountKeys or wrong-account reads.

Thread the missing system_program parameter through the API and pass accounts in the correct order:

 pub fn create_ctoken_account_signed<'info>(
     program_id: Pubkey,
     payer: AccountInfo<'info>,
     token_account: AccountInfo<'info>,
     mint_account: AccountInfo<'info>,
     authority: Pubkey,
     signer_seeds: &[&[u8]],
     ctoken_rent_sponsor: AccountInfo<'info>,
     ctoken_config_account: AccountInfo<'info>,
+    system_program: AccountInfo<'info>,
     pre_pay_num_epochs: Option<u8>,
     lamports_per_write: Option<u32>,
 ) -> std::result::Result<(), solana_program_error::ProgramError> {
     // ... existing code ...
     
     solana_cpi::invoke_signed(
         &ix,
         &[
-            payer,
             token_account,
             mint_account,
+            payer,
             ctoken_config_account,
+            system_program,
             ctoken_rent_sponsor,
-            ctoken_config_account,
         ],
         &[signer_seeds],
     )
 }
sdk-libs/compressible-client/src/lib.rs (1)

200-213: Don’t unwrap cpi_context for mixed token/PDA; find first available.

This will panic if the first compressed input is a PDA. Iterate to find a Some(cpi_context) and error if none. (This was already flagged.)

-        if has_pdas && has_tokens {
-            let cpi_context_of_first_input =
-                compressed_accounts[0].0.tree_info.cpi_context.unwrap();
+        if has_pdas && has_tokens {
+            let cpi_context_of_first_input = compressed_accounts
+                .iter()
+                .find_map(|(account, _)| account.tree_info.cpi_context)
+                .ok_or_else(|| {
+                    std::io::Error::new(
+                        std::io::ErrorKind::InvalidInput,
+                        "Missing cpi_context for mixed token/PDA decompression",
+                    )
+                })?;
             let system_config = SystemAccountMetaConfig::new_with_cpi_context(
                 *program_id,
                 cpi_context_of_first_input,
             );
             remaining_accounts.add_system_accounts_v2(system_config)?;
🧹 Nitpick comments (8)
cli/src/commands/token-balance/index.ts (1)

47-49: Consider defining a proper type instead of any.

While the explicit any annotation is an improvement over implicit typing, defining a proper interface for the compressed token account structure would provide better type safety and IDE support.

For example, you could define:

interface CompressedTokenAccount {
  parsed: {
    mint: PublicKey;
    amount: bigint | string;
    // ... other fields
  };
  // ... other fields
}

Then use it as:

-const compressedTokenAccounts = tokenAccounts.items.filter((acc: any) =>
+const compressedTokenAccounts = tokenAccounts.items.filter((acc: CompressedTokenAccount) =>
  acc.parsed.mint.equals(refMint),
);
sdk-libs/compressible-client/src/get_compressible_account.rs (2)

63-69: Do the two RPCs concurrently.

Run get_account and get_compressed_account in parallel to cut latency and avoid head-of-line blocking.

+use tokio::try_join;
@@
-    // TODO: concurrency
-    let onchain_account = rpc.get_account(*address).await?;
-    let compressed_account = rpc
-        .get_compressed_account(compressed_address, None)
-        .await?
-        .value;
+    // Fetch in parallel
+    let (onchain_account, compressed_resp) = try_join!(
+        rpc.get_account(*address),
+        rpc.get_compressed_account(compressed_address, None),
+    )?;
+    let compressed_account = compressed_resp.value;

119-142: Non-Anchor path: keep discriminator handling explicit.

You correctly skip the first 8 bytes for Borsh-only deserialization. Consider documenting that this must remain aligned with the producer that prepends Anchor’s 8-byte discriminator to on-chain format, to prevent accidental drift.

sdk-tests/csdk-anchor-test/tests/test.rs (1)

249-258: Brittle error assertion on slot delay.

Asserting string contains "Custom(16001)" is fragile. Prefer matching a typed error, error code enum, or at least a stable prefix.

sdk-libs/compressible-client/src/lib.rs (2)

297-300: Remove println! from library code.

Use tracing/log or drop the debug print to avoid noisy stdout in consumers.

-        println!(
-            "compress_accounts_idempotent - account_pubkeys: {:?}",
-            account_pubkeys
-        );
+        // consider tracing::debug!("compress_accounts_idempotent - account_pubkeys: {:?}", account_pubkeys);

136-143: Config bump hard-coded to 0.

update_compression_config derives the config PDA with bump 0. If initialize ever uses a non-zero bump, this will break. If the design guarantees bump=0, add a comment; otherwise accept bump as a parameter like initialize does.

Based on learnings

sdk-tests/csdk-anchor-test/src/lib.rs (2)

404-416: Avoid panicking in on-chain handlers.

Replace panic! with returning explicit errors (err!/custom error) to keep transactions deterministic and debuggable.

Examples:

  • Rent recipient mismatch (Lines 404–416, 972–976, 1033–1036)
  • Invalid discriminator (Lines 500–503)

I can draft concrete err! variants if you confirm the error enum you want to use.

Based on learnings

Also applies to: 972-976, 1033-1036, 500-503


1601-1631: Unchecked external program accounts.

ctoken_program, ctoken_cpi_authority are UncheckedAccount. Consider adding minimal runtime checks (owner or expected program id) to fail fast in adversarial tests.

Also applies to: 2654-2673

Comment on lines +93 to +101
let account_info = Account {
lamports: ca.lamports,
data: account_data,
owner: ca.owner,
executable: false,
// TODO: consider 0.
rent_epoch: u64::MAX,
};

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Avoid synthetic rent_epoch = u64::MAX.

Setting rent_epoch to u64::MAX can be misleading for rent/exemption logic and tools. Prefer 0 (or the cluster epoch if known).

-                    // TODO: consider 0.
-                    rent_epoch: u64::MAX,
+                    rent_epoch: 0,
📝 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
let account_info = Account {
lamports: ca.lamports,
data: account_data,
owner: ca.owner,
executable: false,
// TODO: consider 0.
rent_epoch: u64::MAX,
};
let account_info = Account {
lamports: ca.lamports,
data: account_data,
owner: ca.owner,
executable: false,
rent_epoch: 0,
};
🤖 Prompt for AI Agents
In sdk-libs/compressible-client/src/get_compressible_account.rs around lines 93
to 101, the code sets rent_epoch to u64::MAX which is misleading; change it to 0
(or the actual cluster epoch if available) so rent/exemption logic and tooling
see a sensible value — update the Account construction to use rent_epoch: 0 (or
wire in the real epoch value if you can fetch it) and add a short comment
explaining why 0 is chosen.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
sdk-libs/sdk/src/compressible/config.rs (1)

340-344: Fix ProgramData deserialization (still unresolved).

bincode::deserialize insists on consuming the entire buffer, so any real ProgramData account (header + program bytes) keeps tripping the trailing‑bytes error—exactly what the earlier review already flagged. Please switch to the loader helper that only reads the header so this runtime path can succeed.

-    let program_state: UpgradeableLoaderState = bincode::deserialize(&data).map_err(|_| {
+    let program_state = UpgradeableLoaderState::deserialize(&mut &data[..]).map_err(|_| {
         msg!("Failed to deserialize program data account");
         LightSdkError::ConstraintViolation
     })?;
🧹 Nitpick comments (3)
program-libs/compressed-account/src/instruction_data/compressed_proof.rs (3)

142-230: Consider reducing code duplication between outer and inner proof types.

The borsh_compat module duplicates the field definitions of both CompressedProof and ValidityProof. While the separation serves a clear purpose (zero-copy vs. Borsh-compatible serialization), maintaining identical field layouts in two places increases the risk of inconsistencies during future updates.

Consider using a macro or shared struct definition to ensure field consistency:

macro_rules! define_compressed_proof_fields {
    () => {
        pub a: [u8; 32],
        pub b: [u8; 64],
        pub c: [u8; 32],
    };
}

Alternatively, verify through tests that conversions remain lossless when fields are updated.


142-230: Consider adding utility methods to borsh_compat types for feature parity.

The borsh_compat::CompressedProof and borsh_compat::ValidityProof types lack the to_array() and TryFrom<&[u8]> implementations present in the outer types (lines 43-50, 52-67, 94-97, 122-133). While users can convert to outer types first, adding these methods would improve ergonomics for consumers working exclusively with Borsh-serialized data.

Example additions:

impl borsh_compat::CompressedProof {
    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 borsh_compat::CompressedProof {
    type Error = crate::CompressedAccountError;
    fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
        // Similar implementation to outer type
    }
}

177-179: Expand documentation to clarify the distinction between proof variants.

The comment explains when to use borsh_compat::ValidityProof, but consider adding more context about the trade-offs and use cases for both variants. This would help developers understand why the outer types exist and when zero-copy optimization is appropriate.

Suggested documentation structure:

/// Borsh-compatible ValidityProof for standard Anchor programs.
/// 
/// Use this variant when:
/// - Working with Anchor instruction handlers that deserialize parameters
/// - Borsh serialization/deserialization is required
/// - Zero-copy constraints are not needed
/// 
/// Use the outer `ValidityProof` when:
/// - Working with zero-copy instruction data
/// - Performance-critical paths requiring in-place parsing
/// - Avoiding deserialization overhead
pub struct ValidityProof(pub Option<CompressedProof>);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d910a44 and 3123c98.

📒 Files selected for processing (5)
  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs (1 hunks)
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs (1 hunks)
  • sdk-libs/sdk/src/compressible/config.rs (1 hunks)
  • sdk-tests/csdk-anchor-test/Anchor.toml (1 hunks)
  • sdk-tests/csdk-anchor-test/tests/test.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (42)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/account_info_trait.rs : Ensure the crate compiles with no features enabled by keeping trait definitions free of SDK-specific dependencies
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Provide PDA derivation helpers (derive_pda, derive_v1_config_pda) in src/config.rs for CompressibleConfig

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/error.rs : Define error types with numeric codes in the 19xxx range and propagate hasher errors in the 7xxx range; include ProgramError conversions (Anchor, Pinocchio, Solana) in src/error.rs

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/programs/compressed-token/anchor/src/lib.rs : Define all program-specific error codes in anchor_compressed_token::ErrorCode in programs/compressed-token/anchor/src/lib.rs; return errors as ProgramError::Custom(error_code as u32)

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Provide default initialization for the CToken V1 config in CompressibleConfig

Applied to files:

  • program-libs/compressed-account/src/instruction_data/compressed_proof.rs
  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/account_info_trait.rs : Ensure the crate compiles with no features enabled by keeping trait definitions free of SDK-specific dependencies

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/checks.rs : Expose and maintain account validation helpers (check_owner, check_program, check_mut/non_mut, check_signer, check_discriminator, set_discriminator, check_pda_seeds, check_account_balance_is_rent_exempt, account_info_init) in checks.rs

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : Validate account type with 8-byte discriminators using check_discriminator before deserialization

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/lib.rs : Load accounts according to type before check_forester: batched via BatchedMerkleTreeAccount::type_from_account_info(); regular via ctx.accounts.account.load()?.metadata; use custom deserialization when required.

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : On account initialization, call account_info_init to set the 8-byte discriminator

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/docs/ACCOUNTS.md : Account documentation must include: description, discriminator, state layout, serialization example, hashing (only for compressed accounts), derivation (only for PDAs), and associated instructions

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:52.712Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:52.712Z
Learning: Applies to program-libs/account-checks/docs/**/DISCRIMINATOR.md : DISCRIMINATOR.md must document 8-byte discriminators, the Discriminator trait, constant arrays for compile-time checks, and integration with account initialization

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/{solana.rs,pinocchio.rs,test_account_info.rs} : Provide SDK-specific AccountInfoTrait implementations in account_info/{solana.rs,pinocchio.rs,test_account_info.rs}

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-11T21:59:52.712Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:52.712Z
Learning: Applies to program-libs/account-checks/docs/**/{ACCOUNT_INFO_TRAIT.md,ACCOUNT_CHECKS.md,ACCOUNT_ITERATOR.md,DISCRIMINATOR.md,ERRORS.md,PACKED_ACCOUNTS.md} : Code examples should demonstrate both Solana and Pinocchio usage where applicable

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/!(account_info)/**/*.rs : Use AccountInfoTrait for runtime-agnostic account handling; avoid direct solana-program or pinocchio AccountInfo in general logic

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/{solana.rs,pinocchio.rs,test_account_info.rs} : Gate SDK-specific implementations with #[cfg(feature = "solana"|"pinocchio"|"test-only")]

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_associated_token_account.rs : Create Associated Token Account instruction must validate that the config state is ACTIVE only

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_token_account.rs : Create Token Account instruction must validate that the config state is ACTIVE only

Applied to files:

  • sdk-libs/sdk/src/compressible/config.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/**/Cargo.toml : Define features solana, pinocchio, and test-only in Cargo.toml; default build should enable none

Applied to files:

  • sdk-tests/csdk-anchor-test/Anchor.toml
📚 Learning: 2025-10-15T03:46:43.242Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:43.242Z
Learning: Applies to sdk-tests/sdk-token-test/**/tests/**/*.rs : Every test should only contain functional integration tests

Applied to files:

  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.

Applied to files:

  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/DECOMPRESSED_TRANSFER.md : Document SPL-compatible transfers between decompressed accounts in instructions/DECOMPRESSED_TRANSFER.md

Applied to files:

  • sdk-tests/csdk-anchor-test/tests/test.rs
  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CLOSE_TOKEN_ACCOUNT.md : Document closing decompressed token accounts with rent distribution in instructions/CLOSE_TOKEN_ACCOUNT.md

Applied to files:

  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CLAIM.md : Document rent reclamation from expired compressible accounts in instructions/CLAIM.md

Applied to files:

  • sdk-tests/csdk-anchor-test/tests/test.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/TRANSFER2.md : Document the batch transfer instruction supporting compressed/decompressed operations in instructions/TRANSFER2.md

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/{CREATE_TOKEN_ACCOUNT,MINT_ACTION,TRANSFER2,CLAIM,CLOSE_TOKEN_ACCOUNT,DECOMPRESSED_TRANSFER,WITHDRAW_FUNDING_POOL}.md : Every instruction description must include sections: path, description, instruction_data, Accounts, instruction logic and checks, Errors

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/program-libs/ctoken-types/** : Define all state and instruction data structures in the light-ctoken-types crate (program-libs/ctoken-types), including state/, instructions/, and state/extensions/

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:45:40.038Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:45:40.038Z
Learning: Applies to programs/compressed-token/program/docs/**/instructions/CREATE_TOKEN_ACCOUNT.md : Provide CREATE_TOKEN_ACCOUNT.md in the instructions/ directory documenting create token account and associated token account instructions

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CREATE_TOKEN_ACCOUNT.md : Document Create Token Account & Associated Token Account instructions in instructions/CREATE_TOKEN_ACCOUNT.md

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/lib.rs : Wrapper instruction handlers must: (1) load the target account metadata; (2) call check_forester with correct authority, target, forester PDA (optional), and computed work_units; (3) delegate via a CPI using a PDA signer.

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-11T21:59:52.712Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:52.712Z
Learning: Applies to program-libs/account-checks/docs/**/PACKED_ACCOUNTS.md : PACKED_ACCOUNTS.md must document index-based dynamic account access, including accessing mint, owner, and delegate accounts by index with bounds checking

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/**/ACCOUNTS.md : Provide complete account layouts and data structures in ACCOUNTS.md

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/error.rs : Maintain stable mapping of AccountError to ProgramError, including Pinocchio code mapping (1–11), in error.rs

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : Return AccountError variants (codes 12006–12021) and rely on automatic ProgramError conversions; avoid returning raw ProgramError directly

Applied to files:

  • sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
🧬 Code graph analysis (3)
program-libs/compressed-account/src/instruction_data/compressed_proof.rs (5)
program-libs/compressed-account/src/instruction_data/data.rs (2)
  • new (31-36)
  • new (155-164)
program-libs/compressed-account/src/instruction_data/traits.rs (1)
  • proof (57-57)
program-libs/compressed-account/src/instruction_data/with_account_info.rs (1)
  • proof (570-572)
program-libs/compressed-account/src/instruction_data/with_readonly.rs (1)
  • proof (470-472)
program-libs/compressed-account/src/instruction_data/zero_copy.rs (2)
  • proof (455-457)
  • proof (603-605)
sdk-tests/csdk-anchor-test/tests/test.rs (6)
sdk-tests/csdk-anchor-test/src/lib.rs (17)
  • get_ctoken_signer2_seeds (242-248)
  • get_ctoken_signer3_seeds (251-261)
  • get_ctoken_signer_seeds (229-239)
  • initialize_compression_config (353-373)
  • create_user_record_and_game_session (1075-1258)
  • create_record (955-1008)
  • decompress_accounts_idempotent (537-953)
  • create_game_session (1011-1072)
  • compress_accounts_idempotent (397-529)
  • get_userrecord_seeds (94-102)
  • get_placeholderrecord_seeds (114-124)
  • get_gamesession_seeds (104-112)
  • get_ctokensigner_authority_seeds (264-270)
  • get_ctokensigner2_authority_seeds (272-275)
  • get_ctokensigner3_authority_seeds (277-280)
  • get_ctokensigner4_authority_seeds (318-321)
  • get_ctokensigner5_authority_seeds (323-326)
sdk-libs/sdk/src/address.rs (2)
  • derive_address (89-99)
  • derive_address (169-179)
sdk-libs/compressed-token-sdk/src/instructions/create_compressed_mint/instruction.rs (3)
  • create_compressed_mint (188-192)
  • find_spl_mint_address (214-219)
  • derive_compressed_mint_address (195-204)
sdk-libs/program-test/src/program_test/compressible_setup.rs (2)
  • initialize_compression_config (75-111)
  • setup_mock_program_data (42-59)
js/stateless.js/src/test-helpers/test-rpc/test-rpc.ts (1)
  • TestRpc (121-969)
sdk-libs/token-client/src/lib.rs (3)
  • derive_ctoken_program_config (51-60)
  • id (20-22)
  • cpi_authority (24-26)
sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs (5)
sdk-libs/compressed-token-sdk/src/instructions/transfer_ctoken.rs (2)
  • transfer_ctoken (42-51)
  • transfer_ctoken_signed (54-68)
sdk-libs/compressed-token-sdk/src/instructions/transfer2/instruction.rs (1)
  • create_transfer2_instruction (71-141)
sdk-libs/compressed-token-sdk/src/utils.rs (1)
  • is_ctoken_account (22-37)
sdk-libs/compressed-token-sdk/src/account2.rs (6)
  • mint (362-364)
  • new (23-51)
  • compress_spl (193-220)
  • decompress_ctoken (224-247)
  • compress_ctoken (169-190)
  • decompress_spl (250-279)
program-libs/compressed-account/src/instruction_data/compressed_proof.rs (4)
  • new (88-90)
  • new (182-184)
  • default (33-39)
  • default (159-165)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
  • GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: stateless-js-v1
  • GitHub Check: stateless-js-v2
  • GitHub Check: cli-v2
  • GitHub Check: cli-v1
  • GitHub Check: lint
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-fast
  • GitHub Check: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p csd...
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
  • GitHub Check: Forester e2e test
🔇 Additional comments (4)
sdk-tests/csdk-anchor-test/Anchor.toml (1)

1-18: LGTM! Anchor configuration is well-structured.

The Anchor.toml configuration is appropriate for the new csdk-anchor-test project. The extended test timeout (1000000ms) accommodates complex integration test scenarios involving compression/decompression workflows.

sdk-tests/csdk-anchor-test/tests/test.rs (3)

290-296: Past issue resolved: Address derivation now correctly uses tree pubkey.

The previous review flagged this location for using .queue instead of .tree for address derivation. The code now correctly uses rpc.get_address_tree_v2().tree for deriving the compressed address.

Also applies to: 686-691, 1219-1225


41-46: LGTM! Test constants are well-defined.

The hardcoded pubkey constants serve as test fixtures for the integration test suite. They are appropriately named and used consistently across test scenarios.


47-2784: Excellent test coverage for compression/decompression workflows.

The test suite comprehensively covers:

  • Normal compression/decompression cycles with CToken integration
  • Idempotency defenses against double compression/decompression attacks
  • Slot delay enforcement
  • Multiple state tree scenarios
  • Custom compression logic via CompressAs trait
  • Empty compressed accounts
  • Decompressed account updates

The tests are well-structured functional integration tests, following the established pattern for sdk-tests.

Based on learnings

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
sdk-tests/csdk-anchor-test/src/lib.rs (2)

706-708: Guard access to CPI context in token decompression path.

Lines 706-708 unconditionally unwrap authority and cpi_context from cpi_accounts, but when the initial check at line 825 finds has_pdas=false (token-only path), CpiAccounts::new is used without context. If tokens are later present, process_tokens will panic on the unwrap.

Apply this diff to guard the unwraps:

-            let authority = cpi_accounts.authority().unwrap();
-            let cpi_context = cpi_accounts.cpi_context().unwrap();
+            let authority = cpi_accounts.authority()
+                .ok_or(ProgramError::InvalidAccountData)?;
+            let cpi_context = cpi_accounts.cpi_context()
+                .ok_or(ProgramError::InvalidAccountData)?;

And at line 769, the conditional should check if cpi_context is available:

-                    if has_pdas { Some(cpi_context.key()) } else { None },
+                    cpi_accounts.cpi_context().map(|c| c.key()),

Also applies to: 779-807


901-902: Guard CPI context access before conditional branching.

Lines 901-902 unconditionally unwrap authority and cpi_context, but these are only available when has_tokens && has_pdas was true at line 825 (triggering new_with_config). If the initial check had only has_pdas=true but has_tokens=false, the unwrap will panic when later has_pdas is confirmed at line 895.

Move these unwraps inside the if has_pdas && has_tokens block where they're actually used:

         let has_pdas = !compressed_pda_infos.is_empty();
         let has_tokens = !ctoken_accounts.is_empty();
         if !has_pdas && !has_tokens {
             return Ok(());
         }
         let fee_payer = ctx.accounts.fee_payer.as_ref();
-        let authority = cpi_accounts.authority().unwrap();
-        let cpi_context = cpi_accounts.cpi_context().unwrap();
 
         // init PDAs.
         if has_pdas && has_tokens {
+            let authority = cpi_accounts.authority()
+                .ok_or(ProgramError::InvalidAccountData)?;
+            let cpi_context = cpi_accounts.cpi_context()
+                .ok_or(ProgramError::InvalidAccountData)?;
             let system_cpi_accounts = light_sdk_types::cpi_context_write::CpiContextWriteAccounts {
🧹 Nitpick comments (2)
sdk-tests/csdk-anchor-test/src/lib.rs (2)

211-212: Document magic number rationale.

Line 211 uses a fixed index 42u64. Consider defining this as a named constant (e.g., CTOKEN_SIGNER5_FIXED_INDEX) to clarify its purpose and make it configurable if needed.

+const CTOKEN_SIGNER5_FIXED_INDEX: u64 = 42;
+
 ...
-                let index_bytes = 42u64.to_le_bytes(); // Fixed index for this variant
+                let index_bytes = CTOKEN_SIGNER5_FIXED_INDEX.to_le_bytes();

740-741: Address TODOs for configuration.

Lines 740-741 have TODOs for making pre_pay_num_epochs and lamports_per_write configurable. Consider whether these should be instruction parameters or config account fields.

Do you want me to generate a proposed implementation for configurable token account parameters, or should these TODOs track future work?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3123c98 and 05eff66.

📒 Files selected for processing (2)
  • sdk-tests/csdk-anchor-test/package.json (1 hunks)
  • sdk-tests/csdk-anchor-test/src/lib.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (27)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/DECOMPRESSED_TRANSFER.md : Document SPL-compatible transfers between decompressed accounts in instructions/DECOMPRESSED_TRANSFER.md
📚 Learning: 2025-10-15T03:46:43.242Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:43.242Z
Learning: Run tests with: cargo test-sbf -p sdk-token-test --test <test-file-name>

Applied to files:

  • sdk-tests/csdk-anchor-test/package.json
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/error.rs : Define error types with numeric codes in the 19xxx range and propagate hasher errors in the 7xxx range; include ProgramError conversions (Anchor, Pinocchio, Solana) in src/error.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/{solana.rs,pinocchio.rs,test_account_info.rs} : Provide SDK-specific AccountInfoTrait implementations in account_info/{solana.rs,pinocchio.rs,test_account_info.rs}

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/{solana.rs,pinocchio.rs,test_account_info.rs} : Gate SDK-specific implementations with #[cfg(feature = "solana"|"pinocchio"|"test-only")]

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/checks.rs : Expose and maintain account validation helpers (check_owner, check_program, check_mut/non_mut, check_signer, check_discriminator, set_discriminator, check_pda_seeds, check_account_balance_is_rent_exempt, account_info_init) in checks.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/programs/compressed-token/anchor/src/lib.rs : Define all program-specific error codes in anchor_compressed_token::ErrorCode in programs/compressed-token/anchor/src/lib.rs; return errors as ProgramError::Custom(error_code as u32)

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_token_account.rs : Create Token Account instruction must validate that the config state is ACTIVE only

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_associated_token_account.rs : Create Associated Token Account instruction must validate that the config state is ACTIVE only

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/lib.rs : Wrapper instruction handlers must: (1) load the target account metadata; (2) call check_forester with correct authority, target, forester PDA (optional), and computed work_units; (3) delegate via a CPI using a PDA signer.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/withdraw_funding_pool.rs : Withdraw Funding Pool instruction must validate that the config state is not INACTIVE (active or deprecated allowed)

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/lib.rs : Load accounts according to type before check_forester: batched via BatchedMerkleTreeAccount::type_from_account_info(); regular via ctx.accounts.account.load()?.metadata; use custom deserialization when required.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/DECOMPRESSED_TRANSFER.md : Document SPL-compatible transfers between decompressed accounts in instructions/DECOMPRESSED_TRANSFER.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/discriminator.rs : Define and keep discriminator constants and the Discriminator trait in discriminator.rs for compile-time verification

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : On account initialization, call account_info_init to set the 8-byte discriminator

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : Validate account type with 8-byte discriminators using check_discriminator before deserialization

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/docs/ACCOUNTS.md : Account documentation must include: description, discriminator, state layout, serialization example, hashing (only for compressed accounts), derivation (only for PDAs), and associated instructions

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/**/ACCOUNTS.md : Provide complete account layouts and data structures in ACCOUNTS.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
🧬 Code graph analysis (1)
sdk-tests/csdk-anchor-test/src/lib.rs (9)
sdk-libs/sdk/src/cpi/invoke.rs (2)
  • invoke (13-13)
  • invoke (39-84)
sdk-libs/compressed-token-sdk/src/instructions/mint_action/instruction.rs (1)
  • create_mint_action_cpi (257-446)
sdk-libs/sdk/src/compressible/compress_account.rs (1)
  • prepare_account_for_compression (30-115)
sdk-libs/sdk/src/compressible/compress_account_on_init.rs (1)
  • prepare_compressed_account_on_init (35-102)
sdk-libs/sdk/src/compressible/decompress_idempotent.rs (2)
  • into_compressed_meta_with_address (23-42)
  • prepare_account_for_decompression_idempotent (80-141)
sdk-libs/sdk/src/compressible/config.rs (3)
  • process_initialize_compression_config_checked (411-446)
  • process_update_compression_config (256-315)
  • load_checked (86-120)
sdk-libs/compressed-token-sdk/src/instructions/decompress_full.rs (2)
  • new (183-190)
  • decompress_full_ctoken_accounts_with_indices (48-130)
sdk-libs/compressed-token-sdk/src/instructions/create_token_account/instruction.rs (2)
  • create_token_account (92-118)
  • create_ctoken_account_signed (122-171)
sdk-libs/compressed-token-sdk/src/instructions/create_compressed_mint/instruction.rs (1)
  • find_spl_mint_address (214-219)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-slow
  • GitHub Check: stateless-js-v1
  • GitHub Check: Forester e2e test
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
  • GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
  • GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • GitHub Check: cli-v1
  • GitHub Check: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p csd...
  • GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
  • GitHub Check: lint
  • GitHub Check: stateless-js-v2
  • GitHub Check: cli-v2
🔇 Additional comments (5)
sdk-tests/csdk-anchor-test/package.json (1)

1-10: Well-structured package.json with appropriate build and test configuration.

The package metadata, build script using cargo build-sbf --release, and test script with --nocapture for output visibility all look appropriate for a Solana program test. The scoped package name follows the repo convention.

Verify that the Rust crate name in Cargo.toml matches csdk-anchor-test (referenced by the -p flag in the cargo commands).

sdk-tests/csdk-anchor-test/src/lib.rs (4)

198-199: Clarify intentional seed duplication.

Lines 198 and 291 use fee_payer for both seed_1 and seed_2, which appears intentional per the comment but creates identical seeds. Verify this is the desired PDA derivation pattern.

Also applies to: 290-291


825-837: Verify CpiAccounts initialization logic.

The CpiAccounts is created with context only when both has_tokens && has_pdas. However, lines 895-896 re-compute these flags based on actual (non-empty) accounts found. If the initial flags differ from the re-computed ones, the context availability won't match expectations in subsequent code.

Ensure test coverage exercises these scenarios:

  1. Initial has_tokens=true, has_pdas=false → later has_tokens=true (should not need context)
  2. Initial has_tokens=false, has_pdas=true → later has_pdas=true (should not need context)
  3. Initial has_tokens=true, has_pdas=true → later both true (should have context)

1155-1224: Review mint action CPI context configuration.

The mint action CPI at lines 1209-1224 constructs a CpiContext with hardcoded indices (in_tree_index: 1, assigned_account_index: 2, etc.). Verify these indices align with the account ordering in cpi_accounts and won't cause out-of-bounds access.


1-1: Document the deprecation suppression and plan an Anchor upgrade.

The #![allow(deprecated)] suppression is justified: Anchor 0.31.1 internally calls the now-deprecated AccountInfo::realloc from the Solana SDK (replaced with resize). This is not a direct API usage issue in the test code itself, but a framework-level concern.

  • Add a comment above line 1 explaining that the suppression targets Anchor framework internals, not program code.
  • Plan an upgrade to Anchor 0.32.1 or later to eliminate the warnings, which will remove the need for this suppression.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
sdk-tests/csdk-anchor-test/src/lib.rs (1)

729-731: Guard access to CPI context in token path to prevent panic.

Unconditional unwraps of authority() and cpi_context() will panic when has_pdas is false, because the caller creates CpiAccounts without context for token-only decompressions (line 857-861). Access these only when has_pdas is true or handle the None case explicitly.

Apply this diff to guard context access:

-            let authority = cpi_accounts.authority().unwrap();
-            let cpi_context = cpi_accounts.cpi_context().unwrap();
+            let cpi_context_key = if has_pdas {
+                Some(cpi_accounts.cpi_context().ok_or(ProgramError::InvalidAccountData)?.key())
+            } else {
+                None
+            };
+            let authority_key = cpi_accounts.authority().ok_or(ProgramError::InvalidAccountData)?.key();

And update line 794:

-                    if has_pdas { Some(cpi_context.key()) } else { None },
+                    cpi_context_key,

And line 761:

-                        *authority.clone().to_account_info().key,
+                        authority_key,
🧹 Nitpick comments (1)
sdk-tests/csdk-anchor-test/src/lib.rs (1)

533-541: Remove or document commented-out code.

Multiple large commented-out blocks exist throughout the file (lines 533-541, 1736-1749, 2170-2185). If obsolete, remove them to reduce clutter. If deferred work, add a TODO comment explaining why.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bfbd82 and 0110113.

📒 Files selected for processing (2)
  • .github/workflows/sdk-tests.yml (1 hunks)
  • sdk-tests/csdk-anchor-test/src/lib.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/sdk-tests.yml
🧰 Additional context used
🧠 Learnings (29)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/DECOMPRESSED_TRANSFER.md : Document SPL-compatible transfers between decompressed accounts in instructions/DECOMPRESSED_TRANSFER.md
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/error.rs : Define error types with numeric codes in the 19xxx range and propagate hasher errors in the 7xxx range; include ProgramError conversions (Anchor, Pinocchio, Solana) in src/error.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/program-libs/ctoken-types/** : Define all state and instruction data structures in the light-ctoken-types crate (program-libs/ctoken-types), including state/, instructions/, and state/extensions/

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/account_info/{solana.rs,pinocchio.rs,test_account_info.rs} : Gate SDK-specific implementations with #[cfg(feature = "solana"|"pinocchio"|"test-only")]

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/checks.rs : Expose and maintain account validation helpers (check_owner, check_program, check_mut/non_mut, check_signer, check_discriminator, set_discriminator, check_pda_seeds, check_account_balance_is_rent_exempt, account_info_init) in checks.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_token_account.rs : Create Token Account instruction must validate that the config state is ACTIVE only

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/create_associated_token_account.rs : Create Associated Token Account instruction must validate that the config state is ACTIVE only

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/lib.rs : Wrapper instruction handlers must: (1) load the target account metadata; (2) call check_forester with correct authority, target, forester PDA (optional), and computed work_units; (3) delegate via a CPI using a PDA signer.

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/withdraw_funding_pool.rs : Withdraw Funding Pool instruction must validate that the config state is not INACTIVE (active or deprecated allowed)

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : Return AccountError variants (codes 12006–12021) and rely on automatic ProgramError conversions; avoid returning raw ProgramError directly

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/programs/compressed-token/anchor/src/lib.rs : Define all program-specific error codes in anchor_compressed_token::ErrorCode in programs/compressed-token/anchor/src/lib.rs; return errors as ProgramError::Custom(error_code as u32)

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/error.rs : Maintain stable mapping of AccountError to ProgramError, including Pinocchio code mapping (1–11), in error.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/rent.rs : Implement and maintain rent calculation algorithms (rent_curve_per_epoch, calculate_rent_and_balance, claimable_lamports, calculate_close_lamports) in src/rent.rs

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CLOSE_TOKEN_ACCOUNT.md : Document closing decompressed token accounts with rent distribution in instructions/CLOSE_TOKEN_ACCOUNT.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CLAIM.md : Document rent reclamation from expired compressible accounts in instructions/CLAIM.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:55.362Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/docs/ACCOUNTS.md : Account documentation must include: description, discriminator, state layout, serialization example, hashing (only for compressed accounts), derivation (only for PDAs), and associated instructions

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/packed_accounts.rs : For dynamic account sets, use PackedAccounts for index-based access with bounds checks instead of manual indexing

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/**/ACCOUNTS.md : Provide complete account layouts and data structures in ACCOUNTS.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-11T21:59:25.222Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-10-11T21:59:25.222Z
Learning: Applies to program-libs/account-checks/src/**/*.rs : On account initialization, call account_info_init to set the 8-byte discriminator

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
📚 Learning: 2025-10-15T03:46:03.556Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/DECOMPRESSED_TRANSFER.md : Document SPL-compatible transfers between decompressed accounts in instructions/DECOMPRESSED_TRANSFER.md

Applied to files:

  • sdk-tests/csdk-anchor-test/src/lib.rs
🧬 Code graph analysis (1)
sdk-tests/csdk-anchor-test/src/lib.rs (6)
sdk-libs/sdk/src/cpi/invoke.rs (2)
  • invoke (13-13)
  • invoke (39-84)
sdk-libs/compressed-token-sdk/src/instructions/mint_action/instruction.rs (1)
  • create_mint_action_cpi (257-446)
sdk-libs/sdk/src/compressible/compress_account.rs (1)
  • prepare_account_for_compression (30-115)
sdk-libs/sdk/src/compressible/compress_account_on_init.rs (1)
  • prepare_compressed_account_on_init (35-102)
sdk-libs/sdk/src/compressible/decompress_idempotent.rs (2)
  • into_compressed_meta_with_address (23-42)
  • prepare_account_for_decompression_idempotent (80-141)
sdk-libs/compressed-token-sdk/src/instructions/create_token_account/instruction.rs (2)
  • create_token_account (92-118)
  • create_ctoken_account_signed (122-171)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Forester e2e test
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test program-libs-slow
  • GitHub Check: stateless-js-v1
  • GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
  • GitHub Check: system-programs (anchor & pinocchio, ["cd sdk-tests/csdk-anchor-test && cargo build-sbf && cargo ...
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • GitHub Check: cli-v2
  • GitHub Check: cli-v1
  • GitHub Check: stateless-js-v2
  • GitHub Check: lint
🔇 Additional comments (4)
sdk-tests/csdk-anchor-test/src/lib.rs (4)

461-461: Address or track TODO comments.

Several TODO comments indicate incomplete functionality or hard-coded values that should be configurable. Consider creating tracking issues for these items.

Do you want me to open tracking issues for these TODOs?

Also applies to: 765-766, 1193-1193, 1220-1220


217-219: CTokenSigner4 uses fee_payer twice in seed derivation.

Line 219 uses fee_payer for both seed_1 and seed_2. If intentional for testing, consider adding a comment. Otherwise, verify whether the second seed should be a different account.


418-552: Compression logic is well-structured.

The idempotent compression flow correctly:

  1. Validates rent sponsor against config
  2. Handles multiple account types via discriminator dispatch
  3. Prepares compressed account info
  4. Invokes CPI and closes PDAs

The TODO at line 461 about seed validation should be addressed before production use.


1179-1209: No actionable issues found after verification.

The mint derivation using find_spl_mint_address is consistent with SDK patterns used throughout the codebase. The five recipient PDAs are intentionally derived using distinct seed patterns (test helpers in csdk-anchor-test), each serving as an owner of minted compressed tokens. This design correctly demonstrates minting to multiple recipients with varying PDA configurations. No correction needed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
prover/client/src/prover.rs (1)

40-111: Consider refactoring for better maintainability.

The CI/non-CI branching spans 70+ lines, making the function difficult to read and test. Consider extracting into separate functions:

async fn spawn_prover_ci(prover_path: &str, output_buffer: Arc<Mutex<Vec<u8>>>) {
    // CI-specific logic here
}

fn spawn_prover_non_ci(prover_path: &str) {
    // Non-CI specific logic here
}

pub async fn spawn_prover() {
    // ... setup ...
    let is_ci = std::env::var("CI").is_ok();
    let output_buffer = Arc::new(Mutex::new(Vec::new()));
    
    if is_ci {
        spawn_prover_ci(prover_path, Arc::clone(&output_buffer)).await;
    } else {
        spawn_prover_non_ci(prover_path);
    }
    // ... health check ...
}

This would improve testability and make each spawning strategy easier to understand and maintain.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21339af and 782b846.

📒 Files selected for processing (1)
  • prover/client/src/prover.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : Pass the data Vec<u8> through unchanged from the wrapper to the target program CPI; the target program performs deserialization.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:03.556Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/DECOMPRESSED_TRANSFER.md : Document SPL-compatible transfers between decompressed accounts in instructions/DECOMPRESSED_TRANSFER.md
🧬 Code graph analysis (1)
prover/client/src/prover.rs (2)
sdk-libs/program-test/src/program_test/config.rs (1)
  • new (60-69)
sdk-libs/program-test/src/program_test/light_program_test.rs (1)
  • new (68-380)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test program-libs-slow
  • GitHub Check: cli-v1
  • GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • GitHub Check: stateless-js-v2
  • GitHub Check: stateless-js-v1
  • GitHub Check: Forester e2e test
  • GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • GitHub Check: cli-v2
  • GitHub Check: lint
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
  • GitHub Check: system-programs (anchor & pinocchio, ["cd sdk-tests/csdk-anchor-test && cargo build-sbf && cargo ...
🔇 Additional comments (1)
prover/client/src/prover.rs (1)

37-38: LGTM: Clean CI detection and buffer setup.

The use of Arc<Mutex<Vec<u8>>> is appropriate for sharing the output buffer across async tasks.

.unwrap_or_else(|_| {
File::create(&log_path).expect("Failed to create prover log file")
});
let log_file_stderr = log_file.try_clone().ok();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Handle stderr clone errors explicitly.

The .ok() silently ignores clone errors, which means stderr will be redirected to null if cloning fails. This could hide important error messages from the prover.

Consider handling this more explicitly:

-                let log_file_stderr = log_file.try_clone().ok();
+                let log_file_stderr = log_file
+                    .try_clone()
+                    .expect("Failed to clone log file handle for stderr");

Or at minimum, log a warning if cloning fails:

-                let log_file_stderr = log_file.try_clone().ok();
+                let log_file_stderr = log_file.try_clone().ok();
+                if log_file_stderr.is_none() {
+                    eprintln!("Warning: Failed to clone log file handle, stderr will be discarded");
+                }
📝 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
let log_file_stderr = log_file.try_clone().ok();
let log_file_stderr = log_file
.try_clone()
.expect("Failed to clone log file handle for stderr");
🤖 Prompt for AI Agents
In prover/client/src/prover.rs around line 100, the code uses let
log_file_stderr = log_file.try_clone().ok(); which silently swallows clone
errors; change this to explicitly handle the Result from try_clone by matching
the Err case and either (a) return or propagate an error (convert the function
to return Result if appropriate), or (b) log a warning with the error details
and then fall back to None — do not silently ignore the error so stderr isn't
silently redirected to null; implement the chosen handling (propagate or warn)
and ensure the warning includes the clone error and context so callers can
diagnose failures.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
prover/client/src/prover.rs (2)

42-89: Address race condition and unbounded buffer growth.

The async output capture in the CI branch has the same concerns previously flagged:

  1. Race condition: Spawned tasks write to output_buffer indefinitely while the main thread reads it at lines 119-125 without proper synchronization.
  2. Unbounded growth: The buffer accumulates all output without size limits, risking high memory consumption.
  3. Early drop: drop(child) at line 89 detaches from the process immediately after spawning tasks.

These issues remain unaddressed from the previous review.


101-101: Handle stderr clone errors explicitly.

The .ok() at line 101 silently ignores clone errors, causing stderr to be redirected to null if cloning fails. This could hide important prover error messages, as previously noted in the earlier review.

🧹 Nitpick comments (1)
prover/client/src/prover.rs (1)

39-40: Move buffer initialization into the CI branch.

The output_buffer is only used when is_ci is true (lines 42-89), but it's allocated unconditionally at line 40. This creates an unnecessary Arc<Mutex<Vec>> allocation in non-CI environments.

Apply this diff to move the buffer creation into the CI branch:

         if !health_check(10, 1).await && !IS_LOADING.load(Ordering::Relaxed) {
             IS_LOADING.store(true, Ordering::Relaxed);

             let is_ci = std::env::var("CI").is_ok();
-            let output_buffer: Arc<Mutex<Vec<u8>>> = Arc::new(Mutex::new(Vec::new()));

             if is_ci {
+                let output_buffer: Arc<Mutex<Vec<u8>>> = Arc::new(Mutex::new(Vec::new()));
                 use tokio::{io::AsyncReadExt, process::Command as TokioCommand};
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 782b846 and 876dddc.

📒 Files selected for processing (2)
  • programs/account-compression/src/instructions/migrate_state.rs (1 hunks)
  • prover/client/src/prover.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Maintain CompressibleConfig account structure with Anchor/Borsh/Pod (Pinocchio/Pod) serialization and related state validation methods (validate_active, validate_not_inactive) in src/config.rs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/docs/CONFIG_ACCOUNT.md : Document the CompressibleConfig account structure and methods in docs/CONFIG_ACCOUNT.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: When working with ctoken accounts that have the Compressible extension, consult the rent system documentation (RENT.md, CONFIG_ACCOUNT.md, SOLANA_RENT.md) to follow rent authority, compression, and lamport distribution rules
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export each new operation module by adding pub mod <operation>; and re-export with pub use <operation>::*.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:45:40.038Z
Learning: Applies to programs/compressed-token/program/docs/**/ACCOUNTS.md : Maintain ACCOUNTS.md with complete account layouts and data structures
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/docs/ACCOUNTS.md : Account documentation must include: description, discriminator, state layout, serialization example, hashing (only for compressed accounts), derivation (only for PDAs), and associated instructions
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
🧬 Code graph analysis (1)
prover/client/src/prover.rs (2)
sdk-libs/program-test/src/program_test/config.rs (1)
  • new (60-69)
sdk-libs/program-test/src/program_test/light_program_test.rs (1)
  • new (68-380)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: cli-v1
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
  • GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
  • GitHub Check: stateless-js-v1
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • GitHub Check: system-programs (anchor & pinocchio, ["cd sdk-tests/csdk-anchor-test && cargo build-sbf && cargo ...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
  • GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: Test program-libs-slow
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
  • GitHub Check: Forester e2e test
  • GitHub Check: stateless-js-v2
  • GitHub Check: lint
  • GitHub Check: cli-v2
🔇 Additional comments (3)
programs/account-compression/src/instructions/migrate_state.rs (1)

131-137: LGTM! Good conditional compilation for testability.

The conditional slot value (real Clock::get()?.slot for Solana, mock 0u64 for unit tests) enables the Merkle tree logic to be tested without requiring the Solana runtime. Using a mock slot of 0 is appropriate for unit tests focused on cryptographic correctness and tree operations rather than timing/sequencing behavior.

prover/client/src/prover.rs (2)

1-11: Imports support the new CI-aware I/O strategy.

The added imports (File, OpenOptions, PathBuf, Stdio, Arc, Mutex) are appropriate for implementing both the async output capture in CI and file-based logging in non-CI environments.


114-132: CI error reporting is helpful but depends on fixing the race condition.

The approach of printing accumulated prover output in CI environments (lines 120-126) is valuable for debugging. However, this read of output_buffer is part of the race condition flagged earlier for lines 42-89: the spawned async tasks may still be writing to the buffer when this code executes, even after the health check completes.

Once the race condition is addressed (e.g., by using bounded channels and awaiting task completion), this error reporting will work reliably.

Comment on lines +91 to +93
let log_dir = PathBuf::from("test-ledger");
std::fs::create_dir_all(&log_dir).ok();
let log_path = log_dir.join("prover.log");
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Handle directory creation errors explicitly.

Line 92 uses .ok() to silently ignore errors from create_dir_all, which could hide permission issues or filesystem errors. This would cause the subsequent open() call at line 94 to fail with a less clear error message.

Apply this diff to handle directory creation errors:

             } else {
                 let log_dir = PathBuf::from("test-ledger");
-                std::fs::create_dir_all(&log_dir).ok();
+                std::fs::create_dir_all(&log_dir)
+                    .expect("Failed to create test-ledger directory for prover logs");
                 let log_path = log_dir.join("prover.log");
📝 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
let log_dir = PathBuf::from("test-ledger");
std::fs::create_dir_all(&log_dir).ok();
let log_path = log_dir.join("prover.log");
let log_dir = PathBuf::from("test-ledger");
std::fs::create_dir_all(&log_dir)
.expect("Failed to create test-ledger directory for prover logs");
let log_path = log_dir.join("prover.log");
🤖 Prompt for AI Agents
In prover/client/src/prover.rs around lines 91 to 93, the call to
std::fs::create_dir_all(&log_dir).ok() silently ignores failures; replace it
with explicit error propagation and contextual logging so permission/filesystem
errors aren't hidden — e.g. call std::fs::create_dir_all(&log_dir).map_err(|e|
std::io::Error::new(e.kind(), format!("failed to create log dir '{}': {}",
log_dir.display(), e)))?; or match the result and return or log a descriptive
error before returning, ensuring the function's Result type is used to propagate
the error rather than swallowing it.

@SwenSchaeferjohann SwenSchaeferjohann force-pushed the swen/csdk branch 3 times, most recently from 36cd222 to 8967887 Compare November 11, 2025 21:37
@SwenSchaeferjohann SwenSchaeferjohann changed the title chore: csdk rebase [wip] chore: csdk Nov 12, 2025
}
}

pub mod borsh_compat {
Copy link
Contributor

Choose a reason for hiding this comment

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

pls remove or move to light-sdk.

Comment on lines -12 to -49
use light_account_checks::AccountInfoTrait;
use light_sdk::cpi::CpiSigner;

#[derive(Clone, Debug)]
pub struct CpiContextWriteAccounts<'a, T: AccountInfoTrait + Clone> {
pub mint_signer: &'a T,
pub light_system_program: &'a T,
pub fee_payer: &'a T,
pub cpi_authority_pda: &'a T,
pub cpi_context: &'a T,
pub cpi_signer: CpiSigner,
}

impl<T: AccountInfoTrait + Clone> CpiContextWriteAccounts<'_, T> {
pub fn bump(&self) -> u8 {
self.cpi_signer.bump
}

pub fn invoking_program(&self) -> [u8; 32] {
self.cpi_signer.program_id
}

pub fn to_account_infos(&self) -> Vec<T> {
// The 5 accounts expected by create_compressed_mint_cpi_write:
// [mint_signer, light_system_program, fee_payer, cpi_authority_pda, cpi_context]
vec![
self.mint_signer.clone(),
self.light_system_program.clone(),
self.fee_payer.clone(),
self.cpi_authority_pda.clone(),
self.cpi_context.clone(),
]
}

pub fn to_account_info_refs(&self) -> [&T; 3] {
[self.mint_signer, self.fee_payer, self.cpi_context]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

pls revert

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39d570c and bcf5798.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock and included by none
  • sdk-tests/sdk-compressible-test/tests/multi_account_tests.rs is excluded by none and included by none
📒 Files selected for processing (1)
  • sdk-libs/program-test/src/program_test/config.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: Forester e2e test
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-fast

Comment on lines +24 to +25
pub auto_register_custom_programs_for_pda_compression: bool,
#[cfg(feature = "devenv")]
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider adding a builder method for consistency.

The struct provides builder methods for other boolean configuration flags (e.g., with_light_protocol_events at lines 110-119), but none for auto_register_custom_programs_for_pda_compression. Adding corresponding methods would improve API consistency and ergonomics.

Consider adding builder methods after line 119:

    #[cfg(feature = "devenv")]
    pub fn with_auto_register_compression(mut self) -> Self {
        self.auto_register_custom_programs_for_pda_compression = true;
        self
    }

    #[cfg(feature = "devenv")]
    pub fn without_auto_register_compression(mut self) -> Self {
        self.auto_register_custom_programs_for_pda_compression = false;
        self
    }

Also applies to: 137-138


🧹 Nitpick | 🔵 Trivial

Add documentation for the new field.

The new auto_register_custom_programs_for_pda_compression field lacks a doc comment explaining its purpose and behavior. Other fields in this struct have documentation (see lines 45-56), so adding a brief description would maintain consistency and improve maintainability.

Apply this diff to add documentation:

     #[cfg(feature = "devenv")]
+    /// Automatically register custom programs for PDA compression during test setup
     pub auto_register_custom_programs_for_pda_compression: bool,

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In sdk-libs/program-test/src/program_test/config.rs around lines 24 to 25, the
field `auto_register_custom_programs_for_pda_compression` is missing a doc
comment; add a brief doc comment immediately above the field (preserving the
existing #[cfg(feature = "devenv")] attribute) that succinctly explains its
purpose and behavior (e.g., what “auto register” does, when it runs, and any
default/expected value or effect), following the style and tone of the other
field docs in this struct so maintainers can understand why and how to use it.

@ananas-block ananas-block merged commit 35aa28a into main Nov 18, 2025
47 checks passed
@ananas-block ananas-block deleted the swen/csdk branch November 18, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants