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

Infrastructure for changing the hash function #894

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

larskuhtz
Copy link
Contributor

@larskuhtz larskuhtz commented Jan 28, 2020

This PR adds support for more selecting the POW hash algorithm based on chainweb version and block height. It also adds support for allowing more than a single POW hash algorithm at the same block height.

In detail:

  • Move BlockHeight into its own module.

  • Add a PowHashAlg enumeration type.

  • Add a chainweb version property ChainwebVersion -> BlockHeight -> [(PowHashAlg, Natural)], where the Natural number designates the multiplier for difficulty of the respective algorithm.

  • Use the first byte (actually, currently only the first bit) of the features flags in the BlockHeader to indicate the POW hash algorithm that is used.

  • Add validation logic to verify that the a block header uses a hash algorithm that is supported for the respective chainweb version and block height.

  • Change validation logic to include the multiplier for the POW hash when checking the target.

  • Add a utility function for transitioning between two algorithms while keeping the block rate constant.

  • Address FIXMEs in Chainweb.PowHash.

  • Adapt implementation in Chainweb.Miner.Core to select the correct POW hash.

  • Add selection of hash algorithm to mining coordinator configuration.

This PR also contains an unrelated bug fix, that adds a validation rule that verifies that unused features flags are set to 0. Important: Complete history catchup and validation must be performed before rolling this out.

@@ -104,6 +100,10 @@ module Chainweb.BlockHeader
, blockFlags
, _blockPow
, blockPow
, _blockPowHashAlg
, blockPowHashAlg
, _blockPowMultiplyer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, _blockPowMultiplyer
, _blockPowMultiplier

@emilypi emilypi changed the title Infrastructure for chainging the hash function Infrastructure for changing the hash function Feb 27, 2020
@fosskers fosskers added the component:core Core code not associated with any one component. label Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:core Core code not associated with any one component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants