Skip to content

Commit

Permalink
Fix branches_empty with custom ordering in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Feb 27, 2022
1 parent 143288f commit 4c0fbe6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rust/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ fn left_branches_are_empty(spec: &ics23::InnerSpec, op: &ics23::InnerOp) -> Resu
_ => return Ok(false),
};
for i in 0..left_branches {
let from = actual_prefix + i * child_size;
let idx = spec.child_order.iter().find(|&&x| x == i as i32).unwrap();
let idx = *idx as usize;
let from = actual_prefix + idx * child_size;
if spec.empty_child != op.prefix[from..from + child_size] {
return Ok(false);
}
Expand All @@ -300,7 +302,9 @@ fn right_branches_are_empty(spec: &ics23::InnerSpec, op: &ics23::InnerOp) -> Res
return Ok(false);
}
for i in 0..right_branches {
let from = i * spec.child_size as usize;
let idx = spec.child_order.iter().find(|&&x| x == i as i32).unwrap();
let idx = *idx as usize;
let from = idx * spec.child_size as usize;
if spec.empty_child != op.suffix[from..from + spec.child_size as usize] {
return Ok(false);
}
Expand Down

0 comments on commit 4c0fbe6

Please sign in to comment.