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

Median Block Selection for DAA now follows ABC algorithm. #12

Merged
merged 1 commit into from
May 10, 2020

Conversation

joshmg
Copy link
Member

@joshmg joshmg commented Feb 29, 2020

The median Block selection algorithm for the Difficulty Adjustment Algorithm now follows the expanded footprints specified in the specification.

The median selection algorithm previously used a descending order stable sort algorithm via a custom Comparitor on the Block's Timestamp. This operation is inconsistent with ABC's implementation when 2 of the 3 Blocks have the same Timestamp value, which causes the node to select a different median Block with a different ChainWork value, ultimately hypothetically leading to a different difficulty calculation.

This implementation difference was never encountered on main net. Although the likeliness of encountering this edge case is rare, all nodes should upgrade to the next release containing this patch as it would result in a chain split if encountered.

This bug fix is in response to Issue #11 . His commentary is located in more depth here: https://read.cash/@Fernando/on-daa-implementation-algorithms-and-specifications-b739e631

@joshmg joshmg added the bug Something isn't working label Feb 29, 2020
@joshmg joshmg self-assigned this Feb 29, 2020
@joshmg joshmg linked an issue Feb 29, 2020 that may be closed by this pull request
@joshmg joshmg merged commit b71bf0d into master May 10, 2020
@joshmg joshmg deleted the bug/0011_difficulty_adjustment_median_sorting branch January 31, 2021 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DAA is not compatible with reference implementation code.
1 participant