feat: sparse block header storage for wallet scanner#7744
feat: sparse block header storage for wallet scanner#77440xPepeSilvia wants to merge 1 commit intotari-project:developmentfrom
Conversation
Replace the fixed 720-block cache with a sparse storage schedule that keeps progressively fewer block headers as they age. This reduces the chance of having to rescan from the wallet birthday after a reorg, since the wallet now retains checkpoint headers much further back. Sparse schedule: - tip - 720 to tip: all blocks (unchanged) - tip - 10,000 to tip - 720: every 100th block - tip - 100,000 to tip - 10,000: every 1,000th block - genesis to tip - 100,000: every 5,000th block Blocks containing recovered outputs are always preserved regardless of the schedule. Closes tari-project#7738 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request implements a sparse storage schedule for scanned blocks in the wallet database, replacing the previous simple pruning mechanism. The new logic preserves all blocks within the last 720 heights and maintains progressively sparser checkpoints for older blocks. A significant issue was identified where the mechanism to protect blocks with recovered outputs from pruning is currently non-functional, as the 'num_outputs' field is not yet populated or tracked in the underlying data structures.
| if let Some(outputs) = block.num_outputs { | ||
| if outputs > 0 { | ||
| continue; | ||
| } | ||
| } |
There was a problem hiding this comment.
The logic to preserve blocks with recovered outputs (num_outputs > 0) is currently non-functional because the num_outputs field is never populated. The ScannedBlock domain model (defined in service.rs) does not include this field, and the From<ScannedBlock> for ScannedBlockSql implementation explicitly sets it to None. Consequently, all blocks will be pruned according to the sparse schedule regardless of whether they contain recovered outputs, which contradicts the PR description. The ScannedBlock struct and the scanner task need to be updated to track and store the number of recovered outputs per block.
Summary
Closes #7738
Test plan
🤖 Generated with Claude Code