Skip to content

Commit 23193a0

Browse files
committed
feat: add addresses to cpi context, enable spending of created accounts in same ix
1 parent eb7ca14 commit 23193a0

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

programs/account-compression/src/processor/insert_into_queues.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ pub fn process_insert_into_queues<'a, 'b, 'c: 'info, 'info>(
3434
// msg!("insert_leaves {:?}", inputs.leaves.len());
3535
// msg!("insert_addresses {:?}", inputs.addresses.len());
3636

37-
#[cfg(feature = "bench-sbf")]
38-
light_heap::bench_sbf_start!("insert_nullifiers");
39-
insert_nullifiers(
40-
inputs.num_queues,
41-
inputs.tx_hash,
42-
inputs.nullifiers.as_slice(),
43-
&mut accounts,
44-
&current_slot,
45-
)?;
46-
#[cfg(feature = "bench-sbf")]
47-
light_heap::bench_sbf_end!("insert_nullifiers");
4837
#[cfg(feature = "bench-sbf")]
4938
light_heap::bench_sbf_start!("append_leaves");
5039
insert_leaves(
@@ -57,6 +46,18 @@ pub fn process_insert_into_queues<'a, 'b, 'c: 'info, 'info>(
5746
#[cfg(feature = "bench-sbf")]
5847
light_heap::bench_sbf_end!("append_leaves");
5948

49+
#[cfg(feature = "bench-sbf")]
50+
light_heap::bench_sbf_start!("insert_nullifiers");
51+
insert_nullifiers(
52+
inputs.num_queues,
53+
inputs.tx_hash,
54+
inputs.nullifiers.as_slice(),
55+
&mut accounts,
56+
&current_slot,
57+
)?;
58+
#[cfg(feature = "bench-sbf")]
59+
light_heap::bench_sbf_end!("insert_nullifiers");
60+
6061
#[cfg(feature = "bench-sbf")]
6162
light_heap::bench_sbf_start!("insert_addresses");
6263
insert_addresses(

programs/system/src/context.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use light_compressed_account::{
33
hash_to_bn254_field_size_be,
44
instruction_data::{
55
cpi_context::CompressedCpiContext,
6-
data::OutputCompressedAccountWithPackedContext,
6+
data::{NewAddressParamsPacked, OutputCompressedAccountWithPackedContext},
77
invoke_cpi::InstructionDataInvokeCpi,
88
traits::{InputAccount, InstructionData, NewAddress, OutputAccount},
99
zero_copy::{ZPackedReadOnlyAddress, ZPackedReadOnlyCompressedAccount},
@@ -370,9 +370,17 @@ impl<'a, T: InstructionData<'a>> WrappedInstructionData<'a, T> {
370370
.output_compressed_accounts
371371
.push(output_account);
372372
}
373-
374-
if !self.instruction_data.new_addresses().is_empty() {
375-
unimplemented!("Address assignment cannot be guaranteed with cpi context.");
373+
for address in self.instruction_data.new_addresses() {
374+
let new_address_params = NewAddressParamsPacked {
375+
seed: address.seed(),
376+
address_merkle_tree_account_index: address.address_merkle_tree_account_index(),
377+
address_merkle_tree_root_index: address.address_merkle_tree_root_index(),
378+
address_queue_account_index: address.address_queue_index(),
379+
};
380+
if address.assigned_compressed_account_index().is_some() {
381+
unimplemented!("Implement logic for assigned compressed account index");
382+
}
383+
cpi_account_data.new_address_params.push(new_address_params);
376384
}
377385
}
378386

0 commit comments

Comments
 (0)