-
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
Tracking: proof of work validation #802
Comments
Removed the checkbox from #829 since I don't think it's essential to do immediately. |
How much is there left to do on this for the Alpha release? We should move this out of the milestone once we have the Alpha release items done |
The difficulty adjustment validation doesn't have any tests yet. I have been prioritising fixing known bugs and errors over writing extra tests. If I get time, I'll write a few tests for this code. (There are other tests I'd like to do, but they will probably take more time than we have.) This ticket already had a "lower-priority tasks" section. I've renamed it to "future releases", and moved most of the testing work into it. |
I've created specific tickets for the remaining first alpha release work in this ticket, and moved it out of the milestone. |
Removing Epic label as there are no longer any issues tracked under this Epic and this better fits a github tracking issue instead. |
There are no required tasks left in this tracking issue. |
In #572, we created
CompactDifficulty
andExpandedDifficulty
wrapper types for block proof of work difficulty.But we also use difficulty to validate blocks, and choose the best tip.
Alpha Releases
Context-free block validation
difficulty_threshold
toblock.hash()
(Block difficulty checks - context-free #809)Choosing the best tip
Convert
difficulty_threshold
toWork
((2**256 - bnTarget - 1) / (bnTarget+1)) + 1
or(~bnTarget / (bnTarget+1)) + 1
check the total cumulative work against zcashd's calculationImplement Expanded to Compact
ExpandedDifficulty
toCompactDifficulty
Arbitrary for CompactDifficulty
by converting from random, non-zeroHash
Arbitrary for CompactDifficulty
inArbitrary for Block
Arbitrary for ExpandedDifficulty
by converting fromArbitrary for CompactDifficulty
Arbitrary for Work
using a random u128Arbitrary for PartialCumulativeWork
using a random u128Testing
CompactDifficulty
andExpandedDifficulty
Work
, and doAdd
andSub
onPartialCumulativeWork
Difficulty adjustment - contextual
Spec Issues:
Design:
Implementation:
Check that
difficulty_threshold
satisfies the difficulty adjustment consensus rulesdifficulty_threshold_is_valid
AdjustedDifficulty
andnew_from_block
expected_difficulty_threshold
threshold_bits
mean_target_difficulty
median_timespan_bounded
median_time
averaging_window_timespan
andaveraging_window_timespan_for_height
onNetworkUpgrade
is_testnet_min_difficulty_block
onNetworkUpgrade
>
, and it's easy to get>
confused with>=
Check that the
time
field is valid:Tests:
Tests for spec errors:
zcashd
Testnet min-difficulty rules are incorrectly specified zcash/zips#416Cleanup
Semantic validation:
block::Header
- Move the difficulty filter into ablock::Header
method #1445<=
, and it's easy to get<=
confused with<
Refactor:
chain
methods toany_block_iter
, to avoid confusion - Rename state methods based on any chain or best chain #1446Later Releases
Additional Tests
zcashd
for test vectorsTests for spec errors:
RFC Improvements
Guide-level:
Reference-level:
Test Plan:
Explain how the feature will be tested, including:
The tests should cover:
Denial of Service resistance
CheckpointVerifier
blocks, so that a single bad peer can't poison arbitrary heights in the verifier's queuePotential Refactor
{ mantissa: NonZeroU32, exponent: NonZeroU8 }
u32
to a bag of bits2^23
34 = 255/8 + OFFSET
Difficulty cache
Dependencies
primitive_types
withbigint
#829)The text was updated successfully, but these errors were encountered: