ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.83k stars 897 forks source link

Why is peer disconnected after closing channel? #3455

Open s-tikhomirov opened 4 years ago

s-tikhomirov commented 4 years ago

Issue and Steps to Reproduce

I have two nodes A and B in a local testnet-based setup. I opened a channel from B to A and then closed it. The close was mutual. Then I found that the P2P connection had been dropped.

Is this an intended behavior? If so, why drop the connection after a channel closure? Nobody misbehaved in this situation.

getinfo output

{
   "id": "02f67d5b7185ac67172807fc8f9d6b000305e93793332ed5a2087478a69909371e",
   "alias": "clightningB",
   "color": "02f67d",
   "num_peers": 3,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 2,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 9740
      }
   ],
   "version": "v0.8.0-40-g899f5de",
   "blockheight": 1664151,
   "network": "testnet",
   "msatoshi_fees_collected": 0,
   "fees_collected_msat": "0msat",
   "lightning-dir": "/home/sergei/.lightningB/testnet"
}
ZmnSCPxj commented 4 years ago

I question that myself. I suppose this is just us being over-parsimonious of resources: an open connection is something that consumes resources on the OS side as well as in C-Lightning, and disconnecting as soon as we close a channel is not prohibited by the BOLT spec anyway, so we disconnect to free up resources ASAP.

Note that fundchannel will now automatically connect to a node.if not already connected (though some of our docs still claim it needs to be connected first before fundchannel, it is no longer true and we should probably go fix the docs), so this tends to be benign when looking at it from a high-enough level: if all you care about is making channels to the network graph, you just fundchannel and close and we automatically connect / disconnect.