backport: refactor(wallet): simplify platform sync by removing PlatformSyncMode#635
Conversation
Remove the PlatformSyncMode enum (Auto/ForceFull/TerminalOnly) and terminal sync logic (apply_recent_balance_changes, last_terminal_block, last_full_sync_balance). The SDK now handles incremental sync internally via AddressProvider::current_balances() and last_sync_height(). Key changes: - Remove PlatformSyncMode enum from backend_task::wallet - Simplify fetch_platform_address_balances to use new SDK API with stored state (with_stored_state, current_balances, last_sync_height) - Change CoreTask::RefreshWalletInfo to use bool instead of Option<PlatformSyncMode> - Remove last_full_sync_balance from PlatformAddressInfo - Simplify database sync info to 2-tuple (timestamp, height) - Remove set_last_terminal_block from database - Simplify RefreshMode enum (remove PlatformFull, PlatformTerminal, CoreAndPlatformFull, CoreAndPlatformTerminal variants) Note: requires updated dash-sdk with new sync_address_balances API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (17)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🔍 Audit Summary — PR #635Reviewed by: Claude Code with a 3-agent team:
Overall AssessmentRisk: LOW-MEDIUM. This PR is a net improvement — the UTXO two-phase select/remove pattern is a significant safety upgrade, the platform sync simplification removes ~250 lines of error-prone manual balance delta arithmetic, and the fee calculation is properly tested. The findings below are mostly pre-existing gaps surfaced by the refactoring, not new regressions. Findings
Pre-existing / Outside-diff IssuesFindings #1, #2, #3, #5, #8 affect files not in the GitHub diff (they're from backported commits already merged to Finding #1 detail: The Finding #2 detail: Finding #3 detail: Positive Observations
Redundancy3 agents reported 10 unique findings. Cross-agent overlap:
🤖 Co-authored by Claudius the Magnificent AI Agent |
…rm-sync-simplification
- DB schema v28: drop obsolete columns (last_terminal_block, last_full_sync_balance), rename last_platform_sync_checkpoint → last_platform_sync_height, with SQLite ≥3.35 runtime check - Store asset lock TX before broadcast to prevent SPV InstantSend race - Defer UTXO removal until after successful broadcast - Replace .unwrap() on RwLock with .map_err() to avoid panics - Remove unused _is_sync_operation param and set_platform_address_info_from_sync wrapper - Fix redundant let-mut rebinding in fetch_platform_address_balances - Extract broadcast_and_commit_asset_lock() on AppContext to consolidate the store→broadcast→cleanup→UTXO-removal pattern from 5 code paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… interface (#653) - Bump DEFAULT_DB_VERSION 27 → 28 - Drop last_terminal_block from wallet table (unused after sync simplification) - Drop last_full_sync_balance from platform_address_balances table - Rename last_platform_sync_checkpoint → last_platform_sync_height - Add runtime SQLite ≥3.35 check (required for DROP COLUMN) - Idempotent migration: checks column existence before each ALTER - Remove unused _is_sync_operation param from set_platform_address_info() - Remove set_platform_address_info_from_sync() wrapper - Fix redundant let-mut rebinding in fetch_platform_address_balances Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR backports a Platform sync simplification by removing the legacy PlatformSyncMode (auto/full/terminal) and replacing the previous full+terminal sync logic with SDK-managed incremental syncing via sync_address_balances(provider, config, last_ts). It also updates persistence to drop obsolete sync columns and introduces a shared “store → broadcast → commit UTXO removal” helper for asset lock flows.
Changes:
- Simplifies refresh controls (UI + task APIs) to a boolean “sync Platform” flag and
RefreshMode::{All, CoreOnly, PlatformOnly}. - Refactors Platform address balance sync to use SDK incremental sync and new persisted
(last_sync_timestamp, last_sync_height)state. - Adjusts asset-lock flows to persist-before-broadcast and defer UTXO removal until after successful broadcast.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui/wallets/wallets_screen/mod.rs | Simplifies refresh dropdown options and updates refresh actions to new task APIs. |
| src/model/wallet/mod.rs | Removes last_full_sync_balance; adds incremental-sync baseline fields/methods to WalletAddressProvider. |
| src/model/wallet/asset_lock_transaction.rs | Stops removing selected UTXOs inside asset-lock builder; returns them to caller. |
| src/database/wallet.rs | Drops last_full_sync_balance read/write; updates Platform sync info getters/setters. |
| src/database/initialization.rs | Bumps DB version to 28; adds migration to drop obsolete columns and rename checkpoint column. |
| src/context/wallet_lifecycle.rs | Updates DB writes to new set_platform_address_info signature. |
| src/context/transaction_processing.rs | Adds broadcast_and_commit_asset_lock helper and related imports. |
| src/backend_task/wallet/withdraw_from_platform_address.rs | Updates Platform refresh call to new fetch_platform_address_balances(seed_hash) signature. |
| src/backend_task/wallet/mod.rs | Removes PlatformSyncMode and its use from wallet task definitions. |
| src/backend_task/wallet/fund_platform_address_from_wallet_utxos.rs | Switches to new broadcast/store/commit helper and simplified balance refresh. |
| src/backend_task/wallet/fund_platform_address_from_asset_lock.rs | Updates Platform refresh call to new fetch_platform_address_balances(seed_hash) signature. |
| src/backend_task/wallet/fetch_platform_address_balances.rs | Replaces legacy full/terminal logic with SDK incremental sync and persisted sync state. |
| src/backend_task/mod.rs | Updates wallet-task dispatch for changed FetchPlatformAddressBalances shape. |
| src/backend_task/identity/top_up_identity.rs | Uses new broadcast/store/commit helper; improves poisoned-lock error handling. |
| src/backend_task/identity/register_identity.rs | Uses new broadcast/store/commit helper; improves poisoned-lock error handling. |
| src/backend_task/core/mod.rs | Replaces Option<PlatformSyncMode> with bool for “sync Platform” during Core refresh. |
| docs/ai-design/2026-02-24-platform-sync-simplification/manual-test-scenarios.md | Adds manual test scenarios for simplified sync + migration paths. |
| Cargo.toml | Bumps dash-sdk git rev to include incremental sync API. |
| Cargo.lock | Updates lockfile to match new dash-sdk rev and transitive dependency changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The v28 schema changes (drop obsolete sync columns, rename last_platform_sync_checkpoint → last_platform_sync_height) will be applied separately and should not ship on this branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve merge conflict in fund_platform_address_from_wallet_utxos.rs (keep simplified fetch_platform_address_balances call without PlatformSyncMode). Fix wallets_screen/mod.rs: get_platform_sync_info returns (u64, u64) on this branch, not a 3-tuple. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove dead `_is_sync_operation` parameter from `Database::set_platform_address_info` and all call sites (Finding #6) - Add doc comment on `set_platform_sync_info` explaining column name drift: `last_platform_sync_checkpoint` now stores SDK sync height (Finding #4) - Remove trivial `set_platform_address_info_from_sync` delegate and update callers to use `set_platform_address_info` directly (Finding #7) - Combine unnecessary `let provider` + `let mut provider = provider` rebinding into single `let mut` block (Finding #10) - Document UTXO selection race window on `broadcast_and_commit_asset_lock`: std::sync::RwLock guard is !Send so it cannot span async broadcast Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
PlatformSyncModeenum (Auto/ForceFull/TerminalOnly) and the 250-lineapply_recent_balance_changes()methodsync_address_balances(provider, config, last_ts)last_full_sync_balancefromPlatformAddressInfoandlast_terminal_blockfrom DBRefreshModeto just All/CoreOnly/PlatformOnly0fa82e6652097d17a700d8bcc006d6b2aa922c6ewhich includes the incremental sync APITest plan
Manual test scenarios:
docs/ai-design/2026-02-24-platform-sync-simplification/manual-test-scenarios.md🤖 Co-authored by Claudius the Magnificent AI Agent