Skip to content

dash-spv: rescan re-applies blocks whose last processing already saw the new scripts #1229

Closed

Description

@xdustinface

BlockMatchTracker::track_for_new_scripts (dash-spv/src/sync/filters/block_match_tracker.rs:100-115) always re-tracks a matched block and never answers AlreadyProcessed. Its doc comment assumes the block's earlier processing predates the newly derived scripts. That is often false: the block may have been processed after those scripts were derived, for example when it was the block that triggered the derivation, or when a later batch already re-applied it. The block is then loaded from storage and applied to the wallet again with nothing new to find.

Evidence. 12 full testnet syncs of dev 0dcdd823 with the same HD wallet. Each run re-applies 656 to 770 already processed blocks (final SyncProgress: blocks processed minus distinct blocks downloaded, equal to from_storage on dev). About 515 of those per run find no new transaction and no new script. Only about 28 to 61 re-applies per run find anything. Final wallet state is identical in every run (20.66198098 DASH, 3,266 transactions), so this is wasted work, not a correctness bug. Each re-apply is a storage load plus a full wallet pass under the wallet write lock.

Why it matters more soon. The rescan rework on refactor/network-mod (#902) runs this path far more often, and there the same counter reaches 1,007 to 8,612 per run.

Fix. Tag each entry in pending_new_scripts with the wallet monitor_revision at derivation, store the revision a block was processed at in record_processed, and make track_for_new_scripts return AlreadyProcessed when the block's processed revision is at least the scripts' revision. Keep re-tracking when the scripts are newer, since those passes do find real transactions.

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