-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: DOS protection of non relay protocols - rate limit phase3 #2897
Conversation
- Enhanced TokenBucket to be able to add compensation tokens based on previous usage percentage, - per peer rate limiter 'PeerRateLimier' applied on waku_filter_v2 with opinionated default of acceptable request rate - Add traffic metrics to filter message push - RequestRateLimiter added to combine simple token bucket limiting of request numbers but consider per peer usage over time and prevent some peers to over use the service (although currently rule violating peers will not be disconnected by this time only their requests will get not served) - TimedMap utility created (inspired and taken from libp2p TimedCache) which serves as forgiving feature for peers had been overusing the service. - Added more tests - Fix rebase issues - Applied new RequestRateLimiter for store and legacy_store and lightpush
You can find the image built from this PR at
Built from 8325b5b |
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.
Amazing work!
As for what settings to use, it's hard to say. Real usage would be how we determine that.
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.
Really great work! 🎉
Only very minor comments below.
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.
Looks amazing! 🔥 🔥
Thanks so much!
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.
LGTM! Thanks for it! 💯
I just added some comments that I hope you find useful :)
Description
This PR is the final phase for Rate Limiting non relay protocols.
Aimed three major target:
Notice for reviewers:
Filter protocol has an arbitrary limit applied per peers (30 req / 1 min / peer)
RequestRateLimiter applies a ratio calculation for managing fair usage of peers.
The ratio is calculated currently as - if main time period is set to:
This is debatable I wanted to apply reasonable scale in time on the applied multiplication factor.
Peer measurement also time capped, non requester peers will be wiped out from the store.
Changes
How to test
Unit tests applied.
Issue
#2683 covers #2032