Skip to content

Commit 77e383c

Browse files
committed
cleanup
1 parent 8a92c3e commit 77e383c

File tree

5 files changed

+23
-109
lines changed

5 files changed

+23
-109
lines changed

cli/accounts/group_pda_G6iaDqLrGGjrPXgsyV2NmcRjzAQzWWiaVyAaixbLCNNu.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,3 @@ pub struct AccountOptions {
8888
pub cpi_context_account: bool,
8989
pub write_to_cpi_context: bool,
9090
}
91-
92-
impl AccountOptions {
93-
pub fn get_num_expected_accounts(&self) -> usize {
94-
let mut num = 3;
95-
if !self.write_to_cpi_context {
96-
num += 1;
97-
}
98-
if self.sol_pool_pda {
99-
num += 1;
100-
}
101-
if self.decompression_recipient {
102-
num += 1;
103-
}
104-
if self.cpi_context_account {
105-
num += 1;
106-
}
107-
num
108-
}
109-
}

program-libs/compressed-account/tests/account_option_config.rs

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rand::{rngs::StdRng, Rng, SeedableRng};
1717

1818
/// Tests for account_option_config() implementations
1919
/// Structs tested:
20-
/// 1. ZInstructionDataInvokeCpi - 4 tests for lamports/compress/context combinations
20+
/// 1. ZInstructionDataInvokeCpi - 4 tests for lamports/compress/context combinations
2121
/// 2. ZInstructionDataInvokeCpiWithReadOnly - 4 tests for write_to_cpi_context logic
2222
/// 3. ZInstructionDataInvokeCpiWithAccountInfo - 2 tests for full config scenarios
2323
/// 4. AccountOptions::get_num_expected_accounts - 6 tests for account counting
@@ -380,89 +380,6 @@ fn test_account_info_compress_mode() {
380380
assert_eq!(options, expected);
381381
}
382382

383-
// =============================================================================
384-
// AccountOptions::get_num_expected_accounts Tests
385-
// =============================================================================
386-
387-
#[test]
388-
fn test_get_num_accounts_base() {
389-
// All flags false
390-
let options = AccountOptions {
391-
sol_pool_pda: false,
392-
decompression_recipient: false,
393-
cpi_context_account: false,
394-
write_to_cpi_context: false,
395-
};
396-
397-
// Base=3, +1 for !write_to_cpi_context = 4
398-
assert_eq!(options.get_num_expected_accounts(), 4);
399-
}
400-
401-
#[test]
402-
fn test_get_num_accounts_sol_pool() {
403-
let options = AccountOptions {
404-
sol_pool_pda: true,
405-
decompression_recipient: false,
406-
cpi_context_account: false,
407-
write_to_cpi_context: false,
408-
};
409-
410-
// Base=3, +1 for !write_to_cpi_context, +1 for sol_pool = 5
411-
assert_eq!(options.get_num_expected_accounts(), 5);
412-
}
413-
414-
#[test]
415-
fn test_get_num_accounts_decompression() {
416-
let options = AccountOptions {
417-
sol_pool_pda: false,
418-
decompression_recipient: true,
419-
cpi_context_account: false,
420-
write_to_cpi_context: false,
421-
};
422-
423-
// Base=3, +1 for !write_to_cpi_context, +1 for decompression = 5
424-
assert_eq!(options.get_num_expected_accounts(), 5);
425-
}
426-
427-
#[test]
428-
fn test_get_num_accounts_cpi_context() {
429-
let options = AccountOptions {
430-
sol_pool_pda: false,
431-
decompression_recipient: false,
432-
cpi_context_account: true,
433-
write_to_cpi_context: false,
434-
};
435-
436-
// Base=3, +1 for !write_to_cpi_context, +1 for cpi_context = 5
437-
assert_eq!(options.get_num_expected_accounts(), 5);
438-
}
439-
440-
#[test]
441-
fn test_get_num_accounts_write_context() {
442-
let options = AccountOptions {
443-
sol_pool_pda: false,
444-
decompression_recipient: false,
445-
cpi_context_account: false,
446-
write_to_cpi_context: true,
447-
};
448-
449-
// Base=3 only (no +1 because write_to_cpi_context=true)
450-
assert_eq!(options.get_num_expected_accounts(), 3);
451-
}
452-
453-
#[test]
454-
fn test_get_num_accounts_all_flags() {
455-
let options = AccountOptions {
456-
sol_pool_pda: true,
457-
decompression_recipient: true,
458-
cpi_context_account: true,
459-
write_to_cpi_context: false,
460-
};
461-
462-
// Base=3, +1 for !write_to_cpi_context, +3 for other flags = 7
463-
assert_eq!(options.get_num_expected_accounts(), 7);
464-
}
465-
466383
// =============================================================================
467384
// Randomized Property Tests
468385
// =============================================================================

programs/system/src/context.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::panic::Location;
2+
13
use light_compressed_account::{
24
hash_to_bn254_field_size_be,
35
instruction_data::{
@@ -84,6 +86,7 @@ impl SystemContext<'_> {
8486
}
8587

8688
impl<'info> SystemContext<'info> {
89+
#[track_caller]
8790
pub fn get_index_or_insert(
8891
&mut self,
8992
ix_data_index: u8,
@@ -102,7 +105,15 @@ impl<'info> SystemContext<'info> {
102105
&remaining_accounts
103106
.get(ix_data_index as usize)
104107
.ok_or_else(|| {
105-
msg!("Index: {}, account name: {}", ix_data_index, name);
108+
let location = Location::caller();
109+
msg!(
110+
"Index: {}, account name: {} {}:{}:{}",
111+
ix_data_index,
112+
name,
113+
location.file(),
114+
location.line(),
115+
location.column()
116+
);
106117
SystemProgramError::PackedAccountIndexOutOfBounds
107118
})?;
108119
self.accounts.push(AccountMeta {

programs/system/src/cpi_context/state.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ use std::slice;
22

33
use borsh::BorshDeserialize;
44
use light_account_checks::{checks::check_owner, discriminator::Discriminator};
5-
use light_compressed_account::instruction_data::{
6-
data::OutputCompressedAccountWithPackedContext,
7-
zero_copy::{ZPackedMerkleContext, ZPackedReadOnlyAddress, ZPackedReadOnlyCompressedAccount},
5+
use light_compressed_account::{
6+
instruction_data::{
7+
data::OutputCompressedAccountWithPackedContext,
8+
zero_copy::{
9+
ZPackedMerkleContext, ZPackedReadOnlyAddress, ZPackedReadOnlyCompressedAccount,
10+
},
11+
},
12+
Pubkey as LightPubkey,
813
};
914
use light_program_profiler::profile;
1015
use light_zero_copy::{errors::ZeroCopyError, slice_mut::ZeroCopySliceMut, vec::ZeroCopyVecU8};
@@ -283,7 +288,7 @@ fn deserialize_cpi_context_account_inner<'a, const CLEARED: bool>(
283288
msg!("Invalid cpi context account discriminator.");
284289
return Err(SystemProgramError::InvalidCpiContextDiscriminator.into());
285290
}
286-
let (fee_payer, data) =
291+
let (mut fee_payer, data) =
287292
Ref::<&'a mut [u8], light_compressed_account::pubkey::Pubkey>::from_prefix(data)
288293
.map_err(ZeroCopyError::from)?;
289294

@@ -305,6 +310,7 @@ fn deserialize_cpi_context_account_inner<'a, const CLEARED: bool>(
305310
let (mut output_data_len, mut data) =
306311
Ref::<&'a mut [u8], U16>::from_prefix(data).map_err(ZeroCopyError::from)?;
307312
let output_data = if CLEARED {
313+
*fee_payer = LightPubkey::default();
308314
new_addresses.zero_out();
309315
readonly_addresses.zero_out();
310316
readonly_accounts.zero_out();

0 commit comments

Comments
 (0)