Skip to content
Permalink
Browse files

Merge pull request #448 from 0xProject/fix/disable-rate-limiting

Temporarily disable bandwidth-based rate-limiting
  • Loading branch information
albrow committed Oct 16, 2019
2 parents 1ce232d + edf3671 commit 11e0fa48c3795b0e910b90e6b8428f830b64fd44
Showing with 19 additions and 12 deletions.
  1. +16 −12 p2p/bandwidth_checker.go
  2. +3 −0 p2p/bandwidth_checker_test.go
@@ -77,26 +77,30 @@ func (checker *bandwidthChecker) checkUsage() {
"remotePeerID": remotePeerID.String(),
"bytesPerSecondIn": stats.RateIn,
"maxBytesPerSecond": checker.maxBytesPerSecond,
}).Warn("banning peer due to high bandwidth usage")
}).Warn("would ban peer due to high bandwidth usage")
// There are possibly multiple connections to each peer. We ban the IP
// address associated with each connection.
for _, conn := range checker.node.host.Network().ConnsToPeer(remotePeerID) {
if err := checker.node.BanIP(conn.RemoteMultiaddr()); err != nil {
if err == errProtectedIP {
continue
}
log.WithFields(log.Fields{
"remotePeerID": remotePeerID.String(),
"remoteMultiaddr": conn.RemoteMultiaddr().String(),
"error": err.Error(),
}).Error("could not ban peer")
}
// TODO(albrow): We don't actually ban for now due to an apparent bug in
// libp2p's BandwidthCounter. Uncomment this once the issue is resolved.
// See: https://github.com/libp2p/go-libp2p-core/issues/65
//
// if err := checker.node.BanIP(conn.RemoteMultiaddr()); err != nil {
// if err == errProtectedIP {
// continue
// }
// log.WithFields(log.Fields{
// "remotePeerID": remotePeerID.String(),
// "remoteMultiaddr": conn.RemoteMultiaddr().String(),
// "error": err.Error(),
// }).Error("could not ban peer")
// }
log.WithFields(log.Fields{
"remotePeerID": remotePeerID.String(),
"remoteMultiaddr": conn.RemoteMultiaddr().String(),
"rateIn": stats.RateIn,
"maxBytesPerSecond": checker.maxBytesPerSecond,
}).Trace("banning IP/multiaddress due to high bandwidth usage")
}).Trace("would ban IP/multiaddress due to high bandwidth usage")
}
// Banning the IP doesn't close the connection, so we do that
// separately. ClosePeer closes all connections to the given peer.
@@ -14,6 +14,9 @@ import (
)

func TestBandwidthChecker(t *testing.T) {
// TODO(albrow): Unskip this test.
t.Skip("Skipping due to apparent bug in libp2p's BandwidthCounter")

t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

0 comments on commit 11e0fa4

Please sign in to comment.
You can’t perform that action at this time.