Skip to content

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Dec 8, 2025

Summary by CodeRabbit

  • New Features

    • Added input validations with clear errors: max 8 addresses, max 10 nullifiers, and max 10 items per output-queue batch; oversized inputs return explicit errors.
  • Chores

    • Tuned address/state initialization defaults: increased address batch size, larger bloom filter capacity, and extended address root history length.
  • Bug Fixes

    • Clarified error messaging for leaf limits across versions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Adds address- and state-specific batch and bloom constants (including DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN = 120 and DEFAULT_ADDRESS_BATCH_SIZE = 30000), doubles address bloom capacity, and enforces per-instruction limits (addresses ≤ 8, nullifiers ≤ 10) plus a max leaf-batch size (≤ 10); adds two new error variants. (39 words)

Changes

Cohort / File(s) Change Summary
Constants
program-libs/batched-merkle-tree/src/constants.rs
Added pub const DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN: u32 = 120 and pub const DEFAULT_ADDRESS_BATCH_SIZE: u64 = 30000; increased ADDRESS_BLOOM_FILTER_CAPACITY from 2_301_536 to 4_603_072; added contextual comments about 15k/30k false-positive contexts.
Address Tree Init
program-libs/batched-merkle-tree/src/initialize_address_tree.rs
Switched hard-coded/defaults to address-specific constants: ADDRESS_BLOOM_FILTER_NUM_HASHES, DEFAULT_ADDRESS_BATCH_SIZE, DEFAULT_BATCH_ADDRESS_TREE_HEIGHT, DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN, and ADDRESS_BLOOM_FILTER_CAPACITY.
State Tree Init
program-libs/batched-merkle-tree/src/initialize_state_tree.rs
Replaced hard-coded bloom parameters with STATE_BLOOM_FILTER_NUM_HASHES and STATE_BLOOM_FILTER_CAPACITY.
Error Definitions
programs/account-compression/src/errors.rs
Updated TooManyLeaves message to "The maximum number of leaves is 30 for v1 and 10 for v2"; added TooManyAddresses ("Too many addresses. The maximum is 8 per instruction.") and TooManyNullifiers ("Too many nullifiers. The maximum is 10 per instruction.").
Queue Insert Validation
programs/account-compression/src/processor/insert_into_queues.rs
Added pre-checks: if inputs.addresses.len() > 8 log and return TooManyAddresses; if inputs.nullifiers.len() > 10 log and return TooManyNullifiers; these run before authority initialization.
Leaf Batch Validation
programs/account-compression/src/processor/insert_leaves.rs
Added guard: if an OutputQueue batch span (end - start) > 10, log and return AccountCompressionErrorCode::TooManyLeaves (short-circuiting oversized batches).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Verify the updated TooManyLeaves message exactly matches intended wording and any user-facing docs/tests.
  • Confirm tests, utilities, and callers expecting previous batch sizes, bloom capacities, or root-history lengths are updated to use the new address-specific constants.
  • Inspect any ABI/serialization or error-code ordering implications from adding enum variants in AccountCompressionErrorCode.

Possibly related PRs

  • chore: pre release #2014 — overlaps changes to program-libs/batched-merkle-tree/src/initialize_address_tree.rs (address init/constants).
  • fix: osec audit fixes #1882 — touches batched-merkle-tree initialization and bloom parameter handling; likely related to bloom capacity/parameter changes.

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

Eight addresses stand in row, then ten nullifiers slow,
Bloomers widen, roots remember, batches capped to safer tempo,
Small guards rise where inputs meet — concise and tidy, neat.

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 accurately describes the main change—updating default values for trees related to mainnet configurations across multiple files and modules.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.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/chore-update-tree-mainnet-default-values

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.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7deedcd and 6ce68d0.

📒 Files selected for processing (6)
  • program-libs/batched-merkle-tree/src/constants.rs (2 hunks)
  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs (2 hunks)
  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs (2 hunks)
  • programs/account-compression/src/errors.rs (1 hunks)
  • programs/account-compression/src/processor/insert_into_queues.rs (1 hunks)
  • programs/account-compression/src/processor/insert_leaves.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
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/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
program-libs/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in program-libs must not depend on light-test-utils; tests requiring light-test-utils must be located in program-tests/

Files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
🧠 Learnings (63)
📓 Common learnings
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)
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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.
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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.
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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: forester/README.md:0-0
Timestamp: 2025-11-24T17:53:53.971Z
Learning: Applies to forester/src/**/*{transaction,batch}*.rs : Transaction V1 processing should configure `--max-concurrent-sends 50`, `--legacy-ixs-per-tx 1`, `--transaction-max-concurrent-batches 20`, `--cu-limit 1000000`, and `--enable-priority-fees false` by default
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
📚 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/account-compression/src/errors.rs
📚 Learning: 2025-12-07T03:17:42.199Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.199Z
Learning: Applies to program-libs/account-checks/**/error.rs : Define AccountError enum with 16 variants mapped to error codes 12006-12021

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Create wrapper instruction module at `src/account_compression_cpi/new_operation.rs` with `NewOperationContext` struct defining required accounts

Applied to files:

  • programs/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Use error code range 20000-20015 for AccountError variants

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:54.233Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/PACKED_ACCOUNTS.md:0-0
Timestamp: 2025-11-24T17:59:54.233Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/**/*.rs : Provide descriptive names in ProgramPackedAccounts error messages (e.g., 'token_mint' instead of 'account')

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export new wrapper modules in `account_compression_cpi/mod.rs` using `pub mod new_operation;` and `pub use new_operation::*;`, then import in `lib.rs`

Applied to files:

  • programs/account-compression/src/errors.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 : Error types must use numeric codes in the 19xxx range for CToken-specific errors

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Map Pinocchio standard ProgramError variants (InvalidArgument, InvalidInstructionData, InvalidAccountData, AccountDataTooSmall, InsufficientFunds, IncorrectProgramId, MissingRequiredSignature, AccountAlreadyInitialized, UninitializedAccount, NotEnoughAccountKeys, AccountBorrowFailed) to AccountError::PinocchioProgramError with codes 1-11

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-07T18:10:14.595Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.595Z
Learning: Applies to programs/compressed-token/program/programs/compressed-token/anchor/src/lib.rs : Custom error codes must be defined in programs/compressed-token/anchor/src/lib.rs as part of the anchor_compressed_token::ErrorCode enum and returned as ProgramError::Custom(error_code as u32)

Applied to files:

  • programs/account-compression/src/errors.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • programs/account-compression/src/errors.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-06T00:50:17.433Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: DOCS.md:0-0
Timestamp: 2025-12-06T00:50:17.433Z
Learning: Applies to **/docs/*instructions* : Error documentation must use format: `ErrorType::Variant` (error code: N) - Description with actual numeric codes. For standard Solana ProgramError variants use: InvalidInstructionData (3), InvalidAccountData (4), InsufficientFunds (6), MissingRequiredSignature (8), NotEnoughAccountKeys (11), InvalidSeeds (14). For custom errors show u32 value from logs. For external crate errors show directly without wrapping.

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_into_queues.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 : Verify merkle_tree_account data length matches calculated size in `src/initialize_address_tree.rs`. Return error `AccountError::InvalidAccountSize` (error code: 12006) if account data length doesn't match calculated size requirements.

Applied to files:

  • programs/account-compression/src/errors.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`, reject insertions when batch is in `Full` state with error code 14301

Applied to files:

  • programs/account-compression/src/errors.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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Define tree configuration parameters in `InitStateTreeAccountsInstructionData` struct: height (u32, default 32), index (u64), and root_history_capacity (u32, default 200)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Initialize address tree with integrated address queue in `src/initialize_address_tree.rs`. Creates one `BatchedMerkleTreeAccount` with account layout defined in `src/merkle_tree.rs`, metadata in `src/merkle_tree_metadata.rs`, tree type `TreeType::AddressV2` (5), initial root `ADDRESS_TREE_INIT_ROOT_40`, starts at next_index 1, and discriminator `BatchMta` (8 bytes).

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Initialize root history as cyclic buffer with capacity=root_history_capacity and first entry = `ADDRESS_TREE_INIT_ROOT_40` in `src/initialize_address_tree.rs`.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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 : Address trees must initialize with `ADDRESS_TREE_INIT_ROOT_40` (hardcoded for height 40) and start with next_index = 1 (pre-initialized with one element at index 0)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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/**/*.rs : Use constants from constants.rs including ADDRESS_TREE_INIT_ROOT_40 generated from IndexedMerkleTree reference implementation

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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 : Define batch size parameters in `InitStateTreeAccountsInstructionData` struct: input_queue_batch_size (u64, default 15,000), output_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 500), and output_queue_zkp_batch_size (u64, default 500)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 tree_type to `TreeType::AddressV2` (5) and associated_queue to Pubkey::default() for address trees in `src/initialize_address_tree.rs`. Address trees have no separate output queue - the address queue is integrated into the tree account.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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/**/initialize_address_tree.rs : Address tree initialization must create a single Solana account: BatchedMerkleTreeAccount with integrated input queue, initialized with a single leaf: H(0, HIGHEST_ADDRESS_PLUS_ONE)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Validate root_history_capacity is at least equal to (input_queue_batch_size / input_queue_zkp_batch_size) in `src/initialize_address_tree.rs`. This ensures sufficient space for roots generated by address queue operations.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Define rollover and fee parameters: rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 5,000 lamports), additional_bytes (u64, default 20KB + 8 bytes), and close_threshold (Option<u64>, placeholder unimplemented)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Validate that root_history_capacity >= (output_queue_batch_size / output_queue_zkp_batch_size) + (input_queue_batch_size / input_queue_zkp_batch_size) to ensure sufficient space for roots generated by both input and output operations

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that ZKP batch sizes must be 10 or 500 (only supported circuit sizes)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Check `tree_capacity` (2^height) against new insertions to prevent overflow in `BatchedQueueAccount`

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.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 queue insertion must use BatchedQueueAccount::insert_into_current_batch method

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/queue.rs : In `src/queue.rs`, define BatchedQueueAccount layout and implement `mark_as_inserted_in_merkle_tree` method to increment `num_inserted_zkp_batches` and transition batch state to `Inserted` when all ZKP batches are complete

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_address_into_queue`, check tree capacity by calling `check_queue_next_index_reached_tree_capacity()` and ensure `queue_next_index < tree_capacity` before insertion. Return `BatchedMerkleTreeError::TreeIsFull` (error code 14310) if capacity is reached.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.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 : BatchedMerkleTreeAccount must be of type `TreeType::StateV2` when updating tree from output queue

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.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 a state Merkle tree with a `TreeType::StateV2` (4) tree type, storing tree roots, root history, and integrated input queue (bloom filters + hash chains for nullifiers) in the `BatchedMerkleTreeAccount` with discriminator b`BatchMta` [66, 97, 116, 99, 104, 77, 116, 97]

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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/**/initialize_state_tree.rs : State tree initialization must create two Solana accounts: BatchedMerkleTreeAccount with integrated input queue and separate BatchedQueueAccount

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 output queue value vectors (2 vectors, one per batch with capacity = batch_size each) and hash chain stores (2 vectors with capacity = batch_size / zkp_batch_size each)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Define access control parameters: program_owner (Option<Pubkey>), forester (Option<Pubkey>) for non-Light foresters, and owner (Pubkey passed as function parameter)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 output queue with 2 alternating batches, each with batch_size = output_queue_batch_size and zkp_batch_size = output_queue_zkp_batch_size

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-07T03:17:42.199Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.199Z
Learning: Applies to program-libs/account-checks/**/*.rs : Implement account validation with 8-byte discriminators for account type safety

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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`, verify tree type is `TreeType::StateV2` before allowing nullifier insertion; reject address trees

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_address_into_queue`, verify that the tree type is `TreeType::AddressV2` before proceeding with address insertion. Reject state trees with `MerkleTreeMetadataError::InvalidTreeType`.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-07T03:17:42.199Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.199Z
Learning: Applies to program-libs/account-checks/**/packed_accounts.rs : Implement index-based account access in PackedAccounts with bounds-checked retrieval

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-07T18:10:14.595Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.595Z
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/account-compression/src/processor/insert_into_queues.rs
🪛 GitHub Actions: rust
program-libs/batched-merkle-tree/src/initialize_address_tree.rs

[error] 147-147: Bloom filter capacity must be divisible by 8. (initialize_batched_address_tree_params assertion failure)


[error] 147-147: Bloom filter capacity must be divisible by 8. (initialize_root_history_capacity_address_tree assertion failure)


[error] 147-147: Bloom filter capacity must be divisible by 8. (initialize_root_history_capacity_insufficient_address_tree assertion failure)

⏰ 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). (7)
  • GitHub Check: cli-v2
  • 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 (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-ctoke...
  • GitHub Check: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk...
  • GitHub Check: cli-v1
  • GitHub Check: Forester e2e test
🔇 Additional comments (5)
programs/account-compression/src/errors.rs (1)

69-72: LGTM! Clean error variant additions.

The new error variants TooManyAddresses and TooManyNullifiers are well-defined with clear error messages that communicate the 8-element limit per instruction.

programs/account-compression/src/processor/insert_leaves.rs (1)

46-52: LGTM! Proper batch size validation.

The guard correctly enforces the 8-leaf maximum for v2 trees in the OutputQueue processing path. The use of saturating_sub prevents underflow, and the error message helpfully distinguishes v1/v2 behavior.

programs/account-compression/src/processor/insert_into_queues.rs (1)

17-30: LGTM! Proper input validation.

The early validation checks for addresses and nullifiers correctly enforce the 8-element limit before any account construction or processing occurs. The diagnostic logging aids debugging.

program-libs/batched-merkle-tree/src/initialize_state_tree.rs (1)

12-12: LGTM! Good refactoring to use named constants.

Replacing magic numbers with STATE_BLOOM_FILTER_CAPACITY and STATE_BLOOM_FILTER_NUM_HASHES improves code maintainability and makes the configuration more explicit. The state tree defaults remain appropriate for 15k elements.

Also applies to: 51-51, 58-58

program-libs/batched-merkle-tree/src/initialize_address_tree.rs (1)

10-11: LGTM on the refactoring approach, but note issues with underlying constants.

The refactoring to use named constants (ADDRESS_BLOOM_FILTER_CAPACITY, ADDRESS_BLOOM_FILTER_NUM_HASHES, DEFAULT_ADDRESS_BATCH_SIZE, DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN, DEFAULT_BATCH_ADDRESS_TREE_HEIGHT) is good for maintainability.

However, the underlying constant values in constants.rs have critical issues:

  1. ADDRESS_BLOOM_FILTER_CAPACITY = 4_603_051 is not divisible by 8 (see my comment on constants.rs line 30-31)
  2. DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN = 100 is insufficient for batch size 30000 (see my comment on constants.rs line 11)

These issues are causing the pipeline failures. Once the constant values are corrected in constants.rs, this file will work correctly.

Also applies to: 42-47

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (2)
programs/account-compression/src/processor/insert_leaves.rs (1)

36-53: Clarify and align the TooManyLeaves limit between code, log message, and error enum.

The new guard

if end.saturating_sub(start) > 8 {TooManyLeaves }

does enforce a hard cap of 8 leaves per output queue per instruction, which is consistent with the rest of this PR’s “max 8” policy. Two small inconsistencies are worth fixing:

  • The log message says “The maximum for v2 trees is 8. There is no limit for v1 trees.” but this branch doesn’t distinguish v1 vs v2 output queues—it will apply the 8-element limit to any AcpAccount::OutputQueue you pass in.
  • The AccountCompressionErrorCode::TooManyLeaves message still reads “The maximum number of leaves is 255”, which now conflicts with the enforced limit of 8 for this path.

To avoid confusing downstream tooling and error docs, I’d suggest either:

  • Make the limit and messaging fully consistent (e.g. explicitly say “8 for v2 queues” and branch on queue type/version if v1 truly has a different limit), or
  • If v1 queues are no longer relevant here, update the error and log strings to simply say “The maximum is 8 leaves per output queue per instruction.”

That keeps the on-chain behavior and the surfaced error semantics in sync.

programs/account-compression/src/errors.rs (1)

57-72: New TooManyAddresses/TooManyNullifiers errors are fine; consider harmonizing with TooManyLeaves semantics.

Appending TooManyAddresses and TooManyNullifiers at the end of AccountCompressionErrorCode is ABI-safe and the messages clearly express the “8 per instruction” policy used in process_insert_into_queues.

Given insert_leaves now also enforces a max of 8 leaves for v2 output queues, you may want to revisit the existing TooManyLeaves message (“The maximum number of leaves is 255”) so that all three “TooMany*” variants describe limits consistently (or explicitly call out when a limit only applies to certain versions). This will make error docs and client-side handling less confusing.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7deedcd and 6ce68d0.

📒 Files selected for processing (6)
  • program-libs/batched-merkle-tree/src/constants.rs (2 hunks)
  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs (2 hunks)
  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs (2 hunks)
  • programs/account-compression/src/errors.rs (1 hunks)
  • programs/account-compression/src/processor/insert_into_queues.rs (1 hunks)
  • programs/account-compression/src/processor/insert_leaves.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
program-libs/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in program-libs must not depend on light-test-utils; tests requiring light-test-utils must be located in program-tests/

Files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
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/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
🧠 Learnings (67)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Addresses are stored in both bloom filters and hash chains with the same value until the bloom filter is zeroed. The hash chain stores a running Poseidon hash that will be used by batch updates to insert queued addresses into the merkle tree.
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/**/*.rs : Input queues (nullifier queue for state trees, address queue for address trees) must use bloom filters for non-inclusion proofs
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
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/**/*.rs : Bloom filters in input queues must be zeroed after the batch is fully inserted into the tree and the next batch is 50% full to prevent false positives
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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)
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`, when batch state is `Inserted`, verify bloom filter is zeroed before clearing hash chain stores and transitioning to `Fill` state
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 : Bloom filters must be zeroed after a batch is fully inserted and the next batch is 50% full and at least one batch update has occurred since batch completion
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 : Zero out input queue bloom filter when all conditions are met: (1) current batch is ≥50% full (`num_inserted_elements >= batch_size / 2`), (2) current batch NOT in `Inserted` state, (3) previous batch in `Inserted` state, (4) previous batch bloom filter not already zeroed, (5) at least one tree update since batch completion (`batch.sequence_number != current_tree.sequence_number`)
📚 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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Define tree configuration parameters in `InitStateTreeAccountsInstructionData` struct: height (u32, default 32), index (u64), and root_history_capacity (u32, default 200)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 a state Merkle tree with a `TreeType::StateV2` (4) tree type, storing tree roots, root history, and integrated input queue (bloom filters + hash chains for nullifiers) in the `BatchedMerkleTreeAccount` with discriminator b`BatchMta` [66, 97, 116, 99, 104, 77, 116, 97]

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Zero out input queue bloom filter when all conditions are met: (1) current batch is ≥50% full (`num_inserted_elements >= batch_size / 2`), (2) current batch NOT in `Inserted` state, (3) previous batch in `Inserted` state, (4) previous batch bloom filter not already zeroed, (5) at least one tree update since batch completion (`batch.sequence_number != current_tree.sequence_number`)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 tree_capacity = 2^height in output queue metadata

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : Define batch size parameters in `InitStateTreeAccountsInstructionData` struct: input_queue_batch_size (u64, default 15,000), output_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 500), and output_queue_zkp_batch_size (u64, default 500)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Validate that ZKP batch sizes must be 10 or 500 (only supported circuit sizes)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • program-libs/batched-merkle-tree/src/constants.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 output queue value vectors (2 vectors, one per batch with capacity = batch_size each) and hash chain stores (2 vectors with capacity = batch_size / zkp_batch_size each)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
  • programs/account-compression/src/errors.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
  • programs/account-compression/src/processor/insert_into_queues.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 : Define access control parameters: program_owner (Option<Pubkey>), forester (Option<Pubkey>) for non-Light foresters, and owner (Pubkey passed as function parameter)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.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 output queue with 2 alternating batches, each with batch_size = output_queue_batch_size and zkp_batch_size = output_queue_zkp_batch_size

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_state_tree.rs
📚 Learning: 2025-12-07T03:17:42.199Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.199Z
Learning: Applies to program-libs/account-checks/**/error.rs : Define AccountError enum with 16 variants mapped to error codes 12006-12021

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:54.233Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/PACKED_ACCOUNTS.md:0-0
Timestamp: 2025-11-24T17:59:54.233Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/**/*.rs : Provide descriptive names in ProgramPackedAccounts error messages (e.g., 'token_mint' instead of 'account')

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Create wrapper instruction module at `src/account_compression_cpi/new_operation.rs` with `NewOperationContext` struct defining required accounts

Applied to files:

  • programs/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Use error code range 20000-20015 for AccountError variants

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export new wrapper modules in `account_compression_cpi/mod.rs` using `pub mod new_operation;` and `pub use new_operation::*;`, then import in `lib.rs`

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Map Pinocchio standard ProgramError variants (InvalidArgument, InvalidInstructionData, InvalidAccountData, AccountDataTooSmall, InsufficientFunds, IncorrectProgramId, MissingRequiredSignature, AccountAlreadyInitialized, UninitializedAccount, NotEnoughAccountKeys, AccountBorrowFailed) to AccountError::PinocchioProgramError with codes 1-11

Applied to files:

  • programs/account-compression/src/errors.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 : Verify merkle_tree_account data length matches calculated size in `src/initialize_address_tree.rs`. Return error `AccountError::InvalidAccountSize` (error code: 12006) if account data length doesn't match calculated size requirements.

Applied to files:

  • programs/account-compression/src/errors.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 : Error types must use numeric codes in the 19xxx range for CToken-specific errors

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-12-06T00:50:17.433Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: DOCS.md:0-0
Timestamp: 2025-12-06T00:50:17.433Z
Learning: Applies to **/docs/*instructions* : Error documentation must use format: `ErrorType::Variant` (error code: N) - Description with actual numeric codes. For standard Solana ProgramError variants use: InvalidInstructionData (3), InvalidAccountData (4), InsufficientFunds (6), MissingRequiredSignature (8), NotEnoughAccountKeys (11), InvalidSeeds (14). For custom errors show u32 value from logs. For external crate errors show directly without wrapping.

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_into_queues.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`, reject insertions when batch is in `Full` state with error code 14301

Applied to files:

  • programs/account-compression/src/errors.rs
  • programs/account-compression/src/processor/insert_into_queues.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/**/*.rs : Use constants from constants.rs including ADDRESS_TREE_INIT_ROOT_40 generated from IndexedMerkleTree reference implementation

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Initialize root history as cyclic buffer with capacity=root_history_capacity and first entry = `ADDRESS_TREE_INIT_ROOT_40` in `src/initialize_address_tree.rs`.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Address trees must initialize with `ADDRESS_TREE_INIT_ROOT_40` (hardcoded for height 40) and start with next_index = 1 (pre-initialized with one element at index 0)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Validate root_history_capacity is at least equal to (input_queue_batch_size / input_queue_zkp_batch_size) in `src/initialize_address_tree.rs`. This ensures sufficient space for roots generated by address queue operations.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Validate that root_history_capacity >= (output_queue_batch_size / output_queue_zkp_batch_size) + (input_queue_batch_size / input_queue_zkp_batch_size) to ensure sufficient space for roots generated by both input and output operations

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Initialize address tree with integrated address queue in `src/initialize_address_tree.rs`. Creates one `BatchedMerkleTreeAccount` with account layout defined in `src/merkle_tree.rs`, metadata in `src/merkle_tree_metadata.rs`, tree type `TreeType::AddressV2` (5), initial root `ADDRESS_TREE_INIT_ROOT_40`, starts at next_index 1, and discriminator `BatchMta` (8 bytes).

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 tree_type to `TreeType::AddressV2` (5) and associated_queue to Pubkey::default() for address trees in `src/initialize_address_tree.rs`. Address trees have no separate output queue - the address queue is integrated into the tree account.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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/**/initialize_address_tree.rs : Address tree initialization must create a single Solana account: BatchedMerkleTreeAccount with integrated input queue, initialized with a single leaf: H(0, HIGHEST_ADDRESS_PLUS_ONE)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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 : Define rollover and fee parameters: rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 5,000 lamports), additional_bytes (u64, default 20KB + 8 bytes), and close_threshold (Option<u64>, placeholder unimplemented)

Applied to files:

  • program-libs/batched-merkle-tree/src/initialize_address_tree.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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 : Check `tree_capacity` (2^height) against new insertions to prevent overflow in `BatchedQueueAccount`

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In src/merkle_tree.rs, implement BatchedMerkleTreeAccount::update_tree_from_address_queue method for batch address append operations on AddressV2 trees. The method must verify ZKP proving correctness of: old_root + queue addresses → new_root using indexed Merkle tree insertion, update tree root, increment tree sequence_number, increment tree next_index by zkp_batch_size, mark ZKP batch as inserted, transition batch state to Inserted when all ZKP batches complete, and zero out bloom filter when current batch is 50% inserted.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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 queue insertion must use BatchedQueueAccount::insert_into_current_batch method

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/queue.rs : In `src/queue.rs`, define BatchedQueueAccount layout and implement `mark_as_inserted_in_merkle_tree` method to increment `num_inserted_zkp_batches` and transition batch state to `Inserted` when all ZKP batches are complete

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : After inserting an address into the batch, check if `num_inserted_elements == batch_size`. If true, transition batch state from `Fill` to `Full`, increment `currently_processing_batch_index` to switch to the other batch, and update `pending_batch_index` to mark this batch ready for tree update.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.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 : BatchedMerkleTreeAccount must be of type `TreeType::StateV2` when updating tree from output queue

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_address_into_queue`, check tree capacity by calling `check_queue_next_index_reached_tree_capacity()` and ensure `queue_next_index < tree_capacity` before insertion. Return `BatchedMerkleTreeError::TreeIsFull` (error code 14310) if capacity is reached.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_into_queues.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`, verify tree type is `TreeType::StateV2` before allowing nullifier insertion; reject address trees

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_into_queues.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`, increment `nullifier_next_index` after each insertion to provide sequence number for indexers

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/**/merkle_tree.rs : State tree nullifier insertion must use the BatchedMerkleTreeAccount::insert_nullifier_into_queue method

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Always increment `queue_next_index` by 1 after successfully inserting an address. This value serves as a sequence number for indexers to track address insertion order.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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`, transition batch state from `Fill` to `Full` when `num_inserted_elements == batch_size`, and switch `currently_processing_batch_index` to the other batch

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/**/merkle_tree.rs : Address tree address insertion must use the BatchedMerkleTreeAccount::insert_address_into_queue method

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-07T18:10:14.595Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.595Z
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/account-compression/src/processor/insert_into_queues.rs
🧬 Code graph analysis (1)
programs/account-compression/src/processor/insert_into_queues.rs (2)
program-libs/indexed-merkle-tree/src/array.rs (1)
  • len (164-166)
program-libs/hash-set/src/lib.rs (1)
  • nullifiers (1018-1018)
🪛 GitHub Actions: rust
program-libs/batched-merkle-tree/src/initialize_address_tree.rs

[error] 147-147: initialize_address_tree::test_validate_batched_address_tree_params: Bloom filter capacity must be divisible by 8. left: 3, right: 0.


[error] 147-147: initialize_address_tree::test_validate_root_history_capacity_address_tree: Bloom filter capacity must be divisible by 8. left: 3, right: 0.


[error] 147-147: initialize_address_tree::test_validate_root_history_capacity_insufficient_address_tree: Bloom filter capacity must be divisible by 8. left: 3, right: 0.

⏰ 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). (1)
  • GitHub Check: Forester e2e test
🔇 Additional comments (2)
program-libs/batched-merkle-tree/src/initialize_state_tree.rs (1)

10-13: Centralizing state-tree bloom filter parameters on constants looks correct.

Swapping bloom_filter_num_iters and bloom_filter_capacity over to STATE_BLOOM_FILTER_NUM_HASHES and STATE_BLOOM_FILTER_CAPACITY keeps the defaults consistent with validate_batched_tree_params (capacity ≥ batch_size * 8 and divisible by 8) and mirrors the address-tree changes. Test-only configs still use the “3 hashes / 20k * 8” pattern from the docs for non-production.

Also applies to: 51-59

programs/account-compression/src/processor/insert_into_queues.rs (1)

17-30: The new per-instruction caps on addresses/nullifiers are correctly implemented; error codes exist and guards are properly positioned.

The early guards on inputs.addresses.len() > 8 and inputs.nullifiers.len() > 8 with TooManyAddresses and TooManyNullifiers errors are clean, properly defined in errors.rs, and execute before any account processing. This is a straightforward runtime enforcement of the max-8 policy.

All CPI callers in programs/system/src/processor/ cast their counts to u8 before constructing the instruction data, but the new guard remains the only enforcement point for the 8-item limit. Ensure off-chain builders and system program integrations respect this cap by splitting larger batches across multiple instructions.

@ananas-block ananas-block force-pushed the jorrit/chore-update-tree-mainnet-default-values branch from f70becc to 95e98e6 Compare December 8, 2025 22:19
@ananas-block ananas-block force-pushed the jorrit/chore-update-tree-mainnet-default-values branch from 95e98e6 to 855c0ac Compare December 8, 2025 22:25
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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ce68d0 and 855c0ac.

⛔ Files ignored due to path filters (4)
  • js/compressed-token/tests/e2e/compress.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/mint-to.test.ts is excluded by none and included by none
  • program-tests/compressed-token-test/tests/mint/random.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/v1.rs is excluded by none and included by none
📒 Files selected for processing (1)
  • program-libs/batched-merkle-tree/src/constants.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
program-libs/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in program-libs must not depend on light-test-utils; tests requiring light-test-utils must be located in program-tests/

Files:

  • program-libs/batched-merkle-tree/src/constants.rs
🧠 Learnings (22)
📓 Common learnings
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.
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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.
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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.
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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8
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 : Address trees must initialize with `ADDRESS_TREE_INIT_ROOT_40` (hardcoded for height 40) and start with next_index = 1 (pre-initialized with one element at index 0)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch nullify operations must check that tree type is TreeType::StateV2 before processing, verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.
📚 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/**/*.rs : Use constants from constants.rs including ADDRESS_TREE_INIT_ROOT_40 generated from IndexedMerkleTree reference implementation

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Initialize root history as cyclic buffer with capacity=root_history_capacity and first entry = `ADDRESS_TREE_INIT_ROOT_40` in `src/initialize_address_tree.rs`.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Address trees must initialize with `ADDRESS_TREE_INIT_ROOT_40` (hardcoded for height 40) and start with next_index = 1 (pre-initialized with one element at index 0)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate root_history_capacity is at least equal to (input_queue_batch_size / input_queue_zkp_batch_size) in `src/initialize_address_tree.rs`. This ensures sufficient space for roots generated by address queue operations.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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:

  • program-libs/batched-merkle-tree/src/constants.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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that root_history_capacity >= (output_queue_batch_size / output_queue_zkp_batch_size) + (input_queue_batch_size / input_queue_zkp_batch_size) to ensure sufficient space for roots generated by both input and output operations

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In src/merkle_tree.rs, implement BatchedMerkleTreeAccount::update_tree_from_address_queue method for batch address append operations on AddressV2 trees. The method must verify ZKP proving correctness of: old_root + queue addresses → new_root using indexed Merkle tree insertion, update tree root, increment tree sequence_number, increment tree next_index by zkp_batch_size, mark ZKP batch as inserted, transition batch state to Inserted when all ZKP batches complete, and zero out bloom filter when current batch is 50% inserted.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Verify tree capacity constraint before tree update: `tree.next_index + zkp_batch_size <= tree_capacity`; error with `TreeIsFull` (14310) if violated

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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/**/{merkle_tree,merkle_tree_metadata}.rs : Trees must maintain a cyclic buffer of recent roots (default: 200) enabling validity proofs for recently spent compressed accounts

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Tree height must be fixed at 40 for address trees in `src/initialize_address_tree.rs`. Validate that height equals 40.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define batch size parameters in `InitStateTreeAccountsInstructionData` struct: input_queue_batch_size (u64, default 15,000), output_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 500), and output_queue_zkp_batch_size (u64, default 500)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define tree configuration parameters in `InitStateTreeAccountsInstructionData` struct: height (u32, default 32), index (u64), and root_history_capacity (u32, default 200)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that ZKP batch sizes must be 10 or 500 (only supported circuit sizes)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
⏰ 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). (1)
  • GitHub Check: Test batched-merkle-tree-simulate
🔇 Additional comments (3)
program-libs/batched-merkle-tree/src/constants.rs (3)

19-24: Address batch size doubled to 30k; related constants remain internally consistent

With DEFAULT_ADDRESS_BATCH_SIZE: u64 = 30000 and DEFAULT_ADDRESS_ZKP_BATCH_SIZE: u64 = 250, we now have 120 ZKP batches per full address batch, and DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN was set to 120, so the root_history_capacity >= batch_size / zkp_batch_size invariant for address trees is satisfied by construction. This also keeps the bloom-filter constraint intact because the new ADDRESS_BLOOM_FILTER_CAPACITY is still orders of magnitude larger than batch_size * 8.

From a constants/invariants perspective this looks solid and much easier to reason about than the previous mismatch.

Based on learnings, this keeps the initialize_address_tree validation for root-history and bloom filter sizing satisfied for the new address defaults.


26-29: Clarified state bloom-filter comment aligns with validation rules

The updated comment explicitly tying STATE_BLOOM_FILTER_CAPACITY to a 1.0E-12 false-positive rate for 15k elements is useful context. The value 2_301_536 is divisible by 8 and comfortably larger than DEFAULT_BATCH_SIZE * 8, so it continues to satisfy the “capacity divisible by 8 and >= batch_size * 8” requirement enforced during state-tree initialization.

No changes needed here; the comment now better documents the design choice.

Based on learnings, this respects the bloom-filter capacity constraints for state trees.


30-32: Address bloom-filter capacity now respects the divisibility and sizing invariants

ADDRESS_BLOOM_FILTER_CAPACITY: u64 = 4_603_056 is:

  • Divisible by 8 (4_603_056 / 8 = 575_382), so it won’t trip the bloom_filter_capacity % 8 == 0 check.
  • Far above DEFAULT_ADDRESS_BATCH_SIZE * 8 (30000 * 8 = 240_000), so the capacity >= batch_size * 8 requirement is also satisfied.
  • Consistent with the comment stating a 1.0E-12 false positive probability for 30k elements.

This fixes the earlier issue where the address bloom-filter capacity failed the divisibility-by-8 validation while keeping the intended false-positive profile.

Based on learnings, this brings the address bloom-filter config back into alignment with the initialize_address_tree invariants.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
program-libs/batched-merkle-tree/src/constants.rs (1)

11-12: Address defaults now match documented invariants; consider deriving them formulaically.

The new address constants line up with the tree/docs constraints:

  • DEFAULT_ADDRESS_BATCH_SIZE = 30000 and DEFAULT_ADDRESS_ZKP_BATCH_SIZE = 25030000 / 250 = 120, so DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN = 120 exactly meets the root_history_capacity >= input_queue_batch_size / input_queue_zkp_batch_size requirement for address trees.
  • ADDRESS_BLOOM_FILTER_CAPACITY = 4_603_072 is 2 × STATE_BLOOM_FILTER_CAPACITY and divisible by 8, and it comfortably satisfies capacity >= batch_size * 8 for 30k elements.

That fixes the earlier mismatch between defaults and the initialize_address_tree validations.

To keep these from drifting in future tweaks, you might consider expressing them in terms of the other constants, e.g.:

pub const DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN: u32 =
    (DEFAULT_ADDRESS_BATCH_SIZE / DEFAULT_ADDRESS_ZKP_BATCH_SIZE) as u32;

pub const ADDRESS_BLOOM_FILTER_CAPACITY: u64 = 2 * STATE_BLOOM_FILTER_CAPACITY;

Even if you keep the literals, the current values look correct and consistent with the learned docs.

Also applies to: 21-22, 26-31

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 855c0ac and 8acd42d.

📒 Files selected for processing (3)
  • program-libs/batched-merkle-tree/src/constants.rs (2 hunks)
  • programs/account-compression/src/processor/insert_into_queues.rs (1 hunks)
  • programs/account-compression/src/processor/insert_leaves.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
program-libs/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in program-libs must not depend on light-test-utils; tests requiring light-test-utils must be located in program-tests/

Files:

  • program-libs/batched-merkle-tree/src/constants.rs
🧠 Learnings (46)
📓 Common learnings
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)
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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.
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/**/*.rs : Input queues (nullifier queue for state trees, address queue for address trees) must use bloom filters for non-inclusion proofs
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 : Zero out input queue bloom filter when all conditions are met: (1) current batch is ≥50% full (`num_inserted_elements >= batch_size / 2`), (2) current batch NOT in `Inserted` state, (3) previous batch in `Inserted` state, (4) previous batch bloom filter not already zeroed, (5) at least one tree update since batch completion (`batch.sequence_number != current_tree.sequence_number`)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.
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/**/*.rs : Bloom filters in input queues must be zeroed after the batch is fully inserted into the tree and the next batch is 50% full to prevent false positives
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`, when batch state is `Inserted`, verify bloom filter is zeroed before clearing hash chain stores and transitioning to `Fill` state
📚 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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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 : Check `tree_capacity` (2^height) against new insertions to prevent overflow in `BatchedQueueAccount`

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.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 queue insertion must use BatchedQueueAccount::insert_into_current_batch method

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/queue.rs : In `src/queue.rs`, define BatchedQueueAccount layout and implement `mark_as_inserted_in_merkle_tree` method to increment `num_inserted_zkp_batches` and transition batch state to `Inserted` when all ZKP batches are complete

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In src/merkle_tree.rs, implement BatchedMerkleTreeAccount::update_tree_from_address_queue method for batch address append operations on AddressV2 trees. The method must verify ZKP proving correctness of: old_root + queue addresses → new_root using indexed Merkle tree insertion, update tree root, increment tree sequence_number, increment tree next_index by zkp_batch_size, mark ZKP batch as inserted, transition batch state to Inserted when all ZKP batches complete, and zero out bloom filter when current batch is 50% inserted.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • program-libs/batched-merkle-tree/src/constants.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.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 : BatchedMerkleTreeAccount must be of type `TreeType::StateV2` when updating tree from output queue

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_address_into_queue`, check tree capacity by calling `check_queue_next_index_reached_tree_capacity()` and ensure `queue_next_index < tree_capacity` before insertion. Return `BatchedMerkleTreeError::TreeIsFull` (error code 14310) if capacity is reached.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/**/*.rs : Use constants from constants.rs including ADDRESS_TREE_INIT_ROOT_40 generated from IndexedMerkleTree reference implementation

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • programs/account-compression/src/processor/insert_into_queues.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 : Address trees must initialize with `ADDRESS_TREE_INIT_ROOT_40` (hardcoded for height 40) and start with next_index = 1 (pre-initialized with one element at index 0)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Initialize root history as cyclic buffer with capacity=root_history_capacity and first entry = `ADDRESS_TREE_INIT_ROOT_40` in `src/initialize_address_tree.rs`.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate root_history_capacity is at least equal to (input_queue_batch_size / input_queue_zkp_batch_size) in `src/initialize_address_tree.rs`. This ensures sufficient space for roots generated by address queue operations.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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:

  • program-libs/batched-merkle-tree/src/constants.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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define batch size parameters in `InitStateTreeAccountsInstructionData` struct: input_queue_batch_size (u64, default 15,000), output_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 500), and output_queue_zkp_batch_size (u64, default 500)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that root_history_capacity >= (output_queue_batch_size / output_queue_zkp_batch_size) + (input_queue_batch_size / input_queue_zkp_batch_size) to ensure sufficient space for roots generated by both input and output operations

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
  • programs/account-compression/src/processor/insert_into_queues.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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Verify tree capacity constraint before tree update: `tree.next_index + zkp_batch_size <= tree_capacity`; error with `TreeIsFull` (14310) if violated

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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/**/{merkle_tree,merkle_tree_metadata}.rs : Trees must maintain a cyclic buffer of recent roots (default: 200) enabling validity proofs for recently spent compressed accounts

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Tree height must be fixed at 40 for address trees in `src/initialize_address_tree.rs`. Validate that height equals 40.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : When all ZKP batches of a batch are inserted, set batch `sequence_number = tree_sequence_number + root_history_capacity` (threshold when root at root_index is overwritten) and set `root_index` to identify root that must not exist when bloom filter is zeroed

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define tree configuration parameters in `InitStateTreeAccountsInstructionData` struct: height (u32, default 32), index (u64), and root_history_capacity (u32, default 200)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that ZKP batch sizes must be 10 or 500 (only supported circuit sizes)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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`, verify tree type is `TreeType::StateV2` before allowing nullifier insertion; reject address trees

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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`, increment `nullifier_next_index` after each insertion to provide sequence number for indexers

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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`, reject insertions when batch is in `Full` state with error code 14301

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Always increment `queue_next_index` by 1 after successfully inserting an address. This value serves as a sequence number for indexers to track address insertion order.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/**/merkle_tree.rs : State tree nullifier insertion must use the BatchedMerkleTreeAccount::insert_nullifier_into_queue method

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_address_into_queue`, verify that the tree type is `TreeType::AddressV2` before proceeding with address insertion. Reject state trees with `MerkleTreeMetadataError::InvalidTreeType`.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Create wrapper instruction module at `src/account_compression_cpi/new_operation.rs` with `NewOperationContext` struct defining required accounts

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_into_queues.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 : Verify merkle_tree_account data length matches calculated size in `src/initialize_address_tree.rs`. Return error `AccountError::InvalidAccountSize` (error code: 12006) if account data length doesn't match calculated size requirements.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
⏰ 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). (8)
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: stateless-js-v2
  • GitHub Check: Forester e2e test
  • 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...

@ananas-block ananas-block force-pushed the jorrit/chore-update-tree-mainnet-default-values branch from 8acd42d to 8f5e48b Compare December 8, 2025 23:34
@ananas-block ananas-block force-pushed the jorrit/chore-update-tree-mainnet-default-values branch from 8f5e48b to 6fbef70 Compare December 8, 2025 23:36
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: 3

♻️ Duplicate comments (2)
programs/account-compression/src/processor/insert_into_queues.rs (1)

24-30: Resolve the nullifier limit inconsistency (10 vs 8).

This validation has a consistency issue that was already flagged in a previous review: the code enforces a limit of 10 nullifiers, but the TooManyNullifiers error variant message reportedly states "The maximum is 8 per instruction." Please align the enforced limit, the msg! string, and the error variant's message to use the same value.

programs/account-compression/src/processor/insert_leaves.rs (1)

46-52: Clarify or remove the v1 reference in the error message.

The message now correctly states "10" (good!), which addresses part of the earlier review concern. However, the claim "There is no limit for v1 trees" remains problematic:

  • This guard applies to all AcpAccount::OutputQueue variants without any version check.
  • If v1 output queues can reach this code path, they ARE subject to the 10-leaf limit, making the message incorrect.
  • If v1 output queues cannot reach this code path, the v1 reference is confusing noise.

Either add an explicit version check to allow unlimited leaves for v1 (if that's the intended behavior), or remove the v1 reference entirely from the message.

Based on past review comments, which correctly identified the inconsistency.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8acd42d and 6fbef70.

⛔ Files ignored due to path filters (1)
  • program-tests/system-cpi-v2-test/tests/invoke_cpi_with_read_only.rs is excluded by none and included by none
📒 Files selected for processing (3)
  • program-libs/batched-merkle-tree/src/constants.rs (2 hunks)
  • programs/account-compression/src/processor/insert_into_queues.rs (1 hunks)
  • programs/account-compression/src/processor/insert_leaves.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
program-libs/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in program-libs must not depend on light-test-utils; tests requiring light-test-utils must be located in program-tests/

Files:

  • program-libs/batched-merkle-tree/src/constants.rs
🧠 Learnings (54)
📓 Common learnings
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)
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/**/*.rs : Input queues (nullifier queue for state trees, address queue for address trees) must use bloom filters for non-inclusion proofs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.
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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.
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 : Zero out input queue bloom filter when all conditions are met: (1) current batch is ≥50% full (`num_inserted_elements >= batch_size / 2`), (2) current batch NOT in `Inserted` state, (3) previous batch in `Inserted` state, (4) previous batch bloom filter not already zeroed, (5) at least one tree update since batch completion (`batch.sequence_number != current_tree.sequence_number`)
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/**/*.rs : Bloom filters in input queues must be zeroed after the batch is fully inserted into the tree and the next batch is 50% full to prevent false positives
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`, when batch state is `Inserted`, verify bloom filter is zeroed before clearing hash chain stores and transitioning to `Fill` state
📚 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 : Check `tree_capacity` (2^height) against new insertions to prevent overflow in `BatchedQueueAccount`

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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 queue insertion must use BatchedQueueAccount::insert_into_current_batch method

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/queue.rs : In `src/queue.rs`, define BatchedQueueAccount layout and implement `mark_as_inserted_in_merkle_tree` method to increment `num_inserted_zkp_batches` and transition batch state to `Inserted` when all ZKP batches are complete

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : After inserting an address into the batch, check if `num_inserted_elements == batch_size`. If true, transition batch state from `Fill` to `Full`, increment `currently_processing_batch_index` to switch to the other batch, and update `pending_batch_index` to mark this batch ready for tree update.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_address_into_queue`, check tree capacity by calling `check_queue_next_index_reached_tree_capacity()` and ensure `queue_next_index < tree_capacity` before insertion. Return `BatchedMerkleTreeError::TreeIsFull` (error code 14310) if capacity is reached.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.rs
  • program-libs/batched-merkle-tree/src/constants.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 : Verify tree capacity constraint before tree update: `tree.next_index + zkp_batch_size <= tree_capacity`; error with `TreeIsFull` (14310) if violated

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • program-libs/batched-merkle-tree/src/constants.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/**/{merkle_tree,merkle_tree_metadata}.rs : Trees must maintain a cyclic buffer of recent roots (default: 200) enabling validity proofs for recently spent compressed accounts

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • program-libs/batched-merkle-tree/src/constants.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`, verify tree type is `TreeType::StateV2` before allowing nullifier insertion; reject address trees

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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 tree_capacity = 2^height in output queue metadata

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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 : Tree height must be fixed at 40 for address trees in `src/initialize_address_tree.rs`. Validate that height equals 40.

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.rs
  • program-libs/batched-merkle-tree/src/constants.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 : BatchedMerkleTreeAccount must be of type `TreeType::StateV2` when updating tree from output queue

Applied to files:

  • programs/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_leaves.rs
  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_leaves.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/account-compression/src/processor/insert_into_queues.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`, increment `nullifier_next_index` after each insertion to provide sequence number for indexers

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Always increment `queue_next_index` by 1 after successfully inserting an address. This value serves as a sequence number for indexers to track address insertion order.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/**/merkle_tree.rs : State tree nullifier insertion must use the BatchedMerkleTreeAccount::insert_nullifier_into_queue method

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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`, reject insertions when batch is in `Full` state with error code 14301

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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`, transition batch state from `Fill` to `Full` when `num_inserted_elements == batch_size`, and switch `currently_processing_batch_index` to the other batch

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In `BatchedMerkleTreeAccount::insert_address_into_queue`, verify that the tree type is `TreeType::AddressV2` before proceeding with address insertion. Reject state trees with `MerkleTreeMetadataError::InvalidTreeType`.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T17:59:54.233Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/PACKED_ACCOUNTS.md:0-0
Timestamp: 2025-11-24T17:59:54.233Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/**/*.rs : Provide descriptive names in ProgramPackedAccounts error messages (e.g., 'token_mint' instead of 'account')

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-07T03:17:42.199Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.199Z
Learning: Applies to program-libs/account-checks/**/*.rs : Implement account validation with 8-byte discriminators for account type safety

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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`, update hash chain store with Poseidon hash: `Poseidon(prev_hash_chain, nullifier)`

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-12-07T18:09:57.230Z
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.230Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : CompressibleConfig account size must be exactly 256 bytes including the 8-byte discriminator to maintain compatibility with Light Protocol Solana programs

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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 : The discriminator must be exactly 8 bytes in length (DISCRIMINATOR_LEN constant)

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/account-compression/src/processor/insert_into_queues.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Create wrapper instruction module at `src/account_compression_cpi/new_operation.rs` with `NewOperationContext` struct defining required accounts

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.rs
  • program-libs/batched-merkle-tree/src/constants.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/account-compression/src/processor/insert_into_queues.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 : Verify merkle_tree_account data length matches calculated size in `src/initialize_address_tree.rs`. Return error `AccountError::InvalidAccountSize` (error code: 12006) if account data length doesn't match calculated size requirements.

Applied to files:

  • programs/account-compression/src/processor/insert_into_queues.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/**/*.rs : Use constants from constants.rs including ADDRESS_TREE_INIT_ROOT_40 generated from IndexedMerkleTree reference implementation

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Initialize root history as cyclic buffer with capacity=root_history_capacity and first entry = `ADDRESS_TREE_INIT_ROOT_40` in `src/initialize_address_tree.rs`.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Address trees must initialize with `ADDRESS_TREE_INIT_ROOT_40` (hardcoded for height 40) and start with next_index = 1 (pre-initialized with one element at index 0)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate root_history_capacity is at least equal to (input_queue_batch_size / input_queue_zkp_batch_size) in `src/initialize_address_tree.rs`. This ensures sufficient space for roots generated by address queue operations.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define batch size parameters in `InitStateTreeAccountsInstructionData` struct: input_queue_batch_size (u64, default 15,000), output_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 500), and output_queue_zkp_batch_size (u64, default 500)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Define tree configuration parameters in `InitStateTreeAccountsInstructionData` struct: height (u32, default 32), index (u64), and root_history_capacity (u32, default 200)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that root_history_capacity >= (output_queue_batch_size / output_queue_zkp_batch_size) + (input_queue_batch_size / input_queue_zkp_batch_size) to ensure sufficient space for roots generated by both input and output operations

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
📚 Learning: 2025-11-24T17:58:10.392Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : In src/merkle_tree.rs, implement BatchedMerkleTreeAccount::update_tree_from_address_queue method for batch address append operations on AddressV2 trees. The method must verify ZKP proving correctness of: old_root + queue addresses → new_root using indexed Merkle tree insertion, update tree root, increment tree sequence_number, increment tree next_index by zkp_batch_size, mark ZKP batch as inserted, transition batch state to Inserted when all ZKP batches complete, and zero out bloom filter when current batch is 50% inserted.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
📚 Learning: 2025-11-24T17:57:02.558Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : When all ZKP batches of a batch are inserted, set batch `sequence_number = tree_sequence_number + root_history_capacity` (threshold when root at root_index is overwritten) and set `root_index` to identify root that must not exist when bloom filter is zeroed

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.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 : Validate that ZKP batch sizes must be 10 or 500 (only supported circuit sizes)

Applied to files:

  • program-libs/batched-merkle-tree/src/constants.rs
⏰ 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). (1)
  • GitHub Check: Test batched-merkle-tree-simulate
🔇 Additional comments (3)
programs/account-compression/src/processor/insert_leaves.rs (1)

40-41: The u8 limits for batch and total leaf counts are intentional design constraints.

The codebase explicitly defines a 255-leaf maximum via the TooManyLeaves error message ("The maximum number of leaves is 255"), confirming that using u8 for batch_size (line 40) and leaves_processed (line 41) is an intentional protocol-level constraint. The per-batch limit of 10 leaves (enforced at line 46) combined with the overall 255-leaf limit ensures the comparison at line 77 remains valid.

program-libs/batched-merkle-tree/src/constants.rs (2)

11-11: Address root-history default correctly matches ZKP batch geometry

DEFAULT_ADDRESS_BATCH_ROOT_HISTORY_LEN = 120 exactly equals DEFAULT_ADDRESS_BATCH_SIZE / DEFAULT_ADDRESS_ZKP_BATCH_SIZE = 30000 / 250, so the invariant root_history_capacity >= input_queue_batch_size / input_queue_zkp_batch_size is satisfied by construction for mainnet defaults.

Based on learnings, this aligns with the initialize_address_tree.rs validation requirements.


30-31: Address bloom-filter capacity now satisfies divisibility and capacity invariants

ADDRESS_BLOOM_FILTER_CAPACITY = 4_603_072 (2 × STATE_BLOOM_FILTER_CAPACITY) preserves the bits-per-element ratio for the larger 30k address batch, so the ~1e-12 false-positive rate is maintained, while also ensuring:

  • ADDRESS_BLOOM_FILTER_CAPACITY % 8 == 0, and
  • ADDRESS_BLOOM_FILTER_CAPACITY >= DEFAULT_ADDRESS_BATCH_SIZE * 8.

This lines up with the validations in initialize_address_tree.rs and the documented bloom-filter requirements for address queues.

Based on learnings, this keeps the address input-queue bloom filters consistent with the required invariants.

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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fbef70 and 288251c.

⛔ Files ignored due to path filters (2)
  • program-tests/account-compression-test/tests/address_merkle_tree_tests.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/functional.rs is excluded by none and included by none
📒 Files selected for processing (1)
  • programs/account-compression/src/errors.rs (2 hunks)
🧰 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/account-compression/src/errors.rs
🧠 Learnings (18)
📓 Common learnings
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.
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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.
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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)
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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8
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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).
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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.
📚 Learning: 2025-11-24T17:59:54.233Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/PACKED_ACCOUNTS.md:0-0
Timestamp: 2025-11-24T17:59:54.233Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/**/*.rs : Provide descriptive names in ProgramPackedAccounts error messages (e.g., 'token_mint' instead of 'account')

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-12-07T03:17:42.199Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:42.199Z
Learning: Applies to program-libs/account-checks/**/error.rs : Define AccountError enum with 16 variants mapped to error codes 12006-12021

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.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 : Verify merkle_tree_account data length matches calculated size in `src/initialize_address_tree.rs`. Return error `AccountError::InvalidAccountSize` (error code: 12006) if account data length doesn't match calculated size requirements.

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Use error code range 20000-20015 for AccountError variants

Applied to files:

  • programs/account-compression/src/errors.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • programs/account-compression/src/errors.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 : Error types must use numeric codes in the 19xxx range for CToken-specific errors

Applied to files:

  • programs/account-compression/src/errors.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 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)

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.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 `MerkleTreeMetadataError::InvalidRolloverThreshold` when rollover threshold value is invalid (must be percentage)

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Map Pinocchio standard ProgramError variants (InvalidArgument, InvalidInstructionData, InvalidAccountData, AccountDataTooSmall, InsufficientFunds, IncorrectProgramId, MissingRequiredSignature, AccountAlreadyInitialized, UninitializedAccount, NotEnoughAccountKeys, AccountBorrowFailed) to AccountError::PinocchioProgramError with codes 1-11

Applied to files:

  • programs/account-compression/src/errors.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`, reject insertions when batch is in `Full` state with error code 14301

Applied to files:

  • programs/account-compression/src/errors.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 : PropagateHasher errors from light-hasher module with 7xxx code range in error handling

Applied to files:

  • programs/account-compression/src/errors.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/**/*.rs : Error handling must use BatchedMerkleTreeError enum from errors.rs with u32 error codes in the 14301-14312 range

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-12-06T00:50:17.433Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: DOCS.md:0-0
Timestamp: 2025-12-06T00:50:17.433Z
Learning: Applies to **/docs/*instructions* : Error documentation must use format: `ErrorType::Variant` (error code: N) - Description with actual numeric codes. For standard Solana ProgramError variants use: InvalidInstructionData (3), InvalidAccountData (4), InsufficientFunds (6), MissingRequiredSignature (8), NotEnoughAccountKeys (11), InvalidSeeds (14). For custom errors show u32 value from logs. For external crate errors show directly without wrapping.

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-12-07T18:10:14.595Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-12-07T18:10:14.595Z
Learning: Applies to programs/compressed-token/program/src/mint_action/*.rs : MintAction instruction (discriminator: 103) must support 9 action types: CreateCompressedMint, MintTo, UpdateMintAuthority, UpdateFreezeAuthority, CreateSplMint, MintToCToken, UpdateMetadataField, UpdateMetadataAuthority, RemoveMetadataKey

Applied to files:

  • programs/account-compression/src/errors.rs
⏰ 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). (10)
  • GitHub Check: Forester e2e test
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test program-libs-fast
  • GitHub Check: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk...
  • 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 (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-and-e2e, ["cargo test -p light-compressed-token", "cargo-test-sbf -p c...
🔇 Additional comments (1)
programs/account-compression/src/errors.rs (1)

69-72: New TooManyAddresses / TooManyNullifiers variants align with per-instruction limits

These variants and messages line up well with the new caps (8 addresses, 10 nullifiers per instruction) and make the failure mode explicit.

Two follow-ups to keep things in sync over time:

  • Ensure the validation logic uses shared constants for these limits, and that those constants match the values in the messages, so future limit changes don’t leave stale text.
  • Update the error documentation tables to include AccountCompressionErrorCode::TooManyAddresses and AccountCompressionErrorCode::TooManyNullifiers with their numeric codes in the ErrorType::Variant (error code: N) - Description format. Based on learnings, this keeps DOCS.md-style error docs consistent.

@ananas-block ananas-block force-pushed the jorrit/chore-update-tree-mainnet-default-values branch from 288251c to 5fea716 Compare December 9, 2025 17:50
@ananas-block ananas-block force-pushed the jorrit/chore-update-tree-mainnet-default-values branch from 704f863 to 52b0a74 Compare December 10, 2025 16:13
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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 288251c and 52b0a74.

⛔ Files ignored due to path filters (4)
  • js/compressed-token/tests/e2e/compress.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/mint-to.test.ts is excluded by none and included by none
  • program-tests/account-compression-test/tests/address_merkle_tree_tests.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/functional.rs is excluded by none and included by none
📒 Files selected for processing (1)
  • programs/account-compression/src/errors.rs (2 hunks)
🧰 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/account-compression/src/errors.rs
🧠 Learnings (22)
📓 Common learnings
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.
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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.
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 : Validate that bloom filter capacity must be divisible by 8 and must be >= batch_size * 8
📚 Learning: 2025-11-24T17:59:54.233Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/PACKED_ACCOUNTS.md:0-0
Timestamp: 2025-11-24T17:59:54.233Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/**/*.rs : Provide descriptive names in ProgramPackedAccounts error messages (e.g., 'token_mint' instead of 'account')

Applied to files:

  • programs/account-compression/src/errors.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/**/error.rs : Define AccountError enum with 16 variants mapped to error codes 12006-12021

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.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 : Verify merkle_tree_account data length matches calculated size in `src/initialize_address_tree.rs`. Return error `AccountError::InvalidAccountSize` (error code: 12006) if account data length doesn't match calculated size requirements.

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Use error code range 20000-20015 for AccountError variants

Applied to files:

  • programs/account-compression/src/errors.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • programs/account-compression/src/errors.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 : Error types must use numeric codes in the 19xxx range for CToken-specific errors

Applied to files:

  • programs/account-compression/src/errors.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 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)

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Map Pinocchio standard ProgramError variants (InvalidArgument, InvalidInstructionData, InvalidAccountData, AccountDataTooSmall, InsufficientFunds, IncorrectProgramId, MissingRequiredSignature, AccountAlreadyInitialized, UninitializedAccount, NotEnoughAccountKeys, AccountBorrowFailed) to AccountError::PinocchioProgramError with codes 1-11

Applied to files:

  • programs/account-compression/src/errors.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 : Verify tree capacity constraint before tree update: `tree.next_index + zkp_batch_size <= tree_capacity`; error with `TreeIsFull` (14310) if violated

Applied to files:

  • programs/account-compression/src/errors.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/**/{merkle_tree,merkle_tree_metadata}.rs : Trees must maintain a cyclic buffer of recent roots (default: 200) enabling validity proofs for recently spent compressed accounts

Applied to files:

  • programs/account-compression/src/errors.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/**/rollover_{state,address}_tree.rs : Trees must support rollover when reaching capacity (2^height leaves) by creating a new tree and marking the old tree as rolled over, preserving old tree roots

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:13.714Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_ITERATOR.md:0-0
Timestamp: 2025-11-24T17:59:13.714Z
Learning: Applies to program-libs/account-checks/docs/**/*.rs : Use descriptive account names when calling AccountIterator methods (e.g., `iter.next_account("token_mint")` instead of `iter.next_account("account_3")`)

Applied to files:

  • programs/account-compression/src/errors.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 `MerkleTreeMetadataError::InvalidRolloverThreshold` when rollover threshold value is invalid (must be percentage)

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.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`, reject insertions when batch is in `Full` state with error code 14301

Applied to files:

  • programs/account-compression/src/errors.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/**/*.rs : Error handling must use BatchedMerkleTreeError enum from errors.rs with u32 error codes in the 14301-14312 range

Applied to files:

  • programs/account-compression/src/errors.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 : PropagateHasher errors from light-hasher module with 7xxx code range in error handling

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-12-06T00:50:17.433Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: DOCS.md:0-0
Timestamp: 2025-12-06T00:50:17.433Z
Learning: Applies to **/docs/*instructions* : Error documentation must use format: `ErrorType::Variant` (error code: N) - Description with actual numeric codes. For standard Solana ProgramError variants use: InvalidInstructionData (3), InvalidAccountData (4), InsufficientFunds (6), MissingRequiredSignature (8), NotEnoughAccountKeys (11), InvalidSeeds (14). For custom errors show u32 value from logs. For external crate errors show directly without wrapping.

Applied to files:

  • programs/account-compression/src/errors.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/mint_action/*.rs : MintAction instruction (discriminator: 103) must support 9 action types: CreateCompressedMint, MintTo, UpdateMintAuthority, UpdateFreezeAuthority, CreateSplMint, MintToCToken, UpdateMetadataField, UpdateMetadataAuthority, RemoveMetadataKey

Applied to files:

  • programs/account-compression/src/errors.rs
⏰ 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). (17)
  • GitHub Check: stateless-js-v1
  • GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: 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 -p light-compressed-token", "cargo-test-sbf -p c...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: stateless-js-v2
  • GitHub Check: cli-v1
  • 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: 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-ctoke...
  • GitHub Check: Forester e2e test
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: cli-v2
🔇 Additional comments (1)
programs/account-compression/src/errors.rs (1)

57-58: TooManyLeaves message is now clear and version-specific

The updated message is much more explicit and matches the intended v1/v2 limits, while preserving the existing variant and error code ordering. This is a good improvement for operator/debugger ergonomics.

Comment on lines +69 to +72
#[msg("Too many addresses. The maximum is 8 per instruction.")]
TooManyAddresses,
#[msg("Too many nullifiers. The maximum is 10 per instruction.")]
TooManyNullifiers,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, get the full error enum to see code assignments
cat -n programs/account-compression/src/errors.rs | head -80

Repository: Lightprotocol/light-protocol

Length of output: 2971


🏁 Script executed:

# Find all usages of these error variants
rg -n 'TooManyAddresses|TooManyNullifiers' --type rust

Repository: Lightprotocol/light-protocol

Length of output: 493


🏁 Script executed:

# Check if DOCS.md exists and search for error documentation
find . -name 'DOCS.md' -o -name 'ERRORS.md' | head -20

Repository: Lightprotocol/light-protocol

Length of output: 169


🏁 Script executed:

# Look for validation logic in queue insertion and processor code
rg -n 'max.*address|max.*nullifier' --type rust -i

Repository: Lightprotocol/light-protocol

Length of output: 928


🏁 Script executed:

# Get the processor code to understand the validation context
cat -n programs/account-compression/src/processor/insert_into_queues.rs | head -50

Repository: Lightprotocol/light-protocol

Length of output: 2363


🏁 Script executed:

# Get numeric error codes - in Anchor, error codes are sequential
# Count the position of TooManyAddresses and TooManyNullifiers
python3 << 'EOF'
# Error enum order in errors.rs
errors = [
    "AddressMerkleTreeAccountDiscriminatorMismatch",  # 0
    "EmptyLeaf",  # 1
    "InputDeserializationFailed",  # 2
    "InputElementsEmpty",  # 3
    "InsufficientRolloverFee",  # 4
    "IntegerOverflow",  # 5
    "InvalidAccount",  # 6
    "InvalidAccountBalance",  # 7
    "InvalidAccountSize",  # 8
    "InvalidAuthority",  # 9
    "InvalidGroup",  # 10
    "InvalidMerkleProof",  # 11
    "InvalidNoopPubkey",  # 12
    "InvalidQueueType",  # 13
    "InvalidSequenceThreshold",  # 14
    "LeafNotFound",  # 15
    "MerkleTreeAlreadyRolledOver",  # 16
    "MerkleTreeAndQueueNotAssociated",  # 17
    "NoLeavesForMerkleTree",  # 18
    "NotAllLeavesProcessed",  # 19
    "NotReadyForRollover",  # 20
    "NumberOfChangeLogIndicesMismatch",  # 21
    "NumberOfIndicesMismatch",  # 22
    "NumberOfLeavesMismatch",  # 23
    "NumberOfProofsMismatch",  # 24
    "ProofLengthMismatch",  # 25
    "RegistryProgramIsNone",  # 26
    "RolloverNotConfigured",  # 27
    "StateMerkleTreeAccountDiscriminatorMismatch",  # 28
    "TooManyLeaves",  # 29
    "TxHashUndefined",  # 30
    "UnsupportedAdditionalBytes",  # 31
    "UnsupportedCanopyDepth",  # 32
    "UnsupportedCloseThreshold",  # 33
    "UnsupportedHeight",  # 34
    "UnsupportedParameters",  # 35
    "UnsupportedMerkleTreeHeight",  # 36
    "V1AccountMarkedAsProofByIndex",  # 37
    "TooManyAddresses",  # 38
    "TooManyNullifiers",  # 39
]

for i, err in enumerate(errors):
    if err in ["TooManyAddresses", "TooManyNullifiers"]:
        print(f"{err}: code {i}")
EOF

Repository: Lightprotocol/light-protocol

Length of output: 158


🏁 Script executed:

# Check DOCS.md for error documentation
grep -n "TooManyAddresses\|TooManyNullifiers" DOCS.md

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Check instruction-specific docs for account-compression
find . -path "*/account-compression/docs/*" -name "*.md" | head -20

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Get context around the validation in insert_into_queues.rs
sed -n '1,35p' programs/account-compression/src/processor/insert_into_queues.rs

Repository: Lightprotocol/light-protocol

Length of output: 1431


🏁 Script executed:

# Check if DOCS.md has any account-compression error documentation
head -200 DOCS.md | grep -A 5 -B 5 "account-compression\|AccountCompressionErrorCode" || echo "Not in first 200 lines"

Repository: Lightprotocol/light-protocol

Length of output: 94


🏁 Script executed:

# Search for error documentation patterns in DOCS.md
grep -n "ErrorType::\|error code:" DOCS.md | head -20

Repository: Lightprotocol/light-protocol

Length of output: 232


🏁 Script executed:

# Check if instruction docs exist for insert_into_queues
find . -path "*/programs/account-compression*" -name "*.md"

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Get the structure of DOCS.md to understand where errors should be documented
wc -l DOCS.md

Repository: Lightprotocol/light-protocol

Length of output: 83


🏁 Script executed:

# Check if there's a pattern for error documentation in existing docs
grep -B 3 -A 3 "error code: [0-9]" DOCS.md | head -40

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Check context around the error documentation requirements
sed -n '115,155p' DOCS.md

Repository: Lightprotocol/light-protocol

Length of output: 1642


🏁 Script executed:

# Check if there's already account-compression errors documented
sed -n '1,227p' DOCS.md | grep -i "account.compression" -A 10 -B 5

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Get numeric error codes - Anchor uses 6000 + enum position
# Count positions in the error enum
sed -n '4,73p' programs/account-compression/src/errors.rs | grep -n "."

Repository: Lightprotocol/light-protocol

Length of output: 2617


🏁 Script executed:

# Verify the error code calculation by checking if there's a test or documentation showing the scheme
grep -r "6000\|6065\|6068" . --type rust --type md | head -20

Repository: Lightprotocol/light-protocol

Length of output: 189


🏁 Script executed:

# Check what the actual enum position is by counting from start
python3 << 'EOF'
# Counting from the error enum definition
# The enum starts with AddressMerkleTreeAccountDiscriminatorMismatch as position 0
positions = {
    "AddressMerkleTreeAccountDiscriminatorMismatch": 0,
    "EmptyLeaf": 1,
    "InputDeserializationFailed": 2,
    "InputElementsEmpty": 3,
    "InsufficientRolloverFee": 4,
    "IntegerOverflow": 5,
    "InvalidAccount": 6,
    "InvalidAccountBalance": 7,
    "InvalidAccountSize": 8,
    "InvalidAuthority": 9,
    "InvalidGroup": 10,
    "InvalidMerkleProof": 11,
    "InvalidNoopPubkey": 12,
    "InvalidQueueType": 13,
    "InvalidSequenceThreshold": 14,
    "LeafNotFound": 15,
    "MerkleTreeAlreadyRolledOver": 16,
    "MerkleTreeAndQueueNotAssociated": 17,
    "NoLeavesForMerkleTree": 18,
    "NotAllLeavesProcessed": 19,
    "NotReadyForRollover": 20,
    "NumberOfChangeLogIndicesMismatch": 21,
    "NumberOfIndicesMismatch": 22,
    "NumberOfLeavesMismatch": 23,
    "NumberOfProofsMismatch": 24,
    "ProofLengthMismatch": 25,
    "RegistryProgramIsNone": 26,
    "RolloverNotConfigured": 27,
    "StateMerkleTreeAccountDiscriminatorMismatch": 28,
    "TooManyLeaves": 29,
    "TxHashUndefined": 30,
    "UnsupportedAdditionalBytes": 31,
    "UnsupportedCanopyDepth": 32,
    "UnsupportedCloseThreshold": 33,
    "UnsupportedHeight": 34,
    "UnsupportedParameters": 35,
    "V1AccountMarkedAsProofByIndex": 36,
    "TooManyAddresses": 37,
    "TooManyNullifiers": 38,
}

for err in ["TooManyAddresses", "TooManyNullifiers"]:
    pos = positions[err]
    code = 6000 + pos
    print(f"{err}: position {pos}, error code {code}")
EOF

Repository: Lightprotocol/light-protocol

Length of output: 166


New TooManyAddresses/TooManyNullifiers variants correctly enforce per-instruction limits

The error definitions with explicit "8 addresses" and "10 nullifiers" per-instruction limits are well-designed, and the validation logic in insert_into_queues.rs (lines 17 and 24) correctly enforces these exact thresholds.

However, these errors are not yet documented in DOCS.md per the project's error-doc guidelines. Add them following the format ErrorType::Variant (error code: N) - Description:

  • AccountCompressionErrorCode::TooManyAddresses (error code: 6037) - Triggered when more than 8 addresses are provided in a single insert_into_queues instruction.
  • AccountCompressionErrorCode::TooManyNullifiers (error code: 6038) - Triggered when more than 10 nullifiers are provided in a single insert_into_queues instruction.
🤖 Prompt for AI Agents
programs/account-compression/src/errors.rs lines 69-72: Add entries to DOCS.md
documenting the two new error variants; specifically add a line for
AccountCompressionErrorCode::TooManyAddresses (error code: 6037) - Triggered
when more than 8 addresses are provided in a single insert_into_queues
instruction, and a line for AccountCompressionErrorCode::TooManyNullifiers
(error code: 6038) - Triggered when more than 10 nullifiers are provided in a
single insert_into_queues instruction, following the existing DOCS.md error
format `ErrorType::Variant` (error code: N) - Description. Ensure the entries
are placed in the appropriate section for AccountCompressionErrorCode and match
the project's formatting and sorting conventions.

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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 288251c and 52b0a74.

⛔ Files ignored due to path filters (4)
  • js/compressed-token/tests/e2e/compress.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/mint-to.test.ts is excluded by none and included by none
  • program-tests/account-compression-test/tests/address_merkle_tree_tests.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/functional.rs is excluded by none and included by none
📒 Files selected for processing (1)
  • programs/account-compression/src/errors.rs (2 hunks)
🧰 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/account-compression/src/errors.rs
🧠 Learnings (22)
📓 Common learnings
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 : Initialize integrated address queue in merkle tree account with 2 bloom filter stores and 2 hash chain stores. Bloom filter capacity = bloom_filter_capacity / 8 bytes each. Hash chain stores capacity = (input_queue_batch_size / input_queue_zkp_batch_size) each.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : When inserting an address into the current batch, call the bloom filter's insert method which must: insert the address into the bloom filter, perform a non-inclusion check across all bloom filters (returning `BatchedMerkleTreeError::NonInclusionCheckFailed` error code 14311 if address already exists), update the hash chain with `Poseidon(prev_hash_chain, address)`, and increment the batch's element counter.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INSERT_ADDRESS_QUEUE.md:0-0
Timestamp: 2025-11-24T17:57:02.558Z
Learning: The address queue uses a two-batch alternating system where one bloom filter is being zeroed by the forester while the other is active. The bloom filter is zeroed after the batch is fully inserted into the tree AND the next batch reaches 50% capacity AND at least one batch update has occurred since batch completion.
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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).
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 : ZKP batch sizes for address trees must be 10 or 250 in `src/initialize_address_tree.rs`. Only these circuit sizes are supported for address trees.
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 : Validate bloom_filter_capacity is divisible by 8 in `src/initialize_address_tree.rs`. Capacity must be >= batch_size * 8.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/UPDATE_FROM_INPUT_QUEUE.md:0-0
Timestamp: 2025-11-24T17:58:10.392Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/merkle_tree.rs : Batch address append operations must check that tree type is TreeType::AddressV2 before processing, verify tree capacity constraint (tree.next_index + zkp_batch_size <= tree_capacity), verify batch has ready ZKP batches (num_full_zkp_batches > num_inserted_zkp_batches), and reject if batch is already in Inserted state.
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 : Define bloom filter configuration for input queue: bloom_filter_capacity (u64, default batch_size * 8) and bloom_filter_num_iters (u64, default 3 for test and 10 for production)
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 : Define batch size parameters in `InitStateTreeAccountsInstructionData` struct: input_queue_batch_size (u64, default 15,000), output_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 500), and output_queue_zkp_batch_size (u64, default 500)
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 integrated input queue with 2 bloom filter stores (one per batch, size = bloom_filter_capacity / 8 bytes each) and 2 hash chain stores (one per batch, capacity = input_queue_batch_size / input_queue_zkp_batch_size each)
📚 Learning: 2025-11-24T17:59:54.233Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/PACKED_ACCOUNTS.md:0-0
Timestamp: 2025-11-24T17:59:54.233Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/**/*.rs : Provide descriptive names in ProgramPackedAccounts error messages (e.g., 'token_mint' instead of 'account')

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.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 : Verify merkle_tree_account data length matches calculated size in `src/initialize_address_tree.rs`. Return error `AccountError::InvalidAccountSize` (error code: 12006) if account data length doesn't match calculated size requirements.

Applied to files:

  • programs/account-compression/src/errors.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/**/error.rs : Define AccountError enum with 16 variants mapped to error codes 12006-12021

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Use error code range 20000-20015 for AccountError variants

Applied to files:

  • programs/account-compression/src/errors.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 : `InitAddressTreeAccountsInstructionData` struct in `src/initialize_address_tree.rs` must include: height (u32, default 40), index (u64), root_history_capacity (u32, default 200), input_queue_batch_size (u64, default 15,000), input_queue_zkp_batch_size (u64, default 250), bloom_filter_capacity (u64, default batch_size * 8), bloom_filter_num_iters (u64, default 3 for test/10 for production), program_owner (Option<Pubkey>), forester (Option<Pubkey>), rollover_threshold (Option<u64>, default 95%), network_fee (Option<u64>, default 10,000 lamports), and close_threshold (Option<u64>).

Applied to files:

  • programs/account-compression/src/errors.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 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)

Applied to files:

  • programs/account-compression/src/errors.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 : Error types must use numeric codes in the 19xxx range for CToken-specific errors

Applied to files:

  • programs/account-compression/src/errors.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/account-compression/src/errors.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 : Verify tree capacity constraint before tree update: `tree.next_index + zkp_batch_size <= tree_capacity`; error with `TreeIsFull` (14310) if violated

Applied to files:

  • programs/account-compression/src/errors.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/**/{merkle_tree,merkle_tree_metadata}.rs : Trees must maintain a cyclic buffer of recent roots (default: 200) enabling validity proofs for recently spent compressed accounts

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:13.714Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_ITERATOR.md:0-0
Timestamp: 2025-11-24T17:59:13.714Z
Learning: Applies to program-libs/account-checks/docs/**/*.rs : Use descriptive account names when calling AccountIterator methods (e.g., `iter.next_account("token_mint")` instead of `iter.next_account("account_3")`)

Applied to files:

  • programs/account-compression/src/errors.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/**/rollover_{state,address}_tree.rs : Trees must support rollover when reaching capacity (2^height leaves) by creating a new tree and marking the old tree as rolled over, preserving old tree roots

Applied to files:

  • programs/account-compression/src/errors.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 `MerkleTreeMetadataError::InvalidRolloverThreshold` when rollover threshold value is invalid (must be percentage)

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-11-24T17:59:46.693Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T17:59:46.693Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/error.rs : Map Pinocchio standard ProgramError variants (InvalidArgument, InvalidInstructionData, InvalidAccountData, AccountDataTooSmall, InsufficientFunds, IncorrectProgramId, MissingRequiredSignature, AccountAlreadyInitialized, UninitializedAccount, NotEnoughAccountKeys, AccountBorrowFailed) to AccountError::PinocchioProgramError with codes 1-11

Applied to files:

  • programs/account-compression/src/errors.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`, reject insertions when batch is in `Full` state with error code 14301

Applied to files:

  • programs/account-compression/src/errors.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/**/*.rs : Error handling must use BatchedMerkleTreeError enum from errors.rs with u32 error codes in the 14301-14312 range

Applied to files:

  • programs/account-compression/src/errors.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 : PropagateHasher errors from light-hasher module with 7xxx code range in error handling

Applied to files:

  • programs/account-compression/src/errors.rs
📚 Learning: 2025-12-06T00:50:17.433Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: DOCS.md:0-0
Timestamp: 2025-12-06T00:50:17.433Z
Learning: Applies to **/docs/*instructions* : Error documentation must use format: `ErrorType::Variant` (error code: N) - Description with actual numeric codes. For standard Solana ProgramError variants use: InvalidInstructionData (3), InvalidAccountData (4), InsufficientFunds (6), MissingRequiredSignature (8), NotEnoughAccountKeys (11), InvalidSeeds (14). For custom errors show u32 value from logs. For external crate errors show directly without wrapping.

Applied to files:

  • programs/account-compression/src/errors.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/mint_action/*.rs : MintAction instruction (discriminator: 103) must support 9 action types: CreateCompressedMint, MintTo, UpdateMintAuthority, UpdateFreezeAuthority, CreateSplMint, MintToCToken, UpdateMetadataField, UpdateMetadataAuthority, RemoveMetadataKey

Applied to files:

  • programs/account-compression/src/errors.rs
⏰ 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). (1)
  • GitHub Check: Test batched-merkle-tree-simulate
🔇 Additional comments (1)
programs/account-compression/src/errors.rs (1)

57-58: Updated TooManyLeaves message is clear and actionable

The new wording explicitly ties the limits to v1/v2 and is far more readable for operators and integrators; no further changes needed here.

Comment on lines +69 to +72
#[msg("Too many addresses. The maximum is 8 per instruction.")]
TooManyAddresses,
#[msg("Too many nullifiers. The maximum is 10 per instruction.")]
TooManyNullifiers,
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Per‑instruction limit errors are well‑named; keep limits aligned with callers/docs

Defining TooManyAddresses and TooManyNullifiers with explicit numeric caps in the messages is good for debuggability and makes the ABI self‑describing. Just ensure these 8/10 limits stay in lock‑step with the validation logic in insert_into_queues.rs and any public docs so they don’t drift over time.

🤖 Prompt for AI Agents
In programs/account-compression/src/errors.rs around lines 69–72, the numeric
caps in the error messages (8 and 10) must be kept in sync with the validation
logic and docs; refactor so these limits come from a single source of truth
(e.g., shared constants in a common module referenced by insert_into_queues.rs
and the error definitions) or update the validation/docs whenever the constants
change, and replace the hard‑coded literals in the message strings with values
derived from those constants so they never drift.

@ananas-block ananas-block merged commit 2ac09cc into main Dec 13, 2025
33 checks passed
@ananas-block ananas-block deleted the jorrit/chore-update-tree-mainnet-default-values branch December 13, 2025 17:48
ananas-block added a commit that referenced this pull request Dec 13, 2025
* feat: update mainnet batched tree values

* feat: add limits for queue insertion

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants