Skip to content

platform-wallet: shielded notes sync runs 16 parallel chunk queries, most of them past the end of the tree #4999

Open

Description

@romchornyi

Expected Behavior

Background shielded note sync should not crowd out the wallet's own requests. When the wallet is caught up, it should fetch the chunks that can contain notes and nothing more.

Current Behavior

  1. 16 chunk queries in flight per sync cycle. platform-wallet raises the SDK's DEFAULT_MAX_CONCURRENT = 4 (types.rs#L9) to max_concurrent: 16 (sync.rs#L274-L281). On testnet these queries took 2–37 s each against the 10 s default request timeout (request_settings.rs#L9). Queries that time out get their nodes banned, and a user transition sent during the burst shares the same nodes. In one ~25 min session the gRPC log shows 240 Timeout expired, in bursts that line up with the sync cycles. One of those bursts caused the broadcast failure in the linked issue.
  2. Most of those queries are past the end of the tree. The stream seeds the whole window up front (sync_shielded_notes.rs#L238-L260) without using the tree size it already knows. In the reproduction the tree had total_count=4574, yet one cycle queried 16 chunks of 8192 starting at 4096 … 126976. Only the first returned notes (478); the other 15 returned notes_returned=0 after up to 37 s each, and every cycle repeats them.

Log shape (one cycle, reproduction values):

fetching shielded notes chunk chunk_start=4096 chunk_size=8192
fetching shielded notes chunk chunk_start=12288 chunk_size=8192
… 14 more, up to chunk_start=126976
shielded notes chunk fetched chunk_start=4096 notes_returned=478 total_count=4574 elapsed_ms=Some(11319)
shielded notes chunk fetched chunk_start=86016 notes_returned=0 total_count=4574 elapsed_ms=Some(37528)

Possible Solution

  • Bound the window by the tree size. Once total_count is known (from the first response, or from the previous cycle), stop queueing chunks whose start is >= total_count. In steady state that is one query per cycle instead of 16.
  • Revisit the 16. It was chosen for the initial download across ~13 nodes. For incremental cycles the SDK default of 4 (or fewer) is enough. Alternatively, make it depend on the remaining distance to total_count.
  • Optional. Give user-initiated broadcasts priority, or a separate connection/budget, so a background sync cannot delay them past the request timeout.

Steps to Reproduce (for bugs)

  1. Run a wallet with shielded sync enabled on testnet (iOS app or SwiftExampleApp) until it is caught up.
  2. Watch dash_sdk/run.log and grpc/run.log: each sync cycle logs 16 fetching shielded notes chunk lines with starts far above total_count, followed by Timeout expired / ban address bursts.
  3. Send any state transition during a burst and it may time out (see the linked issue).

Context

Surfaced by dashpay/dashwallet-ios#1156 testing on testnet. This load is what pushed an IdentityCreate broadcast past its timeout; the resulting AlreadyExists failure is tracked in the linked issue. It also costs mobile data and battery on every cycle.

Your Environment

  • Version used: v4.3-dev @ b1a4f35f9b
  • Environment name and version: SwiftDashSDK (rs-platform-wallet shielded sync), iOS 26.5 simulator
  • Operating System and version: macOS 27 host, testnet
  • Link to your project: dashpay/dashwallet-ios

Activity

  1. romchornyi commented on Sep 25, 2026

    @romchornyi
    ContributorAuthor

    Related: #4998 — the AlreadyExists failure one of these bursts caused.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions