Skip to content

refactor: light-sdks detach account metas from account infos#1848

Merged
ananas-block merged 3 commits intomainfrom
jorrit/refactor-sdk-detach-metas-from-account-infos
Jul 7, 2025
Merged

refactor: light-sdks detach account metas from account infos#1848
ananas-block merged 3 commits intomainfrom
jorrit/refactor-sdk-detach-metas-from-account-infos

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Jul 1, 2025

Summary by CodeRabbit

  • New Features

    • Introduced new public constants for account authorities and discriminators.
    • Expanded error handling with new error types and more descriptive error messages.
  • Refactor

    • Improved account validation by making account constructors fallible and enforcing stricter checks.
    • Updated account metadata construction for more explicit configuration and improved clarity.
    • Enhanced error propagation and validation throughout account creation and CPI logic.
  • Chores

    • Added a new dependency to support additional functionality.
  • Style

    • Minor updates to trait bounds and import statements for improved code clarity.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 1, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update refactors the construction and validation of CPI account structures across the SDK, tests, and example programs. It replaces infallible constructors with fallible ones that return Result, introduces stricter validation and new error variants, and modularizes account meta construction through configuration objects and conversion traits. Several new constants and error codes are added.

Changes

Files/Paths Change Summary
sdk-libs/sdk-types/src/cpi_accounts.rs Replaces infallible new/new_with_config with fallible try_new/try_new_with_config, adding strict validation and error returns.
sdk-libs/sdk-types/src/error.rs, sdk-libs/sdk-pinocchio/src/error.rs, sdk-libs/sdk/src/error.rs Adds new error variants for stricter validation, updates error code mappings, and integrates AccountError from light_account_checks.
sdk-libs/sdk-types/src/constants.rs Adds new public constants for program IDs and discriminators.
sdk-libs/sdk-types/Cargo.toml Adds solana-msg as a new dependency.
sdk-libs/sdk/src/cpi/accounts.rs Refactors account meta construction to use a configuration struct; adds TryFrom for CpiAccounts to config.
sdk-libs/sdk/src/cpi/invoke.rs Refactors to use new config-based account meta construction; updates function signatures for explicit lifetimes and types.
program-libs/account-checks/src/account_info/account_info_trait.rs Adds Debug bound to Pubkey associated type in AccountInfoTrait.
examples/anchor/token-escrow/src/escrow_with_compressed_pda/escrow.rs,
examples/anchor/token-escrow/src/escrow_with_compressed_pda/withdrawal.rs,
program-tests/create-address-test-program/src/lib.rs,
program-tests/sdk-pinocchio-test/src/create_pda.rs,
program-tests/sdk-pinocchio-test/src/update_pda.rs,
program-tests/sdk-test/src/create_pda.rs,
program-tests/sdk-test/src/update_pda.rs
Updates all usages of CpiAccounts::new_with_config to try_new_with_config, handling errors with unwrap() or ? for propagation.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant CpiAccounts
    participant Error

    Caller->>CpiAccounts: try_new_with_config(...)
    alt Validation passes
        CpiAccounts-->>Caller: Ok(CpiAccounts)
    else Validation fails
        CpiAccounts-->>Error: Return specific error variant
        Error-->>Caller: Err(LightSdkTypesError)
    end
Loading
sequenceDiagram
    participant CpiAccounts
    participant CpiInstructionConfig
    participant get_account_metas_from_config

    CpiAccounts->>CpiInstructionConfig: TryFrom<&CpiAccounts>
    CpiInstructionConfig-->>get_account_metas_from_config: get_account_metas_from_config(config)
    get_account_metas_from_config-->>CpiInstructionConfig: Vec<AccountMeta>
Loading

Possibly related PRs

  • Lightprotocol/light-protocol#1795: Refactors CpiAccounts constructors to be fallible, enforcing validation and error propagation, which directly aligns with this PR’s changes.
  • Lightprotocol/light-protocol#1746: Introduces version 2 support with try_new_with_config methods and enhanced CPI account validation, closely related to this PR’s modifications.

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

In fields of code where rabbits hop,
New errors bloom, old panics stop.
Constructors check, configs guide,
Account metas built with pride.
Constants shine, new types appear—
The protocol’s future is bright and clear!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9b1d47 and 9818fe7.

📒 Files selected for processing (1)
  • sdk-libs/sdk-pinocchio/src/error.rs (4 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ananas-block ananas-block force-pushed the jorrit/refactor-sdk-detach-metas-from-account-infos branch from 6b12c7a to 12f5cfd Compare July 1, 2025 02:08
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: 0

🧹 Nitpick comments (1)
sdk-libs/sdk/src/cpi/accounts.rs (1)

26-134: Optimize performance by avoiding unnecessary clones

The function logic is correct and well-documented, but there's a performance issue with cloning light_system_program_meta multiple times.

Consider this optimization to avoid repeated clones:

-    // 8. Light System Program (readonly)
-    let light_system_program_meta = AccountMeta {
-        pubkey: Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID),
-        is_signer: false,
-        is_writable: false,
-    };
+    // 8. Light System Program (readonly) - reused for optional accounts
+    let light_system_program_pubkey = Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID);
+    
+    let create_light_system_meta = || AccountMeta {
+        pubkey: light_system_program_pubkey,
+        is_signer: false,
+        is_writable: false,
+    };

     // 9. Sol Pool PDA (writable) OR Light System Program (readonly)
     if let Some(sol_pool_pda_pubkey) = config.sol_pool_pda_pubkey {
         account_metas.push(AccountMeta {
             pubkey: sol_pool_pda_pubkey,
             is_signer: false,
             is_writable: true,
         });
     } else {
-        account_metas.push(light_system_program_meta.clone());
+        account_metas.push(create_light_system_meta());
     }

     // 10. Sol Compression Recipient (writable) OR Light System Program (readonly)
     if let Some(sol_compression_recipient_pubkey) = config.sol_compression_recipient_pubkey {
         account_metas.push(AccountMeta {
             pubkey: sol_compression_recipient_pubkey,
             is_signer: false,
             is_writable: true,
         });
     } else {
-        account_metas.push(light_system_program_meta.clone());
+        account_metas.push(create_light_system_meta());
     }

     // Skip to line 122...
     } else {
-        account_metas.push(light_system_program_meta);
+        account_metas.push(create_light_system_meta());
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b12c7a and 12f5cfd.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/escrow.rs (1 hunks)
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/withdrawal.rs (1 hunks)
  • program-libs/account-checks/src/account_info/account_info_trait.rs (1 hunks)
  • program-tests/create-address-test-program/src/lib.rs (2 hunks)
  • program-tests/sdk-pinocchio-test/src/create_pda.rs (1 hunks)
  • program-tests/sdk-pinocchio-test/src/update_pda.rs (1 hunks)
  • program-tests/sdk-test/src/create_pda.rs (1 hunks)
  • program-tests/sdk-test/src/update_pda.rs (1 hunks)
  • sdk-libs/sdk-pinocchio/src/error.rs (4 hunks)
  • sdk-libs/sdk-types/Cargo.toml (1 hunks)
  • sdk-libs/sdk-types/src/constants.rs (2 hunks)
  • sdk-libs/sdk-types/src/cpi_accounts.rs (2 hunks)
  • sdk-libs/sdk-types/src/error.rs (3 hunks)
  • sdk-libs/sdk/src/cpi/accounts.rs (1 hunks)
  • sdk-libs/sdk/src/cpi/invoke.rs (6 hunks)
  • sdk-libs/sdk/src/error.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (15)
  • program-tests/sdk-pinocchio-test/src/create_pda.rs
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/escrow.rs
  • sdk-libs/sdk-types/Cargo.toml
  • program-tests/sdk-test/src/create_pda.rs
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/withdrawal.rs
  • program-tests/sdk-test/src/update_pda.rs
  • program-libs/account-checks/src/account_info/account_info_trait.rs
  • program-tests/sdk-pinocchio-test/src/update_pda.rs
  • program-tests/create-address-test-program/src/lib.rs
  • sdk-libs/sdk/src/cpi/invoke.rs
  • sdk-libs/sdk-types/src/constants.rs
  • sdk-libs/sdk-types/src/error.rs
  • sdk-libs/sdk/src/error.rs
  • sdk-libs/sdk-types/src/cpi_accounts.rs
  • sdk-libs/sdk-pinocchio/src/error.rs
⏰ Context from checks skipped due to timeout of 90000ms (23)
  • GitHub Check: cli-v1
  • GitHub Check: cli-v2
  • GitHub Check: lint
  • GitHub Check: system-programs (sdk-test-program, ["cargo-test-sbf -p sdk-test"])
  • GitHub Check: system-programs (counter-test, ["cargo test-sbf -p counter"])
  • GitHub Check: system-programs (sdk-anchor-test-program, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -...
  • GitHub Check: system-programs (token-escrow-test, [ "cargo test-sbf -p token-escrow" ])
  • GitHub Check: stateless-js-v1
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test concurrent-merkle-tree
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test sdk-libs
  • GitHub Check: Test program-libs-fast
  • GitHub Check: stateless-js-v2
  • GitHub Check: system-programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test"])
  • GitHub Check: system-programs (random-e2e-test, ["cargo-test-sbf -p e2e-test"])
  • GitHub Check: system-programs (system-cpi-test-v2-other, ["cargo-test-sbf -p system-cpi-v2-test -- --skip funct...
  • GitHub Check: system-programs (system-cpi-test-v2-functional, ["cargo-test-sbf -p system-cpi-v2-test -- functio...
  • GitHub Check: system-programs (light-compressed-token, ["cargo-test-sbf -p compressed-token-test"])
  • GitHub Check: system-programs (account-compression, ["cargo-test-sbf -p account-compression-test"])
  • GitHub Check: system-programs (light-system-program, ["cargo-test-sbf -p system-test"])
  • GitHub Check: system-programs (system-cpi-test-v2-event, ["cargo-test-sbf -p system-cpi-v2-test -- event::parse"])
  • GitHub Check: system-programs (light-registry, ["cargo-test-sbf -p registry-test"])
🔇 Additional comments (3)
sdk-libs/sdk/src/cpi/accounts.rs (3)

2-6: LGTM: Clean import organization

The additional imports are well-organized and necessary for the new functionality. The explicit import of constants improves code readability.


13-22: Well-designed configuration struct

The CpiInstructionConfig struct provides a clean separation of configuration data from conversion logic. The use of optional pubkeys for conditional accounts is elegant and type-safe.


136-162: Robust error handling in conversion trait

The TryFrom implementation correctly handles the conversion from CpiAccounts to CpiInstructionConfig with proper error propagation. The logic appropriately checks configuration flags before attempting to access optional accounts.

@ananas-block ananas-block force-pushed the jorrit/refactor-sdk-detach-metas-from-account-infos branch from 12f5cfd to 0ad4311 Compare July 1, 2025 02:35
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: 0

🧹 Nitpick comments (1)
sdk-libs/sdk/src/cpi/accounts.rs (1)

26-134: Excellent implementation with detailed documentation

The function is well-structured with clear account ordering and comprehensive comments. The performance optimization using Vec::with_capacity and proper handling of optional accounts with fallback to light_system_program_meta is good practice.

Minor optimization opportunity: Consider reducing the repeated cloning of light_system_program_meta:

-    // 8. Light System Program (readonly)
-    let light_system_program_meta = AccountMeta {
-        pubkey: Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID),
-        is_signer: false,
-        is_writable: false,
-    };
+    // 8. Light System Program (readonly) - reused as fallback
+    let light_system_program_meta = &AccountMeta {
+        pubkey: Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID),
+        is_signer: false,
+        is_writable: false,
+    };

Then use *light_system_program_meta instead of .clone() calls.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12f5cfd and 0ad4311.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/escrow.rs (1 hunks)
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/withdrawal.rs (1 hunks)
  • program-libs/account-checks/src/account_info/account_info_trait.rs (1 hunks)
  • program-tests/create-address-test-program/src/lib.rs (2 hunks)
  • program-tests/sdk-pinocchio-test/src/create_pda.rs (1 hunks)
  • program-tests/sdk-pinocchio-test/src/update_pda.rs (1 hunks)
  • program-tests/sdk-test/src/create_pda.rs (1 hunks)
  • program-tests/sdk-test/src/update_pda.rs (1 hunks)
  • sdk-libs/sdk-pinocchio/src/error.rs (4 hunks)
  • sdk-libs/sdk-types/Cargo.toml (1 hunks)
  • sdk-libs/sdk-types/src/constants.rs (2 hunks)
  • sdk-libs/sdk-types/src/cpi_accounts.rs (3 hunks)
  • sdk-libs/sdk-types/src/error.rs (3 hunks)
  • sdk-libs/sdk/src/cpi/accounts.rs (1 hunks)
  • sdk-libs/sdk/src/cpi/invoke.rs (6 hunks)
  • sdk-libs/sdk/src/error.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (15)
  • sdk-libs/sdk-types/Cargo.toml
  • program-tests/sdk-pinocchio-test/src/update_pda.rs
  • program-tests/sdk-test/src/update_pda.rs
  • program-libs/account-checks/src/account_info/account_info_trait.rs
  • program-tests/sdk-test/src/create_pda.rs
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/escrow.rs
  • program-tests/sdk-pinocchio-test/src/create_pda.rs
  • examples/anchor/token-escrow/src/escrow_with_compressed_pda/withdrawal.rs
  • program-tests/create-address-test-program/src/lib.rs
  • sdk-libs/sdk-types/src/constants.rs
  • sdk-libs/sdk-types/src/error.rs
  • sdk-libs/sdk/src/cpi/invoke.rs
  • sdk-libs/sdk-types/src/cpi_accounts.rs
  • sdk-libs/sdk-pinocchio/src/error.rs
  • sdk-libs/sdk/src/error.rs
⏰ Context from checks skipped due to timeout of 90000ms (24)
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test concurrent-merkle-tree
  • GitHub Check: Test sdk-libs
  • GitHub Check: system-programs (system-cpi-test-v2-event, ["cargo-test-sbf -p system-cpi-v2-test -- event::parse"])
  • GitHub Check: system-programs (system-cpi-test-v2-functional, ["cargo-test-sbf -p system-cpi-v2-test -- functio...
  • GitHub Check: system-programs (system-cpi-test-v2-other, ["cargo-test-sbf -p system-cpi-v2-test -- --skip funct...
  • GitHub Check: system-programs (account-compression, ["cargo-test-sbf -p account-compression-test"])
  • GitHub Check: system-programs (random-e2e-test, ["cargo-test-sbf -p e2e-test"])
  • GitHub Check: system-programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test"])
  • GitHub Check: system-programs (light-compressed-token, ["cargo-test-sbf -p compressed-token-test"])
  • GitHub Check: system-programs (light-system-program, ["cargo-test-sbf -p system-test"])
  • GitHub Check: system-programs (light-registry, ["cargo-test-sbf -p registry-test"])
  • GitHub Check: lint
  • GitHub Check: stateless-js-v1
  • GitHub Check: cli-v1
  • GitHub Check: system-programs (sdk-test-program, ["cargo-test-sbf -p sdk-test"])
  • GitHub Check: cli-v2
  • GitHub Check: system-programs (counter-test, ["cargo test-sbf -p counter"])
  • GitHub Check: system-programs (sdk-anchor-test-program, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -...
  • GitHub Check: system-programs (token-escrow-test, [ "cargo test-sbf -p token-escrow" ])
  • GitHub Check: stateless-js-v2
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
sdk-libs/sdk/src/cpi/accounts.rs (3)

2-6: LGTM: Clean import organization

The imports are well-organized and include all necessary constants and types for the refactored functionality.


13-22: LGTM: Well-designed configuration struct

The CpiInstructionConfig struct appropriately separates configuration data from conversion logic. The use of Option<Pubkey> for optional accounts and lifetime parameters for borrowed data is correct.


136-162: Verify consistency of cpi_signer access

I wasn’t able to locate the definition of config() on CpiAccounts<'a, 'info> or its return type in the codebase. Please confirm that:

  • The config() method on CpiAccounts returns a type defining both:
    • A cpi_signer() method (for retrieving the signer key)
    • A cpi_signer field (with a .program_id for the invoking program)
  • Using the method for the signer key and the field for the program ID is intentional and correct
  • If this mix is unintended, consider unifying the access pattern for clarity

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

🧹 Nitpick comments (1)
sdk-libs/sdk/src/cpi/accounts.rs (1)

26-134: Improve vector capacity calculation for better performance.

The vector capacity calculation 1 + SYSTEM_ACCOUNTS_LEN may not accurately reflect the actual number of accounts that will be added, especially considering optional accounts and variable-length packed accounts. This could lead to unnecessary reallocations.

Consider calculating a more accurate initial capacity:

-    let mut account_metas = Vec::with_capacity(1 + SYSTEM_ACCOUNTS_LEN);
+    let base_accounts = 1 + SYSTEM_ACCOUNTS_LEN;
+    let optional_accounts = [
+        config.sol_pool_pda_pubkey.is_some(),
+        config.sol_compression_recipient_pubkey.is_some(), 
+        config.cpi_context_pubkey.is_some()
+    ].iter().count();
+    let mut account_metas = Vec::with_capacity(base_accounts + optional_accounts + config.packed_accounts.len());

The rest of the function implementation is well-structured with clear comments and proper conditional logic for optional accounts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ad4311 and a9b1d47.

📒 Files selected for processing (2)
  • sdk-libs/sdk-types/src/cpi_accounts.rs (4 hunks)
  • sdk-libs/sdk/src/cpi/accounts.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • sdk-libs/sdk-types/src/cpi_accounts.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). (23)
  • GitHub Check: system-programs (system-cpi-test-v2-event, ["cargo-test-sbf -p system-cpi-v2-test -- event::parse"])
  • GitHub Check: system-programs (random-e2e-test, ["cargo-test-sbf -p e2e-test"])
  • GitHub Check: cli-v1
  • GitHub Check: system-programs (system-cpi-test-v2-functional, ["cargo-test-sbf -p system-cpi-v2-test -- functio...
  • GitHub Check: system-programs (light-system-program, ["cargo-test-sbf -p system-test"])
  • GitHub Check: system-programs (system-cpi-test-v2-other, ["cargo-test-sbf -p system-cpi-v2-test -- --skip funct...
  • GitHub Check: system-programs (light-registry, ["cargo-test-sbf -p registry-test"])
  • GitHub Check: system-programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test"])
  • GitHub Check: system-programs (light-compressed-token, ["cargo-test-sbf -p compressed-token-test"])
  • GitHub Check: lint
  • GitHub Check: system-programs (account-compression, ["cargo-test-sbf -p account-compression-test"])
  • GitHub Check: cli-v2
  • GitHub Check: stateless-js-v2
  • GitHub Check: stateless-js-v1
  • GitHub Check: Test sdk-libs
  • GitHub Check: system-programs (sdk-test-program, ["cargo-test-sbf -p sdk-test"])
  • GitHub Check: system-programs (token-escrow-test, [ "cargo test-sbf -p token-escrow" ])
  • GitHub Check: system-programs (sdk-anchor-test-program, ["cargo-test-sbf -p sdk-anchor-test", "cargo-test-sbf -...
  • GitHub Check: system-programs (counter-test, ["cargo test-sbf -p counter"])
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test concurrent-merkle-tree
  • GitHub Check: Test batched-merkle-tree-simulate
🔇 Additional comments (3)
sdk-libs/sdk/src/cpi/accounts.rs (3)

2-6: LGTM! Imports support the new CPI account configuration.

The new imports are appropriate for the refactored CPI account handling functionality.


13-22: Well-designed configuration struct.

The CpiInstructionConfig struct effectively separates configuration data from conversion logic. The use of lifetime parameters and optional pubkeys provides appropriate flexibility for different CPI scenarios.


136-162: Excellent TryFrom implementation with proper error handling.

The conversion logic correctly extracts all necessary data from CpiAccounts and handles optional accounts appropriately. The use of the ? operator for error propagation and unwrap_or(&[]) for safe defaults demonstrates good error handling practices.

Co-authored-by: Swen Schäferjohann <42959314+SwenSchaeferjohann@users.noreply.github.com>
@ananas-block ananas-block merged commit a3d85fc into main Jul 7, 2025
29 of 31 checks passed
@ananas-block ananas-block deleted the jorrit/refactor-sdk-detach-metas-from-account-infos branch July 7, 2025 22:40
@coderabbitai coderabbitai bot mentioned this pull request Sep 21, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 18, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 18, 2026
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