Conversation
📝 WalkthroughWalkthroughThis 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 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
SwenSchaeferjohann
left a comment
There was a problem hiding this comment.
drive-by approve
There was a problem hiding this comment.
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 | 🟠 MajorApply 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 fromAccountInfoTraitinprogram-libs/account-checks/src/account_info/pinocchio.rs: guard pinocchio functions with#[cfg(target_os = "solana")]and fall back tosolana_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() } + };
light_account_pinocchio::solana_pubkey::Pubkey for pinocchio programs instead of bare solana_pubkey::Pubkey
Anchor
light_account_pinocchio::solana_pubkey::Pubkey paths for pinocchio code
solana_instruction/solana_pubkey (gated by std feature)
in pinocchio-light-program-test
Summary by CodeRabbit
New Features
CompressedCpiContextandInstructionDataInvokeCpiWithAccountInfonow available for macro-generated client code.pubkey_arraymacro export for enhanced key handling.solana_instructionandsolana_pubkeycrates when the std feature is enabled, supporting broader runtime environments.Updates