light_instruction_decoder/programs/account_compression.rs
1//! Account Compression program instruction decoder.
2//!
3//! This module provides a macro-derived decoder for the Account Compression program,
4//! which uses 8-byte Anchor discriminators.
5//!
6//! The Account Compression program manages:
7//! - Group authority and program registration
8//! - State Merkle tree initialization and operations
9//! - Address Merkle tree initialization and operations
10//! - Batched tree operations with ZK proofs
11//! - Tree rollover operations
12//! - State migration
13
14// Allow the macro-generated code to reference types from this crate
15extern crate self as light_instruction_decoder;
16
17use light_instruction_decoder_derive::InstructionDecoder;
18
19/// Account Compression program instructions.
20///
21/// The Account Compression program uses 8-byte Anchor discriminators computed from
22/// sha256("global:<snake_case_instruction_name>").
23#[derive(InstructionDecoder)]
24#[instruction_decoder(
25 program_id = "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq",
26 program_name = "Account Compression",
27 discriminator_size = 8
28)]
29pub enum AccountCompressionInstruction {
30 // ========================================================================
31 // Group Authority Management
32 // ========================================================================
33 /// Initialize a group authority (allows multiple programs to share Merkle trees)
34 #[instruction_decoder(account_names = ["authority", "seed", "group_authority", "system_program"])]
35 InitializeGroupAuthority,
36
37 /// Update the group authority
38 #[instruction_decoder(account_names = ["authority", "group_authority"])]
39 UpdateGroupAuthority,
40
41 // ========================================================================
42 // Program Registration
43 // ========================================================================
44 /// Register a program to a group
45 #[instruction_decoder(account_names = ["authority", "program_to_be_registered", "registered_program_pda", "group_authority_pda", "system_program"])]
46 RegisterProgramToGroup,
47
48 /// Deregister a program from its group
49 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "group_authority_pda", "close_recipient"])]
50 DeregisterProgram,
51
52 /// Resize a registered program PDA (v1 to v2 migration)
53 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "system_program"])]
54 ResizeRegisteredProgramPda,
55
56 // ========================================================================
57 // State Tree Operations (v1 - concurrent Merkle tree)
58 // ========================================================================
59 /// Initialize a state Merkle tree and nullifier queue
60 #[instruction_decoder(account_names = ["authority", "merkle_tree", "nullifier_queue", "registered_program_pda"])]
61 InitializeStateMerkleTreeAndNullifierQueue,
62
63 /// Nullify leaves in a state Merkle tree
64 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "log_wrapper", "merkle_tree", "nullifier_queue"])]
65 NullifyLeaves,
66
67 /// Rollover a state Merkle tree and nullifier queue
68 #[instruction_decoder(account_names = ["fee_payer", "authority", "registered_program_pda", "new_state_merkle_tree", "new_nullifier_queue", "old_state_merkle_tree", "old_nullifier_queue"])]
69 RolloverStateMerkleTreeAndNullifierQueue,
70
71 // ========================================================================
72 // Address Tree Operations (v1 - indexed Merkle tree)
73 // ========================================================================
74 /// Initialize an address Merkle tree and queue
75 #[instruction_decoder(account_names = ["authority", "merkle_tree", "queue", "registered_program_pda"])]
76 InitializeAddressMerkleTreeAndQueue,
77
78 /// Update an address Merkle tree with a new address
79 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "queue", "merkle_tree", "log_wrapper"])]
80 UpdateAddressMerkleTree,
81
82 /// Rollover an address Merkle tree and queue
83 #[instruction_decoder(account_names = ["fee_payer", "authority", "registered_program_pda", "new_address_merkle_tree", "new_queue", "old_address_merkle_tree", "old_queue"])]
84 RolloverAddressMerkleTreeAndQueue,
85
86 // ========================================================================
87 // Queue Operations
88 // ========================================================================
89 /// Insert nullifiers, leaves, and addresses into v1 and batched Merkle trees
90 #[instruction_decoder(account_names = ["authority"])]
91 InsertIntoQueues,
92
93 // ========================================================================
94 // Batched Tree Operations (v2 - with ZK proofs)
95 // ========================================================================
96 /// Initialize a batched state Merkle tree and output queue
97 #[instruction_decoder(account_names = ["authority", "merkle_tree", "queue", "registered_program_pda"])]
98 InitializeBatchedStateMerkleTree,
99
100 /// Initialize a batched address Merkle tree
101 #[instruction_decoder(account_names = ["authority", "merkle_tree", "registered_program_pda"])]
102 InitializeBatchedAddressMerkleTree,
103
104 /// Nullify a batch of leaves from input queue to state Merkle tree with ZK proof
105 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "log_wrapper", "merkle_tree"])]
106 BatchNullify,
107
108 /// Append a batch of leaves from output queue to state Merkle tree with ZK proof
109 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "log_wrapper", "merkle_tree", "output_queue"])]
110 BatchAppend,
111
112 /// Insert a batch of addresses into a batched address Merkle tree with ZK proof
113 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "log_wrapper", "merkle_tree"])]
114 BatchUpdateAddressTree,
115
116 // ========================================================================
117 // Batched Rollover Operations
118 // ========================================================================
119 /// Rollover a batched address Merkle tree
120 #[instruction_decoder(account_names = ["fee_payer", "authority", "registered_program_pda", "new_address_merkle_tree", "old_address_merkle_tree"])]
121 RolloverBatchedAddressMerkleTree,
122
123 /// Rollover a batched state Merkle tree and output queue
124 #[instruction_decoder(account_names = ["fee_payer", "authority", "registered_program_pda", "new_state_merkle_tree", "old_state_merkle_tree", "new_output_queue", "old_output_queue"])]
125 RolloverBatchedStateMerkleTree,
126
127 // ========================================================================
128 // Migration
129 // ========================================================================
130 /// Migrate state from a v1 state Merkle tree to a v2 state Merkle tree
131 #[instruction_decoder(account_names = ["authority", "registered_program_pda", "log_wrapper", "merkle_tree", "output_queue"])]
132 MigrateState,
133}