Skip to content

platform-wallet: a shielded note scan advances its watermark past a gap between fetched ranges #6109

Done

Description

@QuantumExplorer

Problem

sync_shielded_notes_stream fetches adjacent note ranges concurrently and emits them in start order. Each range is proved at its own height. So a range answered one block earlier can come back short, while the next range, already in flight, comes back non-empty.

sync_notes_from_stream notices that gap only for covered_height. It still:

  • appends the later range's commitments, which land at shifted positions because the append gate compares against the tree size from before the scan;
  • replays that range's nullifiers;
  • persists the watermark as aligned_start + total_notes_scanned.

The skipped positions are never decrypted, and the local commitment tree no longer matches Platform's. This also undermines the anchor-expiry release of stranded spends.

It needs the tree to grow across a fetch boundary between two responses, so it is rare. It was found by reading the code while reviewing #6090; the same logic is on v5.1-dev.

Proposed fix

Stop consuming at the first gap. Append, publish and advance the watermark only through the contiguous prefix, and let the next pass re-fetch from there.

Test

Drive sync_notes_from_stream with a short range followed by a non-empty one, over two passes. Assert that the watermark stops at the gap and that the second pass recovers the skipped positions.

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