Skip to content

fix: add compress and close account uniqueness#2035

Merged
SwenSchaeferjohann merged 4 commits intomainfrom
jorrit/fix-add-compress-and-close-account-uniqueness
Nov 11, 2025
Merged

fix: add compress and close account uniqueness#2035
SwenSchaeferjohann merged 4 commits intomainfrom
jorrit/fix-add-compress-and-close-account-uniqueness

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Nov 5, 2025

Issue:

  • potential attack to compress and close 2 compressible ctoken accounts to one compressed token account and steal half of the funds by declaring the same output compressed token account as output for both ctoken accounts.
  • it is unlikely that the forester was able to exploit this issue compress_and_close_ctoken_accounts_with_indices builds the instruction based on the ctoken accounts in the registry program -> its not possible for foresters to specify compressed output accounts.
  • As defensive measure we still add a uniqueness check.

Changes:

  • add check for output uniqueness ErrorCode::CompressAndCloseDuplicateOutput (incl unit test)
  • refactor: move light-registry compress and close instruction building from compressed-token-sdk to light-registry (the program should not depend on sdk-libs crates)
  • refactor: require one authority_index and destination_index on instruction level instead of account level

Summary by CodeRabbit

  • New Features

    • Added duplicate output detection for CompressAndClose operations to prevent unintended fund routing.
  • Bug Fixes

    • Implemented validation to reject CompressAndClose transactions referencing duplicate compressed output accounts.
  • Chores

    • Added bitvec dependency to support enhanced validation logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

Adds duplicate-output detection to compress-and-close via a 256-bit bitmap; introduces Transfer2 CPI account parsing (Transfer2CpiAccounts), a registry-side instruction builder that accepts per-account indices plus top-level authority_index/destination_index, updates call sites/tests, and adds the bitvec dependency.

Changes

Cohort / File(s) Change Summary
Workspace & program deps
Cargo.toml, programs/compressed-token/program/Cargo.toml, program-libs/bloom-filter/Cargo.toml, programs/registry/Cargo.toml
Added/converted bitvec to workspace dependency; registry replaced light-compressed-token-sdk with light-ctoken-types and added several workspace deps (light-account-checks, light-program-profiler, light-macros, borsh, solana-account-info, solana-instruction, solana-pubkey, spl-pod).
Error enum & docs
programs/compressed-token/anchor/src/lib.rs, programs/compressed-token/program/docs/instructions/TRANSFER2.md
Added CompressAndCloseDuplicateOutput error variant and documented uniqueness requirement for CompressAndClose outputs.
Bitmap duplicate detection
programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
Implemented 256-bit bitmap-based duplicate/out-of-bounds checks in close_for_compress_and_close, early-failing on duplicates or invalid indices; deferred account closures until after validation; added bitvec import.
Unit tests (new)
programs/compressed-token/program/tests/compress_and_close.rs
Added unit test verifying duplicate compressed_account_index detection and helper for building compressible CToken data.
Program-test updates
program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs, program-tests/compressed-token-test/tests/ctoken/shared.rs
Removed stubbed failure test, added imports (Rpc, Signer), and updated index/account wiring to reflect authority_index/destination_index moved to instruction-level; updated type import paths.
Registry CPI accounts type
programs/registry/src/compressible/compressed_token/accounts.rs
Added Transfer2CpiAccounts struct with try_from_account_infos and to_account_infos to parse/validate CPI account sequences and expose packed_accounts.
Instruction builder & indices
programs/registry/src/compressible/compressed_token/compress_and_close.rs, programs/registry/src/compressible/compressed_token/mod.rs
Added CompressAndCloseIndices struct and compress_and_close_ctoken_accounts_with_indices function: builds Transfer2 instruction using per-account indices and top-level authority_index/destination_index; added compressed-token-related Pubkey constants and re-exports.
Registry handler integration
programs/registry/src/compressible/compress_and_close.rs, programs/registry/src/lib.rs
Updated process_compress_and_close / compress_and_close signatures to accept authority_index and destination_index, refactored to use Transfer2CpiAccounts::try_from_account_infos, and propagate indices into CPI instruction builder.
Forester / program-test refactor
sdk-libs/program-test/src/forester/compress_and_close_forester.rs
Centralized authority and destination handling: collect and emit authority_index and destination_index at instruction level; removed per-CToken authority/destination embedding; adjusted account/index assembly and imports.
SDK struct derive change
sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
Added Copy, Clone derives to CompressAndCloseIndices struct.

Sequence Diagram(s)

sequenceDiagram
    participant Forester as Forester (builder)
    participant Registry as Registry (instruction builder)
    participant Program as CompressedToken Program
    participant Bitmap as Bitmap Validation

    Forester->>Registry: build Transfer2 instruction (fee_payer, authority_idx, destination_idx, indices, packed_accounts)
    Registry->>Program: invoke Transfer2 Instruction (outputs + compressions + authority_idx + destination_idx)
    Program->>Bitmap: close_for_compress_and_close(compressions, accounts)

    rect rgb(240, 250, 240)
      Bitmap->>Bitmap: init 256-bit bitmap
    end

    loop per compression entry
        Bitmap->>Bitmap: compute compressed_idx
        alt idx >= 256 or invalid
            Bitmap-->>Program: InvalidInstructionData (early return)
        else idx already used
            Bitmap-->>Program: CompressAndCloseDuplicateOutput (early return)
        else
            Bitmap->>Bitmap: mark idx
            Bitmap->>Program: proceed to close_token_account (deferred)
        end
    end

    Program-->>Registry: Success / Error
    Registry-->>Forester: Result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay extra attention to:
    • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs — bitmap math, bounds checks, and platform-specific account handling.
    • programs/registry/src/compressible/compressed_token/accounts.rs — account parsing order, validation, and try_from_account_infos error mapping.
    • programs/registry/src/compressible/compressed_token/compress_and_close.rs — reading amounts from packed accounts and correct AccountMeta ordering.
    • Forester and test changes — ensure indices propagation and test fixtures match new instruction shape.

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

🐰 I hopped through bits and marked each space,

A tiny bitmap kept watch with grace.
Authority and destination now align,
Packed accounts in tidy, ordered line.
No duplicate output shall pass my gate — hooray for safe close time! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a uniqueness check for compress-and-close accounts to prevent potential fund theft via duplicate outputs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/fix-add-compress-and-close-account-uniqueness

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eaa8db9 and 2bec55e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • Cargo.toml (1 hunks)
  • program-libs/bloom-filter/Cargo.toml (1 hunks)
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs (1 hunks)
  • program-tests/compressed-token-test/tests/ctoken/shared.rs (2 hunks)
  • programs/compressed-token/anchor/src/lib.rs (1 hunks)
  • programs/compressed-token/program/Cargo.toml (1 hunks)
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md (2 hunks)
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs (3 hunks)
  • programs/compressed-token/program/tests/compress_and_close.rs (1 hunks)
  • programs/registry/Cargo.toml (1 hunks)
  • programs/registry/src/compressible/compress_and_close.rs (3 hunks)
  • programs/registry/src/compressible/compressed_token/accounts.rs (1 hunks)
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs (1 hunks)
  • programs/registry/src/compressible/compressed_token/mod.rs (1 hunks)
  • programs/registry/src/compressible/mod.rs (1 hunks)
  • programs/registry/src/lib.rs (3 hunks)
  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs (1 hunks)
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/compressed-token/program/Cargo.toml
  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • Cargo.toml
  • program-libs/bloom-filter/Cargo.toml
🧰 Additional context used
📓 Path-based instructions (1)
programs/registry/src/lib.rs

📄 CodeRabbit inference engine (programs/registry/CLAUDE.md)

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.
Instruction handlers must compute work_units by operation type: batch operations use account.queue_batches.batch_size; single operations use DEFAULT_WORK_V1; custom operations compute based on complexity.
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.
Apply forester eligibility rules: with a forester PDA, validate epoch registration, eligibility, track work, and require network fee; without a forester PDA, ensure authority matches the tree’s designated forester.

Files:

  • programs/registry/src/lib.rs
🧠 Learnings (44)
📓 Common learnings
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
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: Applies to programs/compressed-token/program/src/transfer2/native_compression/** : Compress & Close operations (via registry) must validate that the config state is not INACTIVE (active or deprecated allowed)
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/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
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/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 : 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
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.
📚 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-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/anchor/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/Cargo.toml
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/mod.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:

  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/mod.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-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/anchor/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/Cargo.toml
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/mod.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-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/anchor/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/mod.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-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/mod.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-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/compressed-token/anchor/src/lib.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/Cargo.toml
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/mod.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/anchor/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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/transfer2/native_compression/** : Compress & Close operations (via registry) must validate that the config state is not INACTIVE (active or deprecated allowed)

Applied to files:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/anchor/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/mod.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/Cargo.toml
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/mod.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/Cargo.toml
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/Cargo.toml
  • programs/registry/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/test_account_info.rs : Use the mock AccountInfo implementation under the test-only feature for unit tests

Applied to files:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/Cargo.toml
📚 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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/Cargo.toml
📚 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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/compressed-token/anchor/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/compressed-token/anchor/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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/compressed-token/anchor/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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.rs
  • programs/registry/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • programs/registry/src/compressible/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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/program-test/src/forester/compress_and_close_forester.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/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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/ERRORS.md : Document error types, codes, causes, and resolutions in docs/ERRORS.md

Applied to files:

  • programs/compressed-token/anchor/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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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/**/ACCOUNTS.md : Maintain ACCOUNTS.md with complete account layouts and data structures

Applied to files:

  • programs/registry/src/compressible/compressed_token/mod.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:

  • programs/registry/src/compressible/compressed_token/mod.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.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: Read this file and all referenced Markdown files in full before working on the compressed-token program

Applied to files:

  • programs/registry/src/compressible/mod.rs
🧬 Code graph analysis (6)
programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs (1)
programs/compressed-token/program/src/close_token_account/processor.rs (2)
  • validate_token_account_for_close_transfer2 (48-53)
  • close_token_account (142-145)
programs/registry/src/compressible/compress_and_close.rs (2)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)
  • compress_and_close_ctoken_accounts_with_indices (52-179)
programs/registry/src/compressible/compressed_token/accounts.rs (1)
  • try_from_account_infos (33-80)
sdk-libs/program-test/src/forester/compress_and_close_forester.rs (1)
programs/registry/src/lib.rs (1)
  • compress_and_close (785-800)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)
js/stateless.js/src/constants.ts (1)
  • COMPRESSED_TOKEN_PROGRAM_ID (256-258)
programs/registry/src/compressible/compressed_token/mod.rs (2)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)
  • compress_and_close_ctoken_accounts_with_indices (52-179)
js/stateless.js/src/constants.ts (1)
  • COMPRESSED_TOKEN_PROGRAM_ID (256-258)
programs/registry/src/lib.rs (1)
programs/registry/src/compressible/compress_and_close.rs (1)
  • process_compress_and_close (34-81)
⏰ 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). (15)
  • 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 (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 (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: Forester e2e test
  • 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: stateless-js-v1
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-slow
  • GitHub Check: lint
  • GitHub Check: stateless-js-v2
🔇 Additional comments (13)
programs/registry/src/lib.rs (3)

49-49: LGTM: Import aligns with refactored module structure.

The import of CompressAndCloseIndices from the new crate::compressible::compressed_token module correctly supports the refactored instruction structure.


785-790: LGTM: Function signature correctly refactored.

The new authority_index and destination_index parameters consolidate what were previously per-account fields into instruction-level parameters, reducing duplication and aligning with the PR's objective to require a single authority and destination for the entire operation.


799-799: LGTM: Call site updated correctly.

The updated call to process_compress_and_close correctly passes the new authority_index and destination_index parameters.

programs/registry/src/compressible/compressed_token/mod.rs (2)

1-9: LGTM: Module structure follows best practices.

The module organization and re-exports provide a clean public API for compress-and-close functionality, consistent with the codebase's module patterns.


11-27: LGTM: Program IDs defined with compile-time validation.

Using the pubkey! macro ensures compile-time validation of the program IDs. The COMPRESSED_TOKEN_PROGRAM_ID matches the expected value from the TypeScript constants.

program-tests/compressed-token-test/tests/ctoken/shared.rs (2)

13-13: LGTM: Import path updated for relocated type.

The import correctly references CompressAndCloseIndices from its new location in the light_registry crate, reflecting the refactor that moves instruction building logic from the SDK to the registry program.


837-878: LGTM: Instruction construction refactored correctly.

The updated logic correctly moves authority_index and destination_index from per-account fields to instruction-level parameters, while CompressAndCloseIndices now contains only the per-account fields. This aligns with the PR's objective to enforce a single authority and destination for the entire operation.

programs/registry/src/compressible/compress_and_close.rs (3)

4-10: LGTM: Imports updated for refactored module structure.

The imports correctly reference the new module paths, bringing in the refactored Transfer2CpiAccounts, compress_and_close_ctoken_accounts_with_indices, and CompressAndCloseIndices from the local crate structure.


34-38: LGTM: Function signature correctly updated.

The addition of authority_index and destination_index parameters, along with the lifetime annotation update, correctly supports the refactored instruction structure.


51-62: LGTM: Account parsing and instruction building refactored correctly.

The use of Transfer2CpiAccounts::try_from_account_infos provides structured account validation, and the call to compress_and_close_ctoken_accounts_with_indices correctly passes the new top-level indices along with the parsed accounts.

sdk-libs/program-test/src/forester/compress_and_close_forester.rs (2)

8-14: LGTM: Imports updated for refactored types.

The imports correctly reference types from both light_compressed_token_sdk and light_registry, reflecting the split of responsibilities between SDK and registry.


158-199: LGTM: Instruction construction refactored correctly.

The final assembly correctly calculates authority_index and destination_index at the instruction level, adds system accounts via the config, and constructs the CompressAndClose instruction with the new structure.

programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)

27-33: LGTM: Index structure defined correctly.

The CompressAndCloseIndices struct appropriately contains only per-account indices (source_index, mint_index, owner_index, rent_sponsor_index), separating them from the instruction-level authority and destination indices.


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

@ananas-block ananas-block force-pushed the jorrit/fix-add-compress-and-close-account-uniqueness branch from 6b3c9e9 to e4e6315 Compare November 5, 2025 20:48
@ananas-block ananas-block marked this pull request as ready for review November 5, 2025 23:26
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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs (1)

184-193: Remove the 32-element hard cap when materializing packed accounts.

ArrayVec::<_, 32> panics as soon as packed_accounts.len() > 32. A CompressAndClose batch with diverse owners/rent sponsors easily exceeds that, turning what should be a supported flow into a runtime abort. Use a growable Vec sized to packed_accounts.len() (or another fallible structure) so large batches stay safe.

-    let mut packed_account_metas = arrayvec::ArrayVec::<AccountMeta, 32>::new();
-    for info in packed_accounts.iter() {
-        packed_account_metas.push(AccountMeta {
+    let mut packed_account_metas = Vec::with_capacity(packed_accounts.len());
+    for info in packed_accounts.iter() {
+        packed_account_metas.push(AccountMeta {
             pubkey: *info.key,
             is_signer: info.is_signer,
             is_writable: info.is_writable,
         });
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 170db77 and 21b43de.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (17)
  • Cargo.toml (1 hunks)
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs (1 hunks)
  • program-tests/compressed-token-test/tests/ctoken/shared.rs (2 hunks)
  • programs/compressed-token/anchor/src/lib.rs (1 hunks)
  • programs/compressed-token/program/Cargo.toml (1 hunks)
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md (2 hunks)
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs (3 hunks)
  • programs/compressed-token/program/tests/compress_and_close.rs (1 hunks)
  • programs/registry/Cargo.toml (1 hunks)
  • programs/registry/src/compressible/compress_and_close.rs (3 hunks)
  • programs/registry/src/compressible/compressed_token/accounts.rs (1 hunks)
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs (1 hunks)
  • programs/registry/src/compressible/compressed_token/mod.rs (1 hunks)
  • programs/registry/src/compressible/mod.rs (1 hunks)
  • programs/registry/src/lib.rs (3 hunks)
  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs (1 hunks)
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
programs/compressed-token/program/docs/**/instructions/**/*.md

📄 CodeRabbit inference engine (programs/compressed-token/program/docs/CLAUDE.md)

Keep detailed instruction documentation files under the instructions/ directory; add additional instruction docs as needed

Files:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
programs/compressed-token/program/docs/instructions/*.md

📄 CodeRabbit inference engine (programs/compressed-token/program/CLAUDE.md)

Every instruction description must include: path, description, instruction_data (code paths), Accounts (order and checks), instruction logic and checks, and Errors (with causes)

Files:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
programs/registry/src/lib.rs

📄 CodeRabbit inference engine (programs/registry/CLAUDE.md)

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.
Instruction handlers must compute work_units by operation type: batch operations use account.queue_batches.batch_size; single operations use DEFAULT_WORK_V1; custom operations compute based on complexity.
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.
Apply forester eligibility rules: with a forester PDA, validate epoch registration, eligibility, track work, and require network fee; without a forester PDA, ensure authority matches the tree’s designated forester.

Files:

  • programs/registry/src/lib.rs
🧠 Learnings (50)
📓 Common learnings
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
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/transfer2/native_compression/** : Compress & Close operations (via registry) must validate that the config state is not INACTIVE (active or deprecated allowed)
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 : 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: 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.
📚 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:

  • programs/compressed-token/anchor/src/lib.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.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:

  • programs/compressed-token/anchor/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.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 : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs

Applied to files:

  • programs/compressed-token/anchor/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/registry/src/compressible/mod.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/Cargo.toml
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • programs/compressed-token/anchor/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/registry/src/compressible/mod.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/Cargo.toml
📚 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:

  • programs/compressed-token/anchor/src/lib.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.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:

  • programs/compressed-token/anchor/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/registry/src/compressible/mod.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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/ERRORS.md : Document error types, codes, causes, and resolutions in docs/ERRORS.md

Applied to files:

  • programs/compressed-token/anchor/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:

  • programs/compressed-token/anchor/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/accounts.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:

  • programs/compressed-token/anchor/src/lib.rs
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/lib.rs
  • programs/registry/Cargo.toml
  • programs/registry/src/compressible/compressed_token/mod.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:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/registry/Cargo.toml
📚 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:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/compressed-token/program/Cargo.toml
  • programs/registry/src/compressible/compressed_token/mod.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:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/registry/Cargo.toml
📚 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/test_account_info.rs : Use the mock AccountInfo implementation under the test-only feature for unit tests

Applied to files:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/registry/src/compressible/mod.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/Cargo.toml
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.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:

  • sdk-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/registry/src/compressible/mod.rs
  • programs/registry/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-libs/compressed-token-sdk/src/instructions/compress_and_close.rs
  • programs/registry/src/compressible/mod.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/lib.rs
  • programs/compressed-token/program/Cargo.toml
  • programs/registry/Cargo.toml
  • programs/registry/src/compressible/compressed_token/mod.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/transfer2/native_compression/** : Compress & Close operations (via registry) must validate that the config state is not INACTIVE (active or deprecated allowed)

Applied to files:

  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/registry/src/compressible/mod.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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/**/ACCOUNTS.md : Maintain ACCOUNTS.md with complete account layouts and data structures

Applied to files:

  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • programs/compressed-token/program/tests/compress_and_close.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/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:

  • programs/compressed-token/program/tests/compress_and_close.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/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:

  • programs/compressed-token/program/tests/compress_and_close.rs
  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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/MINT_ACTION.md : Document Mint operations and compressed mint management (9 actions) in instructions/MINT_ACTION.md

Applied to files:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
📚 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:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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/instructions/*.md : Every instruction description must include: path, description, instruction_data (code paths), Accounts (order and checks), instruction logic and checks, and Errors (with causes)

Applied to files:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
📚 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:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
📚 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: Use specific error variants for authorization and fee failures: InvalidSigner, InvalidNetworkFee, ForesterDefined/Undefined.

Applied to files:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
📚 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/**/ERRORS.md : ERRORS.md must document error types with numeric codes in the 12006–12021 range, common causes, resolution strategies, and conversion mappings for Solana and Pinocchio

Applied to files:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.md
📚 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/**/ERRORS.md : Error codes should reference the actual values that appear in transaction logs

Applied to files:

  • programs/compressed-token/program/docs/instructions/TRANSFER2.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 : Provide default initialization for the CToken V1 config in CompressibleConfig

Applied to files:

  • programs/registry/src/compressible/mod.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
  • programs/compressed-token/program/Cargo.toml
📚 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: Read this file and all referenced Markdown files in full before working on the compressed-token program

Applied to files:

  • programs/registry/src/compressible/mod.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/program-test/src/forester/compress_and_close_forester.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-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/accounts.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/program-test/src/forester/compress_and_close_forester.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/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/accounts.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-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.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:

  • programs/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-08-14T00:36:53.191Z
Learnt from: ananas-block
Repo: Lightprotocol/light-protocol PR: 1909
File: program-libs/zero-copy/src/init_mut.rs:241-249
Timestamp: 2025-08-14T00:36:53.191Z
Learning: In the light-protocol zero-copy crate, performance is prioritized over safety checks for edge cases like Vec lengths exceeding u32::MAX, even when there might be wire format inconsistencies.

Applied to files:

  • Cargo.toml
📚 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:

  • programs/registry/src/compressible/compressed_token/accounts.rs
  • programs/registry/src/compressible/compressed_token/mod.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:

  • programs/registry/src/compressible/compressed_token/accounts.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_iterator.rs : Use AccountIterator for sequential account retrieval to get precise file:line:column error locations; avoid manual index handling

Applied to files:

  • programs/registry/src/compressible/compressed_token/accounts.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:

  • programs/compressed-token/program/Cargo.toml
  • programs/registry/Cargo.toml
🧬 Code graph analysis (8)
programs/compressed-token/program/tests/compress_and_close.rs (3)
sdk-libs/compressed-token-sdk/src/account2.rs (2)
  • compression (379-381)
  • mint (371-373)
programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs (1)
  • close_for_compress_and_close (169-225)
program-libs/ctoken-types/src/state/ctoken/zero_copy.rs (1)
  • new_compressible (612-621)
sdk-libs/program-test/src/forester/compress_and_close_forester.rs (2)
programs/registry/src/lib.rs (1)
  • compress_and_close (785-800)
js/stateless.js/src/errors.ts (1)
  • RpcError (79-79)
programs/compressed-token/program/src/transfer2/compression/ctoken/compress_and_close.rs (1)
programs/compressed-token/program/src/close_token_account/processor.rs (2)
  • validate_token_account_for_close_transfer2 (48-53)
  • close_token_account (142-145)
programs/registry/src/compressible/compress_and_close.rs (2)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)
  • compress_and_close_ctoken_accounts_with_indices (51-187)
programs/registry/src/compressible/compressed_token/accounts.rs (2)
  • try_from_account_infos (90-95)
  • packed_accounts (98-100)
programs/registry/src/lib.rs (1)
programs/registry/src/compressible/compress_and_close.rs (1)
  • process_compress_and_close (38-89)
programs/registry/src/compressible/compressed_token/accounts.rs (2)
js/stateless.js/src/constants.ts (1)
  • COMPRESSED_TOKEN_PROGRAM_ID (256-258)
sdk-libs/sdk-types/src/cpi_accounts/v1.rs (1)
  • light_system_program (114-119)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (3)
js/stateless.js/src/constants.ts (1)
  • COMPRESSED_TOKEN_PROGRAM_ID (256-258)
programs/registry/src/compressible/compressed_token/accounts.rs (1)
  • packed_accounts (98-100)
js/stateless.js/src/state/types.ts (1)
  • CompressedCpiContext (353-368)
programs/registry/src/compressible/compressed_token/mod.rs (3)
programs/registry/src/lib.rs (1)
  • compress_and_close (785-800)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)
  • compress_and_close_ctoken_accounts_with_indices (51-187)
js/stateless.js/src/constants.ts (1)
  • COMPRESSED_TOKEN_PROGRAM_ID (256-258)
⏰ 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: stateless-js-v1
  • GitHub Check: lint
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • 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 (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 (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: Test program-libs-slow
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test batched-merkle-tree-simulate
  • 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: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk...
  • GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
  • GitHub Check: cli-v2
  • GitHub Check: cli-v1
  • GitHub Check: stateless-js-v2

@ananas-block ananas-block force-pushed the jorrit/fix-add-compress-and-close-account-uniqueness branch from 21b43de to eaa8db9 Compare November 6, 2025 15:27
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)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (2)

64-116: Critical: Missing bounds validation for authority_index and per-output indices.

While packed_accounts.get_u8(idx.source_index, ...) at line 82 validates the source index, the function never checks that authority_index (used at line 119) or the other indices (mint_index, owner_index, rent_sponsor_index used in lines 96, 99, 107, 110) are within bounds. If a caller supplies an out-of-bounds index, Line 119 will panic, or lines 96-113 will construct invalid output data referencing non-existent accounts.

Add explicit bounds checks at the start of the function:

     // Convert packed_accounts to AccountMetas
     let mut packed_account_metas = Vec::with_capacity(packed_accounts.accounts.len());
+    let packed_len = packed_accounts.accounts.len();
+    
+    // Validate authority_index and destination_index upfront
+    if (authority_index as usize) >= packed_len || (destination_index as usize) >= packed_len {
+        msg!("authority_index or destination_index out of bounds");
+        return Err(ProgramError::NotEnoughAccountKeys.into());
+    }
+
     for info in packed_accounts.accounts.iter() {

And in the loop:

     // Process each set of indices
     for (i, idx) in indices.iter().enumerate() {
+        // Validate all indices for this compression
+        if (idx.source_index as usize) >= packed_len
+            || (idx.mint_index as usize) >= packed_len
+            || (idx.owner_index as usize) >= packed_len
+            || (idx.rent_sponsor_index as usize) >= packed_len
+        {
+            msg!("Invalid index in CompressAndCloseIndices");
+            return Err(ProgramError::NotEnoughAccountKeys.into());
+        }
+        
         // Get the amount from the source token account

167-170: Critical: Use actual system program ID instead of all-zero pubkey.

Line 168 creates an AccountMeta with Pubkey::from([0u8; 32]) for the system program. This all-zero pubkey won't match the actual system program AccountInfo at runtime, causing the CPI via invoke_signed to fail with a key mismatch error.

Replace with the real system program ID:

+use anchor_lang::solana_program::system_program;
+
 // ... 
     account_metas.push(AccountMeta::new_readonly(
-        Pubkey::from([0u8; 32]), // system_program
+        system_program::ID,
         false,
     ));
🧹 Nitpick comments (1)
sdk-libs/program-test/src/forester/compress_and_close_forester.rs (1)

61-63: Remove leftover debug logging

The println! on Line 62 is a stray debug statement that will spam test output. Please drop it to keep the helper quiet.

-    println!("config compression_authority {:?}", compression_authority);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21b43de and eaa8db9.

📒 Files selected for processing (8)
  • Cargo.toml (1 hunks)
  • program-libs/bloom-filter/Cargo.toml (1 hunks)
  • program-tests/compressed-token-test/tests/ctoken/shared.rs (2 hunks)
  • programs/registry/src/compressible/compress_and_close.rs (3 hunks)
  • programs/registry/src/compressible/compressed_token/accounts.rs (1 hunks)
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs (1 hunks)
  • programs/registry/src/lib.rs (3 hunks)
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Cargo.toml
  • programs/registry/src/compressible/compressed_token/accounts.rs
🧰 Additional context used
📓 Path-based instructions (1)
programs/registry/src/lib.rs

📄 CodeRabbit inference engine (programs/registry/CLAUDE.md)

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.
Instruction handlers must compute work_units by operation type: batch operations use account.queue_batches.batch_size; single operations use DEFAULT_WORK_V1; custom operations compute based on complexity.
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.
Apply forester eligibility rules: with a forester PDA, validate epoch registration, eligibility, track work, and require network fee; without a forester PDA, ensure authority matches the tree’s designated forester.

Files:

  • programs/registry/src/lib.rs
🧠 Learnings (37)
📓 Common learnings
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
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/transfer2/native_compression/** : Compress & Close operations (via registry) must validate that the config state is not INACTIVE (active or deprecated allowed)
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/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
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
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
📚 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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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 : Ensure serialization compatibility across Anchor, Pinocchio, and Borsh for core account types used by dependent programs

Applied to files:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • program-libs/bloom-filter/Cargo.toml
📚 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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compress_and_close.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/transfer2/native_compression/** : Compress & Close operations (via registry) must validate that the config state is not INACTIVE (active or deprecated allowed)

Applied to files:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • program-libs/bloom-filter/Cargo.toml
📚 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:

  • program-tests/compressed-token-test/tests/ctoken/shared.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-tests/compressed-token-test/tests/ctoken/shared.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compress_and_close.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-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compress_and_close.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-tests/compressed-token-test/tests/ctoken/shared.rs
  • programs/registry/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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/lib.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.rs
  • sdk-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • program-tests/compressed-token-test/tests/ctoken/shared.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-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.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/program-test/src/forester/compress_and_close_forester.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-libs/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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/program-test/src/forester/compress_and_close_forester.rs
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • programs/registry/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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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:

  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • program-libs/bloom-filter/Cargo.toml
📚 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:

  • program-libs/bloom-filter/Cargo.toml
🧬 Code graph analysis (4)
sdk-libs/program-test/src/forester/compress_and_close_forester.rs (1)
programs/registry/src/lib.rs (1)
  • compress_and_close (785-800)
programs/registry/src/lib.rs (1)
programs/registry/src/compressible/compress_and_close.rs (1)
  • process_compress_and_close (34-81)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)
js/stateless.js/src/constants.ts (1)
  • COMPRESSED_TOKEN_PROGRAM_ID (256-258)
programs/registry/src/compressible/compress_and_close.rs (2)
programs/registry/src/compressible/compressed_token/compress_and_close.rs (1)
  • compress_and_close_ctoken_accounts_with_indices (52-179)
programs/registry/src/compressible/compressed_token/accounts.rs (1)
  • try_from_account_infos (33-80)
⏰ 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 (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • 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: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • 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 (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • 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, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk...
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-fast
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • GitHub Check: Forester e2e test
  • GitHub Check: lint
  • GitHub Check: stateless-js-v2
  • GitHub Check: cli-v2
  • GitHub Check: cli-v1
🔇 Additional comments (14)
program-libs/bloom-filter/Cargo.toml (1)

14-14: No action required.

Verification confirms the workspace Cargo.toml properly declares bitvec = { version = "1.0.1", default-features = false }. The bloom-filter crate correctly references this via workspace = true, and the pattern is consistent with other workspace members (e.g., compressed-token/program also uses the same dependency). The change is valid.

program-tests/compressed-token-test/tests/ctoken/shared.rs (2)

13-13: Import path updated to match new module structure.

The import correctly reflects the move of CompressAndCloseIndices to the registry's compressed_token module.


876-877: Test correctly adapted to new instruction signature.

The authority_index and destination_index are now passed as top-level instruction parameters, aligning with the updated compress_and_close API.

programs/registry/src/compressible/compress_and_close.rs (5)

4-10: Imports correctly updated to match new module structure.

The imports now reference the local compressed_token module with the new instruction builder and types.


12-32: Context struct simplified with new account parsing.

The compressed_token_program field removal is appropriate since Transfer2CpiAccounts now handles the complete account set parsing.


34-39: Function signature updated with proper lifetime constraints.

The new parameters and lifetime bounds correctly support the updated instruction construction flow.


51-54: Account parsing centralized with new abstraction.

The Transfer2CpiAccounts helper properly validates and parses the account set for the CPI call.


56-62: Instruction construction delegated to new builder.

The call correctly passes all required indices and packed accounts to the instruction builder.

programs/registry/src/lib.rs (3)

49-49: Import updated to match new module location.

The type is now correctly imported from the local compressed_token module.


785-789: Public API signature updated with new parameters.

The function correctly exposes authority_index and destination_index as required by the new instruction construction flow.


799-799: Call site correctly propagates new parameters.

The indices are properly passed through to the processor function.

programs/registry/src/compressible/compressed_token/compress_and_close.rs (3)

27-33: Struct definition is well-designed.

The CompressAndCloseIndices properly encapsulates the per-account indices needed for each compress-and-close operation.


52-62: Function signature and empty validation are correct.

The early return for empty indices prevents unnecessary processing.


123-149: Instruction data construction is correct.

The CompressedTokenInstructionDataTransfer2 is properly built with the output accounts and compressions, serialized, and prefixed with the discriminator.

@ananas-block ananas-block force-pushed the jorrit/fix-add-compress-and-close-account-uniqueness branch from eaa8db9 to 2bec55e Compare November 10, 2025 16:34
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