Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix verification of proofs for specs with more than 2 children per node (in Rust implementation) #290

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/src/cosmos.ics23.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub struct ProofSpec {
pub struct InnerSpec {
/// Child order is the ordering of the children node, must count from 0
/// iavl tree is \[0, 1\] (left then right)
/// merk is \[0, 2, 1\] (left, right, here)
/// merk is \[0, 1, 2\] (left, here, right)
#[prost(int32, repeated, tag = "1")]
pub child_order: ::prost::alloc::vec::Vec<i32>,
#[prost(int32, tag = "2")]
Expand Down
4 changes: 2 additions & 2 deletions rust/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
// ensure every step has a prefix and suffix defined to be rightmost, unless it is a placeholder node
for step in path {
if !has_padding(step, &pad) && !right_branches_are_empty(spec, step)? {
bail!("step not leftmost")
bail!("step not rightmost")

Check warning on line 233 in rust/src/verify.rs

View check run for this annotation

Codecov / codecov/patch

rust/src/verify.rs#L233

Added line #L233 was not covered by tests
}
}
Ok(())
Expand Down Expand Up @@ -344,7 +344,7 @@
if right_branches == 0 {
return Ok(false);
}
if op.suffix.len() != spec.child_size as usize {
if op.suffix.len() != right_branches * spec.child_size as usize {
return Ok(false);
}
for i in 0..right_branches {
Expand Down
Loading