Repository navigation
fix(dash-spv): defer a ChainLock until the masternode lists reach it - #1063
Conversation
Once masternode sync was ready, `process_chainlock` verified every ChainLock against whatever lists the engine held and counted a failure as invalid for good. A ChainLock that arrives before the lists covering its signing quorum (newest list below its height) fails only because the engine lags, and it was never retried: `pending_validation` was filled only before the first `MasternodeStateUpdated`, and every later one was ignored. That is how `tests_chainlock::test_chainlock_promotes_in_block_tx` times out on slower CI runners (macOS, Ubuntu ARM): the SPV held lists up to 410, the ChainLocks at 429 and 432 failed with `Threshold signature ... is not valid`, and the QRInfo that brought the list at 432 landed 9 s later with nothing left to validate, so best_validated_height stayed at 0. Now a ChainLock that fails while the newest list is below its height is kept in `pending_validation` (the latest one replaces it, so a forged ChainLock at a far height cannot hold the slot) and retried on every `MasternodeStateUpdated`. It is rejected once the lists reach its height and it still fails, and never accepted without a valid signature. With no lists, or with lists already past it, a failure is rejected at once as before. A pending ChainLock at or below the best one is dropped. Tests: - `test_chainlock_signed_above_the_newest_list_is_not_accepted` (#1059) now expects the ChainLock deferred instead of counted invalid; it is still not accepted. - `test_deferred_chainlock_is_rejected_once_lists_reach_it`: kept across an update that leaves the lists behind it, rejected once a list reaches it. - `test_chainlock_below_the_newest_list_is_rejected_immediately`. The race did not reproduce locally (8/8 runs pinned to 2 cores pass with and without the fix), so the fix rests on the CI log and the unit tests. Verified: fmt, clippy --workspace --all-features --all-targets -D warnings, dash-spv 573 + dashd_masternode 10 + dashd_sync 32, dash-spv-ffi 49 + dashd_sync 7. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedNext included review available in 45 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/rust-dashcore/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
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 #1063 +/- ##
==========================================
+ Coverage 77.45% 77.48% +0.02%
==========================================
Files 317 317
Lines 80680 80754 +74
==========================================
+ Hits 62491 62569 +78
+ Misses 18189 18185 -4
|
|
@coderabbitai review |
|
|
Bots are done — your move: post |
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
@coderabbitai approve |
✅ Action performedComments resolved and changes approved. |
|
Bots are done — your move: post |
Once masternode sync was ready,
process_chainlockverified every ChainLock against whatever lists the engine held and counted a failure as invalid for good. A ChainLock that arrives before the lists covering its signing quorum (newest list below its height) fails only because the engine lags, and it was never retried:pending_validationwas filled only before the firstMasternodeStateUpdated, and every later one was ignored.That is how
tests_chainlock::test_chainlock_promotes_in_block_txtimes out on slower CI runners (macOS, Ubuntu ARM): the SPV held lists up to 410, the ChainLocks at 429 and 432 failed withThreshold signature ... is not valid, and the QRInfo that brought the list at 432 landed 9 s later with nothing left to validate, so best_validated_height stayed at 0.Now a ChainLock that fails while the newest list is below its height is kept in
pending_validation(the latest one replaces it, so a forged ChainLock at a far height cannot hold the slot) and retried on everyMasternodeStateUpdated. It is rejected once the lists reach its height and it still fails, and never accepted without a valid signature. With no lists, or with lists already past it, a failure is rejected at once as before. A pending ChainLock at or below the best one is dropped.Tests:
test_chainlock_signed_above_the_newest_list_is_not_accepted(fix(dash): reject a ChainLock the list below its signing height refuses #1059) now expects the ChainLock deferred instead of counted invalid; it is still not accepted.test_deferred_chainlock_is_rejected_once_lists_reach_it: kept across an update that leaves the lists behind it, rejected once a list reaches it.test_chainlock_below_the_newest_list_is_rejected_immediately.The race did not reproduce locally (8/8 runs pinned to 2 cores pass with and without the fix), so the fix rests on the CI log and the unit tests.
Verified: fmt, clippy --workspace --all-features --all-targets -D warnings, dash-spv 573 + dashd_masternode 10 + dashd_sync 32, dash-spv-ffi 49 + dashd_sync 7.
PR Hygiene ·
0781e07/self-revieweddash-spv(dash-spv/src/sync/chainlock/manager.rs,dash-spv/src/sync/chainlock/sync_manager.rs) — QuantumExplorer or xdustinfaceWhen every box is checked the
PR Hygienecheck passes and this can merge.