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
PackedAddressTreeInfo- Indices of address tree and queue accounts.PackedStateTreeInfo- Indices of state tree and queue accounts.PackedAccounts- Packs accounts and creates indices for instruction building (client-side).SystemAccountMetaConfig- Configures which Light system program accounts to add toPackedAccounts.ValidityProof- Proves that new addresses donโt exist yet, and compressed account state exists.CompressedAccountMeta- Metadata for compressed accounts.
ยง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-
Packedstructs: Contain pubkeys (Pubkey) for use in the client, and are returned by RPC methods. PackedAccounts: Manages account deduplication and index assignment to createPacked*structs.
Modulesยง
Structsยง
- Address
Tree Info - Compressed
Proof - Zero-knowledge proof to prove the validity of existing compressed accounts and new addresses.
- Merkle
Context - Packed
Accounts - Builder for organizing accounts into compressed account instructions.
- Packed
Address Tree Info - Packed
Merkle Context - Packed
State Tree Info - System
Account Meta Config - Configuration for Light system program accounts when building instructions.
- System
Account Pubkeys - Validity
Proof - Zero-knowledge proof to prove the validity of existing compressed accounts and new addresses.
Traitsยง
Functionsยง
- get_
light_ system_ account_ metas - InvokeSystemCpi v1.
- pack_
address_ tree_ info - Returns a
PackedAddressTreeInfoand fills upremaining_accountsbased on the givenmerkle_context. Packs Merkle tree account first. Packs queue account second. - pack_
address_ tree_ infos - Returns an iterator of
PackedAddressTreeInfoand fills upremaining_accountsbased on the givenmerkle_contexts. - pack_
merkle_ context Deprecated - pack_
merkle_ contexts Deprecated - unpack_
address_ tree_ info - unpack_
address_ tree_ infos