Skip to content
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(dot/network): Add warp sync spam limiter #4219

Merged
merged 10 commits into from
Oct 7, 2024

Conversation

dimartiro
Copy link
Contributor

@dimartiro dimartiro commented Oct 2, 2024

Changes

Add spam limiter for warp sync request handler.

  • Introduce RateLimiter interface for our request handlers
  • Use this Ratelimiter as part of the warp sync request handler
  • Create SlidingWindowRateLimiter as an implementation for RateLimiter to cache requests and prevent spam
    • Tests

Open questions

  • Can we solve this using the peer reputation?

Tests

go test ./dot/network

Issues

Closes: #4216

Copy link
Contributor

@jimjbrettj jimjbrettj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, just a few comments and questions

@dimartiro
Copy link
Contributor Author

@jimjbrettj I made some changes to simplify the implementation and turning in into a generic sliding window rate limiter. Can you take a look again please? 🙌

Copy link
Contributor

@jimjbrettj jimjbrettj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

dot/network/ratelimiters/sliding_window.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window_test.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window_test.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window_test.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window_test.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window_test.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window_test.go Outdated Show resolved Hide resolved
dot/network/ratelimiters/sliding_window_test.go Outdated Show resolved Hide resolved
dot/network/warp_sync.go Outdated Show resolved Hide resolved
@EclesioMeloJunior
Copy link
Member

Can we solve this using the peer reputation?

@dimartiro yes. You can decrease the peer reputation if you identify a spamming behavior and it will reach a point where the peer will be disconnected, however the peer still can send messages so we should but it in a block list.

Maybe we can add a layer between peer reputation and networking to avoid incoming messages from peers disconnected from bad behavior.

@dimartiro dimartiro merged commit e1dd783 into development Oct 7, 2024
24 checks passed
@dimartiro dimartiro deleted the dimartiro/warpsync/spam-limiter branch October 7, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement spamming rule for warp requests
4 participants