Skip to content

SPV lifecycle follow-ups after the off-main start (#5512) #5535

Open

Description

@llbartekll

Follow-ups deferred from #5512 (fix(swift-sdk)!: start SPV off the main thread), collected from @romchornyi's and thepastaclaw's reviews. None blocked the freeze fix; each is independent.

Status (2026-11-04): item 1 is a duplicate of #5191 and is struck out below; items 2–5 are still open on v5.1-dev (spvStartsInFlight and the refusals are still Swift-only; PlatformWalletNativeTeardownCalls still carries spvStart).

  1. platform_wallet_manager_spv_stop / spv_clear_storage outside the registry guard. Tracked in platform-wallet-ffi: SPV stop holds the manager registry read guard for its whole run #5191 (same stall, filed first); not part of this issue any more. Note: spv_stop still holds the guard on purpose today, see the comment on platform_wallet_manager_spv_stop in rs-platform-wallet-ffi/src/spv.rs, so platform-wallet-ffi: SPV stop holds the manager registry read guard for its whole run #5191 needs the destroy barrier it describes before the guard can go. Both still hold the handle registry's read guard while waiting for the runtime's shutdown lock, which the start now holds for the whole store open. A native stop overlapping a slow start (Kotlin's blocking stop) parks a queued registry writer and, through parking_lot's writer preference, every later registry reader for the rest of the migration. Pre-existing, but the same stall the start path now avoids; the same treatment (resolve the runtime under the guard, run outside it, owner flag for destroy) would finish the job.
  2. Fail-fast SPV lifecycle admission in the runtime, not the Swift wrapper. spvStartsInFlight and the refusals of a second start / blocking stop / clear live in Swift; Kotlin reaches SpvRuntime directly and observes different outcomes. Move the reservation / typed busy state into rs-platform-wallet (try-lock on shutdown mapped to an error code), exposed through the FFI, so every caller gets the same rule and new SPV entry points cannot forget it.
  3. SwiftExampleApp: gate Start/Pause and Clear across in-flight start and stop. During a slow start spvIsRunning is still false, so the toggle reads "Start", Pause is unreachable and taps are refused; Clear is enabled during an in-flight start and during an async Pause (the client is removed before teardown completes). Disable on the in-flight start/stop state.
  4. SwiftExampleApp: per-network pending stop. isStoppingSpv / pendingSpvStop on WalletManagerStore are store-wide, so a Pause on one network's manager disables and delays the start of another network's independent runtime.
  5. Naming: spvStart lives in PlatformWalletNativeTeardownCalls; the table is no longer teardown-only.
  6. rust-dashcore (separate repo): a storage migration progress/state event, so hosts can show "upgrading storage" instead of a silent multi-second start.

🤖 Generated with Claude Code

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