You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dash-spv: rescan re-applies blocks whose last processing already saw the new scripts #1229
BlockMatchTracker::track_for_new_scripts (dash-spv/src/sync/filters/block_match_tracker.rs:100-115) always re-tracks a matched block and never answers AlreadyProcessed. Its doc comment assumes the block's earlier processing predates the newly derived scripts. That is often false: the block may have been processed after those scripts were derived, for example when it was the block that triggered the derivation, or when a later batch already re-applied it. The block is then loaded from storage and applied to the wallet again with nothing new to find.
Evidence. 12 full testnet syncs of dev0dcdd823 with the same HD wallet. Each run re-applies 656 to 770 already processed blocks (final SyncProgress: blocks processed minus distinct blocks downloaded, equal to from_storage on dev). About 515 of those per run find no new transaction and no new script. Only about 28 to 61 re-applies per run find anything. Final wallet state is identical in every run (20.66198098 DASH, 3,266 transactions), so this is wasted work, not a correctness bug. Each re-apply is a storage load plus a full wallet pass under the wallet write lock.
Why it matters more soon. The rescan rework on refactor/network-mod (#902) runs this path far more often, and there the same counter reaches 1,007 to 8,612 per run.
Fix. Tag each entry in pending_new_scripts with the wallet monitor_revision at derivation, store the revision a block was processed at in record_processed, and make track_for_new_scripts return AlreadyProcessed when the block's processed revision is at least the scripts' revision. Keep re-tracking when the scripts are newer, since those passes do find real transactions.
Activity
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan
fix(dash-spv): skip re-applying blocks on rescan (dashpay#1344)