Skip to content

fix: reset FilterManager in flight state when all peers disconnect#441

Merged
xdustinface merged 2 commits intov0.42-devfrom
fix/filter-in-flight-reset
Feb 17, 2026
Merged

fix: reset FilterManager in flight state when all peers disconnect#441
xdustinface merged 2 commits intov0.42-devfrom
fix/filter-in-flight-reset

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Feb 16, 2026

  • Override stop_sync in FiltersManager to clear the in-flight state when all peers disconnect.
  • Re-initialize the filter pipeline position in start_sync when filters are already at the stored tip preventing extend_target from re-queuing from height 1 after reconnecting.

Summary by CodeRabbit

  • Bug Fixes / Improvements
    • Better cleanup of in-flight processing when peers disconnect to prevent stale or orphaned sync work.
    • Added a stop-sync capability to reliably halt sync processes and reset related state.
    • Improved sync startup when existing filter data is present to avoid redundant reprocessing and ensure correct state transitions.

- Override `stop_sync` in `FiltersManager` to clear the in-flight state when all peers disconnect.
- Re-initialize the filter pipeline position in `start_sync` when filters are already at the stored tip preventing `extend_target` from re-queuing from height 1 after reconnecting.
@xdustinface xdustinface changed the title fix: reset FilterManager when all peers disconnect fix: reset FilterManager in flight state when all peers disconnect Feb 16, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Adds a FiltersManager utility to clear in-flight multi-batch state and resets the filter pipeline; implements stop_sync() to transition to WaitingForConnections and clear in-flight state; adjusts start_sync() to initialize the filter pipeline at stored_filters_tip + 1 when fully synced.

Changes

Cohort / File(s) Summary
Filter Sync State Management
dash-spv/src/sync/filters/manager.rs, dash-spv/src/sync/filters/sync_manager.rs
Adds pub(super) fn clear_in_flight_state(&mut self) to clear active_batches, blocks_remaining, filters_matched, pending_batches, and reset filter_pipeline. Adds fn stop_sync(&mut self) to set state to WaitingForConnections and call the clear utility. Updates start_sync() to initialize the filter pipeline with init(stored_filters_tip + 1, stored_filters_tip) when stored tip equals current height to avoid re-queuing from height 1.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨
I nudge the pipeline clean and bright,
When peers depart I clear the night,
From stored heights we hop anew,
No stale batches in my view,
Hopping forward—sync in sight!

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (4 files):

⚔️ dash-spv/src/sync/block_headers/pipeline.rs (content)
⚔️ dash-spv/src/sync/block_headers/segment_state.rs (content)
⚔️ dash-spv/src/sync/filters/manager.rs (content)
⚔️ dash-spv/src/sync/filters/sync_manager.rs (content)

These conflicts must be resolved before merging into v0.42-dev.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding in-flight state reset functionality to FilterManager when peers disconnect, matching the PR's primary objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/filter-in-flight-reset
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/filter-in-flight-reset
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@dash-spv/src/sync/filters/sync_manager.rs`:
- Around line 88-90: Fix the typo in the nearby comment: change "in flight state
gets resets" to "in flight state gets reset" in the comment that precedes the
call to self.filter_pipeline.init(stored_filters_tip + 1, stored_filters_tip);
leave the logic (init(stored_filters_tip + 1, stored_filters_tip)) unchanged —
only update the comment text referencing filter_pipeline.init and
stored_filters_tip.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@xdustinface xdustinface merged commit 4155ddc into v0.42-dev Feb 17, 2026
53 checks passed
ZocoLini pushed a commit that referenced this pull request Feb 18, 2026
…441)

* fix: reset `FilterManager` when all peers disconnect

- Override `stop_sync` in `FiltersManager` to clear the in-flight state when all peers disconnect.
- Re-initialize the filter pipeline position in `start_sync` when filters are already at the stored tip preventing `extend_target` from re-queuing from height 1 after reconnecting.

* Fix typo

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@xdustinface xdustinface deleted the fix/filter-in-flight-reset branch February 26, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants