Skip to content

Commit da39efa

Browse files
authored
refactor: MerkleContext nullifier_queue_pubkey -> queue_pubkey (#1688)
1 parent d08d694 commit da39efa

File tree

25 files changed

+164
-170
lines changed

25 files changed

+164
-170
lines changed

examples/anchor/token-escrow/tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub async fn perform_escrow<R: RpcConnection, I: Indexer<R> + TestIndexerExtensi
264264
.merkle_context
265265
.leaf_index,
266266
merkle_tree_pubkey: env.merkle_tree_pubkey,
267-
nullifier_queue_pubkey: env.nullifier_queue_pubkey,
267+
queue_pubkey: env.nullifier_queue_pubkey,
268268
prove_by_index: false,
269269
tree_type: TreeType::StateV1,
270270
}],
@@ -426,7 +426,7 @@ pub async fn perform_withdrawal<R: RpcConnection, I: Indexer<R> + TestIndexerExt
426426
.merkle_context
427427
.leaf_index,
428428
merkle_tree_pubkey: env.merkle_tree_pubkey,
429-
nullifier_queue_pubkey: env.nullifier_queue_pubkey,
429+
queue_pubkey: env.nullifier_queue_pubkey,
430430
prove_by_index: false,
431431
tree_type: TreeType::StateV1,
432432
}],

examples/anchor/token-escrow/tests/test_compressed_pda.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ async fn create_escrow_ix<R: RpcConnection + MerkleTreeExt>(
270270
.merkle_context
271271
.leaf_index,
272272
merkle_tree_pubkey: env.merkle_tree_pubkey,
273-
nullifier_queue_pubkey: env.nullifier_queue_pubkey,
273+
queue_pubkey: env.nullifier_queue_pubkey,
274274
prove_by_index: false,
275275
tree_type: TreeType::StateV1,
276276
}],
@@ -475,15 +475,15 @@ pub async fn perform_withdrawal<R: RpcConnection + MerkleTreeExt>(
475475
input_token_escrow_merkle_context: MerkleContext {
476476
leaf_index: token_escrow_account.merkle_context.leaf_index,
477477
merkle_tree_pubkey: env.merkle_tree_pubkey,
478-
nullifier_queue_pubkey: env.nullifier_queue_pubkey,
478+
queue_pubkey: env.nullifier_queue_pubkey,
479479
prove_by_index: false,
480480
tree_type: TreeType::StateV1,
481481
},
482482

483483
input_cpda_merkle_context: MerkleContext {
484484
leaf_index: compressed_escrow_pda.merkle_context.leaf_index,
485485
merkle_tree_pubkey: env.merkle_tree_pubkey,
486-
nullifier_queue_pubkey: env.nullifier_queue_pubkey,
486+
queue_pubkey: env.nullifier_queue_pubkey,
487487
prove_by_index: false,
488488
tree_type: TreeType::StateV1,
489489
},

program-libs/compressed-account/src/compressed_account.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ impl CompressedAccountWithMerkleContext {
114114
&self.merkle_context.merkle_tree_pubkey,
115115
remaining_accounts,
116116
),
117-
nullifier_queue_pubkey_index: pack_account(
118-
&self.merkle_context.nullifier_queue_pubkey,
117+
queue_pubkey_index: pack_account(
118+
&self.merkle_context.queue_pubkey,
119119
remaining_accounts,
120120
),
121121
leaf_index: self.merkle_context.leaf_index,
@@ -143,7 +143,7 @@ pub struct PackedReadOnlyCompressedAccount {
143143
#[derive(Debug, Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Default)]
144144
pub struct MerkleContext {
145145
pub merkle_tree_pubkey: Pubkey,
146-
pub nullifier_queue_pubkey: Pubkey,
146+
pub queue_pubkey: Pubkey,
147147
pub leaf_index: u32,
148148
pub prove_by_index: bool,
149149
pub tree_type: TreeType,
@@ -152,7 +152,7 @@ pub struct MerkleContext {
152152
#[derive(Debug, Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Default)]
153153
pub struct PackedMerkleContext {
154154
pub merkle_tree_pubkey_index: u8,
155-
pub nullifier_queue_pubkey_index: u8,
155+
pub queue_pubkey_index: u8,
156156
pub leaf_index: u32,
157157
pub prove_by_index: bool,
158158
}
@@ -211,10 +211,7 @@ pub fn pack_merkle_context(
211211
&merkle_context.merkle_tree_pubkey,
212212
remaining_accounts,
213213
),
214-
nullifier_queue_pubkey_index: pack_account(
215-
&merkle_context.nullifier_queue_pubkey,
216-
remaining_accounts,
217-
),
214+
queue_pubkey_index: pack_account(&merkle_context.queue_pubkey, remaining_accounts),
218215
prove_by_index: merkle_context.prove_by_index,
219216
})
220217
.collect::<Vec<_>>()

program-libs/compressed-account/src/instruction_data/with_readonly.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ fn test_read_only_zero_copy() {
443443
data_hash: [10; 32],
444444
merkle_context: PackedMerkleContext {
445445
merkle_tree_pubkey_index: 1,
446-
nullifier_queue_pubkey_index: 2,
446+
queue_pubkey_index: 2,
447447
leaf_index: 3,
448448
prove_by_index: false,
449449
},
@@ -473,7 +473,7 @@ fn test_read_only_zero_copy() {
473473
account_hash: [80; 32],
474474
merkle_context: PackedMerkleContext {
475475
merkle_tree_pubkey_index: 5,
476-
nullifier_queue_pubkey_index: 6,
476+
queue_pubkey_index: 6,
477477
leaf_index: 7,
478478
prove_by_index: false,
479479
},

program-libs/compressed-account/src/instruction_data/zero_copy.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl From<&ZNewAddressParamsPacked> for NewAddressParamsPacked {
9090
)]
9191
pub struct ZPackedMerkleContext {
9292
pub merkle_tree_pubkey_index: u8,
93-
pub nullifier_queue_pubkey_index: u8,
93+
pub queue_pubkey_index: u8,
9494
pub leaf_index: U32,
9595
prove_by_index: u8,
9696
}
@@ -318,7 +318,7 @@ impl From<ZPackedMerkleContext> for PackedMerkleContext {
318318
fn from(merkle_context: ZPackedMerkleContext) -> Self {
319319
PackedMerkleContext {
320320
merkle_tree_pubkey_index: merkle_context.merkle_tree_pubkey_index,
321-
nullifier_queue_pubkey_index: merkle_context.nullifier_queue_pubkey_index,
321+
queue_pubkey_index: merkle_context.queue_pubkey_index,
322322
leaf_index: merkle_context.leaf_index.into(),
323323
prove_by_index: merkle_context.prove_by_index == 1,
324324
}
@@ -1073,7 +1073,7 @@ mod test {
10731073
},
10741074
merkle_context: PackedMerkleContext {
10751075
merkle_tree_pubkey_index: 1,
1076-
nullifier_queue_pubkey_index: 2,
1076+
queue_pubkey_index: 2,
10771077
leaf_index: 3,
10781078
prove_by_index: true,
10791079
},
@@ -1092,7 +1092,7 @@ mod test {
10921092
},
10931093
merkle_context: PackedMerkleContext {
10941094
merkle_tree_pubkey_index: rng.gen(),
1095-
nullifier_queue_pubkey_index: rng.gen(),
1095+
queue_pubkey_index: rng.gen(),
10961096
leaf_index: rng.gen(),
10971097
prove_by_index: rng.gen(),
10981098
},
@@ -1300,7 +1300,7 @@ mod test {
13001300
if reference.merkle_tree_pubkey_index != z_copy.merkle_tree_pubkey_index {
13011301
return Err(CompressedAccountError::InvalidArgument);
13021302
}
1303-
if reference.nullifier_queue_pubkey_index != z_copy.nullifier_queue_pubkey_index {
1303+
if reference.queue_pubkey_index != z_copy.queue_pubkey_index {
13041304
return Err(CompressedAccountError::InvalidArgument);
13051305
}
13061306
if reference.leaf_index != u32::from(z_copy.leaf_index) {

program-tests/compressed-token-test/tests/test.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,7 +3096,7 @@ async fn test_burn() {
30963096
let invalid_change_account_merkle_tree = input_compressed_accounts[0]
30973097
.compressed_account
30983098
.merkle_context
3099-
.nullifier_queue_pubkey;
3099+
.queue_pubkey;
31003100
let mut additional_token_pool_accounts = (0..4)
31013101
.map(|x| get_token_pool_pda_with_index(&mint, x))
31023102
.collect::<Vec<_>>();
@@ -3416,7 +3416,7 @@ async fn failing_tests_burn() {
34163416
let invalid_change_account_merkle_tree = input_compressed_accounts[0]
34173417
.compressed_account
34183418
.merkle_context
3419-
.nullifier_queue_pubkey;
3419+
.queue_pubkey;
34203420
let (_, _, _, _, instruction) = create_burn_test_instruction(
34213421
&sender,
34223422
&mut rpc,
@@ -3451,7 +3451,7 @@ async fn failing_tests_burn() {
34513451
let invalid_change_account_merkle_tree = input_compressed_accounts[0]
34523452
.compressed_account
34533453
.merkle_context
3454-
.nullifier_queue_pubkey;
3454+
.queue_pubkey;
34553455
let (_, _, _, _, instruction) = create_burn_test_instruction(
34563456
&sender,
34573457
&mut rpc,
@@ -3481,7 +3481,7 @@ async fn failing_tests_burn() {
34813481
let invalid_change_account_merkle_tree = input_compressed_accounts[0]
34823482
.compressed_account
34833483
.merkle_context
3484-
.nullifier_queue_pubkey;
3484+
.queue_pubkey;
34853485
let (_, _, _, _, mut instruction) = create_burn_test_instruction(
34863486
&sender,
34873487
&mut rpc,
@@ -5368,7 +5368,7 @@ async fn perform_transfer_failing_test<R: RpcConnection>(
53685368
.iter()
53695369
.map(|x| MerkleContext {
53705370
merkle_tree_pubkey: *merkle_tree_pubkey,
5371-
nullifier_queue_pubkey: *nullifier_queue_pubkey,
5371+
queue_pubkey: *nullifier_queue_pubkey,
53725372
leaf_index: x.merkle_context.leaf_index,
53735373
prove_by_index: false,
53745374
tree_type: TreeType::StateV1,

program-tests/system-cpi-test/src/create_pda.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,7 @@ fn cpi_compressed_pda_transfer_as_program<'info>(
327327
match mode {
328328
CreatePdaMode::InvalidReadOnlyAccountMerkleTree => {
329329
read_only_account[0].merkle_context.merkle_tree_pubkey_index =
330-
read_only_account[0]
331-
.merkle_context
332-
.nullifier_queue_pubkey_index;
330+
read_only_account[0].merkle_context.queue_pubkey_index;
333331
}
334332
CreatePdaMode::InvalidReadOnlyAccountRootIndex => {
335333
let init_value = read_only_account[0].root_index;
@@ -350,9 +348,7 @@ fn cpi_compressed_pda_transfer_as_program<'info>(
350348
inputs_struct.proof = Some(CompressedProof::default());
351349
}
352350
CreatePdaMode::InvalidReadOnlyAccountOutputQueue => {
353-
read_only_account[0]
354-
.merkle_context
355-
.nullifier_queue_pubkey_index =
351+
read_only_account[0].merkle_context.queue_pubkey_index =
356352
read_only_account[0].merkle_context.merkle_tree_pubkey_index;
357353
}
358354
CreatePdaMode::AccountNotInValueVecMarkedProofByIndex => {

program-tests/system-cpi-test/tests/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async fn parse_batched_event_functional() {
125125
leaf_index: i,
126126
merkle_tree_pubkey: env.batched_state_merkle_tree,
127127
prove_by_index: true,
128-
nullifier_queue_pubkey: env.batched_output_queue,
128+
queue_pubkey: env.batched_output_queue,
129129
tree_type: light_compressed_account::TreeType::StateV2,
130130
})
131131
})
@@ -276,7 +276,7 @@ async fn parse_batched_event_functional() {
276276
leaf_index: i,
277277
merkle_tree_pubkey: env.batched_state_merkle_tree,
278278
prove_by_index: true,
279-
nullifier_queue_pubkey: env.batched_output_queue,
279+
queue_pubkey: env.batched_output_queue,
280280
tree_type: light_compressed_account::TreeType::StateV2,
281281
})
282282
})

program-tests/system-cpi-test/tests/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,7 @@ pub async fn perform_with_input_accounts<
19151915
);
19161916
}
19171917
let merkle_tree_pubkey = compressed_account.merkle_context.merkle_tree_pubkey;
1918-
let nullifier_pubkey = compressed_account.merkle_context.nullifier_queue_pubkey;
1918+
let nullifier_pubkey = compressed_account.merkle_context.queue_pubkey;
19191919
let cpi_context = match mode {
19201920
WithInputAccountsMode::Freeze
19211921
| WithInputAccountsMode::Thaw
@@ -1970,7 +1970,7 @@ pub async fn perform_with_input_accounts<
19701970
merkle_context: PackedMerkleContext {
19711971
leaf_index: token_account.compressed_account.merkle_context.leaf_index,
19721972
merkle_tree_pubkey_index: 0,
1973-
nullifier_queue_pubkey_index: 1,
1973+
queue_pubkey_index: 1,
19741974
prove_by_index: false,
19751975
},
19761976
lamports: if token_account.compressed_account.compressed_account.lamports != 0 {
@@ -2000,7 +2000,7 @@ pub async fn perform_with_input_accounts<
20002000
merkle_context: PackedMerkleContext {
20012001
leaf_index: compressed_account.merkle_context.leaf_index,
20022002
merkle_tree_pubkey_index: 0,
2003-
nullifier_queue_pubkey_index: 1,
2003+
queue_pubkey_index: 1,
20042004
prove_by_index: false,
20052005
},
20062006
root_index: rpc_result.root_indices[0].unwrap(),

0 commit comments

Comments
 (0)