-
Notifications
You must be signed in to change notification settings - Fork 107
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(rpc): Refactor the serialization of note commitment trees #8533
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upbqdn
added
C-bug
Category: This is a bug
I-usability
Zebra is hard to understand or use
A-rpc
Area: Remote Procedure Call interfaces
P-Medium ⚡
rust
Pull requests that update Rust code
labels
May 14, 2024
1 task
arya2
reviewed
May 16, 2024
Co-authored-by: Arya <aryasolhi@gmail.com>
Co-authored-by: Arya <aryasolhi@gmail.com>
Co-authored-by: Arya <aryasolhi@gmail.com>
Co-authored-by: Arya <aryasolhi@gmail.com>
… into fix-z-gettreestate
oxarbitrage
previously approved these changes
May 20, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, i think it looks great. I love the amount of code we were able to remove from Zebra here.
5 tasks
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
… into fix-z-gettreestate
This reverts commit 0799cb2.
oxarbitrage
approved these changes
May 22, 2024
5 tasks
@Mergifyio refresh |
✅ Pull request refreshed |
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-rpc
Area: Remote Procedure Call interfaces
C-bug
Category: This is a bug
I-usability
Zebra is hard to understand or use
P-Medium ⚡
rust
Pull requests that update Rust code
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Close #8471.
The bug described in #8471 is caused by an incorrect serialization of empty note commitment trees for RPCs. Zebra serializes such trees as the empty string, but
zcashd
serializes them as000000
. This bug is related only to thez_get_treestate
RPC. The state contains the right trees and uses a different serialization format.PR Author Checklist
Check before marking the PR as ready for review:
Solution
Remove the old RPC serialization code.
Use an upstream code to serialize the trees for RPCs.
Note that the serialization of non-empty Sapling treestates now differs between
zebrad
andzcashd
. We can see this in the results of the manual tests below. The difference is thatzebrad
's non-empty Sapling treestates contain trailing zeros, whereaszcashd
's ones don't. Both serializations deserialize to the same frontier and use the sparse format, which permits the omission or inclusion of the trailing zeros. See https://discord.com/channels/809218587167293450/809251012610752513/1240372877358792755 for more details.Cleanups.
Testing
Snapshots
Results of manual tests
The results below compare the responses from
z_gettreestate
tozcashd
. Note thatzebrad
doesn't provide thefinalState
object, and when an object is empty,zebrad
skips its serialization.Sapling
zcash-cli z_gettreestate 419199 | jq
zebrad
:zcashd
:zcash-cli z_gettreestate 419200 | jq
zebrad
:zcashd
:zcash-cli z_gettreestate 419201 | jq
zebrad
:zcashd
:zcash-cli z_gettreestate 1687104 | jq
zebrad
:zcashd
:zcash-cli z_gettreestate 1687107 | jq
zebrad
:zcashd
:Reviewer Checklist
Check before approving the PR:
PR blockers can be dealt with in new tickets or PRs.
And check the PR Author checklist is complete.
Follow Up Work
z_get_treestate
RPC #8536