Skip to content

fix: registry compressible instructions#2050

Merged
SwenSchaeferjohann merged 3 commits into
mainfrom
jorrit/fix-registry-compressible-instructions
Nov 13, 2025
Merged

fix: registry compressible instructions#2050
SwenSchaeferjohann merged 3 commits into
mainfrom
jorrit/fix-registry-compressible-instructions

Conversation

@ananas-block
Copy link
Copy Markdown
Contributor

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

Summary by CodeRabbit

  • Refactor
    • Simplified function signatures for configuration management by consolidating parameters into transaction context.
    • Authority updates now processed through optional account signers rather than function parameters, streamlining the configuration update workflow.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 11, 2025

Walkthrough

The pull request refactors how authority updates are handled in the registry program. Optional signer accounts (new_update_authority and new_withdrawal_authority) are moved from function parameters to context account fields, and the unnecessary System program requirement is removed from the UpdateCompressibleConfig struct.

Changes

Cohort / File(s) Summary
Authority Account Migration
programs/registry/src/compressible/update_config.rs
Removed system_program: Program<'info, System> field; added new_update_authority: Option<Signer<'info>> and new_withdrawal_authority: Option<Signer<'info>> as optional signer fields with documentation notes.
Function Signature Refactoring
programs/registry/src/lib.rs
Updated create_config_counter to accept only Context<CreateConfigCounter> (removed CreateConfigCounterData parameter); updated update_compressible_config to accept only Context<UpdateCompressibleConfig> (removed explicit Option<Pubkey> parameters); authority values now sourced from context accounts via .key() method instead of function parameters.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant update_compressible_config as update_compressible_config
    participant ctx as Context
    participant config as Config State

    rect rgb(220, 230, 255)
    Note over Caller,config: Before: Parameters Passed Directly
    Caller->>update_compressible_config: Call with new_update_authority: Option<Pubkey>
    Caller->>update_compressible_config: Call with new_withdrawal_authority: Option<Pubkey>
    update_compressible_config->>config: Write param directly to update_authority
    end

    rect rgb(230, 255, 220)
    Note over Caller,config: After: Signers in Accounts
    Caller->>ctx: Include new_update_authority: Option<Signer>
    Caller->>ctx: Include new_withdrawal_authority: Option<Signer>
    update_compressible_config->>ctx: Read ctx.accounts.new_update_authority.as_ref()
    ctx->>update_compressible_config: Return optional Signer reference
    update_compressible_config->>config: Write account.key() to update_authority
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Account structure changes: Verify the Option<Signer<'info>> fields are properly documented and that optional semantics align with intended upgrade paths.
  • Authority validation flow: Trace how .as_ref() and .key() are used to ensure signers are correctly validated and their public keys are persisted without introducing gaps in access control.
  • System program removal: Confirm no downstream logic depends on the System program being available in the accounts context.
  • Consistency check: Ensure parameter removal from create_config_counter and update_compressible_config doesn't break callers in other modules or tests.

Poem

Authorities in accounts now dwell,
No parameters to remember or tell,
Signers guard the gates with care,
Optional and precise, a safer affair.
System program bids farewell, ✨
The context now holds what before was passed well.

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 'fix: registry compressible instructions' directly relates to the main changes in the PR, which refactor the registry's compressible config update instructions by moving parameters into context accounts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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-compressible-instructions

📜 Recent 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 e1fa0bf and 23cdf4c.

⛔ Files ignored due to path filters (1)
  • program-tests/registry-test/tests/compressible.rs is excluded by none and included by none
📒 Files selected for processing (2)
  • programs/registry/src/compressible/update_config.rs (1 hunks)
  • programs/registry/src/lib.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
programs/registry/src/lib.rs

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

programs/registry/src/lib.rs: Wrapper instruction handlers must: (1) load the target account metadata; (2) call check_forester with correct authority, target, forester PDA (optional), and computed work_units; (3) delegate via a CPI using a PDA signer.
Instruction handlers must compute work_units by operation type: batch operations use account.queue_batches.batch_size; single operations use DEFAULT_WORK_V1; custom operations compute based on complexity.
Load accounts according to type before check_forester: batched via BatchedMerkleTreeAccount::type_from_account_info(); regular via ctx.accounts.account.load()?.metadata; use custom deserialization when required.
Apply forester eligibility rules: with a forester PDA, validate epoch registration, eligibility, track work, and require network fee; without a forester PDA, ensure authority matches the tree’s designated forester.

Files:

  • programs/registry/src/lib.rs
🧠 Learnings (19)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:55.362Z
Learning: Applies to programs/compressed-token/program/src/transfer2/native_compression/** : Compress & Close operations (via registry) must validate that the config state is not INACTIVE (active or deprecated allowed)
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/**/*.rs : CPI processing functions must derive PDA signer seeds as [CPI_AUTHORITY_PDA_SEED, bump] and use CpiContext::new_with_signer with cpi_authority as the authority account and mapped target accounts.
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Each new operation module must define an Anchor context struct (e.g., NewOperationContext) with required accounts and a process_<operation> function that prepares signer seeds, maps accounts to the target program, and executes the CPI.
📚 Learning: 2025-10-15T03:46:26.767Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-10-15T03:46:26.767Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Context structs for wrapper instructions must include standard accounts: optional registered_forester_pda (mut), authority Signer, cpi_authority with seeds/bump for CPI_AUTHORITY_PDA_SEED, registered_program_pda, target program handle, log_wrapper, and mutable target_account.

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • programs/registry/src/lib.rs
📚 Learning: 2025-10-16T06:33:19.426Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-10-16T06:33:19.426Z
Learning: Applies to program-libs/compressible/src/config.rs : Provide PDA derivation helpers (derive_pda, derive_v1_config_pda) in src/config.rs for CompressibleConfig

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • programs/registry/src/lib.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: Forester e2e test
  • GitHub Check: system-programs (sdk-libs, light-sdk-macros light-sdk light-program-test light-client light-compr...
  • GitHub Check: system-programs (token test, ["cargo-test-sbf -p sdk-token-test"])
  • GitHub Check: system-programs (anchor & pinocchio, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -p sdk...
  • GitHub Check: lint
  • GitHub Check: system-programs (native, ["cargo-test-sbf -p sdk-native-test", "cargo-test-sbf -p sdk-v1-native-t...
  • GitHub Check: programs (compressed-token-batched-tree, ["cargo-test-sbf -p compressed-token-test -- test_transf...
  • GitHub Check: programs (account-compression-and-registry, ["cargo-test-sbf -p account-compression-test", "cargo...
  • GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
  • GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
  • GitHub Check: programs (light-system-program-compression, ["cargo-test-sbf -p system-test -- test_with_compress...
  • GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
  • GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
  • GitHub Check: programs (light-system-program-address, ["cargo-test-sbf -p system-test -- test_with_address", "c...
  • GitHub Check: cli-v2
  • GitHub Check: stateless-js-v1
  • GitHub Check: cli-v1
  • GitHub Check: stateless-js-v2
🔇 Additional comments (3)
programs/registry/src/compressible/update_config.rs (1)

19-23: Excellent refactor: Optional signers improve safety.

This change correctly moves the new authorities from function parameters to optional signer fields in the context. Requiring the new authorities to sign prevents accidental updates to incorrect pubkeys—a meaningful security improvement over accepting raw Pubkey parameters.

The removal of system_program is also correct, as this instruction performs no account initialization or SOL transfers.

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

691-693: LGTM: Signature simplified.

The function signature correctly consolidates inputs into the context struct, following standard Anchor patterns. The logic remains unchanged.


715-727: LGTM: Authority updates correctly implemented.

The refactored implementation correctly:

  1. Requires the current update_authority to sign (via has_one constraint in the context)
  2. Requires new authorities to sign if provided (via Option<Signer<'info>>)
  3. Uses as_ref() to safely check optional signers and extract their keys

This dual-signature pattern meaningfully improves security by ensuring both the current and new authority consent to the transfer.


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

Copy link
Copy Markdown
Contributor

@SwenSchaeferjohann SwenSchaeferjohann left a comment

Choose a reason for hiding this comment

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

LGTM

@SwenSchaeferjohann SwenSchaeferjohann merged commit bae9746 into main Nov 13, 2025
29 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants