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

Add workaround for BandwidthChecker issue #478

Merged
merged 3 commits into from Oct 28, 2019

Conversation

@albrow
Copy link
Member

albrow commented Oct 28, 2019

Fixes #475.

The current implementation will ban peers if they violate bandwidth limits 4 times over the course of 6 hours. Each violation resets the TTL to 6 hours. If there are no violations over a time span of 6 hours, their count of violations is reset.

This workaround does slightly reduce the resiliency of the Mesh network in the face of spamming attacks, but the impact is minimal and it is much better than having no bandwidth limits in place at all.

albrow added 2 commits Oct 28, 2019
@albrow albrow requested a review from fabioberger Oct 28, 2019
@albrow

This comment has been minimized.

Copy link
Member Author

albrow commented Oct 28, 2019

I slightly altered the existing BandwidthChecker test. If you run with the -v flag to display logs, you can see that this workaround is working as intended:

go test ./p2p -run BandwidthChecker -v
=== RUN   TestBandwidthChecker
=== PAUSE TestBandwidthChecker
=== CONT  TestBandwidthChecker
time="2019-10-28T13:22:34-07:00" level=warning msg="detected high bandwidth usage" bytesPerSecondIn=787.3617747810655 maxBytesPerSecond=1 numViolations=1 remotePeerID=16Uiu2HAm5BkJwosfgKCJQTz9cT9ewTfakpuM4YVtXLnfKex6TTKf
time="2019-10-28T13:22:34-07:00" level=warning msg="detected high bandwidth usage" bytesPerSecondIn=787.3617747810655 maxBytesPerSecond=1 numViolations=2 remotePeerID=16Uiu2HAm5BkJwosfgKCJQTz9cT9ewTfakpuM4YVtXLnfKex6TTKf
time="2019-10-28T13:22:34-07:00" level=warning msg="detected high bandwidth usage" bytesPerSecondIn=787.3617747810655 maxBytesPerSecond=1 numViolations=3 remotePeerID=16Uiu2HAm5BkJwosfgKCJQTz9cT9ewTfakpuM4YVtXLnfKex6TTKf
time="2019-10-28T13:22:35-07:00" level=warning msg="banning peer due to high bandwidth usage" bytesPerSecondIn=787.3617747810655 maxBytesPerSecond=1 numViolations=4 remotePeerID=16Uiu2HAm5BkJwosfgKCJQTz9cT9ewTfakpuM4YVtXLnfKex6TTKf
--- PASS: TestBandwidthChecker (2.92s)
PASS
ok  	github.com/0xProject/0x-mesh/p2p	2.941s
@albrow albrow merged commit c3c4828 into development Oct 28, 2019
1 check passed
1 check passed
ci/circleci: build Your tests passed on CircleCI!
Details
@albrow albrow deleted the fix/bandwidth-workaround branch Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.