From d0b405fa62c14842c9f19a454af24b960dfb31d0 Mon Sep 17 00:00:00 2001 From: pm47 Date: Wed, 30 Sep 2020 15:32:09 +0200 Subject: [PATCH] special connection handling on phoenix We always automatically reconnect, whether or not there are existing channels. Manual connection requests are ignored. --- .../fr/acinq/eclair/io/ReconnectionTask.scala | 21 ++++++++++--------- .../scala/fr/acinq/eclair/io/PeerSpec.scala | 4 ++-- .../eclair/io/ReconnectionTaskSpec.scala | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala b/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala index 81e09644f..f5b5f842e 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/io/ReconnectionTask.scala @@ -80,7 +80,7 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends when(IDLE) { case Event(Peer.Transition(previousPeerData, nextPeerData: Peer.DisconnectedData), d: IdleData) => - if (nodeParams.autoReconnect && nextPeerData.channels.nonEmpty) { // we only reconnect if there are existing channels + if (nodeParams.autoReconnect /*&& nextPeerData.channels.nonEmpty*/) { // On Phoenix we always reconnect val (initialDelay, firstNextReconnectionDelay) = (previousPeerData, d.previousData) match { case (Peer.Nothing, _) => // When restarting, we add some randomization before the first reconnection attempt to avoid herd effect @@ -126,15 +126,16 @@ class ReconnectionTask(nodeParams: NodeParams, remoteNodeId: PublicKey) extends case Event(TickReconnect, _) => stay case Event(Peer.Connect(_, hostAndPort_opt), _) => - // manual connection requests happen completely independently of the automated reconnection process; - // we initiate a connection but don't modify our state. - // if we are already connecting/connected, the peer will kill any duplicate connections - hostAndPort_opt - .map(hostAndPort2InetSocketAddress) - .orElse(getPeerAddressFromDb(nodeParams.db.peers, nodeParams.db.network, remoteNodeId)) match { - case Some(address) => connect(address, origin = sender) - case None => sender ! PeerConnection.ConnectionResult.NoAddressFound - } + // On Phoenix we ignore manual reconnection attempts, everything is always handled by the auto-reconnection loop +// // manual connection requests happen completely independently of the automated reconnection process; +// // we initiate a connection but don't modify our state. +// // if we are already connecting/connected, the peer will kill any duplicate connections +// hostAndPort_opt +// .map(hostAndPort2InetSocketAddress) +// .orElse(getPeerAddressFromDb(nodeParams.db.peers, nodeParams.db.network, remoteNodeId)) match { +// case Some(address) => connect(address, origin = sender) +// case None => sender ! PeerConnection.ConnectionResult.NoAddressFound +// } stay } diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala index c7f745210..15cff26ec 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/PeerSpec.scala @@ -90,7 +90,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with StateTe probe.expectMsg(PeerInfo(remoteNodeId, "CONNECTED", Some(fakeIPAddress.socketAddress), 1)) } - test("fail to connect if no address provided or found") { f => + ignore("fail to connect if no address provided or found") { f => import f._ val probe = TestProbe() @@ -99,7 +99,7 @@ class PeerSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with StateTe probe.expectMsg(PeerConnection.ConnectionResult.NoAddressFound) } - test("successfully connect to peer at user request") { f => + ignore("successfully connect to peer at user request") { f => import f._ // this actor listens to connection requests and creates connections diff --git a/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala b/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala index 8291c8aa7..632e9cab6 100644 --- a/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala +++ b/eclair-core/src/test/scala/fr/acinq/eclair/io/ReconnectionTaskSpec.scala @@ -77,7 +77,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike monitor.expectNoMsg() } - test("stay idle at startup if there are no channels", Tag("auto_reconnect"), Tag("with_node_announcements")) { f => + ignore("stay idle at startup if there are no channels", Tag("auto_reconnect"), Tag("with_node_announcements")) { f => import f._ val peer = TestProbe() @@ -158,7 +158,7 @@ class ReconnectionTaskSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike assert(waitingData3.nextReconnectionDelay === (waitingData0.nextReconnectionDelay * 8)) } - test("reconnect using the address from node_announcement") { f => + ignore("reconnect using the address from node_announcement") { f => import f._ // we create a dummy tcp server and update bob's announcement to point to it