Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1161 +/- ##
==========================================
+ Coverage 78.87% 79.07% +0.20%
==========================================
Files 304 304
Lines 81405 81527 +122
==========================================
+ Hits 64206 64467 +261
+ Misses 17199 17060 -139
|
55520e6 to
930a451
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
930a451 to
21e6cf5
Compare
8da4424 to
321d486
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
Headers were only checked against the target in their own bits, so past the last checkpoint a peer could serve a chain of minimal difficulty. Params::next_work_required computes the bits Dash Core requires, as its GetNextWorkRequired from Dark Gravity Wave on, and the header validator rejects a header whose bits differ, from the stored headers before it. Closes #1116 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
321d486 to
03e740e
Compare
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Bots are done — your move: address xdustinface requested changes, then post |
|
@coderabbitai review |
|
xdustinface
left a comment
There was a problem hiding this comment.
-
Mainnet below 68589 needs the 50% tolerance. Core only requires exact
bitsabove 68589 (validation.cpp,ContextualCheckBlockHeader). Below that it allows 50%, because early mainnet ran DGW v1/v2. Real headers from 34140 to 68588 fail the exact check. Real mainnet sync with this branch:--start-height 0rejects 34140 (bits 0x1c00f8a9, required 0x1c00f987) and--start-height 50000rejects 50024. Skip the check, or use the 50% tolerance, on mainnet up to 68589, and add a test at that boundary. -
Checkpoint 750000 has the wrong
timeandbits. It has1491953700/0x1a075a02, but the real block has1507424630/0x1a027884. The hash is correct. Since the anchor now feeds DGW, real mainnet sync with--start-height 750000rejects 750024 (bits 0x1a02b0d8, required 0x1a08c176). Every wallet born in 750000..799999 hits this. Please fix the entry and add a test that checks every checkpoint'stimeandbitsagainst the real block.In all three runs the client then reports headers
Syncedat the stall height (32000, 50000, 750000) and never moves again (#1194). The same runs on the base commit sync through. -
The first 23 headers after the start checkpoint are unchecked, and they seed DGW for everything after. A wallet born after the last checkpoint (2500000) starts there, so a peer can serve 23 minimum-difficulty headers and stay at minimum difficulty from then on. That is the #1116 attack. Either close the gap (for example, start one checkpoint earlier so those headers are pinned by a hash) or change
Closes #1116toPart of #1116and open a follow-up.
|
@xdustinface what if a finish #375 first, that would solve the point 2 issue |
Early mainnet ran the first versions of Dark Gravity Wave, so Dash Core only requires the exact bits above height 68589. Up to it, the bits only have to be within 50% of the required difficulty. The header validator now applies the same rule, so real mainnet headers from 34140 to 68588 are accepted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Also, #375 could store the previous 23, so a checkpoint is now a Vec o headers, and not only one, and, when geenrating the checkpoints, I would be able to validate the chainn in that point |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Bots are done — your move: address xdustinface requested changes, then post |
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
Closes #1116.
Headers were only checked against the target in their own
bits, so past the last checkpoint a peer could serve a chain of minimal difficulty (and, through fork detection, make the client drop stored blocks, #1103).Params::next_work_required(window, last_height, time): thebitsDash Core requires, as itsGetNextWorkRequiredfrom Dark Gravity Wave on, including testnet's min difficulty rules and regtest's fixed limit.Noneon devnets (whose difficulty rules are set per devnet), before DGW, or without 24 headers of history.BlockHeaderValidator::new(network, ancestors, tip_height): each header'sbitsmust match, checked in the same parallel pass as continuity and PoW.BlockHeadersManagerpasses the last 24 stored headers, so both initial sync and announced headers are checked. The first headers after a checkpoint start, without full history, are not.ValidationError::InvalidDifficulty.Header::mainnet_fixture()indashcoretest utils: 30 real mainnet headers (1999976 to 2000005), hashes checked.Tests:
next_work_requiredreproduces thebitsof mainnet header 2000000 and applies the devnet, pre-DGW, regtest and testnet rules; the validator rejects a header whose hash meets an easier target but not the required difficulty.Breaking:
BlockHeadersManager::newtakes the network, andBlockHeaderValidator::newtakes the network, the stored headers the batch extends and the height of the last of them.🤖 Generated with Claude Code
PR Hygiene ·
6383467/self-revieweddash-spv(dash-spv/src/client/lifecycle.rs,dash-spv/src/error.rs,dash-spv/src/sync/block_headers/manager.rsand 1 more) — QuantumExplorer or xdustinfacedash/src/consensus/params.rs,dash/src/pow.rs,dash/src/test_utils/block.rsand 1 more) — QuantumExplorer or xdustinfaceWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.