Skip to content

AICH-recover parts found corrupt during the final completion re-hash - #270

Merged
got3nks merged 2 commits into
amule-org:masterfrom
got3nks:fix/aich-recover-on-completion-rehash
Jul 2, 2026
Merged

AICH-recover parts found corrupt during the final completion re-hash#270
got3nks merged 2 commits into
amule-org:masterfrom
got3nks:fix/aich-recover-on-completion-rehash

Conversation

@got3nks

@got3nks got3nks commented Jul 1, 2026

Copy link
Copy Markdown

Problem

When a completed file is re-hashed and a part fails, PartFileHashFinished re-opens the whole 9.28 MB part (AddGap) but — unlike the mid-download hash path — never requests AICH recovery. So a part that passed its per-part hash during download but was corrupted afterwards is fully re-downloaded, even when a trusted AICH hashset could recover just the bad 180 KB blocks.

This is what surfaces with endgame source rotation (#225): when a faster source evicts a slower one mid-block (OP_CANCELTRANSFER), the block ends up spliced across two sources and can fail the final full-file hash. In testing there, a 4.5 GB file at AICH_TRUSTED (10 sources) had 8 parts fail and re-downloaded them whole, because the completion path never asked AICH to narrow it down — the AICH quorum was reached but unused on this path.

Fix

Collect the parts that fail the final re-hash and, once the file is back in PS_READY, call RequestAICHRecovery() for each.

RequestAICHRecovery() is self-guarded: it returns immediately unless the file has a valid trusted/verified AICH master hash and a source that can serve the recovery data. So the AddGap() whole-part re-open (unchanged and unconditional) is always the fallback, and this only adds an optional narrowing on top:

  • Files without a trusted AICH hashset (quorum not reached, few sources) keep the existing whole-part re-download — no behaviour change, no new data-loss or stuck-state path.
  • Files that reached AICH_TRUSTED / AICH_VERIFIED now recover at 180 KB block granularity, re-downloading only the corrupt blocks, and the CorruptionBlackBox can pinpoint the offending block.

Testing

Debug build clean. The recovery path is best exercised live; this unblocks testing whether AICH recovers endgame split-block corruption on #225 (the motivating scenario), where it previously couldn't because the completion path never requested it.

…le-project#225)

When a completed file is re-hashed and a part fails, PartFileHashFinished
re-opens the whole 9.28 MB part (AddGap) but, unlike the mid-download hash
path, never requests AICH recovery. So a part that passes its per-part
hash during download yet is corrupted afterwards — as happens when endgame
source rotation (OP_CANCELTRANSFER) splices a 180 KB block across two
sources — is fully re-downloaded even when a trusted AICH hashset could
recover just the bad 180 KB blocks.

Collect the parts that fail the final re-hash and, once the file is back
in PS_READY, call RequestAICHRecovery() for each. It is a no-op unless the
file has a trusted/verified AICH master hash, so non-AICH files keep the
existing whole-part re-download; files that reached AICH_TRUSTED now
recover at block granularity and let the CorruptionBlackBox pinpoint the
offending block.
)

Also flag parts that fail the final completion re-hash in m_corrupted_list,
mirroring the mid-download corruption path. The AICH block recovery added
in the previous commit doesn't consult this list, but it primes the ICH
fallback when no trusted AICH hashset is available, and — since
m_corrupted_list is saved to the .met — it keeps the corrupt state across a
restart that happens before recovery finishes.
@got3nks
got3nks merged commit 5160d37 into amule-org:master Jul 2, 2026
10 checks passed
@got3nks
got3nks deleted the fix/aich-recover-on-completion-rehash branch July 2, 2026 15:00
Cflsft pushed a commit to Cflsft/amule that referenced this pull request Jul 6, 2026
… re-hash (amule-org#270)

When the final full-file re-hash finds a part corrupt (e.g. a block rewritten after the part completed, as with endgame source-rotation block splicing, amule-org#225), PartFileHashFinished only re-gapped the whole 9.28 MB part and never requested AICH recovery. Collect the failing parts and call RequestAICHRecovery() for each once the file is back in PS_READY. It is self-guarded (no-op without a trusted/verified AICH hashset), so non-AICH files keep the existing whole-part re-download; AICH files now recover at 180 KB block granularity.
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