Skip to content

identify: rate limit id push protocol - #3266

Merged
sukunrt merged 2 commits into
masterfrom
push-ywoykpktmmtp
May 1, 2025
Merged

sukunrt merged 2 commits into
masterfrom
push-ywoykpktmmtp

Conversation

@sukunrt

@sukunrt sukunrt commented Apr 3, 2025

Copy link
Copy Markdown
Member

The rate limits id pushes from peers to one every five second with an allowed burst of 10 pushes. This should be enough for all but malfunctioning and malicious peers.

We can use the exact same code for autonat, autonatv2, circuit v2, etc.

Introducing limits to identify separately to get some feedback for #3265. For this PR, I'd like to ignore issues regarding where should this piece of code go, and focus on how specifically it should behave. See the long comment in rateLimiter.allow for example. We should probably modify x/time/rate for our usecase.

Part of: #3265

@sukunrt
sukunrt force-pushed the push-ywoykpktmmtp branch from 58d3e36 to beb9ef8 Compare April 3, 2025 13:04
@sukunrt
sukunrt marked this pull request as draft April 3, 2025 13:05
@sukunrt
sukunrt force-pushed the push-ywoykpktmmtp branch 5 times, most recently from 4069b71 to 7016aa4 Compare April 3, 2025 14:16
@MarcoPolo
MarcoPolo self-requested a review April 9, 2025 00:19
The rate limits id pushes from peers to one every five second with an
allowed burst of 10 pushes. This should be enough for all but
malfunctioning and malicious peers. 

We can use the exact same code for autonat, autonatv2, circuit v2, etc. 

Introducing limits to identify separately to get some feedback for
the rate limiting module. For this PR, I'd like to ignore issues 
regarding where should this piece of code go, and focus on how 
specifically it should behave. See the long comment in 
`rateLimiter.allow` for example. We should probably modify 
`x/time/rate` for our usecase.
@sukunrt
sukunrt force-pushed the push-ywoykpktmmtp branch 2 times, most recently from 89f574d to a6c9c71 Compare April 14, 2025 09:50
@sukunrt
sukunrt requested a review from guillaumemichel April 14, 2025 09:52
@sukunrt
sukunrt marked this pull request as ready for review April 14, 2025 09:53
Comment thread p2p/protocol/identify/ratelimit.go Outdated
@@ -0,0 +1,325 @@
package identify

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any reason this is in the identify package?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll move this when introducing it for connections.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For this PR, I'd like to ignore issues regarding where should this piece of code go, and focus on how specifically it should behave.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's fine, but fwiw I would prefer an internal package instead. I know we don't have them very often, but it makes it a little easier to review since the interface is well defined and I can focus on just the one package.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's better. Moved to p2p/internal/rate

@guillaumemichel guillaumemichel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rate limiting mechanism looks good overall. Left a few comments

Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved

@MarcoPolo MarcoPolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

Comment thread p2p/protocol/identify/id.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
Comment thread p2p/protocol/identify/ratelimit.go Resolved
@sukunrt
sukunrt force-pushed the push-ywoykpktmmtp branch 3 times, most recently from d4620d8 to bb1e289 Compare May 1, 2025 15:48
@sukunrt
sukunrt force-pushed the push-ywoykpktmmtp branch from bb1e289 to 61c0681 Compare May 1, 2025 15:52
@sukunrt
sukunrt merged commit 50d714c into master May 1, 2025
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.

3 participants