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

server: fix inbound/outbound peer connection logic #1008

Merged
merged 2 commits into from Jun 7, 2018

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Apr 3, 2018

This PR attempts to fix a small bug where inbound peers were being tracked as outbound and outbound as inbound.

I went through the rest of the connection logic and our uses of inbound/outbound connections seem to be consistent with their respective meanings. Inbound connections should be connections initiated by the remote peer, while outbound connections should be initiated locally.

I believe the small patch below should be enough to remedy this issue, although I might have missed something.

Fixes #997.

@meshcollider meshcollider added the p2p Code related to the peer-to-peer behaviour label Apr 3, 2018
halseth
halseth previously approved these changes Apr 5, 2018
Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

utACK.

Know @cfromknecht had some insights into this.

@cfromknecht
Copy link
Contributor

cfromknecht commented Apr 6, 2018

cACK for now, gonna run this on testnet for a bit to make sure the issues from before don't resurface. My current reasoning that this wasn't working in the past because the persistent connection requests weren't being canceled, causing this to end up in a weird state or flap unnecessarily.

server.go Outdated
@@ -1368,7 +1369,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,

// We'll ensure that we locate the proper port to use within the peer's
// address for reconnecting purposes.
if tcpAddr, ok := addr.(*net.TCPAddr); ok && !inbound {
if tcpAddr, ok := addr.(*net.TCPAddr); ok && inbound {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rebased this to include a recent change that depends on the flipped behavior.

@cfromknecht
Copy link
Contributor

Aight, been seeing some errors that may be attributed to this issue, time to revive. Gonna some more testing with this on current master

@Roasbeef
Copy link
Member

Roasbeef commented Jun 6, 2018

Can you rebase this? Thanks!

In this commit, we address the meaning of the inbound parameter to
peerConnected. An inbound connection is defined as a connection
initiated by the peer, rather than ourselves.

We also update the inbound value for the peerConnected calls within
OutboundPeerConnected and InboundPeerConnected to reflect the definition
above.
This reverts commit 5126e43 since the
underlying issue has now been fixed.
@wpaulino
Copy link
Contributor Author

wpaulino commented Jun 7, 2018

Rebased.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🏄🏾

@Roasbeef Roasbeef merged commit 849ee5e into lightningnetwork:master Jun 7, 2018
@wpaulino wpaulino deleted the peer-connection-logic branch June 7, 2018 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2p Code related to the peer-to-peer behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inbound boolean still reversed
5 participants