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

bug: Remove leaf data from BMT proofs #502

Merged
merged 12 commits into from
Jul 10, 2023
Merged

Conversation

bvrooman
Copy link
Contributor

@bvrooman bvrooman commented Jul 6, 2023

.ok_or(MerkleTreeError::LoadError(proof_index))?
.into_owned();
let leaf_node = Node::from(primitive);
proof_set.push(*leaf_node.hash());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block is what added the hashed leaf data to the proof set. This is now removed, and the proof set no longer includes the leaf data.

Comment on lines +96 to +97
let mut proof_set = VecDeque::from(self.proof_set);
proof_set.pop_front();
Copy link
Contributor Author

@bvrooman bvrooman Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the hashed leaf data from the test-helpers reference version of the BMT proof generation. The reference Merkle tree algorithm used here is different than the one used in production. Because of the specifics of the algorithm, we can only remove the leaf data from the proof after the proof is generated.

@bvrooman bvrooman self-assigned this Jul 6, 2023
@bvrooman bvrooman marked this pull request as ready for review July 8, 2023 14:22
@bvrooman bvrooman requested review from xgreenx and a team and removed request for xgreenx July 8, 2023 14:22
xgreenx
xgreenx previously approved these changes Jul 10, 2023
@@ -1,42 +1,44 @@
use crate::binary::{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to re-use the fuel_merkle::binary::verify function here?

Copy link
Contributor Author

@bvrooman bvrooman Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that reusing the function here is worth considering.
As part of that consideration, some factors include:

  • Do we have a production use case for fuel_merkle::binary::verify yet? If not, it might actually make more sense to keep only test_helpers::binary::verify instead. test_helpers::binary::verify is used specifically to verify proofs during tests (i.e. check the proofs are generated correctly), but fuel_merkle::binary::verify doesn't have a "real" use case.
  • Can we simplify or improve the implementation of fuel_merkle::binary::verify? If so, we can use test-helpers::binary::verify to quickly check the correctness of any refactors to the production version.

@bvrooman bvrooman added this pull request to the merge queue Jul 10, 2023
Merged via the queue into master with commit b8407f7 Jul 10, 2023
@bvrooman bvrooman deleted the bvrooman/bug/bmt-prove-update branch July 10, 2023 18:36
@xgreenx xgreenx mentioned this pull request Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants