Skip to content

fix: correct state transitions in filter sync manager#451

Open
xdustinface wants to merge 1 commit intov0.42-devfrom
fix/filters-state-transitions
Open

fix: correct state transitions in filter sync manager#451
xdustinface wants to merge 1 commit intov0.42-devfrom
fix/filters-state-transitions

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Feb 18, 2026

Move set_state(Syncing) after the early returns in start_download() so the manager stays in the correct state when filter headers haven't reached the needed height. Return to WaitForEvents in that case so new FilterHeadersStored events re-trigger start_download with proper batch processing initialization.

Also transition Synced back to Syncing in handle_new_filter_headers when new filter headers arrive, ensuring is_synced() returns false until all new filters and matched blocks are fully processed.

Based on:

Summary by CodeRabbit

  • Bug Fixes
    • Improved filter synchronization reliability during initial download and state transitions
    • Enhanced handling of filter header updates to ensure proper synchronization state management

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Refactored state transitions in the filter manager's download and event handling logic. Removes immediate Syncing transition, introduces WaitForEvents state for insufficient headers, defers transitions based on available data, and enhances lookahead batch creation. Tests expanded to validate new state behavior and transitions.

Changes

Cohort / File(s) Summary
Filter Manager State Machine
dash-spv/src/sync/filters/manager.rs
Reworked state transitions: removed immediate Syncing at start_download, added WaitForEvents state when headers insufficient, explicit transition to Syncing after computing download_start, Synced→Syncing transition on new headers, and conditional lookahead batch creation. Test imports and validations for new state flows added.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 State machines dance in careful measure,
Headers waiting, transitions at leisure,
WaitForEvents guards the gate,
Until filters sync, filters sync with fate,
Lookahead batches bloom so bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: correct state transitions in filter sync manager' directly and clearly describes the main change: fixing state transitions in the filter sync manager, which is the core purpose of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/filters-state-transitions

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.

@xdustinface xdustinface force-pushed the refactor/filters-start-logic branch from 31e835f to 24f52f9 Compare February 18, 2026 01:26
@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Feb 18, 2026
@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

Base automatically changed from refactor/filters-start-logic to v0.42-dev February 18, 2026 20:44
Move `set_state(Syncing)` after the early returns in `start_download()` so
the manager stays in the correct state when filter headers haven't
reached the needed height. Return to `WaitForEvents` in that case
so new `FilterHeadersStored` events re-trigger `start_download`
with proper batch processing initialization.

Also transition `Synced` back to `Syncing` in `handle_new_filter_headers`
when new filter headers arrive, ensuring `is_synced()` returns false
until all new filters and matched blocks are fully processed.
@xdustinface xdustinface force-pushed the fix/filters-state-transitions branch from e39cb43 to ab06361 Compare February 18, 2026 23:07
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Feb 18, 2026
@xdustinface xdustinface marked this pull request as ready for review February 18, 2026 23:07
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.

1 participant

Comments