Skip to content

Conversation

@xdustinface
Copy link
Collaborator

@xdustinface xdustinface commented Feb 4, 2026

Drop all the code relevant to the legacy sync module.

Summary by CodeRabbit

  • Breaking Changes

    • Terminal UI removed; legacy sequential sync (headers, filters, masternodes, chainlocks) and related public APIs removed.
    • Event receiver APIs, detailed sync progress, address-balance queries, chain-state inspection, and post-sync handlers removed.
  • Documentation

    • Multiple design/implementation docs for sequential sync and reorg status deleted.
  • Tests

    • Numerous legacy sync and filter/header/masternode tests removed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

This PR removes the legacy sequential synchronization pipeline, chainlock manager, terminal UI, persistent chain state, many sync-related types/FFI mappings, message handling, and associated tests/docs, significantly shrinking the public API surface and sync control flow.

Changes

Cohort / File(s) Summary
FFI Layer & Tests
dash-spv-ffi/FFI_API.md, dash-spv-ffi/scripts/generate_ffi_docs.py, dash-spv-ffi/src/types.rs, dash-spv-ffi/src/client.rs, dash-spv-ffi/tests/*
Removed FFISyncStage, legacy/detailed FFI progress structs and conversions; dropped client_test_sync helper and several FFI tests/callbacks; updated generated docs.
Client Core & Events
dash-spv/src/client/core.rs, dash-spv/src/client/lifecycle.rs, dash-spv/src/client/events.rs, dash-spv/src/client/mod.rs, dash-spv/src/client/queries.rs, dash-spv/src/client/sync_coordinator.rs
Removed in-memory ChainState, chainlock_manager, event mpsc channels, terminal_ui plumbing, balance query APIs and report_balance_changes; simplified client struct and constructor.
Message Handling & Status UI
dash-spv/src/client/message_handler.rs, dash-spv/src/client/message_handler_test.rs, dash-spv/src/client/status_display.rs, dash-spv/src/terminal.rs
Deleted MessageHandler and its tests; removed StatusDisplay and terminal UI implementation and tests; removed terminal feature usages.
Chainlock Subsystem
dash-spv/src/chain/chainlock_manager.rs, dash-spv/src/chain/chainlock_test.rs, dash-spv/src/client/chainlock.rs, dash-spv/src/chain/mod.rs
Removed ChainLockManager, ChainLockEntry, chainlock processing/validation methods, client chainlock handlers, and related exports/tests.
Storage: ChainState Persistence
dash-spv/src/storage/chainstate.rs, dash-spv/src/storage/mod.rs
Removed ChainStateStorage trait and PersistentChainStateStorage implementation; removed chainstate integration from DiskStorageManager and persistence worker.
Legacy Sync Pipeline
dash-spv/src/sync/legacy/*
Entire legacy sync subsystem removed: SyncManager, HeaderSyncManager, FilterSyncManager (manager/download/headers/matching/requests/retry/stats/types), MasternodeSyncManager, message_handlers, phase execution, phases, transitions, post_sync, embedded diffs, and public re-exports.
Types & Public API Surface
dash-spv/src/types.rs, dash-spv/src/lib.rs
Removed SharedFilterHeights, SyncProgress, DetailedSyncProgress, SyncStage, ChainState, AddressBalance, SpvEvent and their impls; dropped ChainState/SyncProgress from public re-exports.
CLI / Main & Cargo
dash-spv/src/main.rs, dash-spv/Cargo.toml
Removed terminal-ui CLI flags and wiring; updated run_client signature and wallet creation call; removed crossterm dependency and terminal-ui feature.
Tests & Docs Cleanup
dash-spv/tests/*, docs/implementation-notes/*, dash-spv/ARCHITECTURE.md, dash-spv/CLAUDE.md
Deleted many integration/unit tests for header/filter/masternode sync and block downloads; removed sequential/REORG design docs and trimmed ARCHITECTURE.md and CLAUDE.md text.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as Client
participant SyncMgr as SyncManager (legacy)
participant Header as HeaderSync
participant Filter as FilterSync
participant Masternode as MasternodeSync
participant Network as Network
participant Storage as Storage

rect rgba(200,200,255,0.5)
Client->>SyncMgr: start_sync()
SyncMgr->>Header: prepare/start_headers()
Header->>Network: request_headers()
Header->>Storage: store_headers()
SyncMgr->>Masternode: start_masternode_sync()
Masternode->>Network: request_qrinfo/mnlistdiff
Masternode->>Storage: persist_mnlistdiffs()
SyncMgr->>Filter: start_filter_headers()
Filter->>Network: request_cfheaders/cfilters
Filter->>Storage: store_filters()
end

rect rgba(255,200,200,0.5)
Client->>Network: (post-change) direct requests / simplified flows
Client->>Storage: direct store/retrieve (no SyncManager orchestration)
end

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Suggested reviewers

  • PastaPastaPasta
  • QuantumExplorer
  • ZocoLini

Poem

🐇 I hopped through modules, line by line,

Old phases fell, the code felt fine.
Chainlocks tucked in a tidy heap,
Filters and headers now sleep.
A quieter tree, a clearer view—hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 65.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'chore: remove legacy sync code' accurately summarizes the main change—removal of legacy synchronization modules and related code across multiple files.

✏️ 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 chore/drop-legacy-sync

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 chore/drop-legacy-sync branch 3 times, most recently from f5a88f0 to 9d1b5c7 Compare February 4, 2026 15:44
@xdustinface xdustinface marked this pull request as ready for review February 4, 2026 15:51
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
dash-spv/ARCHITECTURE.md (1)

235-242: ⚠️ Potential issue | 🟠 Major

Update architecture doc to reflect removal of legacy sync.

This document still describes the parallel sync manager/event-bus architecture and legacy sync components, which the PR explicitly removes. Please align the architecture narrative with the new post-legacy sync design (or clearly mark this section as historical if that’s intended).

Based on learnings: “Applies to dash-spv/src/sync/**/*.rs : Use sequential phase-based synchronization via SyncManager for organized sync coordination”.

dash-spv/src/client/lifecycle.rs (1)

158-168: ⚠️ Potential issue | 🟠 Major

Lock order contradicts the documented ordering.

This path locks storage and then acquires mempool_state; the module’s lock-ordering guidance calls for mempool_state before storage, which can deadlock if another path follows the guideline. Load the state, drop the storage lock, then update mempool_state.

Proposed fix to honor lock ordering
-                if let Some(state) = self
-                    .storage
-                    .lock()
-                    .await
-                    .load_mempool_state()
-                    .await
-                    .map_err(SpvError::Storage)?
-                {
-                    *self.mempool_state.write().await = state;
-                }
+                let state = {
+                    let mut storage = self.storage.lock().await;
+                    storage
+                        .load_mempool_state()
+                        .await
+                        .map_err(SpvError::Storage)?
+                };
+                if let Some(state) = state {
+                    *self.mempool_state.write().await = state;
+                }
🧹 Nitpick comments (2)
dash-spv/src/client/core.rs (1)

1-9: Stale documentation: Terminal UI accessors no longer exist.

Line 9 mentions "Terminal UI accessors" but this PR removes all terminal UI functionality. Update the module-level doc comment to remove this reference.

📝 Suggested doc update
 //! Core DashSpvClient struct definition and simple accessor methods.
 //!
 //! This module contains:
 //! - The main `DashSpvClient` struct definition
 //! - Simple getters for wallet, network, storage, etc.
 //! - Storage operations (clear_storage, clear_sync_state, clear_filters)
 //! - State queries (is_running, tip_hash, tip_height, chain_state, stats)
 //! - Configuration updates
-//! - Terminal UI accessors
dash-spv/src/main.rs (1)

274-282: Consider simplifying the discarded result pattern.

The let _ = ...? pattern works but may confuse readers since _ typically signals an intentionally unused value, yet the ? propagates errors. A more idiomatic approach would clarify intent.

💡 Alternative patterns
-    let _ = wallet_manager.create_wallet_from_mnemonic(
+    wallet_manager.create_wallet_from_mnemonic(
         mnemonic_phrase.as_str(),
         "",
         0,
         key_wallet::wallet::initialization::WalletAccountCreationOptions::default(),
     )?;

Or if you want to be explicit about ignoring the return value:

-    let _ = wallet_manager.create_wallet_from_mnemonic(
+    let _wallet_id = wallet_manager.create_wallet_from_mnemonic(
         mnemonic_phrase.as_str(),
         "",
         0,
         key_wallet::wallet::initialization::WalletAccountCreationOptions::default(),
     )?;

@xdustinface xdustinface force-pushed the chore/drop-legacy-sync branch from 9d1b5c7 to 08605e7 Compare February 4, 2026 16:13
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
dash-spv/src/main.rs (1)

276-281: ⚠️ Potential issue | 🟡 Minor

Use WalletAccountCreationOptions::Default instead of default() to match codebase conventions.

The enum variant WalletAccountCreationOptions::Default should be used explicitly rather than the trait method default(). All tests, examples, and implementations throughout the codebase consistently use the explicit enum variant form. While both are technically valid due to the #[derive(Default)] macro on the enum, using the explicit form is the established idiom in this codebase.

    wallet_manager.create_wallet_from_mnemonic(
        mnemonic_phrase.as_str(),
        "",
        0,
        key_wallet::wallet::initialization::WalletAccountCreationOptions::Default,
    )?;
🧹 Nitpick comments (1)
dash-spv/ARCHITECTURE.md (1)

237-241: Keep the refactoring list consistent with current types layout.

The refactoring list now only mentions types/events.rs with MempoolRemovalReason. If other type splits were removed or completed as part of dropping legacy sync, consider updating or pruning this list so it reflects the current, intended layout and doesn’t imply pending work that no longer exists.

Copy link
Collaborator

@ZocoLini ZocoLini left a comment

Choose a reason for hiding this comment

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

we added 2k aprox lines with the new sync right??, feels like a lot of lines tbh

@xdustinface
Copy link
Collaborator Author

we added 2k aprox lines with the new sync right??, feels like a lot of lines tbh

Yes, around 2k lines. I don't think it makes sense to judge whether its a lot or not just by the total number of lines.

@xdustinface xdustinface merged commit 245a330 into v0.42-dev Feb 4, 2026
53 checks passed
@xdustinface xdustinface deleted the chore/drop-legacy-sync branch February 4, 2026 20:09
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