headerssync: carry indexer proofs in CompressedHeader, bound redownload buffer by bytes - #23
Open
Avecci-Claussen wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two issues in the headers-sync anti-DoS logic for Fractal block types:
CompressedHeaderdropped theindexerProofwhen compressing anindexer block header, and
GetFullHeaderreconstructed the headerwithout 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.
The redownload buffer was bounded only by the header count
(
m_redownload_buffer_size, one entry per header), not by serializedsize. 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:
indexerProofmember toCompressedHeader(constructed fromthe full header, restored by
GetFullHeader), and extends the equalityoperator accordingly.
m_redownload_buffer_bytesand rejects the peer (turning the sync intoa 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_statetarget(545k executions under AddressSanitizer, no findings).