-
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
Implement Expanded to Compact Difficulty Conversion #1196
Conversation
Remove the derive, and generate values from random block hashes.
And cleanup some duplicate test code
Remove AddAssign for Work Rewrite a proptest using Sub for PartialCumulativeWork Use Arbitrary for Work Fix an Arbitrary for Work bug
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.
I'll make these changes over the next day or so.
zebra-chain/src/work/arbitrary.rs
Outdated
ExpandedDifficulty::from_hash(&block::Hash(bytes)) | ||
.to_compact() | ||
.into() |
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.
ExpandedDifficulty::from_hash(&block::Hash(bytes)) | |
.to_compact() | |
.into() | |
Some(ExpandedDifficulty::from_hash(&block::Hash(bytes)) | |
.to_compact()) |
This change makes sure that rejected work values don't disable property tests on other types.
I opened #1231 to follow up the Windows failure at: I'll close and re-open the PR to re-run the checks. |
Motivation
We need to check if the compact difficulty in the block header satisfies the difficulty adjustment contextual validation rules.
Those rules require us to perform calculations on
U256
expanded difficulty values, and convert the results toCompactDifficulty
.This PR covers the first stage of these checks: converting expanded to compact difficulty.
(And adds a bunch of tests and cleanups.)
The next step is to design contextual validation for difficulty, see ticket #1036.
Solution
Related Issues
Difficulty Tracking #802
Difficulty Contextual Validation Design #1036
Other Resources
zcashd implementation: