Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Add workaround for BandwidthChecker issue #478

Merged
merged 3 commits into from
Oct 28, 2019

Conversation

albrow
Copy link
Contributor

@albrow 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
Copy link
Contributor 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
@albrow albrow deleted the fix/bandwidth-workaround branch October 28, 2019 21:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants