[F-26] fix(network): remove dead double-read in refresh_ipl() OP_FOUND proof#137
Merged
adequatelimited merged 1 commit intoaudit-fixesfrom Apr 5, 2026
Merged
Conversation
Closes #114 refresh_ipl() performed two sequential read_tfile() calls into tx.buffer. The first read's output was immediately cleared and overwritten by the second, but count from the first read was used to set the packet length — making the OP_FOUND proof malformed (length from read A, buffer content from read B). Receiving peers would reject the mismatched proof, silently breaking the background peer-help mechanism. Replaced with a single read_tfile() matching send_found()'s pattern, including the NTFTX-1 offset for correct inclusive range. Added count != NTFTX check to skip the send on short/failed reads. Added TODO comment in send_found() for the same check.
Collaborator
Author
|
For send_found() triggered by refresh_ipl() trying to help lagging peers realize they are behind the network, we were zeroing the proof buffer after filling it. Essentially telling the lagging peer, "you're behind, here's the proof" and sending them 54 block trailers worth of all 0s. One of the more amusing oversights in the history of the codebase, now corrected, with significant network performance improvements now anticipated. |
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.
Closes #114
Summary
refresh_ipl()sends anOP_FOUNDmessage to help lagging peers discover a heavier chain. The proof payload was malformed due to a dead double-read: the firstread_tfile()result was immediately cleared and overwritten by a second read with different parameters, but the packet length was set from the first read's count. The receiver would reject the mismatched proof, silently breaking the background peer-help mechanism.Change
Removed the dead first read block and redundant
memsetcalls. Replaced with a singleread_tfile()matchingsend_found()'s proven pattern:The
NTFTX - 1offset produces an inclusive range of 54 trailers ending atCblocknum, matching what the receiver'scontention()expects when validating the proof against the advertised weight (stamped bysend_tx()from the globalWeight).Added
count != NTFTXcheck to skip the send on short or failed reads — the receiver would reject incomplete proof anyway, so this avoids a wasted network round trip.Added a TODO comment in
send_found()noting the same check should be added there.Testing
-Wall -Werror -Wextra -Wpedantic