Skip to content

headerssync: carry indexer proofs in CompressedHeader, bound redownload buffer by bytes - #23

Open
Avecci-Claussen wants to merge 1 commit into
fractal-bitcoin:fractal-29.xfrom
Avecci-Claussen:fix/headerssync-indexer-proof
Open

Avecci-Claussen wants to merge 1 commit into
fractal-bitcoin:fractal-29.xfrom
Avecci-Claussen:fix/headerssync-indexer-proof

Conversation

@Avecci-Claussen

Copy link
Copy Markdown

Two issues in the headers-sync anti-DoS logic for Fractal block types:

  1. CompressedHeader dropped the indexerProof when compressing an
    indexer block header, and GetFullHeader reconstructed the header
    without it. During the redownload phase the peer is asked to resend
    full headers, and a headers chain containing indexer blocks could not
    round-trip through the compressed representation correctly.

  2. The redownload buffer was bounded only by the header count
    (m_redownload_buffer_size, one entry per header), not by serialized
    size. Fractal headers can carry arbitrarily large AuxPoW data plus an
    indexer proof, so a fixed count of headers is no longer a meaningful
    memory bound. A malicious headers-sync peer could force buffering of
    far more memory than the anti-DoS design intends.

This change:

  • Adds an indexerProof member to CompressedHeader (constructed from
    the full header, restored by GetFullHeader), and extends the equality
    operator accordingly.
  • Tracks cumulative serialized bytes of buffered redownloaded headers in
    m_redownload_buffer_bytes and rejects the peer (turning the sync into
    a failure) once the buffer exceeds 64 MiB.

No consensus or wire-protocol changes; this only hardens the local
headers-sync state machine. Fuzzed with the headers_sync_state target
(545k executions under AddressSanitizer, no findings).

CompressedHeader dropped indexerProof, so GetFullHeader rebuilt an
indexer header with no proof attached. Downstream, CheckProofOfWork
rejects indexer blocks without a proof and AcceptBlockHeader treats the
peer's chain as invalid, aborting any headers sync that crosses the
FIP-101 indexer range. Preserve the proof alongside auxpow so
reconstructed headers are complete.

Also, auxpow headers carry a parent coinbase transaction plus Merkle
branches and are not fixed at 80 bytes, so REDOWNLOAD_BUFFER_SIZE (a
header count) does not bound redownload-buffer memory. Track the
serialized size of buffered headers and abort the sync once the buffer
exceeds 64 MiB.
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