Registry Mirror
Skip to content

Conversation

@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator

TL;DR: platform-wallet now reads the masternode list only through dash-spv's own "current list" check, so a list restored from disk while the client catches up can no longer make a key in use look unused or vouch for a key the node no longer uses.

User story

As a wallet app developer, I want every current-masternode-list read in platform-wallet to refuse a list that does not follow the chain, to achieve key checks and "unused key" answers that are never based on an outdated list.

Scenario

Base flow

A wallet app restarts with a masternode list stored on disk and, while SPV is still catching up, asks platform-wallet for unused provider key candidates or verifies a masternode key.

Actual behavior

platform-wallet checks readiness and then reads the list in a separate step, so the list can change between the two. Some readers (the blocking key-candidate and key-reference reads) are not gated at all and use the restored list: a key in use can be reported as unused, and an old list can vouch for a key the node has replaced.

Expected behavior

Each current-list read is a single dash-spv call that returns the list only while header and masternode sync follow the chain. While SPV catches up, has a stale header tip, or holds a list behind the tip, the read fails with MasternodeListUnavailable, which clears once sync catches up.

Detailed discussion

Issue being fixed or feature implemented

Stacked atop #6030 (chore/mn-dashcore-k1-s1), which pins rust-dashcore with dash-spv's DashSpvClient::current_masternode_list (dashpay/rust-dashcore#1466). A sibling of #6031, not stacked on it.

What was done?

  • spv/runtime.rs: SpvRuntime::current_masternode_list and the crate's current summaries and entries reads call DashSpvClient::current_masternode_list through one helper. One client call replaces the readiness check, the separate list read and the run-session guard around them, so while_following_the_chain is removed. A list dash-spv refuses (MasternodeListNotCurrentError) becomes PlatformWalletError::MasternodeListUnavailable, as before; the reason is logged at debug.
  • New crate-private current_masternode_list_summaries_blocking, the gated blocking twin:
    • live_provider_key_candidates_blocking (masternode/key_candidates.rs) reads it, so a list restored from disk while sync catches up no longer reports a key in use as unused;
    • masternode_key_reference_blocking (masternode/mod.rs, behind the FFI key verification) reads it, like the async fetch_masternode_key_reference. When the list is refused, the wallet and tracked records still fill in.
  • The ungated masternode_list_entries read is removed; only the readiness-gated wrapper used it.
  • is_synced_to_tip uses dash-spv's MASTERNODE_LIST_TIP_TOLERANCE instead of its own copy.
  • Docs: MasternodeListUnavailable and the FFI locator and update-registrar docs say the list is refused while it does not follow the chain (still syncing, a stale header tip, or a list behind the tip) and that the error clears once sync catches up.
  • Public signatures are unchanged.

FFI / mobile behaviour changes

  • Unused provider key candidates (update registrar) fail with ErrorMasternodeListUnavailable during catch-up, including when a list was restored from disk, instead of answering from that list.
  • Masternode key verification reads list-known keys only from a current list; during catch-up it uses only the wallet's and tracked records.
  • After the host sleeps, a stale header tip now makes current-list reads fail until sync catches up.

Known limitations

  • is_ready stays a cheap progress check on MASTERNODE_LIST_TIP_TOLERANCE, without dash-spv's tip-age rule: the quorum context provider calls it on every lookup, and dash-spv offers no current-list check that does not copy the whole list. After the host sleeps it can report ready while current_masternode_list refuses the list. A TODO waits for a non-cloning dash-spv check.

Follow-ups

  • Other pre-existing ungated list readers: masternode_list_summaries[_blocking], masternodes_by_voting_key_blocking, masternode_validity_snapshot_blocking, track_blocking.
  • A non-cloning current-list check in rust-dashcore.

How Has This Been Tested?

  • spv/runtime.rs: no current list through any read while the runtime is not running; no current list while sync catches up; a list restored from disk is refused while sync catches up, by the gated reads and the provider key candidates; tip-tolerance boundary tests on dash-spv's constant.
  • A full independent review (security, reuse, requirements and a second-model pass) approved it; all in-scope findings were fixed and re-verified.

Breaking Changes

No Rust signature changes. The FFI behaviour changes above apply to mobile hosts.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

https://claude.ai/code/session_01WunYYk4eUkHuGstPtj83j4

🤖 Co-authored by Claudius the Magnificent AI Agent

lklimek and others added 7 commits November 21, 2026 07:10
…-spv

`SpvRuntime::current_masternode_list` and the crate's current summaries and
entries read `DashSpvClient::current_masternode_list`, which returns the list
only while header and masternode sync follow the chain. One client call
replaces the readiness check, the separate list read and the run-session
guard around them, so `while_following_the_chain` goes. A list dash-spv
refuses is `PlatformWalletError::MasternodeListUnavailable`, as before.

`live_provider_key_candidates_blocking` reads the gated blocking twin, so a
list restored from disk while sync catches up no longer reports a key in use
as unused.

`is_ready` keeps its progress check: the quorum context provider calls it on
every lookup, and dash-spv offers no current-list check that does not copy the
whole list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the readiness-gated wrapper read it; the current entries read dash-spv's
current list directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…atches up

The gated reads and the provider key candidates must refuse a list the
engine already holds while sync catches up; the existing tests use fresh
storage, where the ungated read also has no list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…m dash-spv

`is_synced_to_tip` uses dash-spv's `MASTERNODE_LIST_TIP_TOLERANCE` instead of
its own copy. `is_ready` documents that it is a cheap progress check without
dash-spv's tip-age rule, so after the host sleeps it can report ready while
`current_masternode_list` refuses the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t only

`masternode_key_reference_blocking`, behind the FFI key verification, read
the ungated list, so a list restored from disk while sync catches up could
vouch for a key the node no longer uses. It reads the gated blocking list
like `fetch_masternode_key_reference`; the wallet and tracked records still
fill in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The list is refused while it does not follow the chain: still syncing, a
stale header tip, or a list behind the tip. The error clears once sync
catches up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e test

The public read's assertion joins the gated-reads test for a runtime that is
not running. The restored-list test takes its imports from the module top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@thepastaclaw

thepastaclaw commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 0886d0c. Normal review starts when eligible; priority review starts as soon as a slot is available.

@lklimek
lklimek changed the base branch from chore/mn-dashcore-k1-s1 to feat/mn-provider-key-lookup November 24, 2026 11:14
@lklimek
lklimek added this pull request to stack #6211 November 24, 2026 11:14
@lklimek
lklimek force-pushed the refactor/mn-current-list-dash-spv branch from a6416e1 to 0886d0c Compare November 24, 2026 11:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants