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

feat: p2p disconnect with reason #2471

Merged
merged 5 commits into from
Sep 8, 2021
Merged

feat: p2p disconnect with reason #2471

merged 5 commits into from
Sep 8, 2021

Conversation

aloknerurkar
Copy link
Contributor

@aloknerurkar aloknerurkar commented Sep 2, 2021

This change is Reviewable

@acud
Copy link
Member

acud commented Sep 3, 2021

@aloknerurkar could we also have the signature change on the Blocklist method on the Disconnecter interface? (in the p2p.go file)

@aloknerurkar aloknerurkar force-pushed the disconnect branch 2 times, most recently from 82b987c to 723e876 Compare September 7, 2021 08:12
@aloknerurkar aloknerurkar added the ready for review The PR is ready to be reviewed label Sep 7, 2021
@aloknerurkar aloknerurkar self-assigned this Sep 7, 2021
@aloknerurkar
Copy link
Contributor Author

@acud The sonar cloud check is complaining about code duplication in the accounting_test.go file. These don't seem as straightforward. Not sure if we should address this.

Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

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

nice! i have a few comments

Reviewed 7 of 11 files at r1, 9 of 9 files at r3, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @aloknerurkar and @metacertain)


pkg/debugapi/peer.go, line 39 at r3 (raw file):

	if err := s.topologyDriver.Connected(r.Context(), p2p.Peer{Address: bzzAddr.Overlay}, true); err != nil {
		_ = s.p2p.Disconnect(bzzAddr.Overlay, "failed to process connection notification")

failed to notify topology?


pkg/p2p/libp2p/libp2p.go, line 353 at r3 (raw file):

		s.logger.Debugf("stream handler: could not close stream %s: %v", overlay, err)
		s.logger.Errorf("stream handler: unable to handshake with peer %v", overlay)
		_ = s.Disconnect(overlay, "unable to handshake")

here maybe it would be good to disambiguate this error message from the line above, so maybe could not fully close stream on handshake


pkg/p2p/libp2p/libp2p.go, line 516 at r3 (raw file):

						logger.Errorf("unable to blocklist peer %v", peerID)
					}
					logger.Tracef("handler(%s): blocklisted %s reason %s", p.Name, overlay.String(), bpe.Error())

wherever we have "reason" maybe it would be nice to add a colon like, reason: %v


pkg/p2p/libp2p/libp2p.go, line 559 at r3 (raw file):

func (s *Service) Blocklist(overlay swarm.Address, duration time.Duration, reason string) error {
	s.logger.Tracef("libp2p blocklist: peer %s for %v reason %s", overlay.String(), duration, reason)

here too


pkg/p2p/libp2p/libp2p.go, line 562 at r3 (raw file):

	if err := s.blocklist.Add(overlay, duration); err != nil {
		s.metrics.BlocklistedPeerErrCount.Inc()
		_ = s.Disconnect(overlay, "blocklisting peer")

here it would be good to disambiguate the reason from the one below


pkg/p2p/libp2p/libp2p.go, line 655 at r3 (raw file):

	if exists := s.peers.addIfNotExists(stream.Conn(), overlay, i.FullNode); exists {
		if err := handshakeStream.FullClose(); err != nil {
			_ = s.Disconnect(overlay, "failed closing handshake")

here too


pkg/p2p/libp2p/libp2p.go, line 705 at r3 (raw file):

	s.metrics.DisconnectCount.Inc()

	s.logger.Debugf("libp2p disconnect: disconnecting peer %s reason %s", overlay, reason)

here also, would be good to have a colon

Copy link
Contributor Author

@aloknerurkar aloknerurkar left a comment

Choose a reason for hiding this comment

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

Dismissed @acud from 7 discussions.
Reviewable status: 11 of 13 files reviewed, all discussions resolved (waiting on @acud and @metacertain)


pkg/debugapi/peer.go, line 39 at r3 (raw file):

Previously, acud (acud) wrote…

failed to notify topology?

Done.


pkg/p2p/libp2p/libp2p.go, line 353 at r3 (raw file):

Previously, acud (acud) wrote…

here maybe it would be good to disambiguate this error message from the line above, so maybe could not fully close stream on handshake

Done.


pkg/p2p/libp2p/libp2p.go, line 516 at r3 (raw file):

Previously, acud (acud) wrote…

wherever we have "reason" maybe it would be nice to add a colon like, reason: %v

This is actually duplicate. I added this before we added the reason to the function call. Now we log it inside the Blocklist function call.


pkg/p2p/libp2p/libp2p.go, line 559 at r3 (raw file):

Previously, acud (acud) wrote…

here too

Done.


pkg/p2p/libp2p/libp2p.go, line 562 at r3 (raw file):

Previously, acud (acud) wrote…

here it would be good to disambiguate the reason from the one below

Done.


pkg/p2p/libp2p/libp2p.go, line 655 at r3 (raw file):

Previously, acud (acud) wrote…

here too

Done.


pkg/p2p/libp2p/libp2p.go, line 705 at r3 (raw file):

Previously, acud (acud) wrote…

here also, would be good to have a colon

Done.

@aloknerurkar aloknerurkar requested a review from acud September 8, 2021 09:39
Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

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

thank you 🙏

Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @metacertain)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 8, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@metacertain metacertain left a comment

Choose a reason for hiding this comment

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

Great!

@aloknerurkar aloknerurkar merged commit 048a4b3 into master Sep 8, 2021
@aloknerurkar aloknerurkar deleted the disconnect branch September 8, 2021 13:45
@acud acud added this to the v1.2.0 milestone Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull-request ready for review The PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants