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/sync): prevent block sync request spamming #3953

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

EclesioMeloJunior
Copy link
Member

@EclesioMeloJunior EclesioMeloJunior commented May 14, 2024

Changes

  • Introduces a mechanism to identify and punish peers which spams request through the /sync/2 protocol ID
  • The sync package, which is responsible for responding any sync requests takes the peer ID as well as the request message and hash them and insert in a LRU caching layer with the number of this peer and request was seen, if it reaches the max number then the peer is reported and the message is ignored

Tests

WIP

Issues

Primary Reviewer

@timwu20

@EclesioMeloJunior EclesioMeloJunior added C-simple Minor changes changes, no additional research needed. Good first issue/review. S-network issues related to the dot/network package. labels May 14, 2024
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.

great work! One question but lgtm


numOfRequests := s.seenBlockSyncRequests.Get(requestHash)

if numOfRequests > maxNumberOfSameRequestPerPeer {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if numOfRequests > maxNumberOfSameRequestPerPeer {
if numOfRequests + 1 > maxNumberOfSameRequestPerPeer {

Shouldn't we increment this now to report the peer and exit early instead of waiting for the 3rd message spam to do this?

Copy link
Member Author

Choose a reason for hiding this comment

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

but then Gossamer will punish w/o reason, I'm mean, if someone reach the limit that is not a bad thing so should not be punished, however if it goes beyond the limit then it should be punished and have its reputation decreased. That's why we should wait for the third message imo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-simple Minor changes changes, no additional research needed. Good first issue/review. S-network issues related to the dot/network package.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decrease peer reputation on each block sync request to avoid spam
3 participants