-
Notifications
You must be signed in to change notification settings - Fork 108
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(chain): Validate header versions when serializing blocks #6475
Conversation
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.
It looks good, thank you for the fix.
wrong_checkpoint_hash_fail_test
is failing. This seems to be because Zebra now panic in the serialization instead of an error in the verifier.
Can be fixed by changed the version to 5
at https://github.com/ZcashFoundation/zebra/blob/main/zebra-consensus/src/checkpoint/tests.rs#L507
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.
Looks good, I just want to check we handle the serialization error correctly.
In some cases, we panic because we assume serialization errors are not possible. But we only do this when we serialize to a vector or memory. (If we're using the disk or network, we can encounter an IO error like a full disk or a broken connection.)
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6475 +/- ##
==========================================
- Coverage 77.89% 77.72% -0.17%
==========================================
Files 304 304
Lines 39678 39665 -13
==========================================
- Hits 30908 30831 -77
- Misses 8770 8834 +64 |
Thank you!! Applied in 86ec19b.
It looks like |
That makes sense to me! |
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 for the extra docs and tests!
Motivation
This PR updates the
ZcashSerialize
implementation for block headers to apply to same constraints asZcashDeserialize
.Closes #497.
Solution
zcash_deserialize
to acheck_version
functioncheck_version()
fromzcash_serialize
Related changes:
LOW_31_BITS
constant and masking of high bit when deserializing (a high bit causes an error anyways)Review
Anyone can review.
Reviewer Checklist