Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-2954] - Allow fixedDifficulty=1 to mean "all solutions" #1784

Merged
merged 2 commits into from
Jul 30, 2019

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Jul 30, 2019

PR description

If you try and do a difficulty of 1 the UInt256 class used for comparison throws
an error because 2^256 is 33 bytes. Instead use 2^256-1 which is 32 bytes.

If you try and do a difficulty of 1 the UInt256 class used for comparison throws
an error because 2^256 is 33 bytes.  Instead use 2^256-1 which is 32.
@@ -47,8 +47,10 @@ public boolean validate(final BlockHeader header, final BlockHeader parent) {
}
final BigInteger difficulty =
BytesValues.asUnsignedBigInteger(header.getDifficulty().getBytes());
final UInt256 target = UInt256.of(ETHHASH_TARGET_UPPER_BOUND.divide(difficulty));

final UInt256 target =
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about creating a new ethash package somewhere (ethereum/core/.../mainnet/ethash??) to consolidate these types of utilities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a good idea, probably as part of ProgPow work. Opened as PAN-2998

@shemnon shemnon merged commit 4f531b5 into PegaSysEng:master Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants