Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Stop the search at transaction level.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Aug 19, 2022
1 parent ac73b16 commit 185030a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1714,15 +1714,21 @@ declare_syscall!(
let stack_height = invoke_context.get_stack_height();
let instruction_trace = invoke_context.transaction_context.get_instruction_trace();
let mut current_index = 0;
let instruction_context = instruction_trace.iter().rev().find(|instruction_context| {
if instruction_context.get_stack_height() == stack_height {
let mut instruction_context = None;
for current_instruction_context in instruction_trace.iter().rev() {
if current_instruction_context.get_stack_height() == TRANSACTION_LEVEL_STACK_HEIGHT
&& stack_height > TRANSACTION_LEVEL_STACK_HEIGHT
{
break;
}
if current_instruction_context.get_stack_height() == stack_height {
if index.saturating_add(1) == current_index {
return true;
instruction_context = Some(current_instruction_context);
break;
}
current_index = current_index.saturating_add(1);
}
false
});
}

if let Some(instruction_context) = instruction_context {
let ProcessedSiblingInstruction {
Expand Down

0 comments on commit 185030a

Please sign in to comment.