Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit c065f83

Browse files
committed
naming changes
1 parent 0e9cc71 commit c065f83

File tree

8 files changed

+99
-99
lines changed

8 files changed

+99
-99
lines changed

account-compression/programs/account-compression/src/concurrent_tree_wrapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn merkle_tree_append_leaf(
9292
/// lifting with macros. An empty account is a zero'd account. The tree is considered empty if the
9393
/// tree_bytes are all 0. A regular non-batch initialized tree is initialized early on when the
9494
/// init_empty_merkle_tree is called. A batch initialized tree stays uninitialized until the
95-
/// finalize_merkle_tree_with_root is called.
95+
/// init_prepared_tree_with_root is called.
9696
pub fn tree_bytes_uninitialized(tree_bytes: &[u8]) -> bool {
9797
tree_bytes.iter().all(|&x| x == 0)
9898
}

account-compression/programs/account-compression/src/lib.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ pub mod spl_account_compression {
195195
/// expected flow is `init_empty_merkle_tree`. For the latter case, the canopy should be
196196
/// filled with the necessary nodes to render the tree usable. Thus we need to prefill the
197197
/// canopy with the necessary nodes. The expected flow for a tree without canopy is
198-
/// `prepare_tree` -> `finalize_merkle_tree_with_root`. The expected flow for a tree with canopy
199-
/// is `prepare_tree` -> `append_canopy_nodes` (multiple times until all of the canopy is
200-
/// filled) -> `finalize_merkle_tree_with_root`. This instruction initializes the tree header
201-
/// while leaving the tree itself uninitialized. This allows distinguishing between an empty
202-
/// tree and a tree prepare to be initialized with a root.
203-
pub fn prepare_tree(
198+
/// `prepare_batch_merkle_tree` -> `init_prepared_tree_with_root`. The expected flow for a tree
199+
/// with canopy is `prepare_batch_merkle_tree` -> `append_canopy_nodes` (multiple times
200+
/// until all of the canopy is filled) -> `init_prepared_tree_with_root`. This instruction
201+
/// initializes the tree header while leaving the tree itself uninitialized. This allows
202+
/// distinguishing between an empty tree and a tree prepare to be initialized with a root.
203+
pub fn prepare_batch_merkle_tree(
204204
ctx: Context<Initialize>,
205205
max_depth: u32,
206206
max_buffer_size: u32,
@@ -229,19 +229,19 @@ pub mod spl_account_compression {
229229
}
230230

231231
/// This instruction pre-initializes the canopy with the specified leaf nodes of the canopy.
232-
/// This is intended to be used after `prepare_tree` and in conjunction with the
233-
/// `finalize_merkle_tree_with_root` instruction that'll finalize the tree initialization.
232+
/// This is intended to be used after `prepare_batch_merkle_tree` and in conjunction with the
233+
/// `init_prepared_tree_with_root` instruction that'll finalize the tree initialization.
234234
/// The canopy is used to cache the uppermost nodes of the tree, which allows for a smaller
235235
/// proof size when updating the tree. The canopy should be filled with the necessary nodes
236-
/// before calling `finalize_merkle_tree_with_root`. You may call this instruction multiple
236+
/// before calling `init_prepared_tree_with_root`. You may call this instruction multiple
237237
/// times to fill the canopy with the necessary nodes. The canopy may be filled with the
238238
/// nodes in any order. The already filled nodes may be replaced with new nodes before calling
239-
/// `finalize_merkle_tree_with_root` if the step was done in error.
239+
/// `init_prepared_tree_with_root` if the step was done in error.
240240
/// The canopy should be filled with all the nodes that are to the left of the rightmost
241-
/// leaf of the tree before calling `finalize_merkle_tree_with_root`. The canopy should not
241+
/// leaf of the tree before calling `init_prepared_tree_with_root`. The canopy should not
242242
/// contain any nodes to the right of the rightmost leaf of the tree.
243243
/// This instruction calculates and filles in all the canopy nodes "above" the provided ones.
244-
/// The validation of the canopy is done in the `finalize_merkle_tree_with_root` instruction.
244+
/// The validation of the canopy is done in the `init_prepared_tree_with_root` instruction.
245245
pub fn append_canopy_nodes(
246246
ctx: Context<Modify>,
247247
start_index: u32,
@@ -279,14 +279,14 @@ pub mod spl_account_compression {
279279

280280
/// Initializes a prepared tree with a root and a rightmost leaf. The rightmost leaf is used to
281281
/// verify the canopy if the tree has it. Before calling this instruction, the tree should be
282-
/// prepared with `prepare_tree` and the canopy should be filled with the necessary nodes with
283-
/// `append_canopy_nodes` (if the canopy is used). This method should be used for rolluped
284-
/// creation of trees. The indexing of such rollups should be done off-chain. The programs
285-
/// calling this instruction should take care of ensuring the indexing is possible. For example,
286-
/// staking may be required to ensure the tree creator has some responsibility for what is being
287-
/// indexed. If indexing is not possible, there should be a mechanism to penalize the tree
288-
/// creator.
289-
pub fn finalize_merkle_tree_with_root(
282+
/// prepared with `prepare_batch_merkle_tree` and the canopy should be filled with the necessary
283+
/// nodes with `append_canopy_nodes` (if the canopy is used). This method should be used for
284+
/// rolluped creation of trees. The indexing of such rollups should be done off-chain. The
285+
/// programs calling this instruction should take care of ensuring the indexing is possible.
286+
/// For example, staking may be required to ensure the tree creator has some responsibility
287+
/// for what is being indexed. If indexing is not possible, there should be a mechanism to
288+
/// penalize the tree creator.
289+
pub fn init_prepared_tree_with_root(
290290
ctx: Context<Modify>,
291291
root: [u8; 32],
292292
rightmost_leaf: [u8; 32],
@@ -301,7 +301,7 @@ pub mod spl_account_compression {
301301

302302
let (header_bytes, rest) =
303303
merkle_tree_bytes.split_at_mut(CONCURRENT_MERKLE_TREE_HEADER_SIZE_V1);
304-
// the header should already be initialized with prepare_tree
304+
// the header should already be initialized with prepare_batch_merkle_tree
305305
let header = ConcurrentMerkleTreeHeader::try_from_slice(header_bytes)?;
306306
header.assert_valid_authority(&ctx.accounts.authority.key())?;
307307
header.assert_is_batch_initialized()?;

account-compression/sdk/idl/spl_account_compression.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
]
5353
},
5454
{
55-
"name": "prepareTree",
55+
"name": "prepareBatchMerkleTree",
5656
"docs": [
5757
"In order to initialize a tree with a root, we need to create the tree on-chain first with",
5858
"the proper authority. The tree might contain a canopy, which is a cache of the uppermost",
@@ -65,11 +65,11 @@
6565
"expected flow is `init_empty_merkle_tree`. For the latter case, the canopy should be",
6666
"filled with the necessary nodes to render the tree usable. Thus we need to prefill the",
6767
"canopy with the necessary nodes. The expected flow for a tree without canopy is",
68-
"`prepare_tree` -> `finalize_merkle_tree_with_root`. The expected flow for a tree with canopy",
69-
"is `prepare_tree` -> `append_canopy_nodes` (multiple times until all of the canopy is",
70-
"filled) -> `finalize_merkle_tree_with_root`. This instruction initializes the tree header",
71-
"while leaving the tree itself uninitialized. This allows distinguishing between an empty",
72-
"tree and a tree prepare to be initialized with a root."
68+
"`prepare_batch_merkle_tree` -> `init_prepared_tree_with_root`. The expected flow for a tree",
69+
"with canopy is `prepare_batch_merkle_tree` -> `append_canopy_nodes` (multiple times",
70+
"until all of the canopy is filled) -> `init_prepared_tree_with_root`. This instruction",
71+
"initializes the tree header while leaving the tree itself uninitialized. This allows",
72+
"distinguishing between an empty tree and a tree prepare to be initialized with a root."
7373
],
7474
"accounts": [
7575
{
@@ -108,19 +108,19 @@
108108
"name": "appendCanopyNodes",
109109
"docs": [
110110
"This instruction pre-initializes the canopy with the specified leaf nodes of the canopy.",
111-
"This is intended to be used after `prepare_tree` and in conjunction with the",
112-
"`finalize_merkle_tree_with_root` instruction that'll finalize the tree initialization.",
111+
"This is intended to be used after `prepare_batch_merkle_tree` and in conjunction with the",
112+
"`init_prepared_tree_with_root` instruction that'll finalize the tree initialization.",
113113
"The canopy is used to cache the uppermost nodes of the tree, which allows for a smaller",
114114
"proof size when updating the tree. The canopy should be filled with the necessary nodes",
115-
"before calling `finalize_merkle_tree_with_root`. You may call this instruction multiple",
115+
"before calling `init_prepared_tree_with_root`. You may call this instruction multiple",
116116
"times to fill the canopy with the necessary nodes. The canopy may be filled with the",
117117
"nodes in any order. The already filled nodes may be replaced with new nodes before calling",
118-
"`finalize_merkle_tree_with_root` if the step was done in error.",
118+
"`init_prepared_tree_with_root` if the step was done in error.",
119119
"The canopy should be filled with all the nodes that are to the left of the rightmost",
120-
"leaf of the tree before calling `finalize_merkle_tree_with_root`. The canopy should not",
120+
"leaf of the tree before calling `init_prepared_tree_with_root`. The canopy should not",
121121
"contain any nodes to the right of the rightmost leaf of the tree.",
122122
"This instruction calculates and filles in all the canopy nodes \"above\" the provided ones.",
123-
"The validation of the canopy is done in the `finalize_merkle_tree_with_root` instruction."
123+
"The validation of the canopy is done in the `init_prepared_tree_with_root` instruction."
124124
],
125125
"accounts": [
126126
{
@@ -160,17 +160,17 @@
160160
]
161161
},
162162
{
163-
"name": "finalizeMerkleTreeWithRoot",
163+
"name": "initPreparedTreeWithRoot",
164164
"docs": [
165165
"Initializes a prepared tree with a root and a rightmost leaf. The rightmost leaf is used to",
166166
"verify the canopy if the tree has it. Before calling this instruction, the tree should be",
167-
"prepared with `prepare_tree` and the canopy should be filled with the necessary nodes with",
168-
"`append_canopy_nodes` (if the canopy is used). This method should be used for rolluped",
169-
"creation of trees. The indexing of such rollups should be done off-chain. The programs",
170-
"calling this instruction should take care of ensuring the indexing is possible. For example,",
171-
"staking may be required to ensure the tree creator has some responsibility for what is being",
172-
"indexed. If indexing is not possible, there should be a mechanism to penalize the tree",
173-
"creator."
167+
"prepared with `prepare_batch_merkle_tree` and the canopy should be filled with the necessary",
168+
"nodes with `append_canopy_nodes` (if the canopy is used). This method should be used for",
169+
"rolluped creation of trees. The indexing of such rollups should be done off-chain. The",
170+
"programs calling this instruction should take care of ensuring the indexing is possible.",
171+
"For example, staking may be required to ensure the tree creator has some responsibility",
172+
"for what is being indexed. If indexing is not possible, there should be a mechanism to",
173+
"penalize the tree creator."
174174
],
175175
"accounts": [
176176
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export * from './append';
22
export * from './appendCanopyNodes';
33
export * from './closeEmptyTree';
4-
export * from './finalizeMerkleTreeWithRoot';
54
export * from './initEmptyMerkleTree';
5+
export * from './initPreparedTreeWithRoot';
66
export * from './insertOrAppend';
7-
export * from './prepareTree';
7+
export * from './prepareBatchMerkleTree';
88
export * from './replaceLeaf';
99
export * from './transferAuthority';
1010
export * from './verifyLeaf';

account-compression/sdk/src/generated/instructions/finalizeMerkleTreeWithRoot.ts renamed to account-compression/sdk/src/generated/instructions/initPreparedTreeWithRoot.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ import * as web3 from '@solana/web3.js';
1010

1111
/**
1212
* @category Instructions
13-
* @category FinalizeMerkleTreeWithRoot
13+
* @category InitPreparedTreeWithRoot
1414
* @category generated
1515
*/
16-
export type FinalizeMerkleTreeWithRootInstructionArgs = {
16+
export type InitPreparedTreeWithRootInstructionArgs = {
1717
rightmostIndex: number;
1818
rightmostLeaf: number[] /* size: 32 */;
1919
root: number[] /* size: 32 */;
2020
};
2121
/**
2222
* @category Instructions
23-
* @category FinalizeMerkleTreeWithRoot
23+
* @category InitPreparedTreeWithRoot
2424
* @category generated
2525
*/
26-
export const finalizeMerkleTreeWithRootStruct = new beet.BeetArgsStruct<
27-
FinalizeMerkleTreeWithRootInstructionArgs & {
26+
export const initPreparedTreeWithRootStruct = new beet.BeetArgsStruct<
27+
InitPreparedTreeWithRootInstructionArgs & {
2828
instructionDiscriminator: number[] /* size: 8 */;
2929
}
3030
>(
@@ -34,44 +34,44 @@ export const finalizeMerkleTreeWithRootStruct = new beet.BeetArgsStruct<
3434
['rightmostLeaf', beet.uniformFixedSizeArray(beet.u8, 32)],
3535
['rightmostIndex', beet.u32],
3636
],
37-
'FinalizeMerkleTreeWithRootInstructionArgs',
37+
'InitPreparedTreeWithRootInstructionArgs',
3838
);
3939
/**
40-
* Accounts required by the _finalizeMerkleTreeWithRoot_ instruction
40+
* Accounts required by the _initPreparedTreeWithRoot_ instruction
4141
*
4242
* @property [_writable_] merkleTree
4343
* @property [**signer**] authority
4444
* @property [] noop
4545
* @category Instructions
46-
* @category FinalizeMerkleTreeWithRoot
46+
* @category InitPreparedTreeWithRoot
4747
* @category generated
4848
*/
49-
export type FinalizeMerkleTreeWithRootInstructionAccounts = {
49+
export type InitPreparedTreeWithRootInstructionAccounts = {
5050
anchorRemainingAccounts?: web3.AccountMeta[];
5151
authority: web3.PublicKey;
5252
merkleTree: web3.PublicKey;
5353
noop: web3.PublicKey;
5454
};
5555

56-
export const finalizeMerkleTreeWithRootInstructionDiscriminator = [112, 137, 139, 87, 67, 99, 164, 82];
56+
export const initPreparedTreeWithRootInstructionDiscriminator = [218, 248, 192, 55, 91, 205, 122, 10];
5757

5858
/**
59-
* Creates a _FinalizeMerkleTreeWithRoot_ instruction.
59+
* Creates a _InitPreparedTreeWithRoot_ instruction.
6060
*
6161
* @param accounts that will be accessed while the instruction is processed
6262
* @param args to provide as instruction data to the program
6363
*
6464
* @category Instructions
65-
* @category FinalizeMerkleTreeWithRoot
65+
* @category InitPreparedTreeWithRoot
6666
* @category generated
6767
*/
68-
export function createFinalizeMerkleTreeWithRootInstruction(
69-
accounts: FinalizeMerkleTreeWithRootInstructionAccounts,
70-
args: FinalizeMerkleTreeWithRootInstructionArgs,
68+
export function createInitPreparedTreeWithRootInstruction(
69+
accounts: InitPreparedTreeWithRootInstructionAccounts,
70+
args: InitPreparedTreeWithRootInstructionArgs,
7171
programId = new web3.PublicKey('cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK'),
7272
) {
73-
const [data] = finalizeMerkleTreeWithRootStruct.serialize({
74-
instructionDiscriminator: finalizeMerkleTreeWithRootInstructionDiscriminator,
73+
const [data] = initPreparedTreeWithRootStruct.serialize({
74+
instructionDiscriminator: initPreparedTreeWithRootInstructionDiscriminator,
7575
...args,
7676
});
7777
const keys: web3.AccountMeta[] = [

account-compression/sdk/src/generated/instructions/prepareTree.ts renamed to account-compression/sdk/src/generated/instructions/prepareBatchMerkleTree.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ import * as web3 from '@solana/web3.js';
1010

1111
/**
1212
* @category Instructions
13-
* @category PrepareTree
13+
* @category PrepareBatchMerkleTree
1414
* @category generated
1515
*/
16-
export type PrepareTreeInstructionArgs = {
16+
export type PrepareBatchMerkleTreeInstructionArgs = {
1717
maxBufferSize: number;
1818
maxDepth: number;
1919
};
2020
/**
2121
* @category Instructions
22-
* @category PrepareTree
22+
* @category PrepareBatchMerkleTree
2323
* @category generated
2424
*/
25-
export const prepareTreeStruct = new beet.BeetArgsStruct<
26-
PrepareTreeInstructionArgs & {
25+
export const prepareBatchMerkleTreeStruct = new beet.BeetArgsStruct<
26+
PrepareBatchMerkleTreeInstructionArgs & {
2727
instructionDiscriminator: number[] /* size: 8 */;
2828
}
2929
>(
@@ -32,44 +32,44 @@ export const prepareTreeStruct = new beet.BeetArgsStruct<
3232
['maxDepth', beet.u32],
3333
['maxBufferSize', beet.u32],
3434
],
35-
'PrepareTreeInstructionArgs',
35+
'PrepareBatchMerkleTreeInstructionArgs',
3636
);
3737
/**
38-
* Accounts required by the _prepareTree_ instruction
38+
* Accounts required by the _prepareBatchMerkleTree_ instruction
3939
*
4040
* @property [_writable_] merkleTree
4141
* @property [**signer**] authority
4242
* @property [] noop
4343
* @category Instructions
44-
* @category PrepareTree
44+
* @category PrepareBatchMerkleTree
4545
* @category generated
4646
*/
47-
export type PrepareTreeInstructionAccounts = {
47+
export type PrepareBatchMerkleTreeInstructionAccounts = {
4848
anchorRemainingAccounts?: web3.AccountMeta[];
4949
authority: web3.PublicKey;
5050
merkleTree: web3.PublicKey;
5151
noop: web3.PublicKey;
5252
};
5353

54-
export const prepareTreeInstructionDiscriminator = [41, 56, 189, 77, 58, 12, 142, 71];
54+
export const prepareBatchMerkleTreeInstructionDiscriminator = [230, 124, 120, 196, 249, 134, 199, 128];
5555

5656
/**
57-
* Creates a _PrepareTree_ instruction.
57+
* Creates a _PrepareBatchMerkleTree_ instruction.
5858
*
5959
* @param accounts that will be accessed while the instruction is processed
6060
* @param args to provide as instruction data to the program
6161
*
6262
* @category Instructions
63-
* @category PrepareTree
63+
* @category PrepareBatchMerkleTree
6464
* @category generated
6565
*/
66-
export function createPrepareTreeInstruction(
67-
accounts: PrepareTreeInstructionAccounts,
68-
args: PrepareTreeInstructionArgs,
66+
export function createPrepareBatchMerkleTreeInstruction(
67+
accounts: PrepareBatchMerkleTreeInstructionAccounts,
68+
args: PrepareBatchMerkleTreeInstructionArgs,
6969
programId = new web3.PublicKey('cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK'),
7070
) {
71-
const [data] = prepareTreeStruct.serialize({
72-
instructionDiscriminator: prepareTreeInstructionDiscriminator,
71+
const [data] = prepareBatchMerkleTreeStruct.serialize({
72+
instructionDiscriminator: prepareBatchMerkleTreeInstructionDiscriminator,
7373
...args,
7474
});
7575
const keys: web3.AccountMeta[] = [

0 commit comments

Comments
 (0)