Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove parameter from constructor
  • Loading branch information
LucasSte committed Aug 5, 2025
commit 33672c43cfb35bf5f8bf0fb3cda3f61f80ec44bd
3 changes: 1 addition & 2 deletions ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
pubkey,
AccountSharedData::new(0, allocation_size, &Pubkey::new_unique()),
));
instruction_accounts.push(InstructionAccount::new(0, 0, false, true));
instruction_accounts.push(InstructionAccount::new(0, false, true));
vec![]
}
Err(_) => {
Expand Down Expand Up @@ -480,7 +480,6 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
idx
};
InstructionAccount::new(
txn_acct_index as IndexOfAccount,
txn_acct_index as IndexOfAccount,
account_info.is_signer.unwrap_or(false),
account_info.is_writable.unwrap_or(false),
Expand Down
31 changes: 5 additions & 26 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ impl<'a> InvokeContext<'a> {
let instruction_context = self.transaction_context.get_current_instruction_context()?;
debug_assert!(instruction.accounts.len() <= u8::MAX as usize);

for (instruction_account_index, account_meta) in instruction.accounts.iter().enumerate()
{
for account_meta in instruction.accounts.iter() {
let index_in_transaction = self
.transaction_context
.find_index_of_account(&account_meta.pubkey)
Expand Down Expand Up @@ -371,7 +370,6 @@ impl<'a> InvokeContext<'a> {
*index_in_callee = instruction_accounts.len() as u8;
instruction_accounts.push(InstructionAccount::new(
index_in_transaction,
instruction_account_index as IndexOfAccount,
account_meta.is_signer,
account_meta.is_writable,
));
Expand Down Expand Up @@ -498,7 +496,6 @@ impl<'a> InvokeContext<'a> {
let index_in_transaction = *index_in_transaction as usize;
instruction_accounts.push(InstructionAccount::new(
index_in_transaction as IndexOfAccount,
*index_in_callee as IndexOfAccount,
message.is_signer(index_in_transaction),
message.is_writable(index_in_transaction),
));
Expand Down Expand Up @@ -883,23 +880,14 @@ pub fn mock_process_instruction_with_feature_set<
) -> Vec<AccountSharedData> {
let mut instruction_accounts: Vec<InstructionAccount> =
Vec::with_capacity(instruction_account_metas.len());
for (instruction_account_index, account_meta) in instruction_account_metas.iter().enumerate() {
for account_meta in instruction_account_metas.iter() {
let index_in_transaction = transaction_accounts
.iter()
.position(|(key, _account)| *key == account_meta.pubkey)
.unwrap_or(transaction_accounts.len())
as IndexOfAccount;
let index_in_callee = instruction_accounts
.get(0..instruction_account_index)
.unwrap()
.iter()
.position(|instruction_account| {
instruction_account.index_in_transaction == index_in_transaction
})
.unwrap_or(instruction_account_index) as IndexOfAccount;
instruction_accounts.push(InstructionAccount::new(
index_in_transaction,
index_in_callee,
account_meta.is_signer,
account_meta.is_writable,
));
Expand Down Expand Up @@ -1017,12 +1005,7 @@ mod tests {
let program_id = instruction_context.get_last_program_key(transaction_context)?;
let instruction_accounts = (0..4)
.map(|instruction_account_index| {
InstructionAccount::new(
instruction_account_index,
instruction_account_index,
false,
false,
)
InstructionAccount::new(instruction_account_index, false, false)
})
.collect::<Vec<_>>();
assert_eq!(
Expand Down Expand Up @@ -1126,7 +1109,6 @@ mod tests {
));
instruction_accounts.push(InstructionAccount::new(
index as IndexOfAccount,
instruction_accounts.len() as IndexOfAccount,
false,
true,
));
Expand All @@ -1137,7 +1119,6 @@ mod tests {
AccountSharedData::new(1, 1, &solana_pubkey::Pubkey::default()),
));
instruction_accounts.push(InstructionAccount::new(
index as IndexOfAccount,
index as IndexOfAccount,
false,
false,
Expand Down Expand Up @@ -1214,7 +1195,6 @@ mod tests {
let instruction_accounts = (0..4)
.map(|instruction_account_index| {
InstructionAccount::new(
instruction_account_index,
instruction_account_index,
false,
instruction_account_index < 2,
Expand Down Expand Up @@ -1271,7 +1251,6 @@ mod tests {
let instruction_accounts = (0..4)
.map(|instruction_account_index| {
InstructionAccount::new(
instruction_account_index,
instruction_account_index,
false,
instruction_account_index < 2,
Expand Down Expand Up @@ -1361,8 +1340,8 @@ mod tests {
(program_key, program_account),
];
let instruction_accounts = vec![
InstructionAccount::new(0, 0, false, true),
InstructionAccount::new(1, 1, false, false),
InstructionAccount::new(0, false, true),
InstructionAccount::new(1, false, false),
];
with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);
let mut program_cache_for_tx_batch = ProgramCacheForTxBatch::default();
Expand Down
7 changes: 0 additions & 7 deletions program-runtime/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,15 +624,8 @@ mod tests {
.iter()
.enumerate()
.map(|(index_in_instruction, index_in_transaction)| {
let index_in_callee = transaction_indexes
.get(0..index_in_instruction)
.unwrap()
.iter()
.position(|account_index| account_index == index_in_transaction)
.unwrap_or(index_in_instruction);
InstructionAccount::new(
*index_in_transaction,
index_in_callee as IndexOfAccount,
false,
is_writable(index_in_instruction),
)
Expand Down
7 changes: 1 addition & 6 deletions programs/bpf_loader/benches/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {
solana_pubkey::Pubkey,
solana_rent::Rent,
solana_sdk_ids::{bpf_loader, bpf_loader_deprecated},
solana_transaction_context::{IndexOfAccount, InstructionAccount, TransactionContext},
solana_transaction_context::{InstructionAccount, TransactionContext},
};

fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionContext {
Expand Down Expand Up @@ -89,13 +89,8 @@ fn create_inputs(owner: Pubkey, num_instruction_accounts: usize) -> TransactionC
.take(num_instruction_accounts)
.enumerate()
{
let index_in_callee = instruction_accounts
.iter()
.position(|account| account.index_in_transaction == index_in_transaction)
.unwrap_or(instruction_account_index) as IndexOfAccount;
instruction_accounts.push(InstructionAccount::new(
index_in_transaction,
index_in_callee,
false,
instruction_account_index >= 4,
));
Expand Down
2 changes: 1 addition & 1 deletion programs/sbf/benches/bpf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ macro_rules! with_mock_invoke_context {
AccountSharedData::new(2, $account_size, &program_key),
),
];
let instruction_accounts = vec![InstructionAccount::new(2, 0, false, true)];
let instruction_accounts = vec![InstructionAccount::new(2, false, true)];
solana_program_runtime::with_mock_invoke_context!(
$invoke_context,
transaction_context,
Expand Down
4 changes: 2 additions & 2 deletions programs/system/src/system_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ mod test {
(system_program::id(), AccountSharedData::default()),
];
let $instruction_accounts = vec![
InstructionAccount::new(0, 0, true, true),
InstructionAccount::new(1, 1, false, true),
InstructionAccount::new(0, true, true),
InstructionAccount::new(1, false, true),
];
with_mock_invoke_context!($invoke_context, transaction_context, transaction_accounts);
};
Expand Down
4 changes: 2 additions & 2 deletions programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ mod tests {
let mut instruction_context = InstructionContext::default();
instruction_context.configure_for_tests(
vec![0],
vec![InstructionAccount::new(1, 0, false, true)],
vec![InstructionAccount::new(1, false, true)],
&[],
);

Expand Down Expand Up @@ -1318,7 +1318,7 @@ mod tests {
let mut instruction_context = InstructionContext::default();
instruction_context.configure_for_tests(
vec![0],
vec![InstructionAccount::new(1, 0, false, true)],
vec![InstructionAccount::new(1, false, true)],
&[],
);

Expand Down
8 changes: 3 additions & 5 deletions syscalls/src/cpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,11 +1309,9 @@ mod tests {
let instruction_data = $instruction_data;
let instruction_accounts = $instruction_accounts
.iter()
.enumerate()
.map(|(index_in_callee, index_in_transaction)| {
.map(|index_in_transaction| {
InstructionAccount::new(
*index_in_transaction as IndexOfAccount,
index_in_callee as IndexOfAccount,
false,
$transaction_accounts[*index_in_transaction as usize].2,
)
Expand Down Expand Up @@ -1857,8 +1855,8 @@ mod tests {
.configure_for_tests(
vec![0],
vec![
InstructionAccount::new(1, 0, false, true),
InstructionAccount::new(1, 0, false, true),
InstructionAccount::new(1, false, true),
InstructionAccount::new(1, false, true),
],
&[],
);
Expand Down
1 change: 0 additions & 1 deletion syscalls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4448,7 +4448,6 @@ mod tests {
{
let instruction_accounts = vec![InstructionAccount::new(
index_in_trace.saturating_add(1) as IndexOfAccount,
0,
false,
false,
)];
Expand Down
1 change: 0 additions & 1 deletion transaction-context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ pub struct InstructionAccount {
impl InstructionAccount {
pub fn new(
index_in_transaction: IndexOfAccount,
_index_in_callee: IndexOfAccount,
is_signer: bool,
is_writable: bool,
) -> InstructionAccount {
Expand Down