-
Notifications
You must be signed in to change notification settings - Fork 54
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
GossipSub Rate Limit #920
GossipSub Rate Limit #920
Conversation
8a02654
to
0096fbe
Compare
Codecov Report
@@ Coverage Diff @@
## unstable #920 +/- ##
============================================
- Coverage 83.10% 83.10% -0.01%
============================================
Files 91 91
Lines 15235 15288 +53
============================================
+ Hits 12661 12705 +44
- Misses 2574 2583 +9 |
0c948da
to
f2ff1e3
Compare
c8c851a
to
6ffaf32
Compare
c3f9bec
to
397e2c3
Compare
e03756a
to
1dd3a0d
Compare
6842b9a
to
7ea1c8b
Compare
b4d8d88
to
03f67f2
Compare
24588b0
to
c7884d5
Compare
@@ -78,7 +79,8 @@ proc init*(_: type[GossipSubParams]): GossipSubParams = | |||
disconnectBadPeers: false, | |||
enablePX: false, | |||
bandwidthEstimatebps: 100_000_000, # 100 Mbps or 12.5 MBps | |||
iwantTimeout: 3 * GossipSubHeartbeatInterval | |||
iwantTimeout: 3 * GossipSubHeartbeatInterval, | |||
overheadRateLimitConfOpt: Opt.none(tuple[bytes: int, interval: Duration]) |
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.
overheadRateLimitConfOpt: Opt.none(tuple[bytes: int, interval: Duration]) | |
overheadRateLimit: Opt.none(tuple[bytes: int, interval: Duration]) |
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.
This is different from the actual rate limit, it is a config. Adding the Opt makes using withValue
cleaner.
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.
Everything in that structure is a config, it's even named GossipSubParams
And since when do we put the type of a variable in its name?
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.
Done
@@ -116,3 +116,32 @@ func shortLog*(m: RPCMsg): auto = | |||
messages: mapIt(m.messages, it.shortLog), | |||
control: m.control.get(ControlMessage()).shortLog | |||
) | |||
|
|||
proc byteSize*(msg: Message): int = |
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.
Same issue as #944 (comment), but I guess we can unify that after merging this PR
The main idea here is to eventually disconnect peers that send us too much useless data in a short amount of time (potentially DoSing us). The definition of useless we chose depends if the singing mode is enabled or not. If so, it is everything but the messages themselves. Otherwise, it is everything but the data and the topicIDs inside the message. For now, we just log and measure the number of times peers are above their rate limit - the max amount of useless data they can send us for a given interval.