Skip to content

repro: a hash discontinuity inside a non-verify load aborts the sync session - #2728

Draft
dorianvp wants to merge 1 commit into
devfrom
repro/mid-load-reorg-aborts-sync
Draft

repro: a hash discontinuity inside a non-verify load aborts the sync session#2728
dorianvp wants to merge 1 commit into
devfrom
repro/mid-load-reorg-aborts-sync

Conversation

@dorianvp

Copy link
Copy Markdown
Member

Claim (mid-load-reorg-aborts-sync)

process_scan_results in pepper-sync/src/sync.rs:1536-1585 treats a ScanError::ContinuityError(HashDiscontinuity { height, .. }) as a re-org only when height equals the start of the load's range and the load's priority is Verify. Every other hash discontinuity falls through to scan_results? at pepper-sync/src/sync.rs:1584, which returns the error from process_scan_results and therefore from the sync loop at pepper-sync/src/sync.rs:520-531, so the sync session aborts instead of marking the affected blocks Verify and re-scanning.

Secondary: on the re-org path, state::set_scan_priority is called with the load's block range (pepper-sync/src/sync.rs:1550-1554). That function panics when no wallet scan range has exactly that block range (pepper-sync/src/sync/state.rs:436-447). The loader splits a load by output budget (pepper-sync/src/scan/task.rs:504-531), and ScanTask::split truncates the load's scan_range (pepper-sync/src/scan/task.rs:822-838), so a Verify load can arrive as a sub-range of the wallet's scan range and the panic is reachable.

What the tests do

Both tests live in pepper-sync/src/sync.rs under mod test::load_continuity_failure and call process_scan_results directly on a MockWallet.

  • discontinuity_inside_chain_tip_load_is_treated_as_reorg: the wallet holds 90..100 Scanned and 100..200 Scanning. The load 100..200 ChainTip reports HashDiscontinuity { height: 150 }. The test asserts Ok(()) and a Verify range covering the discontinuity.
  • reorg_in_split_verify_load_does_not_panic: the wallet holds 100..110 Scanning (the verify range selected by the loader). The load 100..105 Verify reports HashDiscontinuity { height: 100 }. The test asserts the call does not panic and leaves a Verify range.

The commit also adds Send to the two closure type aliases in the test-only pepper-sync/src/mocks.rs so that MockWallet satisfies the W: Send bound of process_scan_results.

Observed output on dev

test sync::test::load_continuity_failure::discontinuity_inside_chain_tip_load_is_treated_as_reorg ... FAILED
  a discontinuity inside a chain tip load aborted the sync session: Err(ScanError(ContinuityError(HashDiscontinuity { height: BlockHeight(150), .. })))
test sync::test::load_continuity_failure::reorg_in_split_verify_load_does_not_panic ... FAILED
  panicked at pepper-sync/src/sync/state.rs:446:9: scan range with block range BlockHeight(100)..BlockHeight(105) not found!

Notes

This PR is a reproduction and not a fix. Both tests are expected to fail on dev.

The abort in the first case is recoverable on the next sync session, because update_scan_ranges places a fresh Verify range above the highest scanned height. The session itself still ends with an error.

The sync-bench A/B rule was not run because the commit adds tests only.

🤖 Generated with Claude Code

…ts sync

Co-Authored-By: Claude Fable 5 <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