Skip to content

fix: registry program errors#2122

Merged
ananas-block merged 7 commits intomainfrom
jorrit/fix-registry-error
Dec 8, 2025
Merged

fix: registry program errors#2122
ananas-block merged 7 commits intomainfrom
jorrit/fix-registry-error

Conversation

@ananas-block
Copy link
Contributor

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

Summary by CodeRabbit

  • Bug Fixes

    • More specific error reporting for account/token access and serialization failures
    • Added validation to prevent pausing deprecated registry configurations
  • Tests

    • Removed an obsolete top-up unit test
    • Added extensive tests covering rent top-up logic, edge cases, multi-epoch scenarios, and a large consistency stress test
  • Chores

    • Internal API surface and visibility adjustments; test dependencies updated (dev-only)

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Adds granular RegistryError variants and replaces broad InvalidSigner mappings in compress-and-close paths; enforces compressible-config state transitions using CompressibleConfigState; removes an old top-up test and adds extensive compressible rent top-up and consistency tests; reduces visibility of several rent helper functions and adds a dev-dependency.

Changes

Cohort / File(s) Change Summary
Error enum
programs/registry/src/errors.rs
Added InvalidTokenAccountData, EmptyIndices, BorrowAccountDataFailed, and SerializationFailed variants with #[msg(...)] annotations.
Compress-and-close — index check
programs/registry/src/compressible/compress_and_close.rs
Replaced broad InvalidSigner on empty indices with EmptyIndices.
Compress-and-close — ctoken path
programs/registry/src/compressible/compressed_token/compress_and_close.rs
Replaced InvalidSigner mappings with granular errors: BorrowAccountDataFailed, InvalidTokenAccountData, and SerializationFailed for account borrow, token parsing, and serialization failures.
Config state machine
programs/registry/src/lib.rs
Imported CompressibleConfigState; updated pause_compressible_config, unpause_compressible_config, and deprecate_compressible_config to use enum states (Inactive, Active, Deprecated) and reject pausing deprecated configs.
Rent helpers visibility
program-libs/compressible/src/rent/account_rent.rs
Reduced visibility: get_available_rent_balance, get_required_epochs, get_unused_lamports, and slot_to_epoch changed from pub to private fn.
Tests — removed
program-libs/compressible/tests/compression_info.rs
Removed legacy test_calculate_top_up_lamports test.
Tests — added/expanded
program-libs/compressible/tests/top_up.rs, program-libs/compressible/tests/consistency.rs
Added comprehensive test_calculate_top_up_lamports with many scenarios and test_consistency_16_epochs_progression with randomized progression checks and invariants.
Dev-dependency
program-libs/compressible/Cargo.toml
Added rand under [dev-dependencies] for tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect new RegistryError variants for message consistency and code numbering collisions.
  • Verify all replaced error mappings preserve intended semantics and that callers/tests handle new variants.
  • Review compressible config state transitions to ensure enum values match persisted/state representations.
  • Check visibility reduction in rent helpers for compilation impact on callers and tests that previously relied on them.
  • Review new tests for determinism, seeding, and added dev-dependency usage.

Possibly related PRs

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

Errors sharpened, states define the gate,
Tests expand to probe each fate,
Helpers hidden, dev-deps brought in,
Small clarions call the code to win,
A tidy PR — clear, precise, and great. 🛠️✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: registry program errors' is vague and overly broad; it doesn't convey the specific nature of the changes, which involve refactoring error handling to use more granular RegistryError variants, adding new error types, and introducing state machine logic for config management. Consider a more descriptive title like 'fix: improve registry error handling and config state management' to better reflect the specific changes made across error types and state machine introduction.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/fix-registry-error

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: 4

📜 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 06f3122 and fbb43c2.

📒 Files selected for processing (4)
  • programs/registry/src/compressible/compress_and_close.rs (1 hunks)
  • programs/registry/src/compressible/compressed_token/compress_and_close.rs (2 hunks)
  • programs/registry/src/errors.rs (1 hunks)
  • programs/registry/src/lib.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/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/errors.rs
  • programs/registry/src/lib.rs
programs/registry/src/lib.rs

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

In wrapper instruction handler in lib.rs, load account metadata, determine work units, call check_forester(), then call the processing function

Files:

  • programs/registry/src/lib.rs
🧠 Learnings (49)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/**/*.rs : InvalidState (Error Code 19002): For account creation, ensure CompressibleConfig state is `Active` (1). For other operations (claim, withdraw, compress & close), ensure config state is not `Inactive` (0). Validate config state using `config.validate_active()` for creation and `config.validate_not_inactive()` for other operations.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.794Z
Learning: Use compressible token account extensions that allow accounts to be compressed back into compressed state with rent payment mechanisms
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : CompressibleConfig account structure must support serialization via Anchor, Pinocchio, and Borsh formats for Light Registry program integration
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')
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 state in Solana programs must validate active state using `validate_active()` method before allowing new compressible token account creation
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:54.689Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CLOSE_TOKEN_ACCOUNT.md : Close Token Account documentation must cover closing decompressed token accounts with rent distribution
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 : Use `validate_not_inactive()` method before executing claim or account closing operations on CompressibleConfig to prevent operations on deprecated or inactive configurations
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement state validation methods (`validate_active`, `validate_not_inactive`) on CompressibleConfig account structure
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: All compressed token account implementations must reference and comply with the account layout specifications in programs/compressed-token/program/docs/ACCOUNTS.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)
📚 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/registry/src/compressible/compressed_token/compress_and_close.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/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/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/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/decompress_context.rs : Decompression trait implementation (`DecompressContext`) with account accessors, PDA/token separation logic, and token processing delegation should be in `decompress_context.rs`

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/lib.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : CompressibleConfig account structure must support serialization via Anchor, Pinocchio, and Borsh formats for Light Registry program integration

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.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/registry/src/compressible/compressed_token/compress_and_close.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/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/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/**/instructions.rs : Compress/decompress instruction handlers and context struct generation should be implemented in `instructions.rs`, with compress using PDA-only and decompress supporting full PDA + ctoken

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-11-24T18:00:21.501Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/**/*.rs : InvalidState (Error Code 19002): For account creation, ensure CompressibleConfig state is `Active` (1). For other operations (claim, withdraw, compress & close), ensure config state is not `Inactive` (0). Validate config state using `config.validate_active()` for creation and `config.validate_not_inactive()` for other operations.

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/errors.rs
  • programs/registry/src/lib.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/ctoken_transfer.rs : CTokenTransfer instruction (discriminator: 3) must implement SPL-compatible transfers between decompressed accounts

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/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/registry/src/compressible/compressed_token/compress_and_close.rs
  • programs/registry/src/compressible/compress_and_close.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/registry/src/compressible/compressed_token/compress_and_close.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run account-compression tests using `cargo test-sbf -p account-compression-test` to test core account compression program (Merkle tree management)

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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 : Anchor deserialization of CompressibleConfig must use `AccountDeserialize::try_deserialize()` which automatically validates the discriminator to prevent invalid account type mismatches

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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: The `data` parameter must contain serialized instruction data for the target program and be passed through unchanged to maintain compatibility

Applied to files:

  • programs/registry/src/compressible/compressed_token/compress_and_close.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/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/error.rs : Support ProgramError conversions for Anchor, Pinocchio, and Solana frameworks in error implementation

Applied to files:

  • programs/registry/src/compressible/compress_and_close.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/**/pack_unpack.rs : Pubkey compression logic and `PackedXxx` struct generation with Pack/Unpack trait implementations should be in `pack_unpack.rs`

Applied to files:

  • programs/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement state validation methods (`validate_active`, `validate_not_inactive`) on CompressibleConfig account structure

Applied to files:

  • programs/registry/src/compressible/compress_and_close.rs
  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T18:00:21.501Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/error.rs : FailedBorrowRentSysvar (Error Code 19001): Ensure the rent sysvar is properly initialized in test environments and verify the sysvar is accessible for on-chain programs. Use `solana_program::rent::Rent::get()` with proper error handling for borrowing rent sysvar.

Applied to files:

  • programs/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-11-24T17:58:50.237Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_CHECKS.md:0-0
Timestamp: 2025-11-24T17:58:50.237Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/checks.rs : Implement `check_signer` function to verify account is a transaction signer, returning `InvalidSigner` (20009) error if not

Applied to files:

  • programs/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-11-24T17:58:50.237Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_CHECKS.md:0-0
Timestamp: 2025-11-24T17:58:50.237Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/checks.rs : Implement `check_pda_seeds` function to derive PDA using `find_program_address` and verify it matches account key, returning `InvalidSeeds` (20010) error on mismatch

Applied to files:

  • programs/registry/src/compressible/compress_and_close.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/registry/src/compressible/compress_and_close.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 queue and tree association by matching pubkeys; error with `MerkleTreeAndQueueNotAssociated` (14001) if they don't match

Applied to files:

  • programs/registry/src/compressible/compress_and_close.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: Handle errors appropriately: use `InvalidSigner` for unauthorized authority, `InvalidNetworkFee` for fee mismatches, `ForesterDefined` for incorrect forester setup, and `ForesterUndefined` when forester should be present

Applied to files:

  • programs/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Use `check_account_balance_is_rent_exempt` function from `light-account-checks` to verify rent exemption for both queue_account and merkle_tree_account during initialization

Applied to files:

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

  • programs/registry/src/compressible/compress_and_close.rs
📚 Learning: 2025-11-24T17:58:50.237Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_CHECKS.md:0-0
Timestamp: 2025-11-24T17:58:50.237Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/checks.rs : Implement `check_pda_seeds_with_bump` function to verify PDA with known bump seed using `create_program_address`, returning `InvalidSeeds` (20010) error on mismatch

Applied to files:

  • programs/registry/src/compressible/compress_and_close.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/registry/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/registry/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/registry/src/errors.rs
📚 Learning: 2025-11-24T17:59:03.485Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_INFO_TRAIT.md:0-0
Timestamp: 2025-11-24T17:59:03.485Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/account_info/*.rs : AccountInfoTrait implementations must return `AccountError` from all fallible operations: `BorrowAccountDataFailed` (12009) for borrow failures, `InvalidSeeds` (12016) for PDA creation, and `FailedBorrowRentSysvar` (12014) for rent access

Applied to files:

  • programs/registry/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,**/account_info/pinocchio.rs} : Map Pinocchio ProgramError with standard codes 1-11 and handle BorrowError conversions for safe data access

Applied to files:

  • programs/registry/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 : All AccountError variants must convert automatically to `ProgramError::Custom(u32)` for both solana-program and pinocchio SDKs using From trait implementations

Applied to files:

  • programs/registry/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 : Implement From<std::cell::BorrowError> and From<std::cell::BorrowMutError> to convert to AccountError::BorrowAccountDataFailed when using solana-program SDK

Applied to files:

  • programs/registry/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 : Implement automatic error conversions from AccountError to ProgramError for both solana-program and pinocchio SDKs

Applied to files:

  • programs/registry/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/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/registry/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/registry/src/errors.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 : Use `validate_not_inactive()` method before executing claim or account closing operations on CompressibleConfig to prevent operations on deprecated or inactive configurations

Applied to files:

  • programs/registry/src/lib.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 : When deserializing CompressibleConfig accounts, skip the 8-byte discriminator `[180, 4, 231, 26, 220, 144, 55, 168]` before deserialization in zero-copy implementations using bytemuck::pod_from_bytes

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement PDA derivation methods (`derive_pda`, `derive_v1_config_pda`) on CompressibleConfig for account discovery

Applied to files:

  • programs/registry/src/lib.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 PDA must be derived using seeds `[b"compressible_config", version.to_le_bytes()]` with the stored bump seed for deterministic account address generation in Light Protocol

Applied to files:

  • programs/registry/src/lib.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 state in Solana programs must validate active state using `validate_active()` method before allowing new compressible token account creation

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_rent_and_balance` function to determine compressibility by checking if account balance covers required rent for epochs since last claim, returning (bool, u64) tuple.

Applied to files:

  • programs/registry/src/lib.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/claim/*.rs,src/withdraw_funding_pool.rs} : Rent management instructions (Claim, WithdrawFundingPool) require validation that config is not INACTIVE (accepts ACTIVE or DEPRECATED states)

Applied to files:

  • programs/registry/src/lib.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). (18)
  • GitHub Check: cli-v1
  • GitHub Check: Forester e2e test
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-ctoke...
  • GitHub Check: cli-v2
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • 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: lint
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo test -p light-compressed-token", "cargo-test-sbf -p c...
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • 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 (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
  • GitHub Check: stateless-js-v2
  • GitHub Check: stateless-js-v1
🔇 Additional comments (2)
programs/registry/src/errors.rs (1)

37-44: LGTM! Well-structured error variants.

The new error variants provide clear, granular error reporting for compress-and-close operations. The message annotations accurately describe each failure condition, and the variants are appropriately named for their use cases throughout the codebase.

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

736-740: Guard correctly prevents pausing deprecated configs.

The state validation appropriately blocks transitioning from deprecated (state=2) to paused (state=0), as deprecated should be a terminal state for preventing new account creation. The error choice is semantically correct.

One observation: the function allows re-pausing an already-paused config (state=0), making pause idempotent. This differs from unpause_compressible_config which explicitly requires state==0. This appears intentional, but if strict state transitions are desired, consider adding require!(ctx.accounts.compressible_config.state == 1, ...) to only allow pausing active configs.

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 fbb43c2 and 566c8ee.

📒 Files selected for processing (2)
  • program-libs/compressible/tests/compression_info.rs (0 hunks)
  • program-libs/compressible/tests/top_up.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • program-libs/compressible/tests/compression_info.rs
🧰 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/compressible/tests/top_up.rs
🧠 Learnings (13)
📓 Common learnings
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: Compressible extension rent management must follow the specifications in program-libs/compressible/docs/RENT.md including: rent authority can only compress when is_compressible() returns true, lamport distribution on close (rent → rent_sponsor, unutilized → destination), and compression incentive for foresters
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Account closure must distribute lamports according to: Solana rent exemption → returned to user, completed epoch rent → rent recipient, partial epoch rent → user, compression incentive → forester node
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : RentConfig struct must be exactly 8 bytes and contain: base_rent (u16), compression_cost (u16), lamports_per_byte_per_epoch (u8), and 3 bytes of padding.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/error.rs : FailedBorrowRentSysvar (Error Code 19001): Ensure the rent sysvar is properly initialized in test environments and verify the sysvar is accessible for on-chain programs. Use `solana_program::rent::Rent::get()` with proper error handling for borrowing rent sysvar.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/**/*.rs : InvalidState (Error Code 19002): For account creation, ensure CompressibleConfig state is `Active` (1). For other operations (claim, withdraw, compress & close), ensure config state is not `Inactive` (0). Validate config state using `config.validate_active()` for creation and `config.validate_not_inactive()` for other operations.
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: When working with compressible extension (rent management), must read and comply with documentation in program-libs/compressible/docs/ including RENT.md, CONFIG_ACCOUNT.md, and SOLANA_RENT.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.794Z
Learning: Use compressible token account extensions that allow accounts to be compressed back into compressed state with rent payment mechanisms
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Accounts become compressible when they lack rent for the current epoch plus the next epoch (compressibility window).
📚 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/rent.rs : Implement rent calculation functions including `rent_curve_per_epoch`, `calculate_rent_and_balance`, `claimable_lamports`, and `calculate_close_lamports` in rent.rs

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_rent_and_balance` function to determine compressibility by checking if account balance covers required rent for epochs since last claim, returning (bool, u64) tuple.

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement rent constants with values: BASE_RENT = 1,220 lamports, RENT_PER_BYTE = 10 lamports, SLOTS_PER_EPOCH = 432,000.

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_rent_inner` as a generic helper function with INCLUDE_CURRENT const parameter to calculate rent components, returning (required_epochs, rent_per_epoch, epochs_paid, unutilized_lamports).

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `rent_curve_per_epoch` function with formula: base_rent + (num_bytes * lamports_per_byte_per_epoch).

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : In test environments, mock Solana rent exemption instead of calling the actual Rent sysvar, using a hardcoded value like 2_282_880 lamports

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_close_lamports` function to return (u64, u64) tuple splitting lamports between rent recipient and user, with rent recipient receiving completed epochs and user receiving partial epoch remainder.

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : RentConfig struct must be exactly 8 bytes and contain: base_rent (u16), compression_cost (u16), lamports_per_byte_per_epoch (u8), and 3 bytes of padding.

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `get_last_funded_epoch` function to determine the last epoch number covered by rent payments.

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Account closure must distribute lamports according to: Solana rent exemption → returned to user, completed epoch rent → rent recipient, partial epoch rent → user, compression incentive → forester node

Applied to files:

  • program-libs/compressible/tests/top_up.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Light Protocol rent is calculated per epoch as: 1220 minimum + (data_bytes * 10) lamports per epoch

Applied to files:

  • program-libs/compressible/tests/top_up.rs
🧬 Code graph analysis (1)
program-libs/compressible/tests/top_up.rs (1)
sdk-libs/sdk/src/compressible/compression_info.rs (2)
  • compression_info (37-37)
  • last_claimed_slot (126-128)
⏰ 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: stateless-js-v1
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo test -p light-compressed-token", "cargo-test-sbf -p c...
  • 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: Test program-libs-fast
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test batched-merkle-tree-simulate
🔇 Additional comments (11)
program-libs/compressible/tests/top_up.rs (11)

19-28: LGTM! Well-structured test case organization.

The TestCase struct provides excellent organization with descriptive fields and debug support for clear test failure messages.


30-92: LGTM! Comprehensive compressible state test cases.

PATH 1 thoroughly tests scenarios where accounts lack sufficient rent for current + next epoch, correctly calculating deficits including compression costs. The test cases cover epoch boundaries, partial rent, and extreme gaps (10,000 epochs), with accurate expected top-up calculations.


94-149: LGTM! Well-designed non-compressible boundary tests.

PATH 2 correctly validates scenarios where accounts have sufficient rent for current + next epoch but fall below the max_funded_epochs threshold (2 epochs ahead), requiring only the write fee top-up. The fractional epoch rounding tests (1.5 and 1.99 epochs) are particularly valuable for catching off-by-one errors.


151-179: LGTM! Well-funded state validation.

PATH 3 correctly tests the epochs_funded_ahead threshold logic, confirming that 3 epochs funded (covering current + 2 ahead) meets the max threshold, while 2 epochs funded (current + 1 ahead) requires top-up.


220-249: LGTM! Excellent lagging claims verification.

These test cases correctly validate that arrears don't count toward "funded ahead" calculations. The examples clearly demonstrate:

  • 5 epochs from epoch 0 covers through epoch 4 → at epoch 3, only 1 ahead (needs top-up)
  • 6 epochs from epoch 0 covers through epoch 5 → at epoch 3, 2 ahead (no top-up)
  • 4 epochs from epoch 0 covers through epoch 3 → at epoch 3, 0 ahead (needs top-up)

This ensures claims aren't artificially delayed to accumulate rent without proper funding ahead.


251-278: LGTM! Clean test execution with descriptive failure messages.

The test loop properly constructs CompressionInfo instances for each case and provides excellent failure diagnostics including test name, description, expected vs. actual values, and full test case details.


280-324: LGTM! Clear multi-epoch progression test.

This test validates the initial funding period (epochs 0-13 with no top-up needed when starting with 16 epochs rent) and correctly identifies the threshold at epoch 14 when only 1 epoch remains funded ahead.


325-363: LGTM! Correct post-top-up state verification.

After the epoch 14 write adds 2 epochs rent (via lamports_per_write = 388 * 2), the test correctly verifies that epochs 14-15 no longer require top-up (now 2 epochs funded ahead = max threshold).


364-379: LGTM! Validates recurring top-up requirement.

Epoch 16 correctly requires top-up again as the additional 2 epochs from the previous write have been consumed, returning to 1 epoch funded ahead. This validates the ongoing rent sustainability mechanism.


11-13: Document RentConfig::default() assumptions for test stability.

The tests assume RentConfig::default() has max_funded_epochs = 2 (explicitly mentioned in the comment at line 300). If this default changes, multiple test cases would fail unexpectedly. Consider either:

  1. Explicitly constructing RentConfig with known values instead of using default(), OR
  2. Adding a validation assertion at the start of each test

Apply this diff to make the assumption explicit:

 fn test_rent_config() -> RentConfig {
-    RentConfig::default()
+    let config = RentConfig::default();
+    // Tests assume max_funded_epochs = 2
+    assert_eq!(config.max_funded_epochs, 2, "Tests assume default max_funded_epochs=2");
+    config
 }

Alternatively, construct explicitly:

 fn test_rent_config() -> RentConfig {
-    RentConfig::default()
+    RentConfig {
+        base_rent: 128,
+        compression_cost: 1000, // Update with actual default
+        lamports_per_byte_per_epoch: 1,
+        max_funded_epochs: 2,
+        // ... other fields with explicit values
+    }
 }

Also applies to: 300-301

⛔ Skipped due to learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : RentConfig struct must be exactly 8 bytes and contain: base_rent (u16), compression_cost (u16), lamports_per_byte_per_epoch (u8), and 3 bytes of padding.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : In test environments, mock Solana rent exemption instead of calling the actual Rent sysvar, using a hardcoded value like 2_282_880 lamports
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement rent constants with values: BASE_RENT = 1,220 lamports, RENT_PER_BYTE = 10 lamports, SLOTS_PER_EPOCH = 432,000.
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 rent_sponsor PDA and compression_authority PDA must be derived separately using `get_rent_sponsor_seeds()` and `get_compression_authority_seeds()` helper methods with version-specific seeds
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_rent_and_balance` function to determine compressibility by checking if account balance covers required rent for epochs since last claim, returning (bool, u64) tuple.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `get_last_funded_epoch` function to determine the last epoch number covered by rent payments.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `rent_curve_per_epoch` function with formula: base_rent + (num_bytes * lamports_per_byte_per_epoch).
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_rent_inner` as a generic helper function with INCLUDE_CURRENT const parameter to calculate rent components, returning (required_epochs, rent_per_epoch, epochs_paid, unutilized_lamports).
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)
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/rent.rs : Implement rent calculation functions including `rent_curve_per_epoch`, `calculate_rent_and_balance`, `claimable_lamports`, and `calculate_close_lamports` in rent.rs
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement default initialization for CToken V1 config in CompressibleConfig structure

193-200: Remove concern about zero write fee bypass—behavior is correct per specification.

The test case at lines 193-200 correctly expects top_up = 0 when lamports_per_write = 0. This is not a bypass of the funded-ahead threshold; rather, the top-up amount is directly equal to lamports_per_write. When the account needs topping up but the write fee is zero, the contribution to top-up is correctly zero. This is mathematically consistent: zero write fee means zero lamports added per write, regardless of funding status. Compare line 96-104 where identical funding conditions with lamports_per_write = 5000 correctly expect top_up = 5000.

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: 4

📜 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 566c8ee and 24322da.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock and included by none
  • program-tests/registry-test/tests/compressible.rs is excluded by none and included by none
📒 Files selected for processing (4)
  • program-libs/compressible/Cargo.toml (1 hunks)
  • program-libs/compressible/src/rent/account_rent.rs (4 hunks)
  • program-libs/compressible/tests/consistency.rs (1 hunks)
  • programs/registry/src/lib.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
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/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
programs/registry/src/lib.rs

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

In wrapper instruction handler in lib.rs, load account metadata, determine work units, call check_forester(), then call the processing function

Files:

  • programs/registry/src/lib.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/registry/src/lib.rs
program-libs/*/Cargo.toml

📄 CodeRabbit inference engine (CLAUDE.md)

Program-libs crates must depend on other program-libs or external crates only, not on programs or sdk-libs

Files:

  • program-libs/compressible/Cargo.toml
🧠 Learnings (50)
📓 Common learnings
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: Compressible extension rent management must follow the specifications in program-libs/compressible/docs/RENT.md including: rent authority can only compress when is_compressible() returns true, lamport distribution on close (rent → rent_sponsor, unutilized → destination), and compression incentive for foresters
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/**/*.rs : InvalidState (Error Code 19002): For account creation, ensure CompressibleConfig state is `Active` (1). For other operations (claim, withdraw, compress & close), ensure config state is not `Inactive` (0). Validate config state using `config.validate_active()` for creation and `config.validate_not_inactive()` for other operations.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.794Z
Learning: Use compressible token account extensions that allow accounts to be compressed back into compressed state with rent payment mechanisms
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : RentConfig struct must be exactly 8 bytes and contain: base_rent (u16), compression_cost (u16), lamports_per_byte_per_epoch (u8), and 3 bytes of padding.
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: When working with compressible extension (rent management), must read and comply with documentation in program-libs/compressible/docs/ including RENT.md, CONFIG_ACCOUNT.md, and SOLANA_RENT.md
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Account closure must distribute lamports according to: Solana rent exemption → returned to user, completed epoch rent → rent recipient, partial epoch rent → user, compression incentive → forester node
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: The codebase provides rent calculation algorithms and account structure definitions used across light-compressed-token, light-registry, compressed-token-sdk, and related programs
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 rent_sponsor PDA and compression_authority PDA must be derived separately using `get_rent_sponsor_seeds()` and `get_compression_authority_seeds()` helper methods with version-specific seeds
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/error.rs : FailedBorrowRentSysvar (Error Code 19001): Ensure the rent sysvar is properly initialized in test environments and verify the sysvar is accessible for on-chain programs. Use `solana_program::rent::Rent::get()` with proper error handling for borrowing rent sysvar.
📚 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/**/checks.rs : Implement rent exemption checks (`check_account_balance_is_rent_exempt`) in checks module

Applied to files:

  • program-libs/compressible/tests/consistency.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/rent.rs : Implement rent calculation functions including `rent_curve_per_epoch`, `calculate_rent_and_balance`, `claimable_lamports`, and `calculate_close_lamports` in rent.rs

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `get_rent_exemption_lamports` function to return Solana's rent-exempt balance for a given account size, with error handling for unavailable rent sysvar.

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : In test environments, mock Solana rent exemption instead of calling the actual Rent sysvar, using a hardcoded value like 2_282_880 lamports

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_rent_and_balance` function to determine compressibility by checking if account balance covers required rent for epochs since last claim, returning (bool, u64) tuple.

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Implement account compressibility states in the following order: Funded (rent for current + 1 epoch) → Compressible (lacks rent for current + 1 epoch) → Claimable (funded but past epochs unclaimed)

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • programs/registry/src/lib.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement rent constants with values: BASE_RENT = 1,220 lamports, RENT_PER_BYTE = 10 lamports, SLOTS_PER_EPOCH = 432,000.

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_close_lamports` function to return (u64, u64) tuple splitting lamports between rent recipient and user, with rent recipient receiving completed epochs and user receiving partial epoch remainder.

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `rent_curve_per_epoch` function with formula: base_rent + (num_bytes * lamports_per_byte_per_epoch).

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `get_last_funded_epoch` function to determine the last epoch number covered by rent payments.

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Account closure must distribute lamports according to: Solana rent exemption → returned to user, completed epoch rent → rent recipient, partial epoch rent → user, compression incentive → forester node

Applied to files:

  • program-libs/compressible/tests/consistency.rs
  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Light Protocol rent is calculated per epoch as: 1220 minimum + (data_bytes * 10) lamports per epoch

Applied to files:

  • program-libs/compressible/tests/consistency.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : RentConfig struct must be exactly 8 bytes and contain: base_rent (u16), compression_cost (u16), lamports_per_byte_per_epoch (u8), and 3 bytes of padding.

Applied to files:

  • program-libs/compressible/tests/consistency.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement state validation methods (`validate_active`, `validate_not_inactive`) on CompressibleConfig account structure

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T18:00:21.501Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/ERRORS.md:0-0
Timestamp: 2025-11-24T18:00:21.501Z
Learning: Applies to program-libs/compressible/docs/program-libs/compressible/src/**/*.rs : InvalidState (Error Code 19002): For account creation, ensure CompressibleConfig state is `Active` (1). For other operations (claim, withdraw, compress & close), ensure config state is not `Inactive` (0). Validate config state using `config.validate_active()` for creation and `config.validate_not_inactive()` for other operations.

Applied to files:

  • programs/registry/src/lib.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/registry/src/lib.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : CompressibleConfig account structure must support serialization via Anchor, Pinocchio, and Borsh formats for Light Registry program integration

Applied to files:

  • programs/registry/src/lib.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 : Use `validate_not_inactive()` method before executing claim or account closing operations on CompressibleConfig to prevent operations on deprecated or inactive configurations

Applied to files:

  • programs/registry/src/lib.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 state in Solana programs must validate active state using `validate_active()` method before allowing new compressible token account creation

Applied to files:

  • programs/registry/src/lib.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 PDA must be derived using seeds `[b"compressible_config", version.to_le_bytes()]` with the stored bump seed for deterministic account address generation in Light Protocol

Applied to files:

  • programs/registry/src/lib.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/**/instructions.rs : Compress/decompress instruction handlers and context struct generation should be implemented in `instructions.rs`, with compress using PDA-only and decompress supporting full PDA + ctoken

Applied to files:

  • programs/registry/src/lib.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 : When deserializing CompressibleConfig accounts, skip the 8-byte discriminator `[180, 4, 231, 26, 220, 144, 55, 168]` before deserialization in zero-copy implementations using bytemuck::pod_from_bytes

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement default initialization for CToken V1 config in CompressibleConfig structure

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-12-06T00:49:21.983Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:21.983Z
Learning: Applies to program-libs/compressible/src/config.rs : Implement PDA derivation methods (`derive_pda`, `derive_v1_config_pda`) on CompressibleConfig for account discovery

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Light Protocol accounts must satisfy both Solana rent exemption and Light Protocol rent requirements, plus an 11,000 lamport compression incentive during creation

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/decompress_context.rs : Decompression trait implementation (`DecompressContext`) with account accessors, PDA/token separation logic, and token processing delegation should be in `decompress_context.rs`

Applied to files:

  • programs/registry/src/lib.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/claim/*.rs,src/withdraw_funding_pool.rs} : Rent management instructions (Claim, WithdrawFundingPool) require validation that config is not INACTIVE (accepts ACTIVE or DEPRECATED states)

Applied to files:

  • programs/registry/src/lib.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: CompressibleConfig state field determines instruction availability: Active=all operations, Deprecated=no new creation, Inactive=completely disabled, and must be checked before instruction execution

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `calculate_rent_inner` as a generic helper function with INCLUDE_CURRENT const parameter to calculate rent components, returning (required_epochs, rent_per_epoch, epochs_paid, unutilized_lamports).

Applied to files:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `get_rent` function to calculate total rent across multiple epochs using: rent_curve_per_epoch * epochs.

Applied to files:

  • program-libs/compressible/src/rent/account_rent.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:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Use Solana's Rent sysvar to determine base exemption by calling rent.minimum_balance() with the account size in bytes

Applied to files:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T17:58:50.237Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/ACCOUNT_CHECKS.md:0-0
Timestamp: 2025-11-24T17:58:50.237Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/checks.rs : Implement `check_account_balance_is_rent_exempt` function to verify account size matches expected_size and account balance meets rent exemption requirement, returning rent exemption amount or errors `InvalidAccountSize` (20004), `InvalidAccountBalance` (20007), or `FailedBorrowRentSysvar` (20008)

Applied to files:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Applies to program-libs/compressible/docs/**/*.rs : Access Solana's Rent sysvar using the pattern: Rent::get().map_err() to handle potential borrow failures

Applied to files:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Applies to program-libs/compressible/docs/**/*rent*.rs : Implement `claimable_lamports` function to return None if account is compressible, otherwise return Some(amount) for completed epochs only (excluding current ongoing epoch).

Applied to files:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:36.663Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/RENT.md:0-0
Timestamp: 2025-11-24T18:00:36.663Z
Learning: Rent is calculated per epoch (432,000 slots). Accounts must maintain sufficient balance for all epochs since last claim.

Applied to files:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T18:00:48.449Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/SOLANA_RENT.md:0-0
Timestamp: 2025-11-24T18:00:48.449Z
Learning: Use epoch-based accounting (432,000 slots ≈ 2.5 days) instead of continuous time for Light Protocol rent collection

Applied to files:

  • program-libs/compressible/src/rent/account_rent.rs
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Depend on light-compressed-account crate for compressed account types and utilities

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Use light-merkle-tree-reference crate as dev dependency for reference implementation of indexed Merkle trees and generating constants

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-12-07T03:17:28.794Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.794Z
Learning: Applies to sdk-tests/sdk-ctoken-test/**/Cargo.toml : Use path references in Cargo.toml dependencies pointing to `/Users/ananas/dev/light-protocol2/sdk-libs/` for light-ctoken-sdk, light-ctoken-types, light-sdk, light-sdk-types, and light-program-test

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-12-06T00:50:31.314Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-06T00:50:31.314Z
Learning: Applies to sdk-libs/*/Cargo.toml : SDK libs must depend on program-libs, light-prover-client and external crates only; must not depend on programs without devenv feature

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-12-06T00:50:31.314Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-06T00:50:31.314Z
Learning: Applies to programs/*/Cargo.toml : Programs must depend on program-libs and external crates only; must not depend on sdk-libs without devenv feature

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 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/**/mod.rs : Module declaration should be kept in `mod.rs`

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Depend on light-merkle-tree-metadata crate for shared metadata structures

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 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/**/pack_unpack.rs : Pubkey compression logic and `PackedXxx` struct generation with Pack/Unpack trait implementations should be in `pack_unpack.rs`

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-12-07T03:17:28.794Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.794Z
Learning: Applies to sdk-tests/sdk-ctoken-test/**/Xargo.toml : Include Xargo.toml configuration file for Solana BPF build setup in native Solana programs

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-12-07T03:17:52.865Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/CLAUDE.md:0-0
Timestamp: 2025-12-07T03:17:52.865Z
Learning: Applies to sdk-tests/**/*.{rs,toml} : Set RUSTFLAGS environment variable to "-D warnings" for SDK tests compilation

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-11-24T17:55:09.533Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/fuzz/README.md:0-0
Timestamp: 2025-11-24T17:55:09.533Z
Learning: For the `struct_generation` fuzzer, run with `cargo +nightly fuzz run struct_generation` and support address sanitizer via `RUSTFLAGS="-Zsanitizer=address"`

Applied to files:

  • program-libs/compressible/Cargo.toml
📚 Learning: 2025-12-06T00:50:31.314Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-06T00:50:31.314Z
Learning: Use RUSTFLAGS="-D warnings" to fail on warnings when running Rust tests in CI

Applied to files:

  • program-libs/compressible/Cargo.toml
🧬 Code graph analysis (1)
program-libs/compressible/tests/consistency.rs (2)
sdk-libs/sdk/src/compressible/compression_info.rs (2)
  • compression_info (37-37)
  • last_claimed_slot (126-128)
program-libs/compressible/src/rent/account_rent.rs (3)
  • get_last_funded_epoch (202-233)
  • is_compressible (72-92)
  • epochs_funded_ahead (171-182)
⏰ 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). (11)
  • GitHub Check: Forester e2e test
  • GitHub Check: stateless-js-v2
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: lint
  • 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-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo test -p light-compressed-token", "cargo-test-sbf -p c...
  • 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...
🔇 Additional comments (10)
program-libs/compressible/Cargo.toml (1)

38-40: LGTM!

Adding rand as a dev-dependency via workspace reference is appropriate for the new randomized consistency tests. This follows the coding guideline that program-libs crates should only depend on program-libs or external crates.

program-libs/compressible/src/rent/account_rent.rs (4)

51-63: LGTM!

Hiding get_required_epochs behind the public get_completed_epochs() wrapper is clean design. The const generic parameter INCLUDE_ONGOING_EPOCH is an internal optimization detail that external callers shouldn't need to know about.


147-160: LGTM!

Making get_unused_lamports private is appropriate—callers should go through calculate_close_distribution which provides the complete picture of how lamports are split on account closure.


194-198: LGTM!

slot_to_epoch is a straightforward internal utility. Keeping it private ensures callers work with the higher-level rent calculation APIs rather than raw epoch math.


28-36: Good encapsulation: reducing visibility of internal helpers.

Making get_available_rent_balance, get_required_epochs, get_unused_lamports, and slot_to_epoch private is the right call—they are internal implementation details that should not be exposed as public API. No external code depends on these functions, and they remain accessible to other methods within the module.

program-libs/compressible/tests/consistency.rs (4)

23-75: LGTM!

The RentState struct provides a clean test harness for capturing all rent-related computations in one place. The from_account_rent_state method correctly exercises the public API of AccountRentState and CompressionInfo.

Using .unwrap() on line 63 is fine here—in a test context, a panic with a clear stack trace is appropriate for unexpected failures.


77-135: Good reference implementation for cross-checking rent logic.

The expected function provides an independent calculation of rent state, which is excellent for catching regressions. A few observations:

  1. Line 114 hardcodes max_funded_epochs = 2. If CompressionInfo changes this threshold, the test will fail—which is actually desirable behavior for catching unintended changes.

  2. The subtraction on line 87 assumes current_lamports >= rent_exemption_lamports + FULL_COMPRESSION_COSTS. In your test setup this is guaranteed, but the actual implementation uses saturating_sub for safety.


235-240: LGTM!

The balance invariant assertion is the correct way to verify that no lamports are created or destroyed during the rent cycle. This catches any accounting bugs in the claim/top-up logic.


11-17: RENT_PER_EPOCH constant is correct.

The constant RENT_PER_EPOCH = 260 + 128 = 388 correctly matches RentConfig::default().rent_curve_per_epoch(260). With BASE_RENT = 128 and RENT_PER_BYTE = 1, the formula base_rent + (num_bytes * lamports_per_byte_per_epoch) yields 128 + (260 * 1) = 388. No changes needed.

Likely an incorrect or invalid review comment.

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

65-65: Good move to use CompressibleConfigState instead of magic numbers

Importing CompressibleConfigState and using its discriminants to drive the state field removes hard‑coded numeric states and directly reflects the on‑chain state machine described in the compressible docs. This also addresses the earlier feedback about defining a const/enum for state.

@ananas-block ananas-block merged commit 7deedcd into main Dec 8, 2025
32 checks passed
@ananas-block ananas-block deleted the jorrit/fix-registry-error branch December 8, 2025 18:52
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.

2 participants