-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Networking] Enhance Gossipsub Resilience: Configurable Threshold for Invalid Topic IDs in Control Messages #5391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
c.metrics.OnInvalidTopicIdDetectedForControlMessage(p2pmsg.CtrlMsgGraft) | ||
return err, ctrlMsgType | ||
if totalInvalidTopicIdErrs > c.config.GraftPrune.InvalidTopicIdThreshold { | ||
return err, ctrlMsgType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider returning a specific error type (e.g., ErrInvalidTopicIdExceedThreshold
) instead of using the generic error from validateTopics
. This approach provides clearer context, indicating misbehavior from exceeding the threshold, rather than signaling a single invalid topic. This also aligns with our general approach on returning an error when exceeding threshold, e.g., for duplicate topic ids we already have:
if totalDuplicateTopicIds > c.config.GraftPrune.DuplicateTopicIdThreshold {
c.metrics.OnGraftDuplicateTopicIdsExceedThreshold()
return NewDuplicateTopicErr(topic.String(), totalDuplicateTopicIds, p2pmsg.CtrlMsgGraft), p2p.CtrlMsgNonClusterTopicType
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.metrics.OnInvalidTopicIdDetectedForControlMessage(p2pmsg.CtrlMsgPrune) | ||
return err, ctrlMsgType | ||
if totalInvalidTopicIdErrs > c.config.GraftPrune.InvalidTopicIdThreshold { | ||
return err, ctrlMsgType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.metrics.OnInvalidTopicIdDetectedForControlMessage(p2pmsg.CtrlMsgIHave) | ||
return err, ctrlMsgType | ||
if totalInvalidTopicIdErrs > c.config.IHave.InvalidTopicIdThreshold { | ||
return err, ctrlMsgType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
Co-authored-by: Yahya Hassanzadeh, Ph.D. <yhassanzadeh@ieee.org>
…flow/flow-go into khalil/6934-invalid-topicid-threshold
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5391 +/- ##
==========================================
- Coverage 55.99% 55.98% -0.01%
==========================================
Files 1026 1026
Lines 99815 99902 +87
==========================================
+ Hits 55894 55933 +39
- Misses 39627 39674 +47
- Partials 4294 4295 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This pull request mitigates the potential for false positives arising from edge cases in Gossipsub, specifically addressing scenarios where a node receives control messages containing apparently invalid topics (e.g., the node is not subscribed to the topic, subscription dissemination glitches, etc.). The enhancement introduces a configurable
invalid-topic-id-threshold
for graft, prune, and ihave control message topic validation. Now, an error is triggered only when the number of encountered invalid topic ids surpasses this configured threshold. Additionally, the PR includes XX_AboveThreshold and XX_BelowThreshold tests, ensuring that the dissemination of an invalid control message notification aligns with expectations based on whether the count is above or below the configured threshold.