pub fn process_cpi_context<'info>(
    inputs: InstructionDataInvokeCpi,
    cpi_context_account: &mut Option<Account<'info, CpiContextAccount>>,
    fee_payer: Pubkey,
    remaining_accounts: &[AccountInfo<'info>],
) -> Result<Option<InstructionDataInvokeCpi>>
Expand description

Cpi context enables the use of input compressed accounts owned by different programs.

Example:

  • a transaction calling a pda program needs to transfer tokens and modify a compressed pda
  • the pda is owned by pda program while the tokens are owned by the compressed token program

without cpi context:

  • naively invoking each compressed token via cpi and modifying the pda requires two proofs 128 bytes and ~100,000 CU each

with cpi context:

  • only one proof is required -> less instruction data and CU cost
  1. first invocation (token program) performs signer checks of the compressed token accounts, caches these in the cpi context and returns. The state transition is not executed yet.
  2. second invocation (pda program) performs signer checks of the pda compressed account, reads cpi context and combines the instruction inputs with verified inputs from the cpi context. The proof is verified and other state transition is executed with the combined inputs.