-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Stagger Block By Range Responses #5618
Conversation
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.
Cosmetic feedbacks and a question on magic number
|
||
r.blocksRateLimiter.Add(stream.Conn().RemotePeer().String(), int64(m.Count)) | ||
// TODO(3147): Update this with reasonable constraints. | ||
if endSlot-startSlot > 1000 || m.Step == 0 { |
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.
what is this 1000
magic number? should we define it at the top and use a const?
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.
Not actually sure, we have had it for as long as I can remember
@prestonvanloon any idea why its 1000 ?
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.
There is no reason. I put 1000 because I felt that was a large range and anything more than that would be too much to fetch from the DB at once.
r.blocksRateLimiter.Add(stream.Conn().RemotePeer().String(), int64(m.Count)) | ||
// TODO(3147): Update this with reasonable constraints. | ||
if endSlot-startSlot > 1000 || m.Step == 0 { | ||
r.writeErrorResponseToStream(responseCodeInvalidRequest, "invalid range or step", stream) |
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.
can prefine err "invalid range or step"
and use it here and L81
Co-Authored-By: terence tsao <[email protected]>
Co-Authored-By: terence tsao <[email protected]>
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.
Just some cosmetic changes to comments.
Co-Authored-By: Victor Farazdagi <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #5618 +/- ##
======================================
Coverage 1.47% 1.47%
======================================
Files 69 69
Lines 6516 6516
======================================
Hits 96 96
Misses 6411 6411
Partials 9 9 |
For context #5587.
Lighthouse peers were being constantly rate limited by prysm peers due to them request multiple batches of size 64 blocks. These requests being sent at once triggered our rate limiter. To make it easier for other clients asking for bigger batches of blocks, we instead stagger our block responses.
If the requested block range is greater than the alloted
blocksPerSecond
variable, we instead wait one second before sending the next batch over. This prevents prysm from being overwhelmed when serving multiple large requests at once. By spreading out the request over 10 seconds(response deadline), we prevent the rate limiter from being triggered and also allow prysm to serve large requests.