Skip to content

Commit

Permalink
Merge pull request #77 from confio/handle-empty-with-custom-order
Browse files Browse the repository at this point in the history
Handle empty with custom order
  • Loading branch information
ethanfrey authored Feb 27, 2022
2 parents fb04c7f + 4515e39 commit 87a967f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions go/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ func leftBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool {
return false
}
for i := 0; i < leftBranches; i++ {
from := actualPrefix + i*int(spec.ChildSize)
idx := getPosition(spec.ChildOrder, int32(i))
from := actualPrefix + idx*int(spec.ChildSize)
if !bytes.Equal(spec.EmptyChild, op.Prefix[from:from+int(spec.ChildSize)]) {
return false
}
Expand All @@ -373,7 +374,8 @@ func rightBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool {
return false // sanity check
}
for i := 0; i < rightBranches; i++ {
from := i * int(spec.ChildSize)
idx := getPosition(spec.ChildOrder, int32(i))
from := idx * int(spec.ChildSize)
if !bytes.Equal(spec.EmptyChild, op.Suffix[from:from+int(spec.ChildSize)]) {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ics23"
version = "0.7.0-rc"
version = "0.7.0"
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2018"
exclude = ["codegen"]
Expand Down
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 87a967f

Please sign in to comment.