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

change(state): Refactor the naming of note commitment subtrees #7855

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

upbqdn
Copy link
Member

@upbqdn upbqdn commented Oct 26, 2023

Motivation

Close #7463.

Solution

#7463 mentions that "We are storing subtree roots and end heights in the subtree indexes, not the subtree trees themselves." I thought of renaming NoteCommitmentSubtree to SubtreeRoot, but there were at least two problems with that:

  1. There is also the struct NoteCommitmentSubtreeData, which I wasn't sure how to rename.
  2. NoteCommitmentSubtree has a field node, which I had renamed to root, so we would end up with something like subtree_root.root.

Given the issues above, I decided to do a simpler refactor:

  1. Rename the generic type Node in NoteCommitmentSubtree to Root.
  2. Rename the field node in NoteCommitmentSubtree to root.
  3. Rename the field end in NoteCommitmentSubtree to end_height to match the name in the RPC so that the field doesn't need to be renamed for the RPC.

After this refactor, I didn't find any docs that would require changes.

Also, if we ever need to store whole subtrees instead of only roots, we can use the already existing struct NoteCommitmentSubtree, but keep the RPC that currently uses this struct intact because it actually uses NoteCommitmentSubtreeData.

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

@upbqdn upbqdn added A-docs Area: Documentation C-cleanup Category: This is a cleanup P-Low ❄️ A-state Area: State / database changes C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG labels Oct 26, 2023
@upbqdn upbqdn self-assigned this Oct 26, 2023
@upbqdn upbqdn requested a review from a team as a code owner October 26, 2023 23:03
@upbqdn upbqdn requested review from teor2345 and removed request for a team October 26, 2023 23:03
@upbqdn
Copy link
Member Author

upbqdn commented Oct 26, 2023

I'm not actually sure about the solution in this PR. Do others have suggestions for better solutions?

@upbqdn upbqdn requested review from arya2 and removed request for teor2345 October 26, 2023 23:26
arya2
arya2 previously approved these changes Oct 27, 2023
Copy link
Contributor

@arya2 arya2 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, thank you!

zebra-chain/src/subtree.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

Thank you!

mergify bot added a commit that referenced this pull request Oct 30, 2023
@mergify mergify bot merged commit 0d3892f into main Oct 30, 2023
105 checks passed
@mergify mergify bot deleted the rename-subtrees branch October 30, 2023 20:06
@teor2345 teor2345 mentioned this pull request Nov 5, 2023
41 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation A-state Area: State / database changes C-cleanup Category: This is a cleanup C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename subtree methods and types to "subtree root"
2 participants