Skip to content

dash-spv: the per-tick filter rescan re-applies thousands of already processed blocks #1236

Closed

Description

@xdustinface

All paths are under dash-spv/src/ at 8dde9d0c (dev after #902).

FiltersManager calls rescan_active_batches from tick (sync/filters/sync_manager.rs:274-275, sync/filters/manager.rs:802-822) whenever new scripts are pending, over up to 16 active batches (MAX_LOOKAHEAD_BATCHES, sync/filters/manager.rs:82, previously 3). Before #902 the rescan ran only once per batch, in reconcile_untested_scripts at commit. The rescans now hit batches whose blocks are still in flight, which drives the InFlight arm of rescan_batch (sync/filters/manager.rs:906-910) and track_for_new_scripts. A block is re-applied when it was already processed but the filters manager has not yet handled its BlockProcessed.

Evidence. The benchmark runs are 12 interleaved full testnet syncs of the #902 head 39eef40d against dev 0dcdd823. The network code is byte-identical to what landed on dev.

  • Already processed blocks re-applied per run: 1,007 to 8,612 on the refactor, 656 to 770 on dev.
  • Time in filter rescans per run: about 21 to 145s on the refactor, 3 to 7.5s on dev (upper bound, includes wallet lock waits).
  • InFlight rescan entries per run: 0 on dev, 1,944 to 10,174 on the refactor.
  • One block (1450839) was applied 75 times in one run, and 73 of those passes found nothing new.
  • Final wallet state is identical in all 24 runs (20.66198098 DASH, 3,266 transactions), so this is wasted work, not a correctness bug.

Fix. Rescan only batches whose blocks are all processed, or coalesce the per-tick rescan, and don't emit BlocksNeeded for an in-flight block unless its wallet set grew. The underlying re-track of already processed blocks is #1229.

Activity

  1. added 9 commits that reference this issue on Nov 6, 2026
    a62a87b
    7d6f403
    82c1d27
    43d8410
    70033ee
    12b6153
    a9e41b7
    5b95a7b
    fcfadf5
  2. added a commit that references this issue on Nov 9, 2026
    c7bb2ce
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