-
Notifications
You must be signed in to change notification settings - Fork 20k
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
les: reject client connection if it makes too much invalid req #19691
les: reject client connection if it makes too much invalid req #19691
Conversation
d59ed65
to
e8fd364
Compare
Please rebase onto master. |
e8fd364
to
3fd7804
Compare
@karalabe Updated. |
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 with some nitpicks
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.
SGTM
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.
Please fix the hanging test.
les/handler.go
Outdated
@@ -853,6 +866,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { | |||
|
|||
if number = rawdb.ReadHeaderNumber(pm.chainDb, request.BHash); number == nil { | |||
p.Log().Warn("Failed to retrieve block num for proof", "hash", request.BHash) | |||
atomic.AddUint64(&p.invalidReq, 1) |
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.
If the request contain N internal requests for the same missing hash, then this path won't trigger. Might be better to base it off #19701 , and add the counter here: https://github.com/ethereum/go-ethereum/pull/19701/files#diff-d1e187d1b095dcfc1cc773abfd8c4066R873
@@ -853,6 +866,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { | |||
|
|||
if number = rawdb.ReadHeaderNumber(pm.chainDb, request.BHash); number == nil { | |||
p.Log().Warn("Failed to retrieve block num for proof", "hash", request.BHash) | |||
atomic.AddUint32(&p.invalidCount, 1) |
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.
If the request contain N internal requests for the same missing hash, then this path won't trigger. Might be better to base it off #19701 , and add the counter here: https://github.com/ethereum/go-ethereum/pull/19701/files#diff-d1e187d1b095dcfc1cc773abfd8c4066R873
b322e53
to
2b349f4
Compare
This PR is based on #19689.
This PR introduces a very simple reputation system on the server side. If a client sends too much invalid request(e.g. request some non-exist data), it will be kicked out.
The rationale here is: A client should send the requests to servers which can serve the requests.
The server will push the new head announcements steadily. This information is totally enough for clients to manage their requests.