You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rs-sdk: sync_shielded_notes returns notes past a gap between fetched ranges #6181
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.
Or stop consuming at the first gap in sync_shielded_notes, as the wallet does, and return the contiguous prefix with next_start_index at its end.
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.
Activity