Skip to content
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

Block difficulty checks - context-free #809

Merged
merged 5 commits into from
Aug 4, 2020

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Aug 3, 2020

Context-free block difficulty validation

Compare difficulty_threshold to block.hash():

  • implement PartialOrd, Ord (using Eq) for ExpandedDifficulty to BlockHeaderHash
  • add the hash threshold check to BlockVerifier
  • test using the main and test chains
    • disable some checkpoints in a custom build?

Dependencies:

  • add a u256 arithmetic library (division, invert bits, addition, multiplication, comparison)
  • make ExpandedDifficulty use u256 internally

@teor2345 teor2345 added A-docs Area: Documentation A-dependencies Area: Dependency file updates Poll::Ready A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement labels Aug 3, 2020
@teor2345 teor2345 self-assigned this Aug 3, 2020
@teor2345 teor2345 requested a review from a team August 3, 2020 07:39
Adds a dependency on the primitive-types crate.

Also adds custom hex debug formatting for compact and expanded
difficulties.
For some reason, implementing
`PartialOrd<BlockHeaderHash> for ExpandedDifficulty` (or its converse)
makes this unrelated code ambiguous.
@teor2345 teor2345 marked this pull request as ready for review August 3, 2020 07:44
zebra-chain/src/block/difficulty.rs Show resolved Hide resolved
zebra-chain/src/block/difficulty.rs Show resolved Hide resolved
zebra-chain/src/block/difficulty.rs Show resolved Hide resolved
@teor2345 teor2345 merged commit ffb6aac into ZcashFoundation:main Aug 4, 2020
@teor2345 teor2345 mentioned this pull request Nov 5, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Consensus rule updates A-dependencies Area: Dependency file updates A-docs Area: Documentation A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants