@@ -75,7 +75,7 @@ await program.methods
75
75
.createCompressibleConfig (
76
76
100 , // compression_delay
77
77
rentRecipient ,
78
- addressSpace
78
+ [ addressSpace ] // Now accepts an array of address trees (1-4 allowed)
79
79
)
80
80
.accounts ({
81
81
payer: wallet .publicKey ,
@@ -92,7 +92,7 @@ await program.methods
92
92
.updateCompressibleConfig (
93
93
200 , // new_compression_delay (optional)
94
94
newRentRecipient , // (optional)
95
- newAddressSpace , // (optional)
95
+ [ newAddressSpace1 , newAddressSpace2 ], // (optional) - array of 1-4 address trees
96
96
newUpdateAuthority // (optional)
97
97
)
98
98
.accounts ({
@@ -159,6 +159,53 @@ await program.methods
159
159
.rpc ();
160
160
```
161
161
162
+ ## Address Space Configuration
163
+
164
+ The config now supports multiple address trees per address space (1-4 allowed):
165
+
166
+ ``` typescript
167
+ // Single address tree (backward compatible)
168
+ const addressSpace = [addressTree1 ];
169
+
170
+ // Multiple address trees for better scalability
171
+ const addressSpace = [addressTree1 , addressTree2 , addressTree3 ];
172
+
173
+ // When creating config
174
+ await program .methods
175
+ .createCompressibleConfig (
176
+ 100 ,
177
+ rentRecipient ,
178
+ addressSpace // Array of 1-4 unique address tree pubkeys
179
+ )
180
+ // ... accounts
181
+ .rpc ();
182
+ ```
183
+
184
+ ### Address Space Validation Rules
185
+
186
+ ** Create Config:**
187
+
188
+ - Must contain 1-4 unique address tree pubkeys
189
+ - No duplicate pubkeys allowed
190
+ - All pubkeys must be valid address trees
191
+
192
+ ** Update Config:**
193
+
194
+ - Can only ** add** new address trees, never remove existing ones
195
+ - No duplicate pubkeys allowed in the new configuration
196
+ - Must maintain all existing address trees
197
+
198
+ ``` typescript
199
+ // Valid update: adding new trees
200
+ const currentAddressSpace = [tree1 , tree2 ];
201
+ const newAddressSpace = [tree1 , tree2 , tree3 ]; // ✅ Valid: adds tree3
202
+
203
+ // Invalid update: removing existing trees
204
+ const invalidAddressSpace = [tree2 , tree3 ]; // ❌ Invalid: removes tree1
205
+ ```
206
+
207
+ The system validates that compressed accounts use address trees from the configured address space, providing flexibility while maintaining security and preventing accidental removal of active trees.
208
+
162
209
## What You Need to Implement
163
210
164
211
Since the macro only generates compression-related instructions, you need to implement:
@@ -188,13 +235,13 @@ pub fn create_user_record(
188
235
name : String ,
189
236
) -> Result <()> {
190
237
let user_record = & mut ctx . accounts. user_record;
191
-
238
+
192
239
// Your custom initialization logic here
193
240
user_record . compression_info = CompressionInfo :: new ()? ;
194
241
user_record . owner = ctx . accounts. user. key ();
195
242
user_record . name = name ;
196
243
user_record . score = 0 ;
197
-
244
+
198
245
Ok (())
199
246
}
200
247
```
0 commit comments