Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Fee structure

8 messages, Mar 13 to 14, 2019. Started by John-John Markstedt.

John-John Markstedt (4), ZmnSCPxj (3), Andrea RASPITZU

Permalink First message in the Wayback Machine

John-John Markstedt permalink original

I’ve been thinking about the current fee structure I believe it may be problematic as there is no inherent way to incentive balanced channels.

This may be a bit far down the road as there are more direct problems that need to be addressed first. However if you all believe there might be some merit in this line of thinking I can spend some more time formalizing a more proper implementable proposal and run some simulations to verify it’s impact on throughput and robustness.

Although there are methods to balance channels it would be beneficial if the fee could reflect the state in which the channel is left.

Currently the fee is only proportional to the liquidity used, not the state of the channel.

Suppose there exists a channel between Alice and Bob with 10 million satoshis in it. Two payments, [image: P_{1}] and [image: P_{2}] are routed through the channel from Bob to Alice. Both use the same amount of liquidity, 3,500,000 satoshis each, but they start from two different initial states [image: B_{1}] and [image: B_3].

[image: protocol_upgrade.png]

The two payments would incur the same fee,

[image: F_{P_1 P_2} = F_B + (3,500,000 * F_R / 1,000,000)]

but leave the channels in completely different states.[image: P_1] at [image: B_2] and [image: P_2] at [image: B_4]. It is of course possible to reset the channel price after [image: P_1] to be more expensive, but suppose a third larger payment [image: P_3] going from [image: B_1] to [image: B_4] would still run into this problem.

It is possible to limit the maximum allowed payment, to say 1/5 of the total channel capacity, so a fee could be broadcast between payments. However that would reduce possible transacting parties in the network, limiting connectivity.

If the price structure was a scheme of brackets instead, where the cost depend on the channel position, these issues may be resolved. Each satoshi in the channel may be seen as a different bracket, with a different price for each satoshi moved. The channels would then broadcast a cost function instead of the fixed fee.

[image: fee_scheme.png]

Quoted text (1 line)
>From the cost function the fee may be retrieved by calculating the area

under the graphs. Some deterministic way to round the fee to whole satoshis and some way to verify the function is formulated correctly must be defined.

The fees for [image: P_1], [image: P_2] would be very different with this brackets method.

[image: F_{P_1} = F_{B} + \int_{B_1}^{B_2} f(x) dx = F_B + 13,502,153,930 \mu S]

[image: F_{P_2} = F_{B} + \int_{B_3}^{B_4} f(x) dx = F_B + 88,984,850,361 \mu S]

Here the fees are much larger for the payment that unbalances the channel than the payment that balances it.

Brackets would incentivize payments to route in such a way to keep channels balanced which may lead to higher throughput.

This method clearly has some headaches accompanying it. It may be unnecessarily complex and would requires deterministic ways to calculate integrals over multiple systems. There might be better ways to solve this problem and there might be problems with this approach I’m unaware of. Anyway, some small tweaks in the protocol may lead to a much healthier network which may be worthy of exploration.

Best regards, John-John Markstedt

Andrea RASPITZU in reply to John-John Markstedt permalink original

Good morning John-John,

The current version of the spec uses source routing and that requires the sending node to attach the fees to the payment when is sent out, if the onion carries the wrong amount of fees for a channel the intermediate node should reply with a channel_update message containing the actual fees. It seems to me that you are binding the fees of a channel to its actual state but that would require to re-broadcast a channel_update for every payment that traverse the channel, so in short for every payment there would be an update being gossiped on the network and that's unpractical.

Cheers, Andrea.

Le mer. 13 mars 2019 à 15:55, John-John Markstedt <john-john at markstedts.org> a écrit :

Quoted text (96 lines)
> I’ve been thinking about the current fee structure I believe it may be
> problematic
> as there is no inherent way to incentive balanced channels.
>
> This may be a bit far down the road as there are more direct problems
> that need to be addressed first. However if you all believe there might be
> some
> merit in this line of thinking I can spend some more time formalizing a
> more proper
> implementable proposal and run some simulations to verify it’s impact on
> throughput
> and robustness.
>
> Although there are methods to balance channels it would be beneficial if
> the
> fee could reflect the state in which the channel is left.
>
> Currently the fee is only proportional to the liquidity used, not the
> state of the channel.
>
> Suppose there exists a channel between Alice and Bob with 10 million
> satoshis in it.
> Two payments, [image: P_{1}] and [image: P_{2}] are routed through the
> channel from Bob to Alice.
> Both use the same amount of liquidity, 3,500,000 satoshis each, but they
> start from
> two different initial states [image: B_{1}] and [image: B_3].
>
> [image: protocol_upgrade.png]
>
> The two payments would incur the same fee,
>
> [image: F_{P_1 P_2} = F_B + (3,500,000 * F_R / 1,000,000)]
>
> but leave the channels in completely different states.[image: P_1] at [image:
> B_2] and [image: P_2] at [image: B_4].
> It is of course possible to reset the channel price after [image: P_1] to
> be more expensive,
> but suppose a third larger payment [image: P_3] going from [image: B_1]
> to [image: B_4] would still run
> into this problem.
>
> It is possible to limit the maximum allowed payment, to say 1/5 of the
> total channel
> capacity, so a fee could be broadcast between payments. However
> that would reduce possible transacting parties in the network, limiting
> connectivity.
>
> If the price structure was a scheme of brackets instead, where the cost
> depend on the channel position, these issues may be resolved.
> Each satoshi in the channel may be seen as a different bracket, with a
> different price for each
> satoshi moved. The channels would then broadcast a cost function instead
> of the fixed fee.
>
> [image: fee_scheme.png]
>
> From the cost function the fee may be retrieved by calculating the area
> under the graphs.
> Some deterministic way to round the fee to whole satoshis and some way to
> verify the
> function is formulated correctly must be defined.
>
> The fees for [image: P_1], [image: P_2] would be very different with this
> brackets method.
>
> [image: F_{P_1} = F_{B} + \int_{B_1}^{B_2} f(x) dx = F_B + 13,502,153,930
> \mu S]
>
> [image: F_{P_2} = F_{B} + \int_{B_3}^{B_4} f(x) dx = F_B + 88,984,850,361
> \mu S]
>
> Here the fees are much larger for the payment that unbalances the channel
> than the
> payment that balances it.
>
> Brackets would incentivize payments to route in such a way to keep channels
> balanced which may lead to higher throughput.
>
> This method clearly has some headaches accompanying it. It may be
> unnecessarily complex and
> would requires deterministic ways to calculate integrals over multiple
> systems. There might be better
> ways to solve this problem and there might be problems with this approach
> I’m unaware of.
> Anyway, some small tweaks in the protocol may lead to a much healthier
> network which
> may be worthy of exploration.
>
> Best regards,
> John-John Markstedt
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
>
ZmnSCPxj in reply to Andrea RASPITZU permalink original

Good morning John-John and Andrea,

Quoted text (2 lines)
>
> The current version of the spec uses source routing and that requires the sending node to attach the fees to the payment when is sent out, if the onion carries the wrong amount of fees for a channel the intermediate node should reply with a channel_update message containing the actual fees. It seems to me that you are binding the fees of a channel to its actual state but that would require to re-broadcast a channel_update for every payment that traverse the channel, so in short for every payment there would be an update being gossiped on the network and that's unpractical.

This is also very leaky. Monitors can use the timing of `channel_update` to guess the source and destination of every payment.

If a node wishes to maintain balance on its own channels, it can simply scale its feerate depending on the channel state. If it is already very unbalanced away from the node (the node owns less than half the capacity), then it increases the feerate. If it is already very unbalanced towards the node, then it decreases the feerate.

This is already possible within the protocol. Care must be taken that `channel_update` is not spammed, which potentially leaks information about payments passing through the node. A simple heuristic would be to have a random schedule of checking the channel current state, sending a `channel_update` if the feerate should be changed, then sleeping for a random number of seconds before checking again. This will get you reasonably close to what you want, without too much leakage of payments going through you.

John-John Markstedt in reply to ZmnSCPxj permalink original

Good morning Andrea and ZmnSCPxj,

I wrongly assumed the channel balances needed to be known anyway to create a route. I see now why that is not the case and why it would scale horribly, in fact it scales no better than layer 1 as everyone needs to be notified of every payment. It would also defeat effort of keeping payments private. This is clearly the wrong line of thinking.

Quoted text (9 lines)
This is already possible within the protocol.
> Care must be taken that `channel_update` is not spammed, which potentially
> leaks information about payments passing through the node.
> A simple heuristic would be to have a random schedule of checking the
> channel current state, sending a `channel_update` if the feerate should be
> changed, then sleeping for a random number of seconds before checking again.
> This will get you reasonably close to what you want, without too much
> leakage of payments going through you.
>

That would not regard the size of the payments though? A payment leaving the balance at the far end would pay the same proportional fee as one close to the middle. Again fixing that issue by broadcasting each balance change wouldn't scale well and run in the aforementioned leakage so is really a moot point.

I don't see setting the fee only regarding the initial state as obviously beneficial to a routing node, anyway it would indeed be interesting to see if a node utilizing such a strategy, all else being equal, would outperform a node not using it. I will implement something along this line and see it that's the case or not.

JIT Routing from rpickhardt is more sensible as it attempts to rebalance

Quoted text (3 lines)
> only if it would benefit the node to perform the rebalancing.
> (It is more accurately named "JIT rebalancing" actually)
>

I will have another closer look at the JIT Routing emails.

-

Thanks both of you for taking the time to respond and pointing out the clear flaws in this idea.

Best regards, John-John Markstedt

ZmnSCPxj in reply to John-John Markstedt permalink original

Good morning John-John,

Quoted text (1 line)
> That would not regard the size of the payments though? A payment leaving the balance at the far end would pay the same proportional fee as one close to the middle.

"Proportional" means the fee paid is greater if the payment being forwarded is greater. That is what "proportional" means.

Assuming your current balance on the channel is "perfect", in order for a payment passing through you to massively upset that balance, that payment must be large in value relative to the channel capacity.

And the proportional fee is larger if the payment is larger.

So it *perfectly* regards the size of the payments.

Regards, ZmnSCPxj

John-John Markstedt in reply to ZmnSCPxj permalink original
Quoted text (8 lines)
> > That would not regard the size of the payments though? A payment leaving
> the balance at the far end would pay the same proportional fee as one close
> to the middle.
>
> "Proportional" means the fee paid is greater if the payment being
> forwarded is greater.
> That is what "proportional" means.
>

My initial point was that the fee would be proportionally higher for every satoshi used closer to the far end of the channel. So the fee would proportional to the state of the channel in addition to the size of the payment.

Best regards, John-John Markstedt

ZmnSCPxj in reply to John-John Markstedt permalink original

Good morning John-John,

Quoted text (7 lines)
> > > That would not regard the size of the payments though? A payment leaving the balance at the far end would pay the same proportional fee as one close to the middle.
> >
> > "Proportional" means the fee paid is greater if the payment being forwarded is greater.
> > That is what "proportional" means.
>
> My initial point was that the fee would be proportionally higher for every satoshi used closer to the far end of the channel.
> So the fee would proportional to the state of the channel in addition to the size of the payment.

But the final state of the channel has a subtractive relationship from the payment size. So I fear we have largely fallen into an argument on exact semantics and mathematical models that may not be particularly relevant to pragmatic use of LN.

The "standard" solution to balance concerns and manipulations of fee structure has, I think, been "just make the proportional feerate itself proportional to how much the other side owns on the channel". Regardless of whatever mathematical model you use, in the long run this will achieve your goal of a balanced channel anyway, whatever inaccuracy it may have in the short term.

Again, JIT Routing is superior to this anyway, as you have direct evidence that rebalancing would be beneficial to you under the current network conditions. Balance is not always beneficial: consider a balanced channel containing 0.75 mBTC on both sides, that cannot serve a forwarding request for 1.0 mBTC in either direction. JIT Routing handles that case by simply transferring at least 0.25mBTC from some other channel, then serving the forwarding request.

Regards, ZmnSCPxj

John-John Markstedt in reply to ZmnSCPxj permalink original

God afternoon ZmnSCPxj,

Sorry if I was being a bit pedantic,

I just want to be clear that I agree with both yours and Andrea's arguments in the initial responses and I see now why the idea doesn't make much sense at all in terms of scale and privacy.

Quoted text (1 line)
> > My initial point was that the fee would be proportionally higher for

every satoshi used closer to the far end of the channel.

Quoted text (1 line)
> > So the fee would proportional to the state of the channel in addition

to the size of the payment.

Quoted text (7 lines)
>

> But the final state of the channel has a subtractive relationship from the
> payment size.
> So I fear we have largely fallen into an argument on exact semantics and
> mathematical models that may not be particularly relevant to pragmatic use
> of LN.
>

I'm not trying to argue here as I agree with you it's not practical, I just wanted to clarify as we seemed to be talking passed each other on that particular point.

Best regards John-John Markstedt