diff --git a/programs/bpf_loader/src/serialization.rs b/programs/bpf_loader/src/serialization.rs index 6c046b2c0f2f0b..cb02226953420c 100644 --- a/programs/bpf_loader/src/serialization.rs +++ b/programs/bpf_loader/src/serialization.rs @@ -497,21 +497,20 @@ mod tests { &program_indices, ) .instruction_accounts; + let instruction_data = vec![]; - let transaction_context = + let mut transaction_context = TransactionContext::new(transaction_accounts, Some(Rent::default()), 1, 1); - let instruction_data = vec![]; - let instruction_context = InstructionContext::new( - 0, - 0, - &program_indices, - &instruction_accounts, - &instruction_data, - ); + transaction_context + .push(&program_indices, &instruction_accounts, &instruction_data) + .unwrap(); + let instruction_context = transaction_context + .get_instruction_context_at_index_in_trace(0) + .unwrap(); let serialization_result = serialize_parameters( &transaction_context, - &instruction_context, + instruction_context, should_cap_ix_accounts, ); assert_eq!( diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 24d64589f0ef68..b70100c89e30e2 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -766,14 +766,14 @@ pub fn inner_instructions_list_from_instruction_trace( transaction_context: &TransactionContext, ) -> InnerInstructionsList { debug_assert!(transaction_context - .get_instruction_context_at_index(0) + .get_instruction_context_at_index_in_trace(0) .map(|instruction_context| instruction_context.get_stack_height() == TRANSACTION_LEVEL_STACK_HEIGHT) .unwrap_or(true)); let mut outer_instructions = Vec::new(); for index_in_trace in 0..transaction_context.get_instruction_trace_length() { if let Ok(instruction_context) = - transaction_context.get_instruction_context_at_index(index_in_trace) + transaction_context.get_instruction_context_at_index_in_trace(index_in_trace) { if instruction_context.get_stack_height() == TRANSACTION_LEVEL_STACK_HEIGHT { outer_instructions.push(Vec::new()); diff --git a/sdk/src/transaction_context.rs b/sdk/src/transaction_context.rs index a47197c6cce26d..d22a91372b7745 100644 --- a/sdk/src/transaction_context.rs +++ b/sdk/src/transaction_context.rs @@ -211,13 +211,13 @@ impl TransactionContext { return Err(InstructionError::UnbalancedInstruction); } } - let instruction_context = InstructionContext { - nesting_level: self.instruction_stack.len(), - instruction_accounts_lamport_sum: callee_instruction_accounts_lamport_sum, - program_accounts: program_accounts.to_vec(), - instruction_accounts: instruction_accounts.to_vec(), - instruction_data: instruction_data.to_vec(), - }; + let instruction_context = InstructionContext::new( + self.instruction_stack.len(), + callee_instruction_accounts_lamport_sum, + program_accounts.to_vec(), + instruction_accounts.to_vec(), + instruction_data.to_vec(), + ); let index_in_trace = self.instruction_trace.len(); self.instruction_trace.push(instruction_context); if self.instruction_stack.len() >= self.instruction_context_capacity { @@ -335,19 +335,19 @@ pub struct InstructionContext { impl InstructionContext { /// New - pub fn new( + fn new( nesting_level: usize, instruction_accounts_lamport_sum: u128, - program_accounts: &[usize], - instruction_accounts: &[InstructionAccount], - instruction_data: &[u8], + program_accounts: Vec, + instruction_accounts: Vec, + instruction_data: Vec, ) -> Self { InstructionContext { nesting_level, instruction_accounts_lamport_sum, - program_accounts: program_accounts.to_vec(), - instruction_accounts: instruction_accounts.to_vec(), - instruction_data: instruction_data.to_vec(), + program_accounts, + instruction_accounts, + instruction_data, } }