Module instruction

Module instruction 

Source
Expand description

Utilities to build instructions for programs with compressed accounts.

ยงOverview

This module provides types and utilities for building Solana instructions that work with compressed accounts. The main workflow involves:

 โ”œโ”€ ๐‚๐ฅ๐ข๐ž๐ง๐ญ
 โ”‚  โ”œโ”€ Get ValidityProof from RPC.
 โ”‚  โ”œโ”€ pack accounts with PackedAccounts into PackedAddressTreeInfo and PackedStateTreeInfo.
 โ”‚  โ”œโ”€ pack CompressedAccountMeta.
 โ”‚  โ”œโ”€ Build Instruction from packed accounts and CompressedAccountMetas.
 โ”‚  โ””โ”€ Send transaction
 โ”‚
 โ””โ”€ ๐‚๐ฎ๐ฌ๐ญ๐จ๐ฆ ๐๐ซ๐จ๐ ๐ซ๐š๐ฆ
    โ”œโ”€ use PackedAddressTreeInfo to create a new address.
    โ”œโ”€ use CompressedAccountMeta to instantiate a LightAccount struct.
    โ”‚
    โ””โ”€ ๐‹๐ข๐ ๐ก๐ญ ๐’๐ฒ๐ฌ๐ญ๐ž๐ฆ ๐๐ซ๐จ๐ ๐ซ๐š๐ฆ ๐‚๐๐ˆ
       โ”œโ”€ Verify ValidityProof.
       โ”œโ”€ Update State Merkle tree.
       โ”œโ”€ Update Address Merkle tree.
       โ””โ”€ Complete atomic state transition.

ยงMain Types

ยงCompressed Account Metas

Instruction data types to pass compressed account metadata into instructions. CompressedAccountMeta and variations with and without lamports and addresses are used to instantiate LightAccount structs in your program.

ยงPacked Structs Pattern

Structs prefixed with Packed (eg PackedAddressTreeInfo, PackedStateTreeInfo) are instruction data structs that contain account indices instead of pubkeys to reduce instruction size.

  • Packed* structs: Contain indices (u8) for use in instruction data.
  • Non-Packed structs: Contain pubkeys (Pubkey) for use in the client, and are returned by RPC methods.
  • PackedAccounts: Manages account deduplication and index assignment to create Packed* structs.

Modulesยง

account_info
account_meta

Structsยง

AddressTreeInfo
CompressedProof
Zero-knowledge proof to prove the validity of existing compressed accounts and new addresses.
MerkleContext
PackedAccounts
Builder for organizing accounts into compressed account instructions.
PackedAddressTreeInfo
PackedMerkleContext
PackedStateTreeInfo
SystemAccountMetaConfig
Configuration for Light system program accounts when building instructions.
SystemAccountPubkeys
ValidityProof
Zero-knowledge proof to prove the validity of existing compressed accounts and new addresses.

Traitsยง

AccountMetasVec

Functionsยง

get_light_system_account_metas
InvokeSystemCpi v1.
pack_address_tree_info
Returns a PackedAddressTreeInfo and fills up remaining_accounts based on the given merkle_context. Packs Merkle tree account first. Packs queue account second.
pack_address_tree_infos
Returns an iterator of PackedAddressTreeInfo and fills up remaining_accounts based on the given merkle_contexts.
pack_merkle_contextDeprecated
pack_merkle_contextsDeprecated
unpack_address_tree_info
unpack_address_tree_infos