L2-Technology / sensei

A lightning node implementation for everyone
https://l2.technology/sensei
Other
199 stars 39 forks source link

Do reconnections happen? #113

Closed TonyGiorgio closed 2 years ago

TonyGiorgio commented 2 years ago

Curious about reconnections and whether they happen or if I need to do something to make them happen. I'm using senseicore as a library and once a disconnection happened, there does not seem to be any attempt to make connection happen again.

2022-08-25 00:00:01 TRACE [lightning::ln::peer_handler:1688] Handling disconnection of peer {pubkey}, with future connection to the peer possible.

That's the last log I see. I have tried restarting and bringing the nodes up again, but the other node (LND) still does not show it as active.

I see this but I wonder how reconnection should work or if there's some issue on my end: https://github.com/L2-Technology/sensei/blob/4a45ecc96a79c8fc9126d78154bbbc88aa1a1d68/senseicore/src/node.rs#L854

johncantrell97 commented 2 years ago

hm it should be reconnecting but I've never really tested it.

https://github.com/L2-Technology/sensei/blob/main/senseicore/src/p2p/peer_connector.rs#L278

this runs every 5 seconds and loops over every running node.

for each node it loops over each channel it has for each channel it checks if it's usable (will be unusable if peer is disconnected) and if the peer manager is currently connected to the peer. if it's not usable and we are not connected to them then it tries to get known addresses for the peer and then tries to connect over each one.

so I guess add some logging in there and see which part is failing.

Make sure it's showing up in the list of channels, that the channel is unusable, that the peer manager thinks its not already connected, and that we have addresses for them.

interested to hear what's going on.

TonyGiorgio commented 2 years ago

There's one log that recently started showing up that has me interested in why, maybe this has something to do with it?

Db(Query("error returned from database: no such table: peer_address"))                                                                                                    
EVENT: initiated channel with peer 03a21ed10769e4ba7f614043d5eb4d2f1acb2b7032f1a9dedbccd38f6352668ce5.                                                                    

But beyond that, I'm curious how migrations work and how I should be triggering them? Maybe something was added in a recent update that's not working because of migrations not running in the way I have senseicore imported?

TonyGiorgio commented 2 years ago

Okay turns out I was pulling in the migrations manually and that's one of the things I needed to do with the new ones: https://github.com/BitcoinDevShop/pln/pull/71

I think I'll try to pull them directly from sensei at some point soon but that seemed to do the trick. The next channel I opened with the same peer added to the peer_address table, so I copied the row and made a few adjustments for my existing channels and as soon as I added the row, it got reconnected again. Thanks for the help!