Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Towards a Market for Liquidity Providers -- Enforcing Minimum Channel Lifetime

4 messages, Nov 10 to 12, 2018. Started by ZmnSCPxj.

ZmnSCPxj (3), Pierre

Permalink First message in the Wayback Machine

ZmnSCPxj permalink original

Good morning list,

Introduction ============

This thread, effectively continues the discussion, regarding dual-funding and a liquidity market for requesting to provide incoming capacity.

I and Rene Pickhardt, were discussing this a little while ago, and resulted to the solution below.

The Service Being Bought ------------------------

First, let us focus on what is being bought and paid for in this liquidity market.

We have been talking as if all that is being bought and paid for is simply "incoming capacity".

However, I believe this is incomplete. In the "real world" that you humans appear to be excessively obsessed with, a contract for a service involves specifying, not only what is being purchased, but also for how long this service is to be rendered. Indeed, this is the basis for my suggestion, to add an `nLockTime` to the commitment transactions.

Thus, the contract for purchasing liquidity, should specify not only the amount to be allocated for capacity, but also some duration for how long that capacity is to be allocated. Else, there is no reasonable condition for determining if the closure of a channel is improper or not.

Thus, I propose a simple modification for channels that are opened via a dual-fund that responded to an advertisement for liquidity.

A liquidity provider, providers the service as follows: for a fee, I shall provide incoming capacity to your node, and maintain this channel for a certain minimum duration.

Let us introduce our cast of characters:

* Mercy the Merchant, who wishes to receive payments by Lightning,
* Licky the Liquidity Provider, who wishes to earn fees by on-boarding others on Lightning.
* Randy the Random Node, who is simply on Lightning for no particular purpose.

Mercy pays Licky some fee, in order for Licky to provide incoming capacity to Mercy, for at least some number of blocks.

Minimum-lifetime Channels =========================

Let us now consider, how to impose a minimum lifetime to a channel. Naively, commitment transactions may have an `nLockTime` to impose this. However, this complicates HTLCs that appear as outputs of commitment transactions. An HTLC timelock that expires before the `nLockTime` of the commitment transaction cannot be enforced.

This makes the channel particularly useless for incoming payments, as payments that terminate at Mercy, are most likely to have low timelocks and thus most likely to be unenforceable onchain. Licky will prefer not to forward such nonenforceable HTLCs, so Mercy will not receive payments by this channel, when the express purpose, is to receive payments.

Separating Lifetime from HTLCs ------------------------------

However, we could instead consider, to enforce the locktime on the main output for Licky instead. This would allow the HTLC outputs to be unencumbered, allowing proper enforcement onchain.

Thus, after Symmetric CSV, we could also add an additional CLTV constraint that determines the minimum channel lifetime.

For instance, without minimum channel enforcement, Licky-side commitment transaction would have outputs below:

1.  Mercy-side output: Mercy && CSV
2.  Licky-side output: revocation || (Licky && CSV)

But if we now use a CLTV to enforce channel lifetime, Licky-side commitment transaction would have outputs below:

1.  Mercy-side output: Mercy && CSV
2.  Licky-side output: revocation || (Licky && CSV && CLTV)

The CLTV constraint is the block height at which the channel is created, plus the lifetime of the channel in blocks.

Of note, is that only Licky has the CLTV encumberance. Unlike CSV, it is not symmetrical. Asymmetry must exist here, since Licky has an obligation (it must provide this service) that Mercy does not.

The Mercy-side commitment transaction would have the outputs:

1.  Licky-side output: Licky && CSV && CLTV
2.  Mercy-side output: revocation || (Mercy && CSV)

Now we might have the intuition, that perhaps if Mercy closes the channel by its commitment transaction, this implies releasing Licky from its obligation. But a sufficiently evil Licky could play this by misbehaving, in an attempt to make Mercy close the channel by its commitment transaction, to release it from its obligation. (This is the same argument we used, for symmetrical CSV).

Of note, is that if the commitment transactions contain any HTLCs, then they appear simply on the commitment transaction outputs, with no particular change to support this feature.

Also of note, is that CLTV and CSV can indeed combine. A transaction that satisfies both the CSV-imposed `nSequence` and CLTV, would have a `nLockTime` that is the higher of the two imposed constraints. If the channel lifetime (enforced by CLTV) has passed, then the CSV is the only constraint, which reduces to the same as the existing behavior where a unilateral close prevents the money from being claimed by the CSV value. If the channel lifetime has not passed then access to the coin, is constrained by this channel lifetime. CLTV interacts badly with CSV only if CSV precedes it on an earlier output in a chain of transactions.

Games Licky Can Play --------------------

It must be raised to attention, that the commitment transaction can be broadcast at any time, as it has no `nLockTime`. This may be necessary to enforce a HTLC timeout.

Indeed, one thing Licky could try to do, would be to transmit the first commitment transaction as soon as it is signed. However, due to the CLTV constraint, Licky cannot reclaim its money immediately. Although the channel still closes before its purported minimum lifetime and leaves Mercy bereft of the service, Licky cannot gain an advantage in doing so.

On the other hand, if Licky continues to keep the channel open, it has the possibility of earning routing fees. Thus, defection in this game has no benefit, while cooperation has benefit. The rational choice, is to cooperate and retain the channel open.

The same game plays, if Licky pretends to sleep and does not respond. It gains no additional money or utility. If instead it did not pretend to sleep, it could potentially earn routing fees. The same game is playable today even without liquidity providers.

At the same time, in case of emergency (an HTLC is about to time out and Mercy is unresponsive), Licky has the ability to enforce onchain.

Games Mercy Can Play --------------------

Suppose Mercy broadcasts the commitment transaction as soon as it is signed. It thereby ties up Licky funds and Licky cannot thus earn routing fees.

However, the same would be true, if Mercy simply pretended to sleep and did not respond to anything. The funds would still be locked to the channel, and Licky cannot escape this lock.

It should be pointed out that Mercy has already paid for the locking of funds of Licky, from the liquidity provider advertisement. Thus, conceptually Mercy "owns" the lock-rights of the funds of Licky. Presumably, the intent is that Mercy wishes to be paid, and thus Mercy gains economic power from this.

But suppose Mercy never receives payment via this channel. Then the effect is simply: Mercy borrows some money from Licky, and promises to pay it back with some interest (the liquidity provider fee). The difference is that this promise is enforceable onchain, and Mercy cannot escape this by any method: the extra interest will be paid to Licky inevitably, unlike normal bank-based financial instruments. (Thus, this is still not a debt-based instrument: the backing credit is held in escrow by the blockchain, and will always return to Licky after the borrowing period ends; there is no possibility of default) Thus, a rational Mercy would want to be able to utilize this encumbered borrowed funds, by actually providing some service or product and being paid via the channel. Otherwise, it ends up having simply donated money to Licky with no economic benefit to itself.

Reduction of Licky Obligation -----------------------------

Of note, is that the cost of the obligation of Licky would decrease once Mercy actually receives payments. Thus, as Mercy receives more payment, the cost on Licky in defecting reduces.

We should also note, that the entire point of Mercy performing this exercise is to receive money. We can consider, that Mercy receiving money should make Mercy satisfied with this service. Thus even if Licky obligation drops low enough that Licky could economically let some tiny amount be

More Complex Games Licky Can Play ---------------------------------

Suppose Mercy has some outgoing channel to a random node, Randy. Then Licky can move its encumbered funds through some circular route (if one exists) from Licky to Mercy to Randy back to Licky.

This is normally not an issue, since the transfer means that the formerly-outgoing channel between Mercy and Randy is now an incoming channel to Mercy, Thus Mercy still has incoming capacity, as it wants. However, if this channel has no minimum channel lifetime, then Randy could close this channel. Licky would then have disposed of its obligation without having most of its money tied to the channel.

Mercy can mitigate this attack, by only opening channels with similar minimum channel lifetimes (actually, similar dates of earliest termination). This means, Randy is not in fact random, but yet another liquidity provider. Then when Licky disposes of its obligation, the obligation is actually transferred to Randy. This ensures that Mercy can still have its service of incoming capacity.

Acts of God ===========

Rene pointed out, that if an actual physical bolt of Lightning (whatever this "physical realm" that humans apparently inhabit means), were to strike Licky, then Mercy gets no incoming capacity and the contract (liquidity fee for incoming liquidity for a specific time period) is effectively voided. This is simply the same as if a contract is voided by an "act of God" (a physical bolt of Lightning appears to be one). Of note, is that most service contracts in the "real world" have clauses where "act of God" may prevent proper execution of the service, and the service provider then becomes free of liability.

In this case, this is exactly modeled, if Licky truly has been destroyed. On the other hand, if Licky only pretends to be destroyed, it is the same game as above in "Games Licky Can Play".

Regards, ZmnSCPxj

Pierre in reply to ZmnSCPxj permalink original

Hello ZmnSCPxj,

Quoted text (3 lines)
Thus, after Symmetric CSV, we could also add an additional CLTV constraint
> that determines the minimum channel lifetime.
>

I'm nitpicking, but parties have to exchange the first commitment txes (one for each side) *before* the funding tx is even published. As a consequence, the absolute CLTV delay wouldn't really constrain the duration of the channel, because the timer starts running before the channel is created. Do you think that matters?

Cheers,

Pierre

ZmnSCPxj in reply to Pierre permalink original

Good morning Pierre,

Quoted text (3 lines)
>> Thus, after Symmetric CSV, we could also add an additional CLTV constraint that determines the minimum channel lifetime.
>
> I'm nitpicking, but parties have to exchange the first commitment txes (one for each side) *before* the funding tx is even published. As a consequence, the absolute CLTV delay wouldn't really constrain the duration of the channel, because the timer starts running before the channel is created. Do you think that matters?

This is quite correct; but it is similar to the case where Mercy (who is buying liquidity) opens the channel, with Licky providing part of the funds, and then Mercy shutting down its node. As long as the funding transaction gets confirmed and it is possible for Licky to broadcast the commitment transaction, the same analysis applies: Mercy pays Licky to lock its funds, so Licky earns here already, regardless whether Mercy uses the capacity or not.

Since we (broadly) agreed that initiator of the channel pays onchain fees, Mercy is in control of how fast (or slow) the time is between the two of them agreeing to a specific CLTV blockheight, to when the channel actually opens. Thus it could be interpreted, that any discrepancy between the time they agree, and the time the channel gets confirmed and starts its onchain lifetime, is equivalent to Mercy shutting down its node for that duration (and the same analysis applies: Mercy has wasted its money on paying Licky for liquidity it didn't use).

The above analysis hinges on the funding transaction actually getting confirmed, though.

One possibility is that Mercy could lowball the onchain fee for the funding transaction. If the mempool becomes backlogged, instead of Mercy then requesting an RBF of the funding transaction, Mercy could just double-spend only its own inputs, invalidating the funding transaction. This means, that Licky funds have temporarily been locked, then they attempt to open the channel with a low onchain fee, and if that fails then the deal is cancelled and both get their funds back immediately. Licky then loses all ability to earn (but at least the channel lifetime is no longer imposed in that case).

The time from when both sides agree to open the channel and exchange signatures for the funding transaction, to the time the funding transaction confirms, may be sensitive due to the possibility of one side unilaterally RBFing their inputs.

So let us now write the contract in full:

1.  Mercy agrees to pay N satoshi to Licky.
2.  Licky agrees to have L satoshi locked for use in the channel until blockheight B.
3.  Either side may void this contract by paying a miner fee, until the time the funding transaction confirms.
4.  Mercy is responsible for getting the funding transaction confirmed.

Regards, ZmnSCPxj

ZmnSCPxj in reply to ZmnSCPxj permalink original

Good morning all,

Tangentially related to Pierre question, is "initiator pays" principle.

Rene actually wondered about whether this would be fair. Especially, since Licky might very well gather all its dust to provide its side of the funding. Thinking about this a little more, in the context of a liquidity provider, I provide the below analysis:

If the onchain fees were split somehow between Mercy and Licky, a rational Licky would increase its liquidity fees until it reaches the level where it would still earn the opportunity cost of locking its funds, taking into account the onchain fee that Licky would provide. Thus in effect the onchain fee from Licky-side would still end up being paid by Mercy, so we may as well be honest and impose "initiator pays".

If the onchain fees were paid only by Mercy, and Licky provides 100 dust outputs, then a rational Mercy would account for the onchain fees incurred plus the liquidity fee as part of the cost of doing business with Licky. If this cost is too high (regardless of how many outputs Licky provides) then it may be uneconomical for Mercy to do business with that particular Licky and would take its business elsewhere. (Since Mercy has to sign the funding transaction, and the funding transaction will need to refer to all of Licky-side inputs, Mercy can always not enter into the contract by simply refusing to sign the funding transaction if the onchain fees end up being too high). Thus Licky would rationally prefer to keep its own funds in as few outputs as possible in order to be more competitive in the liquidity provider market.

So, naively to me, "initiator pays" seems quite reasonable.

Regards, ZmnSCPxj

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

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Monday, November 12, 2018 8:15 AM, ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> wrote:

Quoted text (25 lines)
> Good morning Pierre,
>
>>> Thus, after Symmetric CSV, we could also add an additional CLTV constraint that determines the minimum channel lifetime.
>>
>> I'm nitpicking, but parties have to exchange the first commitment txes (one for each side) *before* the funding tx is even published. As a consequence, the absolute CLTV delay wouldn't really constrain the duration of the channel, because the timer starts running before the channel is created. Do you think that matters?
>
> This is quite correct; but it is similar to the case where Mercy (who is buying liquidity) opens the channel, with Licky providing part of the funds, and then Mercy shutting down its node.  As long as the funding transaction gets confirmed and it is possible for Licky to broadcast the commitment transaction, the same analysis applies: Mercy pays Licky to lock its funds, so Licky earns here already, regardless whether Mercy uses the capacity or not.
>
> Since we (broadly) agreed that initiator of the channel pays onchain fees, Mercy is in control of how fast (or slow) the time is between the two of them agreeing to a specific CLTV blockheight, to when the channel actually opens.  Thus it could be interpreted, that any discrepancy between the time they agree, and the time the channel gets confirmed and starts its onchain lifetime, is equivalent to Mercy shutting down its node for that duration (and the same analysis applies: Mercy has wasted its money on paying Licky for liquidity it didn't use).
>
> The above analysis hinges on the funding transaction actually getting confirmed, though.
>
> One possibility is that Mercy could lowball the onchain fee for the funding transaction.  If the mempool becomes backlogged, instead of Mercy then requesting an RBF of the funding transaction, Mercy could just double-spend only its own inputs, invalidating the funding transaction.  This means, that Licky funds have temporarily been locked, then they attempt to open the channel with a low onchain fee, and if that fails then the deal is cancelled and both get their funds back immediately.  Licky then loses all ability to earn (but at least the channel lifetime is no longer imposed in that case).
>
> The time from when both sides agree to open the channel and exchange signatures for the funding transaction, to the time the funding transaction confirms, may be sensitive due to the possibility of one side unilaterally RBFing their inputs.
>
> So let us now write the contract in full:
>
> 1.  Mercy agrees to pay N satoshi to Licky.
> 2.  Licky agrees to have L satoshi locked for use in the channel until blockheight B.
> 3.  Either side may void this contract by paying a miner fee, until the time the funding transaction confirms.
> 4.  Mercy is responsible for getting the funding transaction confirmed.
>
> Regards,
> ZmnSCPxj