Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Insufficient funder balance for paying fees

3 messages, Jan 12, 2018. Started by Johan Torås Halseth.

Johan Torås Halseth (2), Pierre

Permalink First message in the Wayback Machine

Johan Torås Halseth permalink original

Hi all, I am wondering how Eclair and c-lightning is handling the following case, as I wasn’t able to derive exactly how to handle it from the BOLTs. If it is described somewhere, please point me to it, if not, let’s agree on a strategy, and get it in :) Let's say Alice is the funder of the channel (meaning she is paying all fees) between Alice and Bob. She wants to add an HTLC, and has just enough balance available for the HTLC + the extra fee for adding it to the commitment transaction. At the same time Bob wants to add an HTLC, and sees that Alice has enough balance to be able to pay the fee for receiving this HTLC (add it to her commitment tx). They both send the AddHTLC at the same time, thinking Alice has enough balance available, but she doesn't have enough to cover her own HTLC+fee, in addition to the fee for adding Bob's. Adding both the HTLCs to her commitment transaction will either 1) violate the channel reserve requirement, or 2) deplete her channel completely if the channel reserve is set to 0. What is the expected way of handling this case, from both Alice and Bob’s point of view? Cheers, Johan

Pierre in reply to Johan Torås Halseth permalink original

Hi Johan,

That's an interesting corner case. I think it shares some similarities with the race condition described in BOLT 2 [1], which handling is specified in BOLT 3 [2].

Note that what matters really is the timing of the `commit_sig`/`revoke_and_ack` messages, not the `update_add_htlc`s, because of the acknowledgment logic that excludes remote's unsigned updates. A side effect is that there can be multiple HTLCs on each side.

Each party will end up receiving a commitment tx which has insufficient (possibly zero) fees. At that point according to [2] it may decide to fail the channel, using its previous commitment (which it hasn't yet revoked). Currently eclair won't fail the channel, but I think we probably should, especially if we are the fundee and would end up with all funds in an unpublishable tx. The funder could face the same situation if the pending htlcs have a high value (at this point its main output is zero anyway).

An appropriate choice of channel parameters (`mainly max_htlc_value_in_flight_msat`, `channel_reserve_satoshis`, `max_accepted_htlcs`) could probably reduce the probability of this happening.

Hope that helps,

Pierre

[1] https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#updating-fees-update_fee
[2] https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#fee-payment
Johan Torås Halseth in reply to Pierre permalink original

Hi Pierre, You’re right, that looks very much like the same kind of situation! I agree, it looks from [2] that a node may fail the channel in this case, and that it probably should to not risk end up with all funds in an unpublishable tx. Seems like something that could be used as a DOS attack vector by a malicious counter party otherwise.

Relevant to this: We use a node’s resulting output (that is, after subtracting fees) when checking that the channel_reserve is met. In these cases we can therefore end up violating the reserve, even though none of the nodes are actually violating the protocol. When this happens we don’t really end up with an unpublishable tx, as the fees are still high enough, and I guess each node can choose what to do. I think we will just fail the channel to not have to deal with this as a special case. Anyway, I think these are cases that are not very likely to occur, especially with the right choice of parameters as you mention. And because of this it might be less error-prone to just fail the channel instead of trying to recover from it. Thanks! - Johan On Fri, Jan 12, 2018 at 12:56, Pierre <pm+lists at acinq.fr> wrote: Hi Johan,

That's an interesting corner case. I think it shares some similarities with the race condition described in BOLT 2 [1], which handling is specified in BOLT 3 [2].

Note that what matters really is the timing of the `commit_sig`/`revoke_and_ack` messages, not the `update_add_htlc`s, because of the acknowledgment logic that excludes remote's unsigned updates. A side effect is that there can be multiple HTLCs on each side.

Each party will end up receiving a commitment tx which has insufficient (possibly zero) fees. At that point according to [2] it may decide to fail the channel, using its previous commitment (which it hasn't yet revoked). Currently eclair won't fail the channel, but I think we probably should, especially if we are the fundee and would end up with all funds in an unpublishable tx. The funder could face the same situation if the pending htlcs have a high value (at this point its main output is zero anyway).

An appropriate choice of channel parameters (`mainly max_htlc_value_in_flight_msat`, `channel_reserve_satoshis`, `max_accepted_htlcs`) could probably reduce the probability of this happening.

Hope that helps,

Pierre

[1] https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#updating-fees-update_fee
[2] https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#fee-payment