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

More antiflood fixes #1861

Merged
merged 15 commits into from
Jun 8, 2020
Merged

More antiflood fixes #1861

merged 15 commits into from
Jun 8, 2020

Conversation

iulianpascalau
Copy link
Contributor

  • added an out-of-specs flood preventer
  • added antiflood debugger
  • moved PeerID from p2p to core package
  • replaced blackListHandler with peerBlackListHandler in antiflood package
  • added the possibility to switch off the observer's antiflood system in system tests

- added antiflood debugger
- moved PeerID from p2p to core package
- replaced blackListHandler with peerBlackListHandler in antiflood package
- added the possibility to switch off the observer's antiflood system in system tests
# Conflicts:
#	p2p/libp2p/networksharding/prioBitsSharder.go
#	p2p/libp2p/networksharding/prioBitsSharder_test.go
@sasurobert sasurobert self-requested a review June 3, 2020 16:22
epochStart/bootstrap/process.go Outdated Show resolved Hide resolved
factory/networkComponents.go Outdated Show resolved Hide resolved
process/throttle/antiflood/p2pAntiflood.go Outdated Show resolved Hide resolved
storage/timecache/peerTimeCache.go Show resolved Hide resolved
debug/antiflood/debugger.go Outdated Show resolved Hide resolved
@iulianpascalau iulianpascalau changed the base branch from release-candidate to development June 4, 2020 13:06
@iulianpascalau iulianpascalau self-assigned this Jun 4, 2020
@iulianpascalau iulianpascalau added type:bug Something isn't working type:feature New feature or request labels Jun 4, 2020
@andreibancioiu andreibancioiu self-requested a review June 5, 2020 09:29
debug/resolver/interceptorResolver.go Show resolved Hide resolved
epochStart/bootstrap/process.go Outdated Show resolved Hide resolved
ResetForTopic(topic string)
SetMaxMessagesForTopic(topic string, maxNum uint32)
SetDebugger(debugger process.AntifloodDebugger) error
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 a good example for injection via methods.
AttachDebugger 🎆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the injection via method was done because a debugger is not a critical component.

@@ -85,6 +86,11 @@ updateNodeConfig() {
cp nodesSetup_edit.json nodesSetup.json
rm nodesSetup_edit.json

if [ $OBSERVERS_ANTIFLOOD_DISABLE -eq 1 ]
then
sed -i '/\[Antiflood\]/,/\[Logger\]/ s/true/false/' config_observer.toml
Copy link
Collaborator

Choose a reason for hiding this comment

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

💥

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, sed stuff :(

}

return nil
}

func (af *p2pAntiflood) canProcessMessage(fp process.FloodPreventer, message p2p.MessageP2P, fromConnectedPeer p2p.PeerID) error {
func (af *p2pAntiflood) recordDebugEvent(pid core.PeerID, topic string, numRejected uint32, sizeRejected uint64, isBlacklisted bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

mutCriticalArea sync.RWMutex
cache storage.Cacher
intervalAutoPrint time.Duration
printEventHandler func(data string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Naming a bit unfortunate (because we use the suffix handler with other meaning usually) - could be printEventFunc, eventPrinter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

printEventFunc shall be


assert.Equal(t, 1, d.cache.Len())
ev := d.GetData([]byte(string(pid) + topic))
require.NotNil(t, ev)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

storage/timecache/peerTimeCache.go Show resolved Hide resolved
andreibancioiu
andreibancioiu previously approved these changes Jun 5, 2020
sasurobert
sasurobert previously approved these changes Jun 5, 2020
# Conflicts:
#	dataRetriever/resolvers/topicResolverSender/export_test.go
- fixed mcl seldom failing test: Test_ScalarMulPkOK
return rs.ReconnectToNetworkCalled()
}

return make(chan struct{}, 1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

why buffered?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made unbuffered

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

👍

@iulianpascalau iulianpascalau merged commit 7ae98c7 into development Jun 8, 2020
@iulianpascalau iulianpascalau deleted the antiflood-fixes branch June 8, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants