fix: revert compressed token account type matching based on tree type#2158
fix: revert compressed token account type matching based on tree type#2158ananas-block wants to merge 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughRemoves the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
💤 Files with no reviewable changes (3)
🧰 Additional context used📓 Path-based instructions (1)programs/**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (62)📓 Common learnings📚 Learning: 2025-11-24T17:59:23.357ZApplied to files:
📚 Learning: 2025-11-24T17:59:36.701ZApplied to files:
📚 Learning: 2025-12-07T18:10:14.606ZApplied to files:
📚 Learning: 2025-11-24T17:59:36.701ZApplied to files:
📚 Learning: 2025-12-07T03:17:42.217ZApplied to files:
📚 Learning: 2025-12-07T18:10:14.606ZApplied to files:
📚 Learning: 2025-11-24T17:56:20.711ZApplied to files:
📚 Learning: 2025-12-07T18:09:57.240ZApplied to files:
📚 Learning: 2025-12-07T18:09:57.240ZApplied to files:
📚 Learning: 2025-12-07T03:17:42.217ZApplied to files:
📚 Learning: 2025-11-24T17:54:20.982ZApplied to files:
📚 Learning: 2025-11-24T17:54:20.982ZApplied to files:
📚 Learning: 2025-11-24T17:59:03.485ZApplied to files:
📚 Learning: 2025-11-24T17:59:03.485ZApplied to files:
📚 Learning: 2025-11-24T17:59:03.485ZApplied to files:
📚 Learning: 2025-11-24T17:59:36.701ZApplied to files:
📚 Learning: 2025-12-07T18:09:57.240ZApplied to files:
📚 Learning: 2025-12-06T00:49:21.983ZApplied to files:
📚 Learning: 2025-11-24T17:56:00.229ZApplied to files:
📚 Learning: 2025-11-24T17:57:53.312ZApplied to files:
📚 Learning: 2025-12-06T00:49:21.983ZApplied to files:
📚 Learning: 2025-11-24T17:57:53.312ZApplied to files:
📚 Learning: 2025-11-24T17:57:39.230ZApplied to files:
📚 Learning: 2025-12-06T00:49:21.983ZApplied to files:
📚 Learning: 2025-11-24T18:01:30.012ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T18:01:30.012ZApplied to files:
📚 Learning: 2025-12-07T18:10:14.606ZApplied to files:
📚 Learning: 2025-11-24T18:01:30.012ZApplied to files:
📚 Learning: 2025-12-07T18:10:14.606ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:57:39.230ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:56:00.229ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:57:39.230ZApplied to files:
📚 Learning: 2025-11-24T17:57:24.369ZApplied to files:
📚 Learning: 2025-11-24T17:57:14.561ZApplied to files:
📚 Learning: 2025-11-24T17:55:17.323ZApplied to files:
📚 Learning: 2025-11-24T17:57:39.230ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:56:20.711ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:59:23.357ZApplied to files:
📚 Learning: 2025-11-24T17:57:39.230ZApplied to files:
📚 Learning: 2025-11-24T17:58:35.079ZApplied to files:
📚 Learning: 2025-11-24T17:56:50.011ZApplied to files:
📚 Learning: 2025-11-24T17:58:50.237ZApplied to files:
📚 Learning: 2025-12-07T18:10:14.606ZApplied to files:
📚 Learning: 2025-11-24T17:58:50.237ZApplied to files:
📚 Learning: 2025-11-24T17:59:36.701ZApplied to files:
📚 Learning: 2025-11-24T17:57:14.561ZApplied to files:
📚 Learning: 2025-11-24T17:58:50.237ZApplied to files:
📚 Learning: 2025-11-24T17:55:17.323ZApplied to files:
📚 Learning: 2025-12-07T03:17:42.217ZApplied to files:
📚 Learning: 2025-12-07T03:17:28.803ZApplied to files:
📚 Learning: 2025-12-07T03:17:28.803ZApplied to files:
📚 Learning: 2025-12-07T18:09:57.240ZApplied to files:
🧬 Code graph analysis (1)programs/compressed-token/anchor/src/freeze.rs (3)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
3a5d57a to
e35a9aa
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
programs/compressed-token/anchor/src/freeze.rs (1)
494-519: Consider adding independent hash verification to tests.The test helper
create_expected_token_output_accountsuses the samehash_v1()method as the production code. This means if there's a bug in hash method selection (e.g., frozen accounts requirehash_frozen_with_hashed_values), the test won't catch it because both expected and actual values would use the incorrect hash.Consider adding a test that verifies hashes against independently computed values or explicitly calls the expected hash functions for frozen vs non-frozen states.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
program-tests/compressed-token-test/tests/v1.rsis excluded by none and included by none
📒 Files selected for processing (5)
programs/compressed-token/anchor/src/burn.rsprograms/compressed-token/anchor/src/delegation.rsprograms/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_mint.rsprograms/compressed-token/anchor/src/process_transfer.rs
💤 Files with no reviewable changes (3)
- programs/compressed-token/anchor/src/delegation.rs
- programs/compressed-token/anchor/src/burn.rs
- programs/compressed-token/anchor/src/process_mint.rs
🧰 Additional context used
📓 Path-based instructions (1)
programs/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
Unit tests in programs must not depend on light-test-utils; integration tests must be located in program-tests/
Files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
🧠 Learnings (54)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/TREE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:53.312Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/*.rs : Account validation for state trees must check: (1) account ownership by Light account compression program, (2) account discriminator is `BatchMta`, and (3) tree type is `STATE_MERKLE_TREE_TYPE_V2` (4)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/TREE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:53.312Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/*.rs : Account validation for address trees must check: (1) account ownership by Light account compression program, (2) account discriminator is `BatchMta`, and (3) tree type is `ADDRESS_MERKLE_TREE_TYPE_V2` (5)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: All compressed token account implementations must reference and comply with the account layout specifications in programs/compressed-token/program/docs/ACCOUNTS.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: Applies to programs/compressed-token/program/src/ctoken_transfer.rs : CTokenTransfer instruction (discriminator: 3) must implement SPL-compatible transfers between decompressed accounts
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: Applies to programs/compressed-token/program/src/close_token_account.rs : Close token account instruction must return rent exemption to rent recipient if compressible and remaining lamports to destination account
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Use compressible token account extensions that allow accounts to be compressed back into compressed state with rent payment mechanisms
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: Applies to programs/compressed-token/program/src/transfer2/*.rs : Transfer2 instruction (discriminator: 101) supports batch operations including Compress, Decompress, and CompressAndClose with multi-mint support and sum checks
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/CONFIG_ACCOUNT.md:0-0
Timestamp: 2025-12-07T18:09:57.240Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : When deserializing CompressibleConfig accounts, skip the 8-byte discriminator `[180, 4, 231, 26, 220, 144, 55, 168]` before deserialization in zero-copy implementations using bytemuck::pod_from_bytes
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Implement all 8 compressed token instructions: create_cmint, mint_to_ctoken, create_token_account_invoke, create_token_account_invoke_signed, create_ata_invoke, create_ata_invoke_signed, transfer_interface_invoke, and transfer_interface_invoke_signed
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.217Z
Learning: Applies to program-libs/account-checks/**/discriminator.rs : Define Discriminator trait with 8-byte account type prefixes and constant arrays for compile-time verification
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:54.689Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/DECOMPRESSED_TRANSFER.md : Decompressed Transfer documentation must cover SPL-compatible transfers between decompressed accounts
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/DISCRIMINATOR.md:0-0
Timestamp: 2025-11-24T17:59:36.701Z
Learning: Applies to program-libs/account-checks/docs/**/account-checks/**/*.rs : Ensure discriminator validation is Anchor-compatible by using sha256 hashing for consistency with Anchor accounts
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:59:23.357Z
Learning: Applies to program-libs/account-checks/docs/src/**/*.rs : Use 8-byte discriminators for account type identification and implement the Discriminator trait for account identification
📚 Learning: 2025-11-24T17:59:36.701Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/DISCRIMINATOR.md:0-0
Timestamp: 2025-11-24T17:59:36.701Z
Learning: Applies to program-libs/account-checks/docs/**/account-checks/**/*.rs : Ensure discriminator validation is Anchor-compatible by using sha256 hashing for consistency with Anchor accounts
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:59:23.357Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:59:23.357Z
Learning: Applies to program-libs/account-checks/docs/src/**/*.rs : Use 8-byte discriminators for account type identification and implement the Discriminator trait for account identification
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T03:17:42.217Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.217Z
Learning: Applies to program-libs/account-checks/**/discriminator.rs : Define Discriminator trait with 8-byte account type prefixes and constant arrays for compile-time verification
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T18:09:57.240Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/CONFIG_ACCOUNT.md:0-0
Timestamp: 2025-12-07T18:09:57.240Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Anchor deserialization of CompressibleConfig must use `AccountDeserialize::try_deserialize()` which automatically validates the discriminator to prevent invalid account type mismatches
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T18:09:57.240Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/CONFIG_ACCOUNT.md:0-0
Timestamp: 2025-12-07T18:09:57.240Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : When deserializing CompressibleConfig accounts, skip the 8-byte discriminator `[180, 4, 231, 26, 220, 144, 55, 168]` before deserialization in zero-copy implementations using bytemuck::pod_from_bytes
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:59:36.701Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/DISCRIMINATOR.md:0-0
Timestamp: 2025-11-24T17:59:36.701Z
Learning: Applies to program-libs/account-checks/docs/**/account-checks/**/*.rs : Implement the Discriminator trait for account types, providing 8-byte LIGHT_DISCRIMINATOR constant and LIGHT_DISCRIMINATOR_SLICE reference in Rust account structures
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/variant_enum.rs : Account variant enum (`CompressedAccountVariant`) generation and `CompressedAccountData` wrapper struct should be implemented in `variant_enum.rs`
Applied to files:
programs/compressed-token/anchor/src/freeze.rs
📚 Learning: 2025-11-24T17:56:20.711Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_ADDRESS_TREE.md:0-0
Timestamp: 2025-11-24T17:56:20.711Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_address_tree.rs : Set discriminator to `BatchMta` `[66, 97, 116, 99, 104, 77, 116, 97]` (8 bytes) for BatchedMerkleTreeAccount in `src/initialize_address_tree.rs`.
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T18:10:14.606Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: Applies to programs/compressed-token/program/src/ctoken_transfer.rs : CTokenTransfer instruction (discriminator: 3) must implement SPL-compatible transfers between decompressed accounts
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:59:36.701Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/DISCRIMINATOR.md:0-0
Timestamp: 2025-11-24T17:59:36.701Z
Learning: Applies to program-libs/account-checks/docs/**/account-checks/**/*.rs : Use the first 8 bytes of account data to store the discriminator identifier for account type verification
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run account-compression tests using `cargo test-sbf -p account-compression-test` to test core account compression program (Merkle tree management)
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Depend on light-compressed-account crate for compressed account types and utilities
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : CompressibleConfig account structure must support serialization via Anchor, Pinocchio, and Borsh formats for Light Registry program integration
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:53.312Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/TREE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:53.312Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/*.rs : Account validation for state trees must check: (1) account ownership by Light account compression program, (2) account discriminator is `BatchMta`, and (3) tree type is `STATE_MERKLE_TREE_TYPE_V2` (4)
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:39.230Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/QUEUE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:39.230Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/queue.rs : Store compressed account hashes in `BatchedQueueAccount` value vectors for immediate proof-by-index access before tree insertion
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:39.230Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/QUEUE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:39.230Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/queue.rs : Validate account ownership by Light account compression program using `check_owner` from `light-account-checks` when deserializing `BatchedQueueAccount` with `output_from_account_info`
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Use `check_account_balance_is_rent_exempt` function from `light-account-checks` to verify rent exemption for both queue_account and merkle_tree_account during initialization
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Charge rollover fee when creating output compressed accounts (insertion into output queue), not on tree operations
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:20.711Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_ADDRESS_TREE.md:0-0
Timestamp: 2025-11-24T17:56:20.711Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Define `BatchedMerkleTreeAccount` account layout in `src/merkle_tree.rs`. Include method `get_merkle_tree_account_size` to calculate account size based on input_queue_batch_size, bloom_filter_capacity, input_queue_zkp_batch_size, root_history_capacity, and height.
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Return error `AccountError::InvalidAccountSize` (error code 12006) when account data length doesn't match calculated size requirements
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T18:10:14.606Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: All compressed token account implementations must reference and comply with the account layout specifications in programs/compressed-token/program/docs/ACCOUNTS.md
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T18:10:14.606Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: Applies to programs/compressed-token/program/src/transfer2/*.rs : Transfer2 instruction (discriminator: 101) supports batch operations including Compress, Decompress, and CompressAndClose with multi-mint support and sum checks
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T03:17:28.803Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Implement all 8 compressed token instructions: create_cmint, mint_to_ctoken, create_token_account_invoke, create_token_account_invoke_signed, create_ata_invoke, create_ata_invoke_signed, transfer_interface_invoke, and transfer_interface_invoke_signed
Applied to files:
programs/compressed-token/anchor/src/freeze.rs
📚 Learning: 2025-12-07T03:17:28.803Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Use compressible token account extensions that allow accounts to be compressed back into compressed state with rent payment mechanisms
Applied to files:
programs/compressed-token/anchor/src/freeze.rs
📚 Learning: 2025-12-07T18:10:14.606Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: Applies to programs/compressed-token/program/src/close_token_account.rs : Close token account instruction must return rent exemption to rent recipient if compressible and remaining lamports to destination account
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Initialize an output queue account as `BatchedQueueAccount` with `QueueType::OutputStateV2`, temporary storage for compressed account hashes before tree insertion with immediate spending capability via proof-by-index, using discriminator b`queueacc` [113, 117, 101, 117, 101, 97, 99, 99]
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T18:09:57.240Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/CONFIG_ACCOUNT.md:0-0
Timestamp: 2025-12-07T18:09:57.240Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : CompressibleConfig account state in Solana programs must validate active state using `validate_active()` method before allowing new compressible token account creation
Applied to files:
programs/compressed-token/anchor/src/freeze.rs
📚 Learning: 2025-11-24T17:57:24.369Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_OUTPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:24.369Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/queue.rs : Insert Into Output Queue: Inserts a compressed account hash into the output queue's currently processing batch by calling `BatchedQueueAccount::insert_into_current_batch` with hash_chain_value and current_slot parameters, updating value vec, hash chain, and managing batch state transitions in src/queue.rs
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/queue.rs : Output queues must store compressed account hashes in value vectors (one per batch) enabling access by leaf index before tree insertion
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:14.561Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:14.561Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_nullifier_into_queue`, insert compressed_account_hash into bloom filter (NOT the nullifier) for non-inclusion checks in subsequent transactions
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Set output queue account discriminator to b`queueacc` (8 bytes) and initialize queue metadata with QueueType::OutputStateV2
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T18:10:14.606Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.606Z
Learning: Applies to programs/compressed-token/program/docs/ACCOUNTS.md : All account documentation must include: description, discriminator, state layout, serialization example, hashing (for compressed accounts only), derivation (for PDAs only), and associated instructions (create, update, close)
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:39.230Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/QUEUE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:39.230Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/queue.rs : Validate account discriminator is `queueacc` (bytes: [113, 117, 101, 117, 101, 97, 99, 99]) using `check_discriminator` from `light-account-checks` when deserializing `BatchedQueueAccount`
Applied to files:
programs/compressed-token/anchor/src/freeze.rsprograms/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-07T03:17:42.217Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.217Z
Learning: Applies to program-libs/account-checks/**/checks.rs : Provide discriminator validation and setting functions (`check_discriminator`, `set_discriminator`) in checks module
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement PDA derivation methods (`derive_pda`, `derive_v1_config_pda`) on CompressibleConfig for account discovery
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:53.312Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/TREE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:53.312Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/*.rs : When deserializing BatchedMerkleTreeAccount in Solana programs, use `BatchedMerkleTreeAccount::state_from_account_info()` for state trees and `BatchedMerkleTreeAccount::address_from_account_info()` for address trees
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/error.rs : Support ProgramError conversions for Anchor, Pinocchio, and Solana frameworks in error implementation
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run Light system program compression tests using `cargo test-sbf -p system-test -- test_with_compression` and `cargo test-sbf -p system-test --test test_re_init_cpi_account` to test compressed account operations
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run compressed token core tests using `cargo test-sbf -p compressed-token-test --test ctoken`, `--test v1`, `--test mint`, and `--test transfer2`
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Compute and store hashed pubkeys by hashing and truncating to 31 bytes for bn254 field compatibility in both queue and tree accounts
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:39.230Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/QUEUE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:39.230Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/queue.rs : Use two value vectors (`[ZeroCopyVecU64<[u8; 32]>; 2]`), one per batch, to store compressed account hashes in `BatchedQueueAccount`
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/decompress_context.rs : Decompression trait implementation (`DecompressContext`) with account accessors, PDA/token separation logic, and token processing delegation should be in `decompress_context.rs`
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Set state Merkle tree account discriminator to b`BatchMta` (8 bytes) and initialize tree metadata with TreeType::StateV2 (4)
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Use `get_merkle_tree_account_size` function from src/merkle_tree.rs to calculate Merkle tree account size based on input_queue_batch_size, bloom_filter_capacity, input_queue_zkp_batch_size, root_history_capacity, and height
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Return error `AccountError::AccountNotRentExempt` (error code 12011) when account balance is insufficient for rent exemption at calculated size
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:59:23.357Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:59:23.357Z
Learning: Applies to program-libs/account-checks/docs/src/**/packed_accounts.rs : Implement index-based dynamic account access with bounds checking for handling variable account sets (mint, owner, delegate accounts)
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:39.230Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/QUEUE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:39.230Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/queue.rs : Implement two hash chain stores (`[ZeroCopyVecU64<[u8; 32]>; 2]`), one per batch, each with `batch_size / zkp_batch_size` hash chains storing Poseidon hashes of ZKP batches in `BatchedQueueAccount`
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:58:35.079Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_OUTPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:35.079Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `src/merkle_tree.rs`, implement `BatchedMerkleTreeAccount::update_tree_from_output_queue_account` method that batch appends values from output queue to state Merkle tree with ZKP verification, verifying proof of old_root + queue_values → new_root
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Store `BatchedMerkleTreeAccount` layout in src/merkle_tree.rs and `BatchedMerkleTreeMetadata` in src/merkle_tree_metadata.rs
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:58:50.237Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_CHECKS.md:0-0
Timestamp: 2025-11-24T17:58:50.237Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/checks.rs : Implement `set_discriminator` function to set 8-byte discriminator on uninitialized account, returning `AlreadyInitialized` (20006) if discriminator is non-zero
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:58:50.237Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_CHECKS.md:0-0
Timestamp: 2025-11-24T17:58:50.237Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/checks.rs : Implement `check_discriminator` function to verify first 8 bytes match expected discriminator for type T, returning `InvalidAccountSize` (20004) if < 8 bytes or `InvalidDiscriminator` (20000) if mismatch
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:57:14.561Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:14.561Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_nullifier_into_queue`, perform non-inclusion check to ensure compressed_account_hash does not exist in any bloom filter to prevent double-spending
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
📚 Learning: 2025-11-24T17:58:50.237Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_CHECKS.md:0-0
Timestamp: 2025-11-24T17:58:50.237Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/checks.rs : Implement `check_account_info` function to validate account ownership by program_id and verify discriminator matches type T
Applied to files:
programs/compressed-token/anchor/src/process_transfer.rs
🧬 Code graph analysis (1)
programs/compressed-token/anchor/src/freeze.rs (1)
programs/compressed-token/anchor/src/process_transfer.rs (6)
process_transfer(37-175)add_data_hash_to_input_compressed_accounts(134-134)add_data_hash_to_input_compressed_accounts(276-316)cpi_execute_compressed_transaction_transfer(327-477)get_input_compressed_accounts_with_merkle_context_and_check_signer(48-48)get_input_compressed_accounts_with_merkle_context_and_check_signer(560-640)
🔇 Additional comments (5)
programs/compressed-token/anchor/src/freeze.rs (2)
13-13: LGTM - Import changes align with fixed discriminator approach.The addition of
TOKEN_COMPRESSED_ACCOUNT_DISCRIMINATORand streamlined imports are consistent with the PR's goal to eliminate dynamic discriminator resolution.Also applies to: 17-17
166-170: No action required—the code correctly handles frozen accounts.The
hash_v1()method at line 169 properly handles frozen accounts. The implementation internally inspects thestatefield (which is correctly set on lines 150–154) and automatically calls the appropriate hashing function:
- If
state != Initialized(i.e., frozen), it callshash_inputs_with_hashed_values::<true>()- If
state == Initialized, it callshash_inputs_with_hashed_values::<false>()This is documented in hash.rs (lines 9–20) under the "Hashing schema" comment. The approach in
freeze.rsis correct and consistent with the dynamic hashing schema already proven inprocess_transfer.rs(which uses the explicit generic approach)—both methods produce the same result because they both respond to the frozen state, just through different code paths.programs/compressed-token/anchor/src/process_transfer.rs (3)
1-2: LGTM - Import changes support fixed discriminator approach.The removal of discriminator-related traits and addition of
TOKEN_COMPRESSED_ACCOUNT_DISCRIMINATORconstant align with the PR's goal to eliminate dynamic discriminator resolution.Also applies to: 16-17, 20-20
238-238: LGTM - Standardized discriminator and amount conversion.The fixed discriminator
TOKEN_COMPRESSED_ACCOUNT_DISCRIMINATORand use of the trait methodto_bytes_le()are correct. The removal of theremaining_accountsparameter (mentioned in AI summary) is appropriate since discriminators are no longer looked up dynamically.Note: Line 288 uses a slightly different method (
to_le_bytes()directly on u64) for the same conversion. While both produce correct results, consider standardizing to one approach for consistency.Also applies to: 248-248
605-605: LGTM - Fixed discriminator usage in input account construction.The standardization to
TOKEN_COMPRESSED_ACCOUNT_DISCRIMINATORis consistent with the PR's approach to eliminate dynamic discriminator resolution.
e35a9aa to
311af55
Compare
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.