diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index 6c03daf3e7..b11c469968 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -1110,7 +1110,7 @@ impl<'a> InvokeContext<'a> { self.check_aligned = check_aligned; } - // Sshould alignment be enforced during user pointer translation + // Should alignment be enforced during user pointer translation pub fn get_check_aligned(&self) -> bool { self.check_aligned } diff --git a/sdk/src/transaction_context.rs b/sdk/src/transaction_context.rs index 49a19f207f..90db0ed3c4 100644 --- a/sdk/src/transaction_context.rs +++ b/sdk/src/transaction_context.rs @@ -112,10 +112,11 @@ impl TransactionContext { self.account_keys.iter().rposition(|key| key == pubkey) } - pub fn get_instruction_context_indicies( + /// Gets an InstructionContext by its nesting level in the stack + pub fn get_instruction_context_at( &self, level: usize, - ) -> Result<(usize, usize), InstructionError> { + ) -> Result<&InstructionContext, InstructionError> { let top_level_index = *self .instruction_stack .get(0) @@ -128,15 +129,6 @@ impl TransactionContext { .get(level) .ok_or(InstructionError::CallDepth)? }; - Ok((top_level_index, cpi_index)) - } - - /// Gets an InstructionContext by its nesting level in the stack - pub fn get_instruction_context_at( - &self, - level: usize, - ) -> Result<&InstructionContext, InstructionError> { - let (top_level_index, cpi_index) = self.get_instruction_context_indicies(level)?; let instruction_context = self .instruction_trace .get(top_level_index) @@ -146,21 +138,6 @@ impl TransactionContext { Ok(instruction_context) } - /// Gets an InstructionContext by its nesting level in the stack - pub fn get_instruction_context_mut_at( - &mut self, - level: usize, - ) -> Result<&mut InstructionContext, InstructionError> { - let (top_level_index, cpi_index) = self.get_instruction_context_indicies(level)?; - let instruction_context = self - .instruction_trace - .get_mut(top_level_index) - .and_then(|instruction_trace| instruction_trace.get_mut(cpi_index)) - .ok_or(InstructionError::CallDepth)?; - debug_assert_eq!(instruction_context.nesting_level, level); - Ok(instruction_context) - } - /// Gets the max height of the InstructionContext stack pub fn get_instruction_context_capacity(&self) -> usize { self.instruction_context_capacity @@ -181,17 +158,6 @@ impl TransactionContext { self.get_instruction_context_at(level) } - /// Returns the current InstructionContext - pub fn get_current_instruction_context_mut( - &mut self, - ) -> Result<&mut InstructionContext, InstructionError> { - let level = self - .get_instruction_context_stack_height() - .checked_sub(1) - .ok_or(InstructionError::CallDepth)?; - self.get_instruction_context_mut_at(level) - } - /// Pushes a new InstructionContext pub fn push( &mut self, @@ -271,26 +237,6 @@ impl TransactionContext { pub fn get_instruction_trace(&self) -> &InstructionTrace { &self.instruction_trace } - - // /// Set the original account lengths - // pub fn set_orig_account_lengths( - // &mut self, - // orig_account_lengths: Vec, - // ) -> Result<(), InstructionError> { - // let level = self - // .get_instruction_context_stack_height() - // .checked_sub(1) - // .ok_or(InstructionError::CallDepth)?; - // let (top_level_index, cpi_index) = self.get_instruction_context_indicies(level)?; - // let instruction_context = self - // .instruction_trace - // .get_mut(top_level_index) - // .and_then(|instruction_trace| instruction_trace.get_mut(cpi_index)) - // .ok_or(InstructionError::CallDepth)?; - // debug_assert_eq!(instruction_context.nesting_level, level); - // instruction_context.orig_account_lengths = Some(orig_account_lengths); - // Ok(()) - // } } /// Return data at the end of a transaction