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

les: reject client connection if it makes too much invalid req #19691

Merged
merged 5 commits into from
Jun 12, 2019

Conversation

rjl493456442
Copy link
Member

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.

@karalabe
Copy link
Member

Please rebase onto master.

@rjl493456442
Copy link
Member Author

@karalabe Updated.

Copy link
Contributor

@holiman holiman left a 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

les/handler.go Outdated Show resolved Hide resolved
les/peer.go Outdated Show resolved Hide resolved
les/handler.go Outdated Show resolved Hide resolved
les/peer.go Outdated Show resolved Hide resolved
les/peer.go Outdated Show resolved Hide resolved
les/peer.go Outdated Show resolved Hide resolved
@karalabe karalabe added this to the 1.9.0 milestone Jun 12, 2019
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

SGTM

Copy link
Member

@karalabe karalabe left a 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)
Copy link
Contributor

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)
Copy link
Contributor

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

@karalabe karalabe merged commit c8c3ebd into ethereum:master Jun 12, 2019
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