Skip to content

fix: macro deps#2231

Merged
ananas-block merged 2 commits intomainfrom
jorrit/fix-macro-deps
Feb 4, 2026
Merged

fix: macro deps#2231
ananas-block merged 2 commits intomainfrom
jorrit/fix-macro-deps

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Feb 4, 2026

  1. Framework-aware pubkey path generation in macros - Updated seed_codegen.rs, seed_utils.rs, visitors.rs to accept is_pinocchio parameter and use
    light_account_pinocchio::solana_pubkey::Pubkey for pinocchio programs instead of bare solana_pubkey::Pubkey
  2. Framework-specific PDA derivation - Modified decompress.rs to use pinocchio::pubkey::find_program_address and [u8; 32] types for pinocchio, vs solana_pubkey::Pubkey methods for
    Anchor
  3. Fixed variant Pack trait implementations - Updated variant_enum.rs and accounts/variant.rs to use fully qualified light_account_pinocchio::solana_instruction::AccountMeta and
    light_account_pinocchio::solana_pubkey::Pubkey paths for pinocchio code
  4. Updated RentConfig path - Changed from light_compressible::rent::RentConfig to light_account_pinocchio::rent::RentConfig in generated InitConfigParams
  5. Added re-exports to light-account-pinocchio - Re-exported CompressedCpiContext, InstructionDataInvokeCpiWithAccountInfo, pubkey_array, and extern crates
    solana_instruction/solana_pubkey (gated by std feature)
  6. Cleaned up test dependencies - Moved client-only dependencies (solana_pubkey, solana_instruction, light_sdk_types, light_compressed_account, etc.) from regular to dev-dependencies
    in pinocchio-light-program-test
  7. Updated test imports - Changed test files to import re-exported types from light_account_pinocchio instead of direct crate imports
  8. Added cfg guards to client functions - Wrapped generated __client_seed_functions module and its re-exports with #[cfg(not(target_os = "solana"))]

Summary by CodeRabbit

  • New Features

    • Expanded SDK public exports: CompressedCpiContext and InstructionDataInvokeCpiWithAccountInfo now available for macro-generated client code.
    • Added pubkey_array macro export for enhanced key handling.
    • Conditionally exported solana_instruction and solana_pubkey crates when the std feature is enabled, supporting broader runtime environments.
  • Updates

    • Enhanced SDK framework compatibility with improved type path resolution for different runtime contexts.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

This PR introduces framework-aware codegen in the macro system to support both Solana and Pinocchio SDK frameworks. It adds new public re-exports for Pinocchio types in account-pinocchio, threads an is_pinocchio boolean parameter through seed generation pipelines, and conditionally uses light_account_pinocchio::solana_pubkey or solana_pubkey::Pubkey paths based on target framework.

Changes

Cohort / File(s) Summary
Account-Pinocchio Public API
sdk-libs/account-pinocchio/src/lib.rs
Consolidated re-exports for instruction data types (CompressedCpiContext, InstructionDataInvokeCpiWithAccountInfo), macro exports (pubkey_array), and added conditional std-feature exports for solana_instruction and solana_pubkey.
Macro Type Path Qualifications
sdk-libs/macros/src/light_pdas/accounts/variant.rs, sdk-libs/macros/src/light_pdas/program/variant_enum.rs
Updated trait impls and type references to qualify AccountMeta and Pubkey with light_account_pinocchio:: prefix, affecting Pack trait signatures and PDA seed handling.
Framework-Aware PDA & Seed Codegen
sdk-libs/macros/src/light_pdas/program/decompress.rs, sdk-libs/macros/src/light_pdas/program/seed_codegen.rs, sdk-libs/macros/src/light_pdas/program/seed_utils.rs
Introduced is_pinocchio parameter to conditionally branch PDA derivation logic and Pubkey type selection; Pinocchio path uses pinocchio::pubkey::find_program_address while non-Pinocchio uses solana_pubkey::Pubkey::find_program_address.
Seed Generation Integration
sdk-libs/macros/src/light_pdas/program/instructions.rs, sdk-libs/macros/src/light_pdas/program/visitors.rs
Plumbed is_pinocchio flag through function calls; updated rent config type path to light_account_pinocchio::rent::RentConfig in Pinocchio path; threaded framework context into visitor AST transformations for consistent type emission.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: pinocchio sdk #1783: Introduces Pinocchio SDK foundation with macro re-exports (CompressedCpiContext, InstructionDataInvokeCpiWithAccountInfo, pubkey_array) and type path adjustments that align directly with this PR's public API changes.
  • fix: sdk macros #2190: Modifies the same macro codegen files (decompress.rs, instructions.rs) for PDA and seed generation, indicating related framework-specific codegen work.
  • feat: light account (pinocchio) #2230: Introduces the light-account-pinocchio crate that this PR imports from extensively; this PR's type qualifications depend on that crate's module structure.

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

🎯 Two paths diverge in frameworks vast,
Pinocchio and Solana dancing—
One is_pinocchio bool to bind them fast,
Type paths conditional, types advancing! 📚✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: macro deps' is vague and does not clearly convey the scope of changes, which involve refactoring public re-exports, updating macro code generation paths for Pinocchio vs. Anchor frameworks, and modifying trait implementations across multiple files. Consider a more specific title such as 'refactor: qualify Pinocchio types in macro codegen and exports' or 'fix: support Pinocchio framework in macro-generated code' to better reflect the substantial architectural changes.
✅ 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%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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-macro-deps

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

@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.

drive-by approve

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

Caution

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

⚠️ Outside diff range comments (1)
sdk-libs/macros/src/light_pdas/program/decompress.rs (1)

620-651: ⚠️ Potential issue | 🟠 Major

Apply cfg-gating to pinocchio PDA derivation for off-chain fallback.

The generated code calls pinocchio::pubkey::find_program_address() directly without cfg-gating, which is unavailable off-chain. This breaks client-side seed derivation for pinocchio programs. Use the established pattern from AccountInfoTrait in program-libs/account-checks/src/account_info/pinocchio.rs: guard pinocchio functions with #[cfg(target_os = "solana")] and fall back to solana_pubkey::Pubkey::find_program_address() for off-chain builds with the solana feature.

Suggested fix: cfg-gated pinocchio vs off-chain PDA derivation
-    let pda_derivation = if is_pinocchio {
-        quote! {
-            let (pda, bump) = pinocchio::pubkey::find_program_address(seeds, program_id);
-        }
-    } else {
-        quote! {
-            let program_id_pubkey = solana_pubkey::Pubkey::from(*program_id);
-            let (pda, bump) = solana_pubkey::Pubkey::find_program_address(seeds, &program_id_pubkey);
-        }
-    };
-
-    let pda_to_bytes = if is_pinocchio {
-        quote! { pda }
-    } else {
-        quote! { pda.to_bytes() }
-    };
+    let pda_derivation = if is_pinocchio {
+        quote! {
+            #[cfg(target_os = "solana")]
+            let (pda, bump) = pinocchio::pubkey::find_program_address(seeds, program_id);
+            #[cfg(not(target_os = "solana"))]
+            let (pda, bump) = solana_pubkey::Pubkey::find_program_address(
+                seeds,
+                &solana_pubkey::Pubkey::from(*program_id),
+            );
+            #[cfg(target_os = "solana")]
+            let pda_bytes = pda;
+            #[cfg(not(target_os = "solana"))]
+            let pda_bytes = pda.to_bytes();
+        }
+    } else {
+        quote! {
+            let program_id_pubkey = solana_pubkey::Pubkey::from(*program_id);
+            let (pda, bump) = solana_pubkey::Pubkey::find_program_address(seeds, &program_id_pubkey);
+        }
+    };
+
+    let pda_to_bytes = if is_pinocchio {
+        quote! { pda_bytes }
+    } else {
+        quote! { pda.to_bytes() }
+    };

@ananas-block ananas-block merged commit 56b3091 into main Feb 4, 2026
25 checks passed
@ananas-block ananas-block deleted the jorrit/fix-macro-deps branch February 4, 2026 11:56
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