lightning-terminal icon indicating copy to clipboard operation
lightning-terminal copied to clipboard

Lightning terminal color categorization of quality of channels

Open darioAnongba opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. I guess this is a feature request (a change) but also a question on whether or not this feature request makes sense to you (from a mathematical standpoint).

The lightning terminal has 3 channel balance modes: Sending, Receiving and Routing. Depending on these channel modes, the "health" of a channel differs, which is represented with the colors red, green and yellow in the Dashboard. For the Routing mode specifically, the computation of this health seems impossible to achieve per channel. Because a routing node needs more knowledge of the network to be able to infer if his channels are healthy.

Describe the solution you'd like Currently, the channel will be red if all the liquidity is outbound or inbound and will be green if the liquidity is well balanced. But if we imagine a node with (for example) 4 channels with peers that are of different types:

  • Peer1 is an exchange and needs a lot of outbound liquidity to be able to send transactions. Peer 1 is in Sending mode
  • Peer2 is a merchant that needs a lot of inbound liquidity to be able to receive payments. Peer 2 is in Receiving mode
  • Peer3 is a routing node that needs a balanced inboud and outbound liquidity. Peer 3 is in Routing mode
  • Peer4 is like peer 1.

In this case, it is better to have a channel with a lot of inbound liquidity with peer1 and peer4, outbound liquidity for peer 2, balanced with peer3. Here the optimal liquidity distribution is 2/3 inboud 1/3 outbound.

Because of this, I believe that it is only possible to give a global state of health of the node channels. A channel with 90% inbound liquidity with a merchant seems fine but will be red in the terminal.

Describe alternatives you've considered Maybe my analysis is not correct and always having a liquidity of 50/50 is somehow always optimal for routing nodes.

Additional context This also seems important for the BOS score. The question is, is a routing node considered better if he has a well balanced set of channels or if all his channels are balanced (individually). That's a pretty big difference because ideally the network should be composed of many merchants needing channels with inbound liquidity that could be bought on Pool.

darioAnongba avatar May 06 '21 18:05 darioAnongba

@darioAnongba this is a great suggestion. You are 100% correct. For routing nodes, a 50/50 balance on all channels is not always the optimal strategy. You really do need to analyze how payments are flowing through your node and into each peer individually. As you stated, the ideal balance will likely be different for each channel. We had this discussion internally and decided to keep the UI simple initially, but we agree with your analysis.

A likely solution to handle this would be to specify a balance mode for each channel. This obviously requires much more effort from the user to specify this, but produces more accurate balance coloring.

Thanks for the thoughtful feedback. 🥇

jamaljsr avatar May 07 '21 00:05 jamaljsr

Hi @jamaljsr, thanks for your reply.

Now the question is whether or not we (as a routing node operator) should optimize the channels to be individually balanced or should we have the channels globally balanced? Ideally they should be globally balanced but I want to make sure the BOS score is not doing the same as the Lightning terminal interface.

I'm asking this because I used Loop (via lightning terminal letting the tool optimize the channel balances automatically) to balance my channels and it ended up doing what I expected, which is balancing channels with mainly everything outbound or inbound depending of the peer. This seems correct to me and I would like to keep it like that instead of doing a circular re-balance to balance the channels.

darioAnongba avatar May 07 '21 10:05 darioAnongba

I would lean more towards optimizing channels individually since what you are optimizing for is payment flow.

Regarding Loop, it does not attempt to balance any channels. If you do not manually select any channels, it will just use LND's channel selection which is used for normal payments. If the outcome was what you desired, it was likely a coincidence.

jamaljsr avatar May 07 '21 20:05 jamaljsr