Skip to content

dash-spv: fork detection acts on headers before they are validated #1193

Open

Description

@xdustinface

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.

Activity

  1. ZocoLini commented on Oct 19, 2026

    @ZocoLini
    Collaborator

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions