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

fix(libp2p,kademlia): fixes discrepency - kademlia and libp2p peers list #1696

Merged
merged 1 commit into from
May 14, 2021

Conversation

istae
Copy link
Member

@istae istae commented May 12, 2021

Added extra checks in libp2p after connect calls to kademlia. This prevents peers that disconnect in the background while the stream handle is ongoing, from remining in the kademlia list


This change is Reviewable

@istae istae changed the title fix(libp2p,kademlia): fixes discrepency between kademlia and libp2p peers list fix(libp2p,kademlia): fixes discrepency - kademlia and libp2p peers list May 12, 2021
@istae istae force-pushed the discrep-rebase branch 2 times, most recently from ac87b03 to 06a8c00 Compare May 12, 2021 14:52
if s.notifier != nil {
s.notifier.Disconnected(peer)
}
if s.lightNodes != nil {
s.lightNodes.Disconnected(peer)
}

if !found {
s.logger.Debugf("libp2p disconnect: peer %s not founds", overlay)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be in singular (found)?

Copy link
Contributor

@mrekucci mrekucci left a comment

Choose a reason for hiding this comment

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

Except the typo :lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @acud, @aloknerurkar, and @esadakar)

@acud acud requested a review from janos May 13, 2021 14:44
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.

Reviewed 1 of 2 files at r1.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @aloknerurkar, @esadakar, and @janos)


pkg/p2p/libp2p/libp2p.go, line 267 at r1 (raw file):

		overlay := i.BzzAddress.Overlay

		if s.notifier == nil {

i think this can be removed. notifier is never nil while the node is running


pkg/p2p/libp2p/libp2p.go, line 363 at r1 (raw file):

		s.metrics.HandledStreamCount.Inc()
		if !s.peers.Exists(overlay) {
			s.logger.Debugf("libp2p: inbound peer %s does not exist, disconnecting", overlay)

isn't the prefix here supposed to be stream handler?


pkg/p2p/libp2p/libp2p.go, line 368 at r1 (raw file):

		}

		s.logger.Debugf("successfully connected to peer %s%s (inbound)", i.BzzAddress.ShortString(), i.LightString())

i would add the same prefix to these messages here too and double check all log lines printed in this function have it too


pkg/p2p/libp2p/libp2p.go, line 602 at r1 (raw file):

				_ = s.Disconnect(overlay)
				s.protocolsmu.RUnlock()
				return nil, fmt.Errorf("connectOut: protocol %w", err)

consider: adding information about which protocol failed. the error is wrapped but the protocol in the message doesn't really say anything. more information will be availble from tn


pkg/p2p/libp2p/libp2p.go, line 609 at r1 (raw file):

	if !s.peers.Exists(overlay) {
		s.logger.Debugf("libp2p Connect: peer %s does not exist, disconnecting", overlay)

it is not necessary to log and return an error. you can decorate the returned error with more information when necessary and the calling context will log is as necessary

@istae istae force-pushed the discrep-rebase branch from 06a8c00 to 2eccb2d Compare May 14, 2021 07:56
Copy link
Member Author

@istae istae left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @acud, @aloknerurkar, @anatollupacescu, @esadakar, and @janos)


pkg/p2p/libp2p/libp2p.go, line 363 at r1 (raw file):

Previously, acud (acud) wrote…

isn't the prefix here supposed to be stream handler?

Done.


pkg/p2p/libp2p/libp2p.go, line 368 at r1 (raw file):

Previously, acud (acud) wrote…

i would add the same prefix to these messages here too and double check all log lines printed in this function have it too

Done.


pkg/p2p/libp2p/libp2p.go, line 602 at r1 (raw file):

Previously, acud (acud) wrote…

consider: adding information about which protocol failed. the error is wrapped but the protocol in the message doesn't really say anything. more information will be availble from tn

Done.


pkg/p2p/libp2p/libp2p.go, line 609 at r1 (raw file):

s.logger.Debugf("libp2p Connect: peer %s does not exist

pkg/p2p/libp2p/libp2p.go, line 609 at r1 (raw file):

Previously, acud (acud) wrote…

it is not necessary to log and return an error. you can decorate the returned error with more information when necessary and the calling context will log is as necessary

Done.


pkg/p2p/libp2p/libp2p.go, line 650 at r1 (raw file):

Previously, anatollupacescu (Anatolie Lupacescu) wrote…

should this be in singular (found)?

Done.

Copy link
Member Author

@istae istae left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 2 files reviewed, 7 unresolved discussions (waiting on @acud, @aloknerurkar, @anatollupacescu, @janos, and @mrekucci)


pkg/p2p/libp2p/libp2p.go, line 267 at r1 (raw file):

Previously, acud (acud) wrote…

i think this can be removed. notifier is never nil while the node is running

Done.

@istae istae requested a review from acud May 14, 2021 07:58
@istae istae added the ready for review The PR is ready to be reviewed label May 14, 2021
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.

Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aloknerurkar, @anatollupacescu, @esadakar, and @janos)

@istae istae force-pushed the discrep-rebase branch from 2eccb2d to 4b5e043 Compare May 14, 2021 12:07
@istae istae merged commit 5bf7137 into master May 14, 2021
@istae istae deleted the discrep-rebase branch May 14, 2021 12:26
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.

4 participants