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: light weight merkle tree didn't forget previously inserted elements #466

Merged
merged 2 commits into from
Jan 16, 2024
Merged
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
4 changes: 2 additions & 2 deletions primitives/src/merkle_tree/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ where
value: children[frontier - 1].value(),
});
}
let increment = children[frontier].extend_internal::<H, Arity>(
let increment = children[frontier].extend_and_forget_internal::<H, Arity>(
height - 1,
&cur_pos,
traversal_path,
Expand Down Expand Up @@ -775,7 +775,7 @@ where
value: children[frontier - 1].value(),
});
}
let increment = children[frontier].extend_internal::<H, Arity>(
let increment = children[frontier].extend_and_forget_internal::<H, Arity>(
height - 1,
&cur_pos,
traversal_path,
Expand Down
4 changes: 4 additions & 0 deletions primitives/src/merkle_tree/light_weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ mod mt_tests {
assert!(mt.push(F::from(0u64)).is_err());
assert!(mt.extend(&[]).is_ok());
assert!(mt.extend(&[F::from(1u64)]).is_err());

// Checks that the prior elements are all forgotten
(0..8).for_each(|i| assert!(mt.lookup(i).expect_not_in_memory().is_ok()));
assert!(mt.lookup(8).expect_ok().is_ok());
}

#[test]
Expand Down
Loading