Skip to content

Persist wallet sync progress at checkpoints - #632

Open
3esmit wants to merge 1 commit into
devfrom
fix/wallet-sync-checkpoint
Open

Persist wallet sync progress at checkpoints#632
3esmit wants to merge 1 commit into
devfrom
fix/wallet-sync-checkpoint

Conversation

@3esmit

@3esmit 3esmit commented Jul 18, 2026

Copy link
Copy Markdown

🎯 Purpose

WalletCore::sync_to_block currently persists the complete wallet storage after
every processed block. A wallet catching up over a large range therefore
performs one full local storage write per block, creating unnecessary disk I/O
and serialization work for every consumer of the wallet core.

Fixes #631

⚙️ Approach

  • Add a local checkpoint counter to block synchronization.
  • Persist after every 100 successfully processed blocks.
  • Persist any remaining tail before a successful sync returns.
  • Keep account state and the last_synced_block watermark in the existing
    single persistence operation. If sync is interrupted between checkpoints,
    reopening resumes from the last durable checkpoint and replays only the
    unpersisted tail.
  • Leave explicit lifecycle saves unchanged.

No wallet storage format, protocol behavior, or FFI/API surface changes.

🧪 How to Test

cargo +nightly fmt --all -- --check
cargo +1.94.0 test -p wallet --lib
RISC0_SKIP_BUILD=1 cargo +1.94.0 clippy -p wallet --lib --all-features -- -D warnings

All passed. The wallet unit suite includes coverage for full checkpoint chunks
and a final partial tail.

🔗 Dependencies

None.

🔜 Future Work

None.

📋 PR Completion Checklist

  • Complete PR description
  • Implement the core functionality
  • Add/update tests
  • Add/update documentation and inline comments

Copilot AI review requested due to automatic review settings July 18, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Reduces wallet sync disk I/O by persisting wallet storage at fixed “checkpoint” intervals during WalletCore::sync_to_block, while still ensuring any remaining tail progress is durably saved before returning successfully.

Changes:

  • Introduces a small checkpoint counter to trigger persistence every 100 processed blocks.
  • Updates sync_to_block to persist only at checkpoints and once at the end if there’s a remaining tail.
  • Adds a unit test covering full checkpoint chunks and a final partial tail.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wallet sync persists storage after every block

3 participants