Repository navigation
Conversation
Add `DashSpvClient::current_masternode_list` and its blocking twin. They return the newest masternode list, whose `known_height` is the height it describes, only while it follows the chain. Otherwise they return a `MasternodeListNotCurrent` saying why: masternode sync is disabled, the client is not running, sync has not caught up since the client started, or the list is behind the header tip. `latest_masternode_list` returns any stored list: one restored from storage before the client synced, one a stopped client still holds, or one whose tip updates keep failing while masternode sync stays `Synced`. Callers had to guess freshness from separate progress reads. A list is current when the client runs, header and masternode sync are both `Synced`, and the list is at most two blocks below the header tip, which covers one tip diff in flight. The running flag, the progress and the list are read under the sync coordinator lock, so `run` and `stop` cannot swap the progress in between and a list from an earlier run is never reported current. The sync state machine is unchanged: masternode sync still stays `Synced` when tip updates fail, and `BehindTip` reports that case to readers of the list. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
`current_masternode_list` judged freshness only against the local header tip. After the host wakes from sleep, or while peers relay nothing, that tip is as old as the list, so an hours-old list was reported current. Return the new `TipStale` when the tip header is older than `MAINNET_MAX_TIP_AGE` (30 min) or `TESTNET_MAX_TIP_AGE` (2 h). Regtest and devnets mine on demand and are exempt. The tip header's block time is carried in `BlockHeadersProgress`, so the check reads the same progress snapshot without touching storage. Also from review: - compare the list against the higher of the header manager's tip and the masternode manager's copy of it; - return `NotRunning` before taking the coordinator lock, which `stop` holds while its tasks drain; - report `Disabled` when a running client has no masternode sync, such as after `update_config` turned it off; - export `MASTERNODE_LIST_TIP_TOLERANCE` and use it in the docs and tests; - rename the error to `MasternodeListNotCurrentError`, like the crate's other error types; - document that `Syncing` also follows a loss of all peers; - test the run-again window on the same client and check the restarted client's list against the engine. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
Assert that `BlockHeadersManager` records the tip header's block time when it starts from stored headers and when it stores a batch. Without it, `current_masternode_list` would report `TipStale` on mainnet 30 minutes after start. Document that the tip age is measured against the host clock, keep the raw Unix timestamp out of the `TipStale` message, and document its `tip_time` field. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
4 of 13 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/provider-key-lookup-by-hash #1466 +/- ##
====================================================================
+ Coverage 86.55% 86.59% +0.03%
====================================================================
Files 271 271
Lines 71045 71218 +173
====================================================================
+ Hits 61491 61668 +177
+ Misses 9554 9550 -4
|
This was referenced Nov 21, 2026
Draft
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TL;DR: dash-spv can now hand out its masternode list only while that list is current, and says why when it is not, so callers stop using a list that is stale, restored from storage, or left over from a stopped client.
User story
As a wallet or application developer using dash-spv, I want to read the masternode list only while it reflects the current chain, to achieve decisions (for example about masternode keys) that are never based on an outdated list.
Scenario
Base flow
An application asks the SPV client for its masternode list, for example right after start-up, after the host wakes from sleep, or while list updates keep failing.
Actual behavior
latest_masternode_listreturns whatever list the client holds: one restored from storage before the client has synced, one a stopped client still keeps, one whose tip updates keep failing while masternode sync staysSynced, or one from before the host slept. Callers have to guess freshness from separate progress reads.Expected behavior
The application gets the newest list only when it is current. Otherwise it gets a typed reason (
Disabled,NotRunning,Syncing,TipStale,BehindTip) and can wait or tell the user.Detailed discussion
What was done
This PR is stacked atop #1465 (
feat/provider-key-lookup-by-hash); the two share no code.DashSpvClient::current_masternode_listandcurrent_masternode_list_blocking. They return the newest list, whoseknown_heightis the height it describes, only while:Synced;MAINNET_MAX_TIP_AGE(30 min) on Mainnet orTESTNET_MAX_TIP_AGE(2 h) on Testnet. Regtest and devnets mine on demand, so their tip age is not checked;MASTERNODE_LIST_TIP_TOLERANCE(2) blocks below the header tip, measured against the header manager's tip when it is ahead of reported progress.MasternodeListNotCurrentError:Disabled,NotRunning,Syncing,TipStale { tip_time }orBehindTip.tip_time), which the age check uses.Not included: the sync state machine is unchanged. Making masternode sync leave
Syncedwhen list updates stop applying is left to a follow-up.Testing
dash-spv/src/client/queries.rs: a list within two blocks of the tip is current; one further behind is not; the header manager's tip is used when ahead; an old header tip isTipStale; Regtest and devnet lists do not age; a client without masternode sync reportsDisabled; a stored list is not current before sync catches up; no list is current while the client is stopped.dash-spv/tests/dashd_masternode/tests_sync.rspins the header tip time the freshness check relies on.Prior work
🤖 Generated with Claude Code
https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4
🤖 Co-authored by Claudius the Magnificent AI Agent