From 7d765f30b9c1db70b71278b740e342c58cb3b284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Fri, 12 Aug 2022 18:04:47 +0200 Subject: [PATCH] Stop the search at transaction level. --- programs/bpf_loader/src/syscalls/mod.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index af76b18dc0264f..950fcded0f337c 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -1715,15 +1715,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 {