This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
fixed #1261, overflow when calculating work #1283
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -509,5 +510,11 @@ mod tests { | |||
} | |||
} | |||
|
|||
#[test] | |||
fn test_difficulty_to_boundary() { | |||
let _ = Ethash::difficulty_to_boundary(&U256::from(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not asserting the actuall result?
arkpar
added
A8-looksgood 🦄
Pull request is reviewed well.
and removed
A0-pleasereview 🤓
Pull request needs code review.
labels
Jun 14, 2016
waiting for the answer... |
gavofyork
added
A5-grumble 🔥
Pull request has minor issues that must be addressed before merging.
and removed
A8-looksgood 🦄
Pull request is reviewed well.
labels
Jun 14, 2016
debris
added
A0-pleasereview 🤓
Pull request needs code review.
and removed
A5-grumble 🔥
Pull request has minor issues that must be addressed before merging.
labels
Jun 14, 2016
rphmeier
added
A8-looksgood 🦄
Pull request is reviewed well.
and removed
A0-pleasereview 🤓
Pull request needs code review.
labels
Jun 15, 2016
@@ -255,12 +255,14 @@ impl Ethash { | |||
|
|||
/// Convert an Ethash boundary to its original difficulty. Basically just `f(x) = 2^256 / x`. | |||
pub fn boundary_to_difficulty(boundary: &H256) -> U256 { | |||
U256::from((U512::one() << 256) / U256::from(boundary.as_slice()).into()) | |||
let d = cmp::max(U256::from(boundary), U256::one()); | |||
((U256::one() << 255) / d) << 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will still overflow if boundary == d == U256::one()
(returning the impossible boundary 0
as the tests confirm).
rather it should probably special-case boundary <= 1
and return !U256::zero()
. see YP(160).
gavofyork
added
A4-gotissues 💥
Pull request is reviewed and has significant issues which must be addressed.
and removed
A8-looksgood 🦄
Pull request is reviewed well.
labels
Jun 15, 2016
debris
added
A0-pleasereview 🤓
Pull request needs code review.
and removed
A4-gotissues 💥
Pull request is reviewed and has significant issues which must be addressed.
labels
Jun 15, 2016
updated |
gavofyork
added
A8-looksgood 🦄
Pull request is reviewed well.
and removed
A0-pleasereview 🤓
Pull request needs code review.
labels
Jun 15, 2016
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
geth does it similarly https://github.com/ethereum/go-ethereum/blob/506c9277911746dfbab0a585aee736bd3095f206/miner/remote_agent.go#L112-L127