Skip to content

dash-spv: ClientConfig has no way to supply a devnet genesis block hash #789

Closed

Description

@QuantumExplorer

Problem

DashSpvClient::start fails on Network::Devnet with:

SPV error: Configuration error: No known genesis hash for network

Source: dash-spv/src/client/lifecycle.rs:309-312 calls config.network.known_genesis_block_hash(). The implementation in dash/src/network/constants.rs:78 returns None for Network::Devnet:

Network::Devnet => None,  // devnets use dynamically-generated genesis blocks

Mainnet, testnet, and regtest all have compiled-in genesis hashes. Devnets don't — every devnet name produces a different genesis from the dynamic devnet seed. So there's no static value known_genesis_block_hash() can return, and ClientConfig exposes no way to override.

The checkpoint fallback at lifecycle.rs:240-306 would normally let start_from_height bootstrap from a later block instead of genesis, but the checkpoint table at lines 243-247 hardcodes mainnet/testnet only:

let checkpoints = match config.network {
    dashcore::Network::Mainnet => crate::chain::checkpoints::mainnet_checkpoints(),
    dashcore::Network::Testnet => crate::chain::checkpoints::testnet_checkpoints(),
    _ => vec![],
};

So there is currently no public-API path to initialize DashSpvClient against a devnet.

Impact

Any consumer pointing dash-spv at a named devnet (e.g. paloma) gets a hard initialization error during SPV startup. Surfaces in dashpay/platform when iOS clients try to start SPV against a paloma devnet — used today for asset-lock-proof acquisition alongside shielded sync benchmarking. Workaround is to skip the SPV start entirely on Network::Devnet, but that loses asset-lock proof acquisition (depends on ChainLockManager / InstantSendManager spawned by SPV) and Core balance sync.

Proposed fix

Add an optional explicit override to ClientConfig:

// dash-spv/src/client/config.rs
pub struct ClientConfig {
    pub network: Network,
    // ... existing fields ...

    /// Optional explicit genesis block hash. Required when `network` is
    /// [`Network::Devnet`], since devnets generate their genesis dynamically
    /// from a devnet name + seed and there is no compiled-in default.
    /// Ignored for other networks (their `known_genesis_block_hash` takes
    /// precedence).
    pub genesis_block_hash: Option<BlockHash>,

    /// Optional explicit genesis block header. Required alongside
    /// `genesis_block_hash` when the network is `Devnet`. The header's
    /// `block_hash()` must equal `genesis_block_hash`.
    pub genesis_block_header: Option<Header>,
}

And in lifecycle.rs::initialize_genesis_block:

let genesis_hash = config
    .genesis_block_hash
    .or_else(|| config.network.known_genesis_block_hash())
    .ok_or_else(|| SpvError::Config(
        "No known genesis hash for network. For Devnet, supply \
         `ClientConfig::genesis_block_hash` and \
         `ClientConfig::genesis_block_header` explicitly.".to_string()
    ))?;

let genesis_header = config
    .genesis_block_header
    .clone()
    .unwrap_or_else(|| dashcore::blockdata::constants::genesis_block(config.network).header);

// Existing hash-mismatch check works unchanged, now applied against the
// (possibly overridden) genesis_hash.
if genesis_header.block_hash() != genesis_hash {
    return Err(SpvError::Config(format!(
        "Genesis header hash mismatch! Expected: {}, Calculated: {}",
        genesis_hash, genesis_header.block_hash()
    )));
}

Behaviour summary:

  • Mainnet/testnet/regtest: unchanged. genesis_block_hash set on these can either be ignored or required to match known_genesis_block_hash() — either is fine; suggest "ignored" for the simpler shape.
  • Devnet without override: fails fast with the new descriptive error that names the field to set.
  • Devnet with override: initializes from caller-supplied values; existing hash/header-consistency check covers tampering.

Acceptance criteria

  • ClientConfig::genesis_block_hash: Option<BlockHash> and genesis_block_header: Option<Header> exposed (both default to None).
  • Network::Devnet with both fields set initializes successfully; storage tip after init equals the supplied genesis hash.
  • Network::Devnet without override fails with the new descriptive error naming the missing fields.
  • Existing hash-mismatch behavior preserved (supplied header must hash to supplied hash).
  • New tests:
    • Network::Devnet + override → success, tip == genesis hash
    • Network::Devnet + only genesis_block_hash (no header) → either accept and synthesize from dashcore::blockdata::constants::genesis_block(network).header (note: still requires devnet-aware genesis_block, which itself fails for Devnet today — so probably reject this combination)
    • Network::Devnet + hash/header mismatch → fail with existing error

Related

  • Surfaced via dashpay/platform shielded sync testing on paloma devnet. SDK_TEST_DATA images (dashpay/drive:3.1-shielded.*) only deploy to devnets, which means any iOS / wallet workflow that mixes shielded sync with SPV-driven asset-lock proofs is currently broken end-to-end on devnet.
  • Related downstream PR for shielded query throughput: dashpay/platform#3756.

Activity

  1. QuantumExplorer commented on May 28, 2026

    @QuantumExplorer
    MemberAuthor

    Apologies — this report was based on f569e7b (the rev currently pinned in dashpay/platform's Cargo.toml), not upstream master. PR #784 ("feat: devnet support for dash-spv", commit 58d61ea) already added a hardcoded Network::Devnet genesis hash to known_genesis_block_hash() and resolves the underlying problem on master.

    Downstream action: dashpay/platform needs to bump its dashcore rev past 58d61ea to pick up the fix. The override-API proposal in the issue body is not needed.

    Closing as already fixed.

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

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