diff --git a/eth/handler_bsc.go b/eth/handler_bsc.go index d01a475ed0..4fb1824f27 100644 --- a/eth/handler_bsc.go +++ b/eth/handler_bsc.go @@ -62,7 +62,6 @@ func (h *bscHandler) Handle(peer *bsc.Peer, packet bsc.Packet) error { // votes broadcast for the local node to process. func (h *bscHandler) handleVotesBroadcast(peer *bsc.Peer, votes []*types.VoteEnvelope) error { if peer.IsOverLimitAfterReceiving() { - peer.Log().Warn("peer sending votes too much, votes dropped; it may be a ddos attack, please check!") return nil } // Here we only put the first vote, to avoid ddos attack by sending a large batch of votes. diff --git a/eth/protocols/bsc/peer.go b/eth/protocols/bsc/peer.go index 77ac11599f..242864fdbb 100644 --- a/eth/protocols/bsc/peer.go +++ b/eth/protocols/bsc/peer.go @@ -26,7 +26,7 @@ const ( receiveRateLimitPerSecond = 10 // the time span of one period - secondsPerPeriod = float64(10) + secondsPerPeriod = float64(30) ) // max is a helper function which returns the larger of the two given integers. @@ -133,6 +133,9 @@ func (p *Peer) AsyncSendVotes(votes []*types.VoteEnvelope) { // Otherwise, check whether the number of received votes extra (secondsPerPeriod * receiveRateLimitPerSecond) func (p *Peer) IsOverLimitAfterReceiving() bool { if timeInterval := time.Since(p.periodBegin).Seconds(); timeInterval >= secondsPerPeriod { + if p.periodCounter > uint(secondsPerPeriod*receiveRateLimitPerSecond) { + p.Log().Debug("sending votes too much", "secondsPerPeriod", secondsPerPeriod, "count ", p.periodCounter) + } p.periodBegin = time.Now() p.periodCounter = 0 return false