Skip to content

rs-sdk: sync_shielded_notes returns notes past a gap between fetched ranges #6181

Backlog

Description

@QuantumExplorer

Problem

sync_shielded_notes_stream (packages/rs-sdk/src/platform/shielded/notes_sync/sync_shielded_notes.rs) fetches adjacent note ranges concurrently and emits them in start order. Each range is proved at its own height, so a range answered a block earlier can come back short while the next range, already in flight, comes back with notes. The positions between the end of the short range and the start of the next one are in neither.

The wallet's consumer of the stream now stops at such a gap (#6172, for #6109). The SDK's own one-shot consumer, sync_shielded_notes, does not:

  • all_notes concatenates the ranges, so the notes after the gap sit at the wrong offset from start_index. A caller that appends all_notes to a commitment tree gets a tree that does not match Platform's.
  • next_start_index rewinds to the start of the last non-empty partial range, which is the range after the gap, so the skipped positions are never fetched again.
  • total_notes_scanned counts the notes on both sides of the gap.

Nothing in this repository calls sync_shielded_notes (the wallet uses the stream), so this only affects other users of the SDK.

Proposed fix

Either of:

Test

The ordering logic is unit-tested through ReorderBuffer. A test for this needs a mock SDK that answers one range short and the next one non-empty, then asserts all_notes, total_notes_scanned and next_start_index cover only the contiguous prefix.

Found while fixing #6109.

Activity

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