-
Notifications
You must be signed in to change notification settings - Fork 106
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 minimum difficulty bugs #1256
Fix minimum difficulty bugs #1256
Conversation
This comment has been minimized.
This comment has been minimized.
Unblocked by Daira, who said that blocks 299188, 299189, and 299190 are minimum-difficulty blocks. I also un-assigned yaahc as the reviewer, because this PR is not ready for review yet. I'm not sure if it actually fixes the bug. |
@yaahc after you approve this PR, I'd like to squash and rebase it myself, so we can keep some of the changes to different modules in different commits. |
And add the network to the difficulty filter error.
And add a method for the minimum difficulty time gap threshold.
`zcashd` converts the PoWLimit into a compact representation before using it to perform difficulty filter checks. The Zcash specification converts to compact for the default difficulty filter, but not for testnet minimum difficulty blocks. (ZIP 205 and ZIP 208 don't specify this conversion either.) See ZcashFoundation#1277.
We need spandoc 0.2.1 to avoid a panic on empty blocks.
7b76d47
to
495685f
Compare
Motivation
There are a bunch of bugs in Zebra's difficulty implementation, and the Zcash difficulty specifications also have some bugs.
Solution
New changes:
zcashd
's implementation Testnet min-difficulty rules are incorrectly specified zcash/zips#416expect("minimum difficulty activation is checked earlier in the test")
into anErr
if the rule is not active (and so the function returnsNone
)Tests for spec errors:
zcashd
Testnet min-difficulty rules are incorrectly specified zcash/zips#416Reviewed changes:
zebra_test::vectors::block
, along with their previous blocksBlockVerifier
difficulty tests pass on these new blocksThe code in this pull request has:
Review
@yaahc has reviewed the Difficulty Contextual Validation RFC, which describes these checks.
Related Issues
Difficulty Contextual Validation RFC PR #1246
Difficulty tracking issue #802
Fixes bugs in:
Follow Up Work
Move the difficulty filter check into the state service- obsoleted by Testnet min-difficulty rules are incorrectly specified zcash/zips#416Block
orExpandedDifficulty
<=
confused with<
This work is listed in the difficulty tracking issue #802