From be69c9bafe5dba0d8a628d995badb9a953e37229 Mon Sep 17 00:00:00 2001 From: DanS Date: Wed, 14 Oct 2026 08:50:12 -0500 Subject: [PATCH] fix(litebe-sync): bound the reorg recovery window to the max depth When sync hit a reorg it stepped the scan back to just before the invalidated block, then set the top of the re-scan range to that point plus the full forward batch size. That window is far larger than any reorg can be: the batch size is tuned for forward streaming (tens of thousands of blocks), while a reorg is capped at the maximum reorg depth and the pass aborts once it is exceeded. So the recovery pass re-fetched and re-scanned a large span of already-good blocks before it could resume moving forward. - The recovery range now reaches only the maximum reorg depth (plus one) above the rewind point, which is the most a reorg can ever disturb. Forward syncing still uses the full batch size; only the pass immediately after a reorg is bounded this way. - The set of blocks that ultimately get scanned is unchanged - the next pass picks up from where recovery stops - so the resulting wallet is identical, just reached with far less redundant fetching and scanning. The wallet file format is unchanged. Co-Authored-By: Claude Opus 4.8 --- .../silentdragonxlite-cli/lib/src/lightclient.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/silentdragonxlite/silentdragonxlite-cli/lib/src/lightclient.rs b/third_party/silentdragonxlite/silentdragonxlite-cli/lib/src/lightclient.rs index e6a27e6..755f342 100644 --- a/third_party/silentdragonxlite/silentdragonxlite-cli/lib/src/lightclient.rs +++ b/third_party/silentdragonxlite/silentdragonxlite-cli/lib/src/lightclient.rs @@ -1805,7 +1805,7 @@ pub fn start_mempool_monitor(lc: Arc) -> Result<(), String> { self.taddr_note_unscanned(start_height, &block_times); // Reset the scanning heights last_scanned_height = (invalid_height - 1) as u64; - end_height = std::cmp::min(last_scanned_height + scan_batch_size, latest_block); + end_height = std::cmp::min(last_scanned_height + crate::lightwallet::MAX_REORG as u64 + 1, latest_block); warn!("Reorg: reset scanning from {} to {}", last_scanned_height, end_height);