Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

channel rebalancing support kind of exists already?

6 messages, Feb 6 to 8, 2018. Started by Robert Olsson.

Robert Olsson (2), Aleksej, ZmnSCPxj, Corné Plooy, Christian Decker

Permalink First message in the Wayback Machine

Robert Olsson permalink original

Hello

Let's say Bob opens a channel to Alice for 2BTC Carol then opens a channel to Bob for 2BTC. Alice and Carol are already connected to Others (and/or eachother even) The network and channel balances will look like this:

Alice 0--2 Bob 0--2 Carol
  |                   |
  +----- OTHERS ------+

Bob for some reason wants the channels to be balanced, so he has some better redundancy and it looks better.

So hypothetically Bob solves this by paying himself an invoice of 1BTC and making sure the route goes out thru Alice and comes back via Carol. Bob pays fees so he isn't ashamed if it disturbs the other balances in the network. Should he care?

Alice 1--1 Bob 1--1 Carol
  |                   |
  +----- OTHERS ------+

Now Bob has two nice balanced channels, meaning he has better connectivity in both directions.

Doesn't the protocol already support that kind of solutions, and all we need is a function in the CLI allowing Bob to pay to himself, and specify which two channels he would like to balance?

Maybe even make it automatically balance.

Is this a good idea of something to support, and/or Is there a risk the entire network will start doing this and it will start oscillating?

Best regards Robert Olsson

Aleksej in reply to Robert Olsson permalink original

Hi Yeah, you can always refund your channels thorugh other channels. I don't think however that it would be usually necessary to balance funds on the channel to be equal. I always assumed that a typical user would have perhaps one channel where he receives funds (employer) and others for spending (stores). In order to refund them, he would simply spend funds thorugh channels that are more unbalanced in direction where the user is "owned" coins. And of course, the other way around, employer would be able to pay the employee throgh channels he has with stores where he owns the money. In conclusion, I don't think rebalnacing would need to be a sperate transaction. This could simply be done automatically when the user sends or receives his usual transactions. I am not sure about all the diffuclties regarding routing in LN. Hopefully all of this can be done safely, reliably and quickly. Best regards, Aleksej On Tue, 2018-02-06 at 18:53 +0200, Robert Olsson wrote:

Quoted text (45 lines)
> Hello
>
> Let's say Bob opens a channel to Alice for 2BTC
> Carol then opens a channel to Bob for 2BTC.
> Alice and Carol are already connected to Others (and/or eachother
> even)
> The network and channel balances will look like this:
>
> Alice 0--2 Bob 0--2 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Bob for some reason wants the channels to be balanced, so he has some
> better redundancy and it looks better.
>
> So hypothetically Bob solves this by paying himself an invoice of
> 1BTC and making sure the route goes out thru Alice and comes back via
> Carol. Bob pays fees so he isn't ashamed if it disturbs the other
> balances in the network. Should he care?
>
> Alice 1--1 Bob 1--1 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Now Bob has two nice balanced channels, meaning he has better
> connectivity in both directions.
>
> Doesn't the protocol already support that kind of solutions, and all
> we need is a function in the CLI allowing Bob to pay to himself, and
> specify which two channels he would like to balance?
>
> Maybe even make it automatically balance.
>
> Is this a good idea of something to support, and/or Is there a risk
> the entire network will start doing this and it will start
> oscillating?
>
> Best regards
> Robert Olsson
>
>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Robert Olsson in reply to Aleksej permalink original

Hi Aleksej,

Yes i was talking about rebalancing without blockchains. and that there is a need for rebalancing, since things routed thru you can also affect balances an a surprising fashion. A function to avoid routing too much thru your channels would be nice too.

Consider a scenario where your employer opens a channel to you, and send your salary. You can then go shopping and use the channel via you employer, but after a while you want some more capacity, or less fees, or redundancy in case your employers node is offline. So you open a new one directly to walmart with a tx because you plan to go there after work, and go there often.

Now it turns out your employer also buys stuff from walmart, so they pay them via your channel to walmart and uses up most of it. So when you go to walmart to shop, you notice your brand new channel with them is already used up so you will have to route it back thru your employer, however they are of course currently doing maintenance on their node. Your redundancy is gone. And if they were up, your fee saving idea with a direct walmart channel would have been gone.

So, I think a function to "refuse routing over this channel if it would result in less than X% of capacity" and "automatically balance this channel to have at least X% of capacity" would be very useful features, and i think they don't have to be extremely hard to implement over current protocol.

Best regards Robert Olsson

On Tue, Feb 6, 2018 at 7:19 PM, Aleksej <aleksej at spidermail.tk> wrote:

Quoted text (74 lines)
> Hi
>
> Yeah, you can always refund your channels thorugh other channels.
> I don't think however that it would be usually necessary to balance funds
> on the channel to be equal.
> I always assumed that a typical user would have perhaps one channel where
> he receives funds (employer) and others for spending (stores).
> In order to refund them, he would simply spend funds thorugh channels that
> are more unbalanced in direction where the user is "owned" coins.
> And of course, the other way around, employer would be able to pay the
> employee throgh channels he has with stores where he owns the money.
>
> In conclusion, I don't think rebalnacing would need to be a sperate
> transaction.
> This could simply be done automatically when the user sends or receives
> his usual transactions.
> I am not sure about all the diffuclties regarding routing in LN. Hopefully
> all of this can be done safely, reliably and quickly.
>
> Best regards,
> Aleksej
>
> On Tue, 2018-02-06 at 18:53 +0200, Robert Olsson wrote:
>
> Hello
>
> Let's say Bob opens a channel to Alice for 2BTC
> Carol then opens a channel to Bob for 2BTC.
> Alice and Carol are already connected to Others (and/or eachother even)
> The network and channel balances will look like this:
>
> Alice 0--2 Bob 0--2 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Bob for some reason wants the channels to be balanced, so he has some
> better redundancy and it looks better.
>
> So hypothetically Bob solves this by paying himself an invoice of 1BTC and
> making sure the route goes out thru Alice and comes back via Carol. Bob
> pays fees so he isn't ashamed if it disturbs the other balances in the
> network. Should he care?
>
> Alice 1--1 Bob 1--1 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Now Bob has two nice balanced channels, meaning he has better connectivity
> in both directions.
>
> Doesn't the protocol already support that kind of solutions, and all we
> need is a function in the CLI allowing Bob to pay to himself, and specify
> which two channels he would like to balance?
>
> Maybe even make it automatically balance.
>
> Is this a good idea of something to support, and/or Is there a risk the
> entire network will start doing this and it will start oscillating?
>
> Best regards
> Robert Olsson
>
>
> _______________________________________________
> Lightning-dev mailing listLightning-dev at lists.linuxfoundation.orghttps://www.learnbitcoin.com/archive/lists/lightning-dev <http://qjx5.mjt.lu/lnk/AEAAScyO3BEAAAAAAAAAAAHPbO0AAABGqAQAAAAAAAotPgBaeeOYwazT33IGS4maS5AFYbV6vAAJw5s/1/vdYGhC4TVolRSbTpj5Km2A/aHR0cHM6Ly9saXN0cy5saW51eGZvdW5kYXRpb24ub3JnL21haWxtYW4vbGlzdGluZm8vbGlnaHRuaW5nLWRldg>
>
>
>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
>
ZmnSCPxj in reply to Robert Olsson permalink original

Good Morning Robert,

Yes, this already is possible, but is not implemented by any implementation to my knowledge at this point.

Note that "balance" is not necessarily a property you might desire for your channels. In your example, under the "unbalanced" case, Bob can pay a 1.5BTC invoice, but in the "balanced" case Bob can no longer pay that 1.5BTC invoice. Of course, once AMP is possible then this consideration is not an issue.

Regards, ZmnSCPxj

Sent with [ProtonMail](https://protonmail.com) Secure Email.

-------- Original Message -------- On February 7, 2018 12:53 AM, Robert Olsson <robban at robtex.com> wrote:

Quoted text (29 lines)
> Hello
>
> Let's say Bob opens a channel to Alice for 2BTC
> Carol then opens a channel to Bob for 2BTC.
> Alice and Carol are already connected to Others (and/or eachother even)
> The network and channel balances will look like this:
>
> Alice 0--2 Bob 0--2 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Bob for some reason wants the channels to be balanced, so he has some better redundancy and it looks better.
>
> So hypothetically Bob solves this by paying himself an invoice of 1BTC and making sure the route goes out thru Alice and comes back via Carol. Bob pays fees so he isn't ashamed if it disturbs the other balances in the network. Should he care?
>
> Alice 1--1 Bob 1--1 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Now Bob has two nice balanced channels, meaning he has better connectivity in both directions.
>
> Doesn't the protocol already support that kind of solutions, and all we need is a function in the CLI allowing Bob to pay to himself, and specify which two channels he would like to balance?
>
> Maybe even make it automatically balance.
>
> Is this a good idea of something to support, and/or Is there a risk the entire network will start doing this and it will start oscillating?
>
> Best regards
> Robert Olsson
Corné Plooy in reply to Robert Olsson permalink original

Hi,

Amiko Pay had this: on an invoice, you could (optionally) specify through which peer you wanted to be paid; on a payment, you could (optionally) specify through which peer you wanted to pay. In fact, if you didn't do this, a payment-to-self would not result in any channel actions, since the most efficient route to yourself makes zero hops. There was some weird edge case in this if you had a channel to yourself(*) and specified it in both the invoice and the payment: the route would actually be forced to go multiple times through the same channel.

Routing in Lightning is a bit different than in Amiko Pay, and I never attempted to adapt Amiko Pay to the Lightning protocol standard. I do think that Lightning offers *better* possibilities for channel re-balancing, since it offers source routing: the source can explicitly specify the entire route. If any channels offer negative fee rates to have them re-balanced, you might even make money by rebalancing other peoples' channels.

I'm not sure when channel re-balancing would be useful: if you are able to pay through the B-A-others-C-B route and through the B-C-anyone route, then certainly B-A-others-C-anyone would work as well?

Maybe to reduce risk that some channels on the 'others' path might be saturated at inconvenient moments? If Bob receives monthly salary from Alice and regularly wants to buy things from Carol, he'd probably want to transfer his funds from the A-B channel as soon as possible to the B-C channel. Alternatively, he could speculate on when fees on the OTHERS route would be optimal to make the transfer.

Another use case could be privacy protection: if Alice is an employer, she probably knows Bob's identity; Bob probably doesn't want her to know details about his spending behavior as well. Bob-Carol could be a pseudonymous contact on the TOR network. On receiving salary from Alice, Bob would immediately transfer it to the B-C link, and perform individual payments from there.

CJP

(*) not very useful in practice, but certainly useful for testing. Besides, *some* user is going to try that sooner or later, so you have to be robust against it.

Op 06-02-18 om 17:53 schreef Robert Olsson:

Quoted text (45 lines)
> Hello
>
> Let's say Bob opens a channel to Alice for 2BTC
> Carol then opens a channel to Bob for 2BTC.
> Alice and Carol are already connected to Others (and/or eachother even)
> The network and channel balances will look like this:
>
> Alice 0--2 Bob 0--2 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Bob for some reason wants the channels to be balanced, so he has some
> better redundancy and it looks better.
>
> So hypothetically Bob solves this by paying himself an invoice of 1BTC
> and making sure the route goes out thru Alice and comes back via
> Carol. Bob pays fees so he isn't ashamed if it disturbs the other
> balances in the network. Should he care?
>
> Alice 1--1 Bob 1--1 Carol
>   |                   |
>   +----- OTHERS ------+
>
> Now Bob has two nice balanced channels, meaning he has better
> connectivity in both directions.
>
> Doesn't the protocol already support that kind of solutions, and all
> we need is a function in the CLI allowing Bob to pay to himself, and
> specify which two channels he would like to balance?
>
> Maybe even make it automatically balance.
>
> Is this a good idea of something to support, and/or Is there a risk
> the entire network will start doing this and it will start oscillating?
>
> Best regards
> Robert Olsson
>
>
>
>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Christian Decker in reply to ZmnSCPxj permalink original

Technically you can do it with c-lightning today, if you create a circular route manually and then use the `sendpay` JSON-RPC command to send funds along that route it'll do just that. It's as simple as that.

We don't have built-in support yet, I don't know if we ever will, since it is trivially implemented outside of the daemon itself. I also don't think we need to consider this use-case at all from a protocol point of view.

Cheers, Christian

ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> writes:

Quoted text (47 lines)
> Good Morning Robert,
>
> Yes, this already is possible, but is not implemented by any implementation to my knowledge at this point.
>
> Note that "balance" is not necessarily a property you might desire for your channels.  In your example, under the "unbalanced" case, Bob can pay a 1.5BTC invoice, but in the "balanced" case Bob can no longer pay that 1.5BTC invoice.  Of course, once AMP is possible then this consideration is not an issue.
>
> Regards,
> ZmnSCPxj
>
> Sent with [ProtonMail](https://protonmail.com) Secure Email.
>
> -------- Original Message --------
> On February 7, 2018 12:53 AM, Robert Olsson <robban at robtex.com> wrote:
>
>> Hello
>>
>> Let's say Bob opens a channel to Alice for 2BTC
>> Carol then opens a channel to Bob for 2BTC.
>> Alice and Carol are already connected to Others (and/or eachother even)
>> The network and channel balances will look like this:
>>
>> Alice 0--2 Bob 0--2 Carol
>>   |                   |
>>   +----- OTHERS ------+
>>
>> Bob for some reason wants the channels to be balanced, so he has some better redundancy and it looks better.
>>
>> So hypothetically Bob solves this by paying himself an invoice of 1BTC and making sure the route goes out thru Alice and comes back via Carol. Bob pays fees so he isn't ashamed if it disturbs the other balances in the network. Should he care?
>>
>> Alice 1--1 Bob 1--1 Carol
>>   |                   |
>>   +----- OTHERS ------+
>>
>> Now Bob has two nice balanced channels, meaning he has better connectivity in both directions.
>>
>> Doesn't the protocol already support that kind of solutions, and all we need is a function in the CLI allowing Bob to pay to himself, and specify which two channels he would like to balance?
>>
>> Maybe even make it automatically balance.
>>
>> Is this a good idea of something to support, and/or Is there a risk the entire network will start doing this and it will start oscillating?
>>
>> Best regards
>> Robert Olsson
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev