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: fork detection acts on headers before they are validated #1193
BlockHeadersManager::handle_headers_pipeline calls fork_height on headers the pipeline did not match and returns SyncEvent::ForkDetected before those headers are validated. BlockHeaderValidator only runs later, in store_headers. handle_fork then truncates headers, filter headers, filters and blocks down to the fork parent.
So one header attached to any stored block between the best ChainLock and the tip makes the client drop and re-download everything above that block. Its hash does not even have to meet its own bits.
#1103 assumes headers are checked for continuity and PoW before fork detection. On dev they are not: see the fork_height call in handle_headers_pipeline versus BlockHeaderValidator::validate in store_headers (dash-spv/src/sync/block_headers/manager.rs).
Fix: validate the branch before emitting ForkDetected. That means continuity, PoW, and the difficulty check from #1161 once it lands, using the stored headers below the fork point as ancestors. Ignore the branch and penalise the peer when validation fails.
I dont know why I remember the validator being executed as soon as we get the headers, anyway, this is just a correction for #1103, you should update that issue or post a comment instead of oppening a new one imo
Activity
ZocoLini commentedon Oct 19, 2026
I dont know why I remember the validator being executed as soon as we get the headers, anyway, this is just a correction for #1103, you should update that issue or post a comment instead of oppening a new one imo