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

Merkle mountain range partial #86

Closed
wants to merge 1 commit into from

Conversation

hackaugusto
Copy link
Contributor

Describe your changes

This adds the MmrPartial structure, useful to keep track of a single entry in the MMR and have infrequent updates.

Checklist before requesting a review

  • Repo forked and branch created from next according to naming convention.
  • Commit messages and codestyle follow conventions.
  • Relevant issues are linked in the PR description.
  • Tests added for new functionality.
  • Documentation/comments updated according to changes.

@hackaugusto hackaugusto changed the base branch from main to next March 2, 2023 21:33
@hackaugusto hackaugusto force-pushed the hacka-merkle-mountain-range-partial branch from 0dd24c2 to 8b87b08 Compare March 2, 2023 21:39
Copy link
Contributor

@vlopes11 vlopes11 left a comment

Choose a reason for hiding this comment

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

Looks good! A preliminary review

/// A partial view of the MMR.
///
/// Data structure used to maintain the proof of a single value up-to-date. Only the data relevant
/// to `value` is stored, meaning the path from the leaf to the root, and the peaks in the MMR that
Copy link
Contributor

Choose a reason for hiding this comment

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

When we say path from the leaf to the root, can we specify in the docs if we refer to a peak or absolute root (i.e. the root of the peaks)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it to path from the leaf to the peak.

Copy link
Contributor Author

@hackaugusto hackaugusto Mar 6, 2023

Choose a reason for hiding this comment

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

And to clarify, this implementation can not have the hash(peaks). That would imply the partial view would need to be updated with every message.

edit: well ... we could change it to have a valid but not necessarily up-to-date value. This isn't implemented ATM. Maybe I should update @bobbinth , any opinions?

Comment on lines +54 to +91
/// Note: It is the caller's responsability to call update with the correct sibling node,
/// otherwise the updated root will be incorrect.
pub fn update(&mut self, right_sibling: Word) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be exposed as public? It might lead to an inconsistent state of the tree, so I think we should either leave it in private scope, or suffix it with _unchecked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the purpose of this structure is to have a partial view of the MMR that can be sporadically updated, this method can not be private.

Is _unchecked the best option? This shouldn't panic

@hackaugusto hackaugusto force-pushed the hacka-merkle-mountain-range-partial branch from 8b87b08 to 21fd481 Compare March 6, 2023 19:31
@hackaugusto hackaugusto force-pushed the hacka-merkle-mountain-range-partial branch from 21fd481 to b305c7e Compare March 6, 2023 20:02
@bobbinth bobbinth mentioned this pull request Apr 9, 2023
12 tasks
@hackaugusto
Copy link
Contributor Author

@bobbinth this PR has a few conflicts now, let me know if I should rebase it, I don't know if we still want this.

@bobbinth
Copy link
Contributor

We'll probably come back to this later - so, don't close it yet. As for rebasing, if it is not too much effort then, yes - I'd keep it up to date.

@bobbinth bobbinth mentioned this pull request Apr 21, 2023
12 tasks
@bobbinth bobbinth mentioned this pull request May 26, 2023
9 tasks
@bobbinth bobbinth mentioned this pull request Jun 25, 2023
10 tasks
@bobbinth bobbinth mentioned this pull request Oct 12, 2023
12 tasks
@hackaugusto
Copy link
Contributor Author

superseded by #195

@hackaugusto hackaugusto deleted the hacka-merkle-mountain-range-partial branch October 17, 2023 15:39
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.

3 participants