Skip to content

refactor(db): schema v28 — drop obsolete sync columns and clean up DB interface#653

Merged
lklimek merged 1 commit into
zk-extract/platform-sync-simplificationfrom
fix/db-migration-v28-cleanup
Feb 24, 2026
Merged

refactor(db): schema v28 — drop obsolete sync columns and clean up DB interface#653
lklimek merged 1 commit into
zk-extract/platform-sync-simplificationfrom
fix/db-migration-v28-cleanup

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented Feb 24, 2026

Summary

  • 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_checkpointlast_platform_sync_height to match new semantics
  • Add runtime SQLite ≥ 3.35 check (required for DROP COLUMN); clear error message if too old
  • Idempotent migration: checks column existence before each ALTER (safe to re-run)
  • Remove unused _is_sync_operation param from set_platform_address_info()
  • Remove set_platform_address_info_from_sync() trivial wrapper
  • Fix redundant let mut rebinding in fetch_platform_address_balances

Test plan

  • Verify fresh install creates correct schema (no dropped columns)
  • Verify upgrade from v27 → v28 drops columns and renames correctly
  • Verify cargo test --all-features --workspace passes
  • Verify cargo clippy --all-features --all-targets -- -D warnings is clean

🤖 Generated with Claude Code

🤖 Co-authored by Claudius the Magnificent AI Agent

… interface

- 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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 24, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • master
  • v1.0-dev

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/db-migration-v28-cleanup

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.

@lklimek lklimek force-pushed the fix/db-migration-v28-cleanup branch from e6af495 to 1d1383b Compare February 24, 2026 22:49
@lklimek lklimek merged commit 65f2946 into zk-extract/platform-sync-simplification Feb 24, 2026
4 of 6 checks passed
@lklimek lklimek deleted the fix/db-migration-v28-cleanup branch February 24, 2026 22:58
@lklimek lklimek restored the fix/db-migration-v28-cleanup branch February 24, 2026 22:58
@lklimek lklimek deleted the fix/db-migration-v28-cleanup branch February 24, 2026 23:01
lklimek added a commit that referenced this pull request Feb 25, 2026
…rmSyncMode (#635)

* refactor(wallet): simplify platform sync by removing PlatformSyncMode

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>

* chore: update platform SDK to rev 0fa82e6652

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add manual test scenarios for platform sync simplification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(wallet): address PR #635 audit findings and extract broadcast helper

- 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>

* refactor(db): schema v28 — drop obsolete sync columns and clean up DB 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>

* revert(db): remove schema v28 migration from this branch

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>

* fix: address PR review comments — remove dead code and document risks

- 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>

* style: apply nightly fmt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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