Skip to content

add pinocchio cross-program-invocation example#584

Open
MarkFeder wants to merge 1 commit into
solana-developers:mainfrom
MarkFeder:pinocchio-cross-program-invocation
Open

add pinocchio cross-program-invocation example#584
MarkFeder wants to merge 1 commit into
solana-developers:mainfrom
MarkFeder:pinocchio-cross-program-invocation

Conversation

@MarkFeder
Copy link
Copy Markdown

Summary

Ports the basics/cross-program-invocation example (hand + lever) from anchor/native to a Pinocchio variant.

  • Two-program workspace at basics/cross-program-invocation/pinocchio/programs/{hand,lever}.
  • Lever exposes initialize and switch_power via a single-byte discriminator (0 / 1), and uses pinocchio-system::CreateAccount to allocate the power account under its own program id during initialize.
  • Hand receives a name and forwards it as switch_power(name) to lever over CPI. The CPI buffer is built on the stack (cap 128 bytes) to stay no_std without an allocator.
  • Bankrun TS test covers initializepull leverpull again, plus an invalid-discriminator rejection.

Test plan

  • cargo fmt --check clean for both crates
  • cargo clippy -- -D warnings clean for both crates
  • cargo build-sbf succeeds for both programs (Anza v4.0.0, platform-tools v1.53)
  • Bankrun TS test passes in CI (not run locally; native binding issue on Windows host)

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

1 participant