This commit is contained in:
Jack May
2022-04-12 17:52:47 -07:00
committed by GitHub
parent 138f04a49f
commit a43ff3bbcb
2 changed files with 4 additions and 58 deletions

View File

@ -1110,7 +1110,7 @@ impl<'a> InvokeContext<'a> {
self.check_aligned = check_aligned; 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 { pub fn get_check_aligned(&self) -> bool {
self.check_aligned self.check_aligned
} }

View File

@ -112,10 +112,11 @@ impl TransactionContext {
self.account_keys.iter().rposition(|key| key == pubkey) 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, &self,
level: usize, level: usize,
) -> Result<(usize, usize), InstructionError> { ) -> Result<&InstructionContext, InstructionError> {
let top_level_index = *self let top_level_index = *self
.instruction_stack .instruction_stack
.get(0) .get(0)
@ -128,15 +129,6 @@ impl TransactionContext {
.get(level) .get(level)
.ok_or(InstructionError::CallDepth)? .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 let instruction_context = self
.instruction_trace .instruction_trace
.get(top_level_index) .get(top_level_index)
@ -146,21 +138,6 @@ impl TransactionContext {
Ok(instruction_context) 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 /// Gets the max height of the InstructionContext stack
pub fn get_instruction_context_capacity(&self) -> usize { pub fn get_instruction_context_capacity(&self) -> usize {
self.instruction_context_capacity self.instruction_context_capacity
@ -181,17 +158,6 @@ impl TransactionContext {
self.get_instruction_context_at(level) 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 /// Pushes a new InstructionContext
pub fn push( pub fn push(
&mut self, &mut self,
@ -271,26 +237,6 @@ impl TransactionContext {
pub fn get_instruction_trace(&self) -> &InstructionTrace { pub fn get_instruction_trace(&self) -> &InstructionTrace {
&self.instruction_trace &self.instruction_trace
} }
// /// Set the original account lengths
// pub fn set_orig_account_lengths(
// &mut self,
// orig_account_lengths: Vec<usize>,
// ) -> 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 /// Return data at the end of a transaction