fix(blocksync): backport of upstream #5860#47
Merged
Conversation
|
I see there is missing block_sync/reactor_test.go and p2p/switch_test.go files in this PR which were in cometbft#5860, should we not include them as well? |
calbera
approved these changes
May 28, 2026
Collaborator
calbera
left a comment
There was a problem hiding this comment.
utACK, lets get in the reactor_test.go at least
9401c41 to
2bbbb18
Compare
cometbft#5860) --- Adds additional validation to blocksync, ensuring _before response unmarshalling_ that we have made a `BlockRequest` to the peer that is sending us a `BlockResponse` recently, and also that the response contains a valid amount of commit signatures (not > MaxVoteCount). To do this preunmarshal validation, we have added a `MsgBytesFilter` interface that `Reactors` can implement. Currently only `BLOCKSYNC` does. The `FilterMsgBytes` function is called for both comet P2P and libp2p implementations, inside of the `onReceive` function when setting up a peer for comet p2p, and inside of `handleStream` for libp2p, just before unmarshalling the message in both. - [x] Tests written/updated - [x] Changelog entry added in `CHANGELOG.md` - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --- Backport adaptations for bera-v1.x: - enabled atomic.Bool field NOT added. - internal/blocksync/reactor.go was hand-edited rather than auto-merged. - bcstub import alias used (proto/tendermint/blocksync) because bcproto already points to api/cometbft/blocksync/v1 in this fork. - lp2p/* hunks dropped — no libp2p reactor in this fork. - CHANGELOG.md not modified - Tests - pool_test.go kept as is - reactor_test.go adapted (different imports) - p2p/switch_test.go dropped adapted (BroadcastAsync/Broadcast, same) (cherry picked from commit 4590e7a)
2bbbb18 to
c83f296
Compare
Author
|
tests had minor divergencies, but yeah looking better the modifications are very tiny. ported now |
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.
fix(blocksync): validate blocksync response sender and signature count (cometbft#5860)
Adds additional validation to blocksync, ensuring before response unmarshalling that we have made a BlockRequest to the peer that is sending us a BlockResponse recently, and also that the response contains a valid amount of commit signatures (not > MaxVoteCount). To do this preunmarshal validation, we have added a MsgBytesFilter interface that Reactors can implement. Currently only BLOCKSYNC does. The FilterMsgBytes function is called for both comet P2P and libp2p implementations, inside of the onReceive function when setting up a peer for comet p2p, and inside of handleStream for libp2p, just before unmarshalling the message in both.
Backport adaptations for bera-v1.x:
CHANGELOG.mdnot modified — left to fork's changelog flow.internal/blocksync/reactor.goupstream's path isblocksync/reactor.go;git renamedetection fails due to content divergence, so the modifications were manually added 1:1, beside a couple of divergencies:enabled atomic.Boolfield NOT added. Upstream'sFilterMsgBytesdoes!r.enabled.Load() || !r.pool.IsRunning(); this fork uses!bcR.pool.IsRunning()alone. Left a comment in the code to explain why it should be ok.bcstubimport alias used forproto/tendermint/blocksyncbecausebcprotoalready points toapi/cometbft/blocksync/v1in this fork.lp2p/*modifications dropped — nolibp2pin this fork.