You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can see that it has stack_height = 2, but parent_instruction = None, which shouldn't be possible.
I believe the issue occurs because you assign the parent on stack pop? That might not happen for the last instruction, so we should assign on stack push? Perhaps something like:
diff --git a/src/utils/instruction.rs b/src/utils/instruction.rs
index 3094d73..2530594 100644
--- a/src/utils/instruction.rs
+++ b/src/utils/instruction.rs
@@ -180,6 +180,7 @@ where
for instruction in flattened_instructions {
let structured_instruction = Rc::new(StructuredInstruction::new(instruction, Vec::new().into(), &accounts));
+ // Pop instructions off stack and establish parent relationships
while !instruction_stack.is_empty() && instruction_stack.last().unwrap().stack_height() >= structured_instruction.stack_height() {
let popped_instruction = instruction_stack.pop().unwrap();
*popped_instruction.logs.borrow_mut() = log_stack.close(logs, popped_instruction.program_id());
@@ -192,6 +193,12 @@ where
}
}
+ // Set parent relationship for current instruction if there's a parent on stack
+ if !instruction_stack.is_empty() && structured_instruction.stack_height().unwrap_or(1) > 1 {
+ *structured_instruction.parent_instruction.borrow_mut() =
+ Some(Rc::downgrade(instruction_stack.last().unwrap()));
+ }
+
log_stack.open(logs, structured_instruction.program_id());
instruction_stack.push(structured_instruction);
}
@@ -201,6 +208,7 @@ where
*popped_instruction.logs.borrow_mut() = log_stack.close(logs, popped_instruction.program_id());
if !instruction_stack.is_empty() {
+ *popped_instruction.parent_instruction.borrow_mut() = Some(Rc::downgrade(instruction_stack.last().unwrap()));
instruction_stack.last_mut().unwrap().inner_instructions.borrow_mut().push(popped_instruction);
} else {
structured_instructions.push(popped_instruction)
The text was updated successfully, but these errors were encountered:
If you parse this transaction: https://explorer.solana.com/tx/599kTg8k8Mz7QJnAimAUmiYXtbynx7oczqFCXXFGXF32Sb8MzKuX42EX2Lsj2PEdk2TDsZTMKqsBUqhxHnBSqJAD
The last inner instruction 3.10, will have:
You can see that it has stack_height = 2, but parent_instruction = None, which shouldn't be possible.
I believe the issue occurs because you assign the parent on stack pop? That might not happen for the last instruction, so we should assign on stack push? Perhaps something like:
The text was updated successfully, but these errors were encountered: