Skip to content

Serialize legacy header sync state across header, block, and peer handlers #1709

Description

@icellan

Legacy header handling is dispatched with go sm.handleHeadersMsg(msg) in services/legacy/netsync/manager.go, while headerList, startHeader, and nextCheckpoint are also accessed by block delivery, sync reset, and peer handling without a common lock. The atomic headersFirstMode flag does not protect those fields or the linked list.

Concurrent header messages can race with each other and with checkpoint advancement/reset. The security review reported race-detector findings and list corruption; this issue records that reported result, rather than claiming a new concurrency reproduction. Static inspection confirms the shared, unsynchronized accesses.

Give header state a single owner or a consistent locking discipline. Cover all reads and mutations, including reset, request construction, checkpoint advancement, and diagnostics. Avoid holding a state lock across the minutes-long block-validation path or network/store waits where practical.

Acceptance: concurrency tests overlap header receipt, block delivery, peer rotation, and reset; run them with -race, assert list/cursor consistency, and verify checkpoint provenance is only granted for a matched header run. Preserve initial-download throughput.

Activity

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