add pinocchio cross-program-invocation example#584
Open
MarkFeder wants to merge 1 commit into
Open
Conversation
Ports the hand+lever CPI example from anchor/native to Pinocchio. - Two-program workspace: hand (caller) and lever (callee). - Lever exposes initialize and switch_power instructions via a 1-byte discriminator; uses pinocchio-system::CreateAccount for account allocation under its own program id. - Hand forwards switch_power(name) over CPI to lever, building the cross-program Instruction on the stack (no_std, no allocator). - Bankrun TS test exercises the full init -> pull -> pull-again flow plus an invalid-discriminator rejection case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the
basics/cross-program-invocationexample (hand + lever) from anchor/native to a Pinocchio variant.basics/cross-program-invocation/pinocchio/programs/{hand,lever}.initializeandswitch_powervia a single-byte discriminator (0/1), and usespinocchio-system::CreateAccountto allocate thepoweraccount under its own program id during initialize.switch_power(name)to lever over CPI. The CPI buffer is built on the stack (cap 128 bytes) to stayno_stdwithout an allocator.initialize→pull lever→pull again, plus an invalid-discriminator rejection.Test plan
cargo fmt --checkclean for both cratescargo clippy -- -D warningsclean for both cratescargo build-sbfsucceeds for both programs (Anza v4.0.0, platform-tools v1.53)