Skip to content

Replace the local voting-key filter with the upstream rust-dashcore helper once #916 lands #4262

Description

@bfoss765

Why the local copy exists

PR #4258 surfaces a "which masternodes does this voting key control?" lookup to
Kotlin, for contested-username voting after the dashj engine is held
post-cutover. It needs rust-dashcore's
MasternodeList::masternodes_by_voting_key, which is not on the Dash-owned
rust-dashcore revision this workspace pins (70d4bf8e36057c58e02d56769a6e9760f701dd06).

The helper does exist upstream, but only as the last of four commits on
dashpay/rust-dashcore#916 (branch feat/owner-tagged-reservations) — a PR whose
main subject is owner-tagged reservations, and which is currently
CHANGES_REQUESTED, conflicting against dev, and whose reviewer has asked for
it to be split. Waiting on it is therefore open-ended.

Pinning the workspace to a revision that carries the helper meant redirecting
all eight rust-dashcore workspace dependencies at a personal fork
(bfoss765/rust-dashcore), which also dragged in ~528 lines of unrelated
owner-tagged-reservation and asset-lock behaviour. That fork pin was rejected in
review on #4258. The workspace therefore stays on the Dash-owned revision and
#4258 carries a small local copy of the filter instead.

The filter reads only long-standing public SML fields (key_id_voting,
pro_reg_tx_hash), so the local copy is low-risk — but it is duplication, and
this issue exists so it does not become permanent.

The duplication site

  • File: packages/rs-platform-wallet/src/spv/runtime.rs
  • Function to delete: private free fn
    masternodes_by_voting_key(list: &MasternodeList, voting_key_id: &PubkeyHash) -> Vec<[u8; 32]>
  • Its tests: #[cfg(test)] mod masternodes_by_voting_key_tests in the same file
  • Sole caller: SpvRuntime::masternodes_by_voting_key_blocking

The local function folds the ProTxHash -> [u8; 32] (internal byte order)
conversion into the same pass; the upstream helper returns Vec<ProTxHash>, so
the conversion has to come back when swapping.

What to do once the helper lands upstream

  1. Move the workspace rust-dashcore pin in Cargo.toml (all 8 deps) and
    Cargo.lock to a Dash-owned revision that contains
    MasternodeList::masternodes_by_voting_key.
  2. Delete the private masternodes_by_voting_key free function in
    runtime.rs.
  3. In SpvRuntime::masternodes_by_voting_key_blocking, replace
    masternodes_by_voting_key(list, voting_key_id) with the upstream call plus
    the byte-order conversion:
    list.masternodes_by_voting_key(voting_key_id)
        .into_iter()
        .map(|pro_tx| {
            let mut out = [0u8; 32];
            out.copy_from_slice(pro_tx.as_ref());
            out
        })
        .collect()
  4. Delete mod masternodes_by_voting_key_tests, or keep it as a regression test
    against the upstream helper — it only touches public API, so it compiles
    either way.
  5. Drop the use dashcore::sml::masternode_list::MasternodeList; import from
    runtime.rs if nothing else there needs it.

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions