Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

eltoo: A Simplified update Mechanism for Lightning and Off-Chain Contracts

27 messages, Apr 30 to Oct 13, 2018. Started by Christian Decker.

Christian Decker (8), ZmnSCPxj (8), Carsten Otto (3), David A. Harding (3), Anthony Towns (3), Corné Plooy, Rusty Russell

Permalink First message in the Wayback Machine

Christian Decker permalinkalso on bitcoin-dev original

(cross-posting to bitcoin-dev since this serves as motivation behind the sighash_noinput proposal)

Quoted text (2 lines)
> TL;DR: we announce a new, simple, update mechanism for off-chain protocols,
> see the announcement [1] and the paper [2] :-)

A little over a year ago, the three Lightning Network implementation teams joined forces to work on a common specification for the protocol stack. Now that both that specification and our three implementations are becoming stable and usable, it is time to look forward: to further improve the protocol, to add new features, to simplify, and to fix downsides.

One of the core innovations that enabled Lightning in the first place was an off-chain update mechanism to renegotiate a new state and ensure that the old state can not be settled on-chain. Today, we're excited to release our latest research paper on a new, simplified, update mechanism for layer 2 protocols, called eltoo.

eltoo is a drop-in replacement for the penalty based invalidation mechanism that is used today in the Lightning specification. It is similar in many ways to the sequence number mechanism that was already present in the original Bitcoin implementation. But, while sequence numbers were unenforceable on the blockchain, eltoo is enforceable by overriding subsequent states on-chain.

Unlike the current mechanism used in Lightning so far, it is not penalty based, i.e., publishing an old state does not result in the faulty node to automatically lose funds, and is most similar to the duplex micropayment channels construction. It is a symmetric scheme, i.e., all participants share an identical set of transactions, and it ensures that the last agreed upon state is settled on-chain, with similar tradeoffs as today's Lightning (timelock vs. online requirement).

eltoo addresses some of the issues we encountered while speficying and implementing the Lightning Network. For example outsourcing becomes very simple since old states becoming public can't hurt us anymore. We completely remove the need to estimate fees ahead of time. The construction allows us to attach fees when settling, and even allows for fees to be bumped using CPFP or RBF.

Beyond Lightning, eltoo can be used as a generic update mechanism for an off-chain contract, for a larger number of participants. This was not possible in the current update mechanism since reactions to a misbehaving participant needed to be tailore to that participant. This enables other protocols such as the channel factories, and in combination with Schnorr signatures allows for very large off-chain contracts with minimal on-chain footprint.

Before we can implement eltoo, we need a minor change to Bitcoin: the introduction of the SIGHASH_NOINPUT flag for signatures. This was first discussed a few months ago in the context of watchtowers to help secure Lightning channels, but was not formally proposed. A formal proposal may now be found in the eltoo paper.

We invite the community to consider our proposal and to participate in its discussion. We hope to arrive at a consensus for the usage of SIGHASH_NOINPUT, so that it can be accepted and included in a future soft fork of Bitcoin Script. Doing so will put us on the road to a more reliable and simpler Lightning Network, incorporating a new update mechanism that can also be used for many other applications.

The full official announcement can be found at [1] and the paper with the full details can be found at [2].

Looking forward to the communities feedback, Christian

[1] https://blockstream.com/2018/04/30/eltoo-next-lightning.html
[2] https://blockstream.com/eltoo.pdf
ZmnSCPxj in reply to Christian Decker permalinkalso on bitcoin-dev original

Good morning Christian,

This is very interesting indeed!

I have started skimming through the paper.

I am uncertain if the below text is correct?

Quoted text (1 line)
> Throughout this paper we will use the terms *input script* to refer to `witnessProgram` and `scriptPubKey`, and *output script* to refer to the `witness` or `scriptSig`.

Figure 2 contains to what looks to me like a `witnessProgram`, `scriptPubKey`, or `redeemScript` but refers to it as an "output script":

Quoted text (8 lines)
>    OP_IF
>        10 OP_CSV
>        2 As Bs 2 OP_CHECKMULTISIGVERIFY
>    OP_ELSE
>        2 Au Bu 2 OP_CHECKMULTISIGVERIFY
>    OP_ENDIF
>
> Figure 2: The output script used by the on-chain update transactions.

Regards, ZmnSCPxj

ZmnSCPxj in reply to Christian Decker permalink original

Hi Christian,

Let me know if I have summarized the paper accurately below:

1.  SIGHASH_NOINPUT removes all inputs of the transaction copy before signing/verifying.
2.  SIGHASH_NOINPUT can be combined with SIGHASH_SINGLE.  It is dangerous to combine it with SIGHASH_NONE (as this also deletes all outputs of the transaction copy, so the signature only commits to nLockTime) and possibly pointless to combine it with SIGHASH_ANYONECANPAY (which deletes other inputs, but since there are no inputs after SIGHASH_NOINPUT, there is nothing else to delete).  The BIP only mentions combining it with SIGHASH_SINGLE, in any case.
3.  We have these kinds transactions: (1) funding transaction paying out to an ordinary N-of-N multisig (confirmed onchain); (2) offchain trigger transaction spending a funding transaction and paying out to the "update transaction script"; (3) offchain update transaction spending a trigger or update transaction and paying out to the "update transaction script" (the same script template as in trigger transaction); (4) offchain settlement transaction spending a trigger or update transaction and paying out to the counterparties according to the final agreed distribution of funds.  Update and settlement transactions are signed with SIGHASH_NOINPUT flags.
4.  The update transaction script has two branches: a CSV-encumbered N-of-N "settlement" branch, and a CLTV-encumbered N-of-N "update" branch.  Crucially, we use past Unix timestamps for the CLTV encumberance on the update.  The CLTV-encumberance starts with a minimum time value on the trigger transaction, and increments by 1 for every update transaction.
5.  The CLTV-encumberance ensures that if a past update transaction is confirmed, we can spend it using any later update transaction, since CLTV uses `stackTop <= nLockTime`.  The actual `nLockTime` we use is a past Unix timestamp so they are not actually time-encumbered, but the `OP_CLTV` still ensures that any later update transaction can be used to spend from any earlier update transaction, but not vice versa.  This is actually quite clever.
6.  The pubkeys on the settlement branch of each update transaction are different, and are derived using any hierarchical derivation method (trivially we can simply use the CLTV-encumberance value as the derivation index).  This ensures that each settlement transaction can only spend a particular update transaction.  Or in other words: There is a one-to-one correspondence between update and settlement transaction, and a settlement transaction can only confirm if the corresponding update transaction can be confirmed deeply enough without having its output re-spent.
7.  The pubkeys on the update branch are all the same in all update transactions.  This lets any update transaction replace any other update transaction, as long as the CLTV-encumberance (which is used for ordering rather than actual absolute locktime) is respected; together they mean that any later update transaction can replace any earlier update transaction.
8.  If an old update transaction is confirmed, the settlement transaction corresponding to it is still encumbered by CSV and cannot be confirmed immediately.  During this time, a later update transaction can spend it and be confirmed.  If that update transaction is still not the latest available, it can be further replaced with any, later transaction (since the CLTV-encumberance and the `nLockTime` increase in lockstep with each other) until the latest update transaction is confirmed.
9.  When the latest update transaction gets confirmed, no other update transaction can successfully spend its "update" branch (as their `nLockTime` is less than the CLTV-encumberance on that branch).  This lets the CSV-encumbered settlement transaction be confirmable after some blocks.
10.  Update transactions pay no fees!  Instead, for update transactions (but not settlement transactions) we additionally give SIGHASH_SINGLE: thus, no matter what transaction they end up in, the signatures for the update transaction will always be verified against only the update transaction output that pays out to the update transaction script.  We join update transactions with a spend of some onchain UTXO we control, which pays for the fees of the joined the update transactions, and may have a second output that is the remainder of the fund after paying the fees.
11.  Settlement transactions can carry contracts (in much the same way that Poon-Dryja commitment transactions); however contracts that contain absolute timelock components will be affected by the CSV-encumberance of the settlement transaction.

---

Some pros and cons relative to Poon-Dryja (LN-penalty) channels:

- Requires more transactions in the worst-case: trigger, update, settlement.  Compare to Poon-Dryja: commitment, claim.  Decker-Russell-Osuntokun channels can be trigger-settlement but only in the degenerate case where the channel was never updated (indeed for implementation simplicity we might rather prefer to make an initial update transaction at the start, instead of starting with a trigger-settlement).
- Dropping unilaterally onchain requires the party doing the drop to have some onchain funds it controls completely, since update transactions do not pay fees by themselves.  We cannot have an autopilot that puts all onchain funds on channels, we need to reserve some small amount for paying fees of unilateral closes.
+ The above is counterbalanced by the fact that we can easily adjust onchain fees for update transactions, unlike the case for Poon-Dryja commitment transactions which once signed cannot have fees updated.

= The onchain reserve (for paying fees for unilaterally dropped channels) is roughly equivalent to the channel reserve under Poon-Dryja; such a channel reserve no longer exists under Decker-Russell-Osuntukun channels, but is replaced by the onchain fee-paying reserve. Possibly the fee-paying reserve here might be feasibly smaller than the channel reserve under Poon-Dryja.

- The CSV-encumberance on settlement transactions, which are the ones which carry the contracts in the channel, affects all absolute-timelocked contracts transported on the channel.  Compare to Poon-Dryja, where commitment transactions themselves are unencumbered by CSV, and we simply insert the revocation to spends of the contracts being transported (i.e. the reason why we have HTLC-success and HTLC-timeout transactions in BOLT spec).
+ Like invalidation trees, we can use N-party funds rather than just 2-party funds (channels).  We can even use M-of-N, so if there is at least some amount of trust you have with a group of entities (family, close friends, conglomeration partners, ZmnSCPxj, politicians...) it would be possible to have funds that require say only a majority of its owners to be updated.

Please inform me if there are important points I missed.

Regards, ZmnSCPxj

Christian Decker in reply to ZmnSCPxj permalinkalso on bitcoin-dev original

ZmnSCPxj <ZmnSCPxj at protonmail.com> writes:

Quoted text (23 lines)
> Good morning Christian,
>
> This is very interesting indeed!
>
> I have started skimming through the paper.
>
> I am uncertain if the below text is correct?
>
>> Throughout this paper we will use the terms *input script* to refer to `witnessProgram` and `scriptPubKey`, and *output script* to refer to the `witness` or `scriptSig`.
>
> Figure 2 contains to what looks to me like a `witnessProgram`, `scriptPubKey`, or `redeemScript` but refers to it as an "output script":
>
>>    OP_IF
>>        10 OP_CSV
>>        2 As Bs 2 OP_CHECKMULTISIGVERIFY
>>    OP_ELSE
>>        2 Au Bu 2 OP_CHECKMULTISIGVERIFY
>>    OP_ENDIF
>>
>> Figure 2: The output script used by the on-chain update transactions.
>
> Regards,
> ZmnSCPxj

Darn last minute changes! Yes, you are right, I seem to have flipped the two definitions. I'll fix that up and push a new version.

Christian Decker in reply to ZmnSCPxj permalink original

Excellent summary ZmnSCPxj, I'll try to address the points inline (if there is anything to add that is):

ZmnSCPxj <ZmnSCPxj at protonmail.com> writes:

Quoted text (6 lines)
> Hi Christian,
>
> Let me know if I have summarized the paper accurately below:
>
> 1.  SIGHASH_NOINPUT removes all inputs of the transaction copy before
>     signing/verifying.

It sets them to a known constant, in this case we just blank them. Removing could entail more costly serialization depending on the implementation. bitcoind serializes into a hash accumulator so it'd not make a difference there, but others may do it differently.

Quoted text (7 lines)
> 2.  SIGHASH_NOINPUT can be combined with SIGHASH_SINGLE.  It is
> dangerous to combine it with SIGHASH_NONE (as this also deletes all
> outputs of the transaction copy, so the signature only commits to
> nLockTime) and possibly pointless to combine it with
> SIGHASH_ANYONECANPAY (which deletes other inputs, but since there are
> no inputs after SIGHASH_NOINPUT, there is nothing else to delete).
> The BIP only mentions combining it with SIGHASH_SINGLE, in any case.

`SIGHASH_SINGLE` really is only singled out (no pun intended) because it is usefull for the fee feature that Rusty came up with. It's not our intention to exclude other uses, but you're right, it's hard to come up with a use-case for `SIGHASH_NOINPUT` in combination with `SIGHASH_NONE` or `SIGHASH_ANYONECANPAY` :-)

In particular we don't want to exclude potential future sighash types, but those will have to be dealt with when they come up.

Quoted text (17 lines)
> 3.  We have these kinds transactions: (1) funding transaction paying
> out to an ordinary N-of-N multisig (confirmed onchain); (2) offchain
> trigger transaction spending a funding transaction and paying out to
> the "update transaction script"; (3) offchain update transaction
> spending a trigger or update transaction and paying out to the "update
> transaction script" (the same script template as in trigger
> transaction); (4) offchain settlement transaction spending a trigger
> or update transaction and paying out to the counterparties according
> to the final agreed distribution of funds.  Update and settlement
> transactions are signed with SIGHASH_NOINPUT flags.
>
> 4.  The update transaction script has two branches: a CSV-encumbered
> N-of-N "settlement" branch, and a CLTV-encumbered N-of-N "update"
> branch.  Crucially, we use past Unix timestamps for the CLTV
> encumberance on the update.  The CLTV-encumberance starts with a
> minimum time value on the trigger transaction, and increments by 1 for
> every update transaction.

Really any monotonically increasing sequence of increments will work, but incrementing by 1 maximizes the number of updates we can perform, yes.

Quoted text (7 lines)
> 5.  The CLTV-encumberance ensures that if a past update transaction is
> confirmed, we can spend it using any later update transaction, since
> CLTV uses `stackTop <= nLockTime`.  The actual `nLockTime` we use is a
> past Unix timestamp so they are not actually time-encumbered, but the
> `OP_CLTV` still ensures that any later update transaction can be used
> to spend from any earlier update transaction, but not vice versa.
> This is actually quite clever.

Correct, the only reason to use `nLocktime` here is that we need the signature of the update transaction to commit to the state number, so we can't put it in the script itself.

Quoted text (9 lines)
> 6.  The pubkeys on the settlement branch of each update transaction
> are different, and are derived using any hierarchical derivation
> method (trivially we can simply use the CLTV-encumberance value as the
> derivation index).  This ensures that each settlement transaction can
> only spend a particular update transaction.  Or in other words: There
> is a one-to-one correspondence between update and settlement
> transaction, and a settlement transaction can only confirm if the
> corresponding update transaction can be confirmed deeply enough
> without having its output re-spent.

Other bindings are possible, e.g., compare the `nLocktime` again, but binding through pubkeys minimizes the script size.

Quoted text (15 lines)
> 7.  The pubkeys on the update branch are all the same in all update
> transactions.  This lets any update transaction replace any other
> update transaction, as long as the CLTV-encumberance (which is used
> for ordering rather than actual absolute locktime) is respected;
> together they mean that any later update transaction can replace any
> earlier update transaction.
>
> 8.  If an old update transaction is confirmed, the settlement
> transaction corresponding to it is still encumbered by CSV and cannot
> be confirmed immediately.  During this time, a later update
> transaction can spend it and be confirmed.  If that update transaction
> is still not the latest available, it can be further replaced with
> any, later transaction (since the CLTV-encumberance and the
> `nLockTime` increase in lockstep with each other) until the latest
> update transaction is confirmed.

Notice that the update transactions are actually paying their keep, i.e., they have fees attached, so we think that participants will simply jump to the latest state and not waste fees on things that have no chance of getting them closer to getting an old state enforced.

Quoted text (20 lines)
> 9.  When the latest update transaction gets confirmed, no other update
> transaction can successfully spend its "update" branch (as their
> `nLockTime` is less than the CLTV-encumberance on that branch).  This
> lets the CSV-encumbered settlement transaction be confirmable after
> some blocks.
>
> 10.  Update transactions pay no fees!  Instead, for update
> transactions (but not settlement transactions) we additionally give
> SIGHASH_SINGLE: thus, no matter what transaction they end up in, the
> signatures for the update transaction will always be verified against
> only the update transaction output that pays out to the update
> transaction script.  We join update transactions with a spend of some
> onchain UTXO we control, which pays for the fees of the joined the
> update transactions, and may have a second output that is the
> remainder of the fund after paying the fees.
>
> 11.  Settlement transactions can carry contracts (in much the same way
> that Poon-Dryja commitment transactions); however contracts that
> contain absolute timelock components will be affected by the
> CSV-encumberance of the settlement transaction.

Exactly, the timeouts need to be chosen high enough in order to allow an orderly resolution on-chain, should one party become uncooperative.

Quoted text (11 lines)
> ---
>
> Some pros and cons relative to Poon-Dryja (LN-penalty) channels:
>
> - Requires more transactions in the worst-case: trigger, update,
> settlement.  Compare to Poon-Dryja: commitment, claim.
> Decker-Russell-Osuntokun channels can be trigger-settlement but only
> in the degenerate case where the channel was never updated (indeed for
> implementation simplicity we might rather prefer to make an initial
> update transaction at the start, instead of starting with a
> trigger-settlement).

Actually the trigger can also be replaced in the cooperative case, meaning that the settlement in that case is just a single transaction, identical to LN-penalty. It is true that we've split the unilateral commitment from LN-penalty into two transactions, but we removed the need for a claim transaction, since funds directly go to the recipient and we have no our_unilateral/to_us or their_unilateral/to_them delay that needs to be sweeped (technically also not necessary, but all implementation do that if I'm not mistaken). Even if funds are not sweeped, the UTXO state is larger due to the bigger script that our simple outputs for the settlement.

Quoted text (5 lines)
> - Dropping unilaterally onchain requires the party doing the drop to
> have some onchain funds it controls completely, since update
> transactions do not pay fees by themselves.  We cannot have an
> autopilot that puts all onchain funds on channels, we need to reserve
> some small amount for paying fees of unilateral closes.

That is true, and I think this falls into the same category as the reserve funds in the LN-penalty mechanism, i.e., funds that are there but can't be used. There may be a clever way to build a penalty on top of eltoo and then combine the fees and the penalties. Then again, a misbehaving participant risking their on-chain fees for an outdated update transaction may be a sufficient deterrent.

Quoted text (10 lines)
> + The above is counterbalanced by the fact that we can easily adjust
> onchain fees for update transactions, unlike the case for Poon-Dryja
> commitment transactions which once signed cannot have fees updated.
>
> = The onchain reserve (for paying fees for unilaterally dropped
> channels) is roughly equivalent to the channel reserve under
> Poon-Dryja; such a channel reserve no longer exists under
> Decker-Russell-Osuntukun channels, but is replaced by the onchain
> fee-paying reserve.  Possibly the fee-paying reserve here might be
> feasibly smaller than the channel reserve under Poon-Dryja.

The one downside that this has is that the channel participants have very little control over the fees that a misbehaving node may get punished with. As one endpoint I can no longer impose an arbitrary minimum loss in case of breach.

Quoted text (7 lines)
> - The CSV-encumberance on settlement transactions, which are the ones
> which carry the contracts in the channel, affects all
> absolute-timelocked contracts transported on the channel.  Compare to
> Poon-Dryja, where commitment transactions themselves are unencumbered
> by CSV, and we simply insert the revocation to spends of the contracts
> being transported (i.e. the reason why we have HTLC-success and
> HTLC-timeout transactions in BOLT spec).

True, but as I argued in another mail, this is a fixed offset, that is in the same range as today's CLTV deltas for some nodes. So for the network of today using eltoo is roughly equivalent of adding another hop to our path :-)

Quoted text (6 lines)
> + Like invalidation trees, we can use N-party funds rather than just
> 2-party funds (channels).  We can even use M-of-N, so if there is at
> least some amount of trust you have with a group of entities (family,
> close friends, conglomeration partners, ZmnSCPxj, politicians...) it
> would be possible to have funds that require say only a majority of
> its owners to be updated.

The trust really comes down to a tradeoff between group size and liveness: the bigger the group and the more churn you have in that group, the less reliable the system becomes. Loss of liveness means that the funds in the contract become unavailable for a know period of time.

ZmnSCPxj in reply to Christian Decker permalink original

Good morning Christian,

Thank you very much!

Quoted text (16 lines)
> > Hi Christian,
> >
> > Let me know if I have summarized the paper accurately below:
> >
> > 1.  SIGHASH_NOINPUT removes all inputs of the transaction copy before
> >
> >     signing/verifying.
> >
>
> It sets them to a known constant, in this case we just blank
>
> them. Removing could entail more costly serialization depending on the
>
> implementation. bitcoind serializes into a hash accumulator so it'd not
>
> make a difference there, but others may do it differently.

Does this then mean that if the transaction has two inputs, we are still committing to the fact that there are two inputs? If so, it is probably useable together with SIGHASH_ANYONECANPAY.

In fact, it seems, if we are using this to provide additional fees to update transactions, we should also use SIGHASH_ANYONECANPAY on the update UTXO path so that we can add new inputs to the transaction that will pay for the fee.

Quoted text (22 lines)
> > Some pros and cons relative to Poon-Dryja (LN-penalty) channels:
> >
> > -   Requires more transactions in the worst-case: trigger, update,
> >
> >     settlement. Compare to Poon-Dryja: commitment, claim.
> >
> >     Decker-Russell-Osuntokun channels can be trigger-settlement but only
> >
> >     in the degenerate case where the channel was never updated (indeed for
> >
> >     implementation simplicity we might rather prefer to make an initial
> >
> >     update transaction at the start, instead of starting with a
> >
> >     trigger-settlement).
> >
>
> Actually the trigger can also be replaced in the cooperative case,
>
> meaning that the settlement in that case is just a single transaction,
>
> identical to LN-penalty.

Yes, but the intent of this second list is to contrast it to Poon-Dryja/LN-penalty channels, so I skipped over similarities (well there is the onchannel reserve vs the onchain fee-paying reserve, but I would argue they are congruent and not exactly identical). One can argue that any viable channel-update-mechanism should be cooperatively collapsible to a single transaction on top of the funding transaction (because neither side has a good chance of contesting what has been agreed on, and collapsing them all to a single closing transaction is always an improvement due to having less data hit the blockchain), so if you did your job right in eltoo (and it looks to me like you all have) then that is already a given.

Quoted text (15 lines)
> It is true that we've split the unilateral
>
> commitment from LN-penalty into two transactions, but we removed the
>
> need for a claim transaction, since funds directly go to the recipient
>
> and we have no our_unilateral/to_us or their_unilateral/to_them delay
>
> that needs to be sweeped (technically also not necessary, but all
>
> implementation do that if I'm not mistaken). Even if funds are not
>
> sweeped, the UTXO state is larger due to the bigger script that our
>
> simple outputs for the settlement.

Ah, that is another difference I had not noticed, thank you.

Quoted text (22 lines)
> > -   The CSV-encumberance on settlement transactions, which are the ones
> >
> >     which carry the contracts in the channel, affects all
> >
> >     absolute-timelocked contracts transported on the channel. Compare to
> >
> >     Poon-Dryja, where commitment transactions themselves are unencumbered
> >
> >     by CSV, and we simply insert the revocation to spends of the contracts
> >
> >     being transported (i.e. the reason why we have HTLC-success and
> >
> >     HTLC-timeout transactions in BOLT spec).
> >
>
> True, but as I argued in another mail, this is a fixed offset, that is
>
> in the same range as today's CLTV deltas for some nodes. So for the
>
> network of today using eltoo is roughly equivalent of adding another hop
>
> to our path :-)

This may complicate routing decisions, however, in a mixed network where some channels are Poon-Dryja and some channels are Decker-Russell-Osuntokun; and if we deploy this as a back-compatible extension to the Lightning Network rather than a completely new network (and we should) then we will have such a mixed network.

A payer routing through such a network finding two routes with identical fees and cltv-deltas, but one going through only Poon-Dryja channels and the other with one channel going through Decker-Russell-Osuntokun (and the rest still Poon-Dryja) would prefer the purely Poon-Dryja one, which does not have any additional csv-delta to impose on the route.

Further, once a payer can find no purely Poon-Dryja routes, then it no longer matters how many Decker-Russell-Osuntokun channels a route hops, because csv-deltas are not additive. Unfortunately most standard routing I know of assume additive costs, meaning we would either have a two-phase routing (first we try to find only purely Poon-Dryja routes, then if there are none we accept Decker-Russell-Osuntokun channels) or hack around with the routing algo to try and make things fit.

Finally, it seems to me that it is very unlikely that we would accept some centrally-imposed csv-delta. Instead this would be negotiated between peers during channel setup (probably similarly to the current closing fee negotiation), and would vary across the network. Indeed in such a system, Poon-Dryja channels would be gossiped as having a csv-delta=0. But now the routing decision on whether to pass through a channel would depend on whether the csv-delta is greater than the current route csv-delta or not. Hmm.

ZmnSCPxj in reply to Christian Decker permalink original

Good morning Christian,

It seems to me we can remove the trigger transaction.

The observation is that `nSequence`-encumbered transactions are only settlement transactions and not any update transactions.

Thus, it is not needed for a trigger transaction to exist, if we can make update transactions behave as the trigger transaction for its settlement transaction or any later update transaction.

So, let me propose, that the funding transaction outpoint could have the below SCRIPT:

    OP_IF
        # Settlement branch
        OP_FALSE
    OP_ELSE
        # Update branch. 500,000,000 is the minimum state number under Decker-Russell-Osuntokun.
        500000000 OP_CHECKLOCKTIMEVERIFY
        2 Au Bu 2 OP_CHECKMULTISIGVERIFY
    OP_ENDIF

Thus, the funding outpoint can be spent directly by any update transaction, which has `<sigAu> <sigBu> OP_FALSE` at its `witness` script.

When creating a mutual close transaction, we simply use the update branch of the funding transaction above, again signing with `<sigAu> <sigBu> OP_FALSE`. This does have the drawback that the mutual close transaction can be RBFed away by an update transaction (requiring more code to handle this case); but the latest update transaction can still be published in that case and we simply devolve down to the usual unilateral close branch.

The drawback is that the mutual close transaction increases by 1 weight unit (the `OP_FALSE` in the `witness` script) plus the size of the more complicated funding transaction SCRIPT, which is no longer a regular 2-of-2 P2WSH and indelibly marking it as a Decker-Russel-Osuntokun mutual close. Taproot would help there by implicitly including a plain 2-of-2 fallback.

Finally, we could argue that the mutual close transaction is expected to be the more common case, so increasing its size by even a small amount may outweigh the size reduction in the much rarer unilateral close case.

Regards, ZmnSCPxj

ZmnSCPxj in reply to ZmnSCPxj permalink original

Good morning Christian,

Quoted text (20 lines)
> > > Hi Christian,
> > >
> > > Let me know if I have summarized the paper accurately below:
> > >
> > > 1.  SIGHASH_NOINPUT removes all inputs of the transaction copy before
> > >
> > >     signing/verifying.
> > >
> >
> > It sets them to a known constant, in this case we just blank
> >
> > them. Removing could entail more costly serialization depending on the
> >
> > implementation. bitcoind serializes into a hash accumulator so it'd not
> >
> > make a difference there, but others may do it differently.
>
> Does this then mean that if the transaction has two inputs, we are still committing to the fact that there are two inputs? If so, it is probably useable together with SIGHASH_ANYONECANPAY.
>
> In fact, it seems, if we are using this to provide additional fees to update transactions, we should also use SIGHASH_ANYONECANPAY on the update UTXO path so that we can add new inputs to the transaction that will pay for the fee.

Ha, no, looking at the detailed `SIGHASH_NOINPUT` spec, `hashPrevouts`, which normally commits to the other inputs, is blanked, so we do not commit to them either. This means that `SIGHASH_NOINPUT` implicitly has a `SIGHASH_ANYONECANPAY`.

(the BIP `SIGHASH_NOINPUT` in the eltoo pdf does not mention `hashSequence`, but it seems you managed to add that to your github BIP repository)

Regards, ZmnSCPxj

Carsten Otto in reply to ZmnSCPxj permalink original

Hi ZmnSCPxj, Christian, list,

the paper is a bit confusing regarding the setup transaction, as it is not described formally. There also seems to be a mixup of "setup transaction" and "funding transaction", also named T_{u,0} without showing it in the diagrams.

In 3.1 the funding transaction is described as funding "to a multisig address". In the description of trigger transactions the change is described as "The output from the setup transaction is changed into a simple 2-of-2 multisig output" - which it already is?

As far as I understand the situation, the the trigger transaction is needed because the broadcasted initial/funding/setup transaction includes an OP_CLV (possibly enforcing premature settlement). Removing OP_CLV, i.e. by changing it to a simple multisig output, seems to solve this issue.

Could you (Christian?) explain how the "setup transaction" is supposed to look like without the changes described in section 4.2?

I like the idea proposed by ZmnSCPxj, but I'm not able to weigh the pro/cons of both approaches. For a direct unilateral close both peers would need to know the first update transaction and an attached settlement transaction, which is comparable to the approach presented in the paper (trigger transaction and settlement transaction).

The main advantage of getting rid of the trigger transaction seems to be that only two transactions (latest update and settlement) have to be committed to the blockchain in the unilateral case, compared to three (trigger, latest update, settlement) in the approach presented in the paper.

Bye, Carsten

Carsten Otto in reply to ZmnSCPxj permalink original

Hi ZmnSCPxj, Christian, list,

the paper is a bit confusing regarding the setup transaction, as it is not described formally. There also seems to be a mixup of "setup transaction" and "funding transaction", also named T_{u,0} without showing it in the diagrams.

In 3.1 the funding transaction is described as funding "to a multisig address". In the description of trigger transactions the change is described as "The output from the setup transaction is changed into a simple 2-of-2 multisig output" - which it already is?

As far as I understand the situation, the trigger transaction is needed because the broadcasted initial/funding/setup transaction includes an OP_CLV, which then starts the timer and could lead to premature settlement. Removing OP_CLV (and having in a transaction that is only published later when it is needed), i.e. by changing it to a simple multisig output, seems to solve this issue.

Could you (Christian?) explain how the "setup transaction" is supposed to look like without the changes described in section 4.2?

I like the idea proposed by ZmnSCPxj, but I'm not able to weigh the pro/cons of both approaches. For a direct unilateral close both peers would need to know the first update transaction and an attached settlement transaction, which is comparable to the approach presented in the paper (trigger transaction and settlement transaction).

The main advantage of getting rid of the trigger transaction seems to be that only two transactions (latest update and settlement) have to be committed to the blockchain in the unilateral case, compared to three (trigger, latest update, settlement) in the approach presented in the paper. As a minor advantage the peers do not need to remember the trigger transaction.

Bye, Carsten

Christian Decker in reply to ZmnSCPxj permalink original

ZmnSCPxj <ZmnSCPxj at protonmail.com> writes:

Quoted text (3 lines)
> Ha, no, looking at the detailed `SIGHASH_NOINPUT` spec, `hashPrevouts`, which normally commits to the other inputs, is blanked, so we do not commit to them either.  This means that `SIGHASH_NOINPUT` implicitly has a `SIGHASH_ANYONECANPAY`.
>
> (the BIP `SIGHASH_NOINPUT` in the eltoo pdf does not mention `hashSequence`, but it seems you managed to add that to your github BIP repository)

Yeah, Russell O'Connor pointed that difference out and I saw no point in committing to the hashSequence, so I amended both the paper and the BIP. The paper will get updated in a few days with the typos people have found, but I thought that the BIP discussion was more urgent to keep up to date, so I pushed that directly :-)

Christian Decker in reply to Carsten Otto permalink original

Carsten Otto <carsten.otto at andrena.de> writes:

Quoted text (4 lines)
> the paper is a bit confusing regarding the setup transaction, as it is
> not described formally. There also seems to be a mixup of "setup
> transaction" and "funding transaction", also named T_{u,0} without
> showing it in the diagrams.

The setup transaction is simply a transaction that spends some funds and creates a single output, which has the script from Figure 2, but since that would be a forward reference, I decided to handwave and call it a multisig. A simple fix would be to change the setup phase bullet point at the beginning of section 3, would that be sufficient?

Quoted text (4 lines)
> In 3.1 the funding transaction is described as funding "to a multisig
> address". In the description of trigger transactions the change is
> described as "The output from the setup transaction is changed into a
> simple 2-of-2 multisig output" - which it already is?

If instead of calling it a multisig we call it a multiparty output and reference the script in Figure 2, that'd be addressed as well.

Quoted text (9 lines)
> As far as I understand the situation, the trigger transaction is needed
> because the broadcasted initial/funding/setup transaction includes an
> OP_CLV, which then starts the timer and could lead to premature
> settlement. Removing OP_CLV (and having in a transaction that is only
> published later when it is needed), i.e. by changing it to a simple
> multisig output, seems to solve this issue.
>
> Could you (Christian?) explain how the "setup transaction" is supposed
> to look like without the changes described in section 4.2?

Well, it has arbitrary inputs, and a single output with the script from Figure 2, in the non-trigger case, and in the trigger case it'd be just a `2 A B 2 OP_CMSV`.

Carsten Otto in reply to Christian Decker permalink original

Hey Christian,

On Thu, May 03, 2018 at 12:51:01PM +0200, Christian Decker wrote:

Quoted text (5 lines)
> The setup transaction is simply a transaction that spends some funds and
> creates a single output, which has the script from Figure 2, but since
> that would be a forward reference, I decided to handwave and call it a
> multisig. A simple fix would be to change the setup phase bullet point
> at the beginning of section 3, would that be sufficient?

A first clarification, which just regards the naming, would be to use just one of "setup transaction" and "funding transaction". The symbol T_{u,0} is only used once, on page 6. I'd either remove it, or used it in other places (Fig. 1?), too.

Without your mail (thanks!) I did not see that the setup transaction output is complicated (has branches) as shown in Fig. 2. A clarification at the named bullet point would indeed help (although I see the issue of forward references).

One idea (just to get my idea across, I'm sure you can do better): old: "to a 2-of-2 multisig address" new: "to a script making use of 2-of-2 multisig"

Quoted text (2 lines)
> If instead of calling it a multisig we call it a multiparty output and
> reference the script in Figure 2, that'd be addressed as well.

I agree.

Quoted text (3 lines)
> Well, it has arbitrary inputs, and a single output with the script from
> Figure 2, in the non-trigger case, and in the trigger case it'd be just
> a `2 A B 2 OP_CMSV`.

Got it. Follow up question: would a second output (change) be OK? I see some advantages, but I'm not sure if it would work.

Thanks Carsten

ZmnSCPxj in reply to Carsten Otto permalink original

Good morning Carsten,

Quoted text (13 lines)
> > The setup transaction is simply a transaction that spends some funds and
> >
> > creates a single output, which has the script from Figure 2, but since
> >
> > that would be a forward reference, I decided to handwave and call it a
> >
> > multisig. A simple fix would be to change the setup phase bullet point
> >
> > at the beginning of section 3, would that be sufficient?
>
> A first clarification, which just regards the naming, would be to use
>
> just one of "setup transaction" and "funding transaction".

Calling it "funding transaction" is my fault, as I prefer that term since it matches in spirit the funding transaction in LN-penalty (Poon-Dryja).

Quoted text (19 lines)
> The symbol
>
> T_{u,0} is only used once, on page 6. I'd either remove it, or used it
>
> in other places (Fig. 1?), too.
>
> Without your mail (thanks!) I did not see that the setup transaction
>
> output is complicated (has branches) as shown in Fig. 2. A clarification
>
> at the named bullet point would indeed help (although I see the issue of
>
> forward references).
>
> One idea (just to get my idea across, I'm sure you can do better):
>
> old: "to a 2-of-2 multisig address"
>
> new: "to a script making use of 2-of-2 multisig"

Note, that when we add the trigger transaction later in the paper, the funding transaction output becomes an ordinary 2-of-2 multisig address. The complex script becomes relegated to the output of the trigger transaction.

So in the final design of eltoo, the funding transaction output is indeed a 2-of-2 multisig.

This is useful as the mutual close transaction (what the paper calls a "final settlement" transaction) just spends an ordinary 2-of-2 multisig and thus has a greater anonymity set, i.e. it prevents blockchain analysis from realizing that it was actually a channel (unless, of course, it was also tracking gossip from LN).

Quoted text (16 lines)
>
> > If instead of calling it a multisig we call it a multiparty output and
> >
> > reference the script in Figure 2, that'd be addressed as well.
>
> I agree.
>
> > Well, it has arbitrary inputs, and a single output with the script from
> >
> > Figure 2, in the non-trigger case, and in the trigger case it'd be just
> >
> > a `2 A B 2 OP_CMSV`.
>
> Got it. Follow up question: would a second output (change) be OK? I see
>
> some advantages, but I'm not sure if it would work.

Yes, it definitely would be OK. In fact, it is good to talk about funding outpoints rather than funding transactions. It is possible for a single Bitcoin transaction to serve as an anchor for several channels at once, and the BOLT spec supports this (but I know of no implementation that actually implements this). Basically, the funding outpoint is some transaction output that pays to a 2-of-2 multisig and which will be spent using some offchain mechanism, or a mutual close transaction --- this is what I call the "funding transaction pattern".

Regards, ZmnSCPxj

Quoted text (29 lines)
>
> Thanks
>
> Carsten
>
>
> -------------------------------------------------------------------------------------------------------------------------------------------------
>
> andrena objects ag
>
> Ganghoferstraße 70
>
> 80339 München
>
> http://www.andrena.de
>
> Vorstand: Hagen Buchwald, Dr. Dieter Kuhn, Stefan Schürle
>
> Aufsichtsratsvorsitzender: Rolf Hetzelberger
>
> Sitz der Gesellschaft: Karlsruhe
>
> Amtsgericht Mannheim, HRB 109694
>
> USt-IdNr. DE174314824
>
> Bitte beachten Sie auch unsere anstehenden Veranstaltungen:
>
> http://www.andrena.de/events
Corné Plooy in reply to Christian Decker permalink original

Hi Christian, ZmnSCPxj ,

Quoted text (11 lines)
>> - The CSV-encumberance on settlement transactions, which are the ones
>> which carry the contracts in the channel, affects all
>> absolute-timelocked contracts transported on the channel.  Compare to
>> Poon-Dryja, where commitment transactions themselves are unencumbered
>> by CSV, and we simply insert the revocation to spends of the contracts
>> being transported (i.e. the reason why we have HTLC-success and
>> HTLC-timeout transactions in BOLT spec).
> True, but as I argued in another mail, this is a fixed offset, that is
> in the same range as today's CLTV deltas for some nodes. So for the
> network of today using eltoo is roughly equivalent of adding another hop
> to our path :-)

Let me think how this is supposed to work (I can't find that other mail you're referring to):

I assume the HTLC outputs are in the settlement transaction. In case of a unilateral close while there are HTLCs present, the following sequence happens: 1. The trigger transaction is broadcasted. 2. One or more update transactions are broadcasted. These are not affected by the CSV condition and can be confirmed immediately. Once the last update transaction gets confirmed, its CSV clock for the settlement transaction starts. 3. The settlement transaction (containing HTLCs) can be broadcasted, but it will not be confirmed before the CSV time-out of the last update transaction. 4. At this point, the HTLC conditions become relevant. Before the HTLC time-out, the receiving side can access the funds with the preimage. After the timeout, the sending side can access the funds without the preimage.

If the HTLC time-out is before the start of step 4, then the sending side can try to get the funds back, even if the preimage was already released much earlier. For the safety of the receiving side, this situation must be avoided. So, if T is the (absolute) HTLC time-out time, S is the CSV time-out period and C is the expected worst-case time involved in confirming everything, then the receiving side of a HTLC must drop the channel on-chain before T - S - C. Obviously, HTLCs for which this time has already passed on creation must be rejected. Dropping on-chain is no longer needed if the HTLC is removed by a channel update before T - S - C.

What happens in case of a transaction time-out? Let's number the nodes 0, 1, ... on the route, and Tn the HTLC time-out between nodes n and n+1. For simplicity, assume the same S+C for all channels. If node n becomes unresponsive after accepting its incoming HTLC, then two moments in time are relevant: * T(n-1) * T(n-2) - S - C In case T(n-1) happens first, node n-1 knows it doesn't have to pay outgoing funds, so it can cooperatively cancel the incoming HTLC. This will propagate back immediately, keeping all channels open. In case T(n-2) - S - C happens first, node n-1 has to close its channel with n-2. On-chain, the HTLC conditions continue to apply, so for the rest, nothing changes. As soon as T(n-1) is reached, node n-1 knows the transaction has timed out, but it no longer has a way to propagate this knowledge to node n-2. For node n-2, two times are relevant: * T(n-2) * T(n-3) - S - C ... and the same steps are repeated. In this case, a transaction time-out leads to closing all channels on the route. This is a major DoS attack vector, and must be prevented.

Therefore, we must set T(n-1) > T(n-2) - S - C, so the HTLC time-out increment must be at least S+C.

Theoretically, it seems workable. What would be a practical value for S (the CSV time-out)? In the absence of watch towers, you'd want to set it to at least a couple of weeks, to allow yourself to go off-line on holiday without worrying about computer issues. However, a time-out increment of a couple of weeks *per hop* for the HTLCs adds up really quickly to unpractical values. Maybe the conclusion simply is that we really really need watchtowers? Otherwise, only professional parties that can manage near-100% uptime can safely perform transaction routing.

CJP

ZmnSCPxj in reply to Corné Plooy permalink original

Good morning Corne,

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On May 15, 2018 9:22 PM, Corné Plooy <corne at bitonic.nl> wrote:

Quoted text (28 lines)
> Hi Christian, ZmnSCPxj ,
>
> > > -   The CSV-encumberance on settlement transactions, which are the ones
> > >
> > >     which carry the contracts in the channel, affects all
> > >
> > >     absolute-timelocked contracts transported on the channel. Compare to
> > >
> > >     Poon-Dryja, where commitment transactions themselves are unencumbered
> > >
> > >     by CSV, and we simply insert the revocation to spends of the contracts
> > >
> > >     being transported (i.e. the reason why we have HTLC-success and
> > >
> > >     HTLC-timeout transactions in BOLT spec).
> > >
> > >     True, but as I argued in another mail, this is a fixed offset, that is
> > >
> > >     in the same range as today's CLTV deltas for some nodes. So for the
> > >
> > >     network of today using eltoo is roughly equivalent of adding another hop
> > >
> > >     to our path :-)
> > >
>
> Let me think how this is supposed to work (I can't find that other mail
>
> you're referring to):

I believe it is on bitcoin-dev: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-May/015916.html

Christian argues that the CSV delay (S in your treatment) is shared across all nodes in the route, but is not additive unlike the CLTV delay. In a heterogeneous network, the S is the maximum S among nodes along the route.

I argue elsewhere (https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/eltoo-a-simplified-update-mechanism-for-lightning-and-off-chain-contracts#m-907f7d6e) that even if the above is true, it does not mesh well with current routing algorithms; most current "shortest-path" algorithms do not handle well anything that is not additive-cost, and S is effectively the max S along the route.

C-lightning is considering to use a "find all paths" algorithm instead, which would simply filter out during route construction any routes that exceed maximum total delay and maximum forwarding fee. This probably works better with "try another route" technique imposed by Lightning forwarding, and would seamlessly support extensions like the above max S or the older "negative fees" idea better than "shortest-path" algorithms; this is done by the simple technique of not actually needing the shortest path (improving privacy by not using the shortest path (we currently add virtual randomized cost multipliers in routing) is already what we do anyway, which is another reason to switch from a "shortest-path" algorithm).

Regards, ZmnSCPxj

David A. Harding in reply to Christian Decker permalink original

Hi,

I finished a re-read of y'alls excellent paper describing Eltoo, and there was something that confused me:

Quoted text (2 lines)
> If the update transaction represents the last agreed upon state it can
> use relatively low fees being certain that it will not be replaced.

I don't understand why this is "certain"? State_2 can't replace State_3 on the block chain (ignoring reorgs) because S_2's nLockTime of n+2 doesn't satisify S_3's CLTV-enforced minimum state number/locktime of n+4. But in the mempool this constraint doesn't hold: if S_3 is in the mempool, S_2 can simply pay more fees than S_3 for RBF replacement.

A mempool replacement of S_3 with S_2 also invalidates the transaction containing S_3 until one of the participants rewrites it from binding to State_1's outpoint to binding to S_2's outpoint.

Unless I'm misunderstanding, this could perhaps be clarified to make clear that, even in the case of a cooperative close, monitoring for old states needs to continue until the final state has whatever number of confirmations a participant deems sufficient to make it immutable.

Thanks,

-Dave

P.S.: The paper I re-read was the version (as of yesterday) at blockstream.com/eltoo.pdf

    $ grep -a CreationDate eltoo.pdf
    /CreationDate (D:20180502232831+02'00')
    $ sha256sum eltoo.pdf
    aa630d637e4e1aedd91249d52609ab75b2eef2da8e4146e74f30e63c96fb7c26  eltoo.pdf
Christian Decker in reply to David A. Harding permalink original

"David A. Harding" <dave at dtrt.org> writes:

Quoted text (11 lines)
> I finished a re-read of y'alls excellent paper describing Eltoo, and
> there was something that confused me:
>
>> If the update transaction represents the last agreed upon state it can
>> use relatively low fees being certain that it will not be replaced.
>
> I don't understand why this is "certain"?  State_2 can't replace State_3
> on the block chain (ignoring reorgs) because S_2's nLockTime of n+2
> doesn't satisify S_3's CLTV-enforced minimum state number/locktime of
> n+4.  But in the mempool this constraint doesn't hold: if S_3 is in the
> mempool, S_2 can simply pay more fees than S_3 for RBF replacement.

That is true, we can't prevent S_2 to make it into the blockchain, but we can make sure it doesn't have any effect (aside from wasting some fees), by simply binding S_3 to it immediately afterwards. So if S_3 is the last agreed upon state, we can bind it to the funding output or any intermediate ones, i.e., when an intermediate update makes it into the blockchain. Eventually S_3, bound to some prior update output and ideally directly to the funding output, will make it into the blockchain at which point the game is over. Intermediate updates may have leaked into the blockchain, but did not unlock the intermediate settlement path and the blockchain was paid with the fees attached to the intermediate updates.

Quoted text (3 lines)
> A mempool replacement of S_3 with S_2 also invalidates the transaction
> containing S_3 until one of the participants rewrites it from binding to
> State_1's outpoint to binding to S_2's outpoint.

It should be noted that anyone can perform the rewriting, and it's easy to do so, by just following the funding output and knowing the final update.

Quoted text (4 lines)
> Unless I'm misunderstanding, this could perhaps be clarified to make
> clear that, even in the case of a cooperative close, monitoring for old
> states needs to continue until the final state has whatever number of
> confirmations a participant deems sufficient to make it immutable.

Good point, we did not mention that finality has to be ensured, and that in a case of a reorg that unconfirms the update we might have to perform additional rewrites. This is similar to LN-penalty where we actually need to make sure that the penalty transaction is final and doesn't get reorged out.

Cheers, Christian

David A. Harding in reply to Christian Decker permalink original

On Tue, Jun 19, 2018 at 04:46:32PM +0200, Christian Decker wrote:

Quoted text (3 lines)
> That is true, we can't prevent S_2 to make it into the blockchain, but
> we can make sure it doesn't have any effect (aside from wasting some
> fees), by simply binding S_3 to it immediately afterwards.

Right, but I'm picking on the phrasing in the paper here, which seems to imply that once the final settlement transaction enters the mempool with a reasonable fee, its confirmation---and the safe close of the channel---is "certain." I don't think that's the case and I think the phrasing might be accidentally misleading to readers who don't have a good grasp of mempool behavior.

Quoted text (3 lines)
> It should be noted that anyone can perform the rewriting, and it's easy
> to do so, by just following the funding output and knowing the final
> update.

Anyone can rewrite a SIGHASH_NOINPUT input's outpoint, but the actual transaction containing the settlement is expected to have (at least) two inputs, with the second one originating the fees. That second input's signature is (I assume) using SIGHASH_ALL to commit to all outpoints in the transaction, so it can't be arbitrarily rewritten by a third-party to apply to a different state outpoint---and so I think we're dependent on a motivated person (e.g. one of the channel participants) performing the rewrite so that the rewritten final settlement transaction pays fees.

Thanks,

-Dave

David A. Harding in reply to David A. Harding permalink original

On Tue, Jun 19, 2018 at 02:02:51PM -0400, David A. Harding wrote:

Quoted text (6 lines)
> Anyone can rewrite a SIGHASH_NOINPUT input's outpoint, but the actual
> transaction containing the settlement is expected to have (at least) two
> inputs, with the second one originating the fees.  That second input's
> signature is (I assume) using SIGHASH_ALL to commit to all outpoints in
> the transaction, so it can't be arbitrarily rewritten by a third-party
> to apply to a different state outpoint

I realized that the fee-paying input could possibly be signed with SIGHASH_ALL|SIGHASH_ANYONECANPAY to allow anyone to arbitrarily rewrite the other input signed with SIGHASH_NOINPUT. However, this reminded me of the well-known DoS against transactions signed with SIGHASH_ANYONECANPAY[1], which seems to apply generally against SIGHASH_NOINPUT as well and may allow theft from HTLCs.

## DoS against Eltoo settlements

Alice and Mallory have a channel with some state updates. Alice tries to initiate a cooperate close, but Mallory stalls and instead broadcasts the trigger transaction and the first state (state 0). Notably, the first state is bundled into a very large vsize transaction with a low feerate. State 1 is added to another very large low-feerate transaction, as are states 2 through 9.

Alice could in theory RBF the state 0 transaction, but per BIP125 rule #3, she needs to pay an absolute fee greater than all the transactions being replaced (not just a higher feerate). That could cost a lot. Alice could also create a transaction that binds the final state to the state 9 transaction and attempt CPFP, but increasing the feerate for the transaction ancestor group to a satisfactory degree would cost the same amount as RBF.

So Alice is stuck waiting for states 0-9 to confirm before the final state can be confirmed. During recent periods of full mempools on default nodes, the waiting time for 10 nBTC/vbyte transactions has been more than two weeks.

## HTLC theft

If Mallory is able to introduce significant settlement delays, HTLC security is compromised. For example, imagine this route:

    Mallory <-> Alice <-> Bob

Mallory orders a widget from Bob and pays via LN by sending 1 BTC to Alice hashlocked and timelocked, which Alice forwards to Bob also hashlocked and timelocked. Mallory releases the preimage to Bob, who claims the funds from Alice and ships the widget, giving Alice the preimage.

At this point, Mallory broadcasts the transactions described in the preceding section.

If the low feerate of states 0-9 prevent them from confirming before the timeout, Mallory can create a transaction containing a dishonest final state that executes the refund branch. Like before, she can bury this in an ancestor transaction chain that would be cost prohibitive for Alice to RBF.

Considered independently, this is a very expensive attack for Mallory, and so perhaps impractical. But Mallory can join forces with someone already creating large low-feerate consolidation transactions. Better yet, from Mallory's perspective, she can execute the attack against hundreds of channels at once (creating long chains of ancestor transactions that are large in aggregate rather than individually large), using the aggregate size of all the victims' channels against each of the individual victims.

Thanks,

-Dave

[1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2014-August/006438.html
Rusty Russell in reply to David A. Harding permalinkalso on bitcoin-dev original

"David A. Harding" <dave at dtrt.org> writes:

Quoted text (14 lines)
> On Tue, Jun 19, 2018 at 02:02:51PM -0400, David A. Harding wrote:
>> Anyone can rewrite a SIGHASH_NOINPUT input's outpoint, but the actual
>> transaction containing the settlement is expected to have (at least) two
>> inputs, with the second one originating the fees.  That second input's
>> signature is (I assume) using SIGHASH_ALL to commit to all outpoints in
>> the transaction, so it can't be arbitrarily rewritten by a third-party
>> to apply to a different state outpoint
>
> I realized that the fee-paying input could possibly be signed with
> SIGHASH_ALL|SIGHASH_ANYONECANPAY to allow anyone to arbitrarily
> rewrite the other input signed with SIGHASH_NOINPUT.  However, this
> reminded me of the well-known DoS against transactions signed with
> SIGHASH_ANYONECANPAY[1], which seems to apply generally against
> SIGHASH_NOINPUT as well and may allow theft from HTLCs.

Yes, RBF Rule #3 again :( It makes RBF unusable in adversarial conditions, and it's not miner incentive-compatible.

The only mitigations I have been able to come up with are:

1. Reduce the RBF grouping depth to 2, not 10.  This doesn't help
   here though, since you can still have ~infinite fan-out of txs
   (create 1000 outputs, spend each with a 400ksipa tx).
2. Revert #3 to a simple "greater feerate" rule, but delay propagation
   proportional to tx weight, say 60 seconds (fuzzed) for a 400 ksipa
   tx.  That reduces your ability to spam the network (you can always
   connect directly to nodes and waste their time and bandwidth, but you
   can do that pretty much today).

Frankly, I'd also like a similar mechanism to not reject low-fee txs (above 250 satoshi per ksipa) but simply not propagate them. Drop them after 60 seconds if there's no CPFP to increase their effective feerate. That would allow us to use CPFP on lightning commitment txs today, without having to guess what fees will be sometime in the future.

Cheers, Rusty.

Quoted text (62 lines)
> ## DoS against Eltoo settlements
>
> Alice and Mallory have a channel with some state updates.  Alice tries
> to initiate a cooperate close, but Mallory stalls and instead broadcasts
> the trigger transaction and the first state (state 0).  Notably, the
> first state is bundled into a very large vsize transaction with a low
> feerate.  State 1 is added to another very large low-feerate
> transaction, as are states 2 through 9.
>
> Alice could in theory RBF the state 0 transaction, but per BIP125 rule
> #3, she needs to pay an absolute fee greater than all the transactions
> being replaced (not just a higher feerate).  That could cost a lot.
> Alice could also create a transaction that binds the final state to the
> state 9 transaction and attempt CPFP, but increasing the feerate for the
> transaction ancestor group to a satisfactory degree would cost the same
> amount as RBF.
>
> So Alice is stuck waiting for states 0-9 to confirm before the final
> state can be confirmed.  During recent periods of full mempools on
> default nodes, the waiting time for 10 nBTC/vbyte transactions has been
> more than two weeks.
>
> ## HTLC theft
>
> If Mallory is able to introduce significant settlement delays, HTLC
> security is compromised.  For example, imagine this route:
>
>     Mallory <-> Alice <-> Bob
>
> Mallory orders a widget from Bob and pays via LN by sending 1 BTC to
> Alice hashlocked and timelocked, which Alice forwards to Bob also
> hashlocked and timelocked.  Mallory releases the preimage to Bob, who
> claims the funds from Alice and ships the widget, giving Alice the
> preimage.
>
> At this point, Mallory broadcasts the transactions described in the
> preceding section.
>
> If the low feerate of states 0-9 prevent them from confirming before the
> timeout, Mallory can create a transaction containing a dishonest final
> state that executes the refund branch.  Like before, she can bury this
> in an ancestor transaction chain that would be cost prohibitive for Alice
> to RBF.
>
> Considered independently, this is a very expensive attack for Mallory,
> and so perhaps impractical.  But Mallory can join forces with someone
> already creating large low-feerate consolidation transactions.  Better
> yet, from Mallory's perspective, she can execute the attack against
> hundreds of channels at once (creating long chains of ancestor
> transactions that are large in aggregate rather than individually
> large), using the aggregate size of all the victims' channels against
> each of the individual victims.
>
> Thanks,
>
> -Dave
>
> [1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2014-August/006438.html
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Anthony Towns in reply to Christian Decker permalink original

(bitcoin-dev dropped from cc)

On Mon, Apr 30, 2018 at 05:41:38PM +0200, Christian Decker wrote:

Quoted text (2 lines)
> eltoo is a drop-in replacement for the penalty based invalidation
> mechanism that is used today in the Lightning specification. [...]

I think you can simplify eltoo further, both in the way the transactions work and in the game theory ensuring people play fair.

In essence: rather than having a funding transaction spending to address "X", and a set of ratcheting states that spend from-and-to the same address "X", I think it's feasible to have a simpler ratchet mechanism:

  (1) funding address: multisig by A and B as usual
  (2) commit to state >=N by A
  (3a) commit to state N by A after delay D; or
  (3b) commit to state M (M>=N) by B

I believe those transactions (while partially signed, before posting to the blockchain) would look like:

  (1) pay to "2 A1 B1 2 OP_CHECKMULTISIG"
  (2) signed by B1, nlocktime set to (N+E)
      pay to "(N+E) OP_CLTV OP_DROP 2 A2a B2a 2 OP_CHECKMULTISIG"
  (3a) signed by B2a, nSequence set to the channel pay to self delay,
       nlocktime set to (N+E)
       pays to the channel balances / HTLCs, with no delays or
       revocation clauses
  (3b) signed by A2a with SIGHASH_NOINPUT_UNSAFE, nlocktime set to (M+E)
       pays to the channel balances / HTLCs, with no delays or
       revocation clauses

You spend (2)+delay+(3a)+[claim balance/HTLC] if your counterparty goes away. You spend (2) and your counterparty spends (3b) if you're both monitoring the blockchain. (3a) and (3b) should have the same tx size, fee rate and outputs.

(A1, A2a are keys held by A; B1, B2a are keys held by B; E is LOCKTIME_THRESHOLD; N is the current state number)

That seems like it has a few nice features:

 - txes at (3a) and (3b) can both pay current market fees with minimal
   risk, and can be CPFPed by a tx spending your own channel balance
 - txes at (2) can pay a non-zero fee, provided it's constant for the
   lifetime of the channel (to conform with the NOINPUT rules)
 - if both parties are monitoring the blockchain, then the channel
   can be fully closed in a single block, by (2)+(3b)+[balance/HTLC
   claims], and the later txes can do CPFP for tx (2).
 - both parties can claim their funds as soon as the other can, no
   matter who initiates the close
 - you only need 3 pre-signed txes for the current state; the txes
   for claiming HTLCs/balances don't need to be half-signed (unless
   you're doing them via schnorr scriptless scripts etc)

The game theory looks fine to me. If you're posting transaction (2), then you can choose between a final state F, paying you f and your counterparty b-f, or some earlier state N, paying you n, and your counterparty b-n. If f>n, it makes sense for you to choose F, in which case your counterparty is also forced to choose state F for (3b) and you're forced to choose F for (3a). If n>f, then if you choose N, your counterparty will either choose state F because b-f>b-n and you will receive f as before, or will choose some other state M>N, where b-m>b-f, and you will receive m<f<n, which is a worse result. So the rational strategy seems to me to be to choose either F all the time, or at worst an earlier state N where every payment since then went from you towards your counterparty, on the off-chance they're not watching the blockchain and you can get that money back.

Note that unlike eltoo, dealing with attempted cheating in this scenario has no extra cost over a completely fair/honest close. Always attempting to cheat by trying to reclaim the last few payments if they were towards your counterparty might help ensure implementations handle cheating well?

Quoted text (3 lines)
> eltoo addresses some of the issues we encountered while speficying and
> implementing the Lightning Network. For example outsourcing becomes very
> simple since old states becoming public can't hurt us anymore.

The scheme above isn't great for (untrusted) outsourcing, because if you reveal enough for an adversary to post tx (3b) for state N, then they can then collaborate with your channel counterparty to roll you back from state N+1000 back to state N.

With eltoo if they do the same, then you have the opportunity to catch them at it, and play state N+1000 to the blockchain -- but if you're monitoring the blockchain carefully enough to catch that, why are you outsourcing in the first place? If you're relying on multiple outsourcers to keep each other honest, then I think you run into challenges paying them to publish the txes for you.

Thoughts? Apart from still requiring NOINPUT and not working with adversarial outsourcing, this seems like it works nicely to me, but maybe I missed something...

Cheers, aj

Anthony Towns in reply to Christian Decker permalink original

On Mon, Apr 30, 2018 at 05:41:38PM +0200, Christian Decker wrote:

Quoted text (2 lines)
> eltoo is a drop-in replacement for the penalty based invalidation
> mechanism that is used today in the Lightning specification. [...]

Maybe this is obvious, but in case it's not, re: the locktime-based sequencing in eltoo:

 "any number above 0.500 billion is interpreted as a UNIX timestamp, and
  with a current timestamp of ~1.5 billion, that leaves about 1 billion
  numbers that are interpreted as being in the past"

I think if you had a more than a 1B updates to your channel (50 updates per second for 4 months?) I think you could reset the locktime by rolling over to use new update keys. When unilaterally closing you'd need to use an extra transaction on-chain to do that roll-over, but you'd save a transaction if you did a cooperative close.

ie, rather than:

  [funding] -> [coop close / re-fund] -> [update 23M] -> [HTLCs etc]
or
  [funding] -> [coop close / re-fund] -> [coop close]
you could have:
  [funding] -> [update 1B] -> [update 23,310,561 with key2] -> [HTLCs]
or
  [funding] -> [coop close]

You could repeat this when you get another 1B updates, making unilateral closes more painful, but keeping cooperative closes cheap.

Cheers, aj

Christian Decker in reply to Anthony Towns permalink original

Thanks Anthony for pointing this out, I was not aware we could roll keypairs to reset the state numbers.

I basically thought that 1billion updates is more than I would ever do, since with splice-in / splice-out operations we'd be re-anchoring on-chain on a regular basis anyway.

On Wed, Oct 10, 2018 at 10:25 AM Anthony Towns <aj at erisian.com.au> wrote:

Quoted text (35 lines)
> On Mon, Apr 30, 2018 at 05:41:38PM +0200, Christian Decker wrote:
> > eltoo is a drop-in replacement for the penalty based invalidation
> > mechanism that is used today in the Lightning specification. [...]
>
> Maybe this is obvious, but in case it's not, re: the locktime-based
> sequencing in eltoo:
>
>  "any number above 0.500 billion is interpreted as a UNIX timestamp, and
>   with a current timestamp of ~1.5 billion, that leaves about 1 billion
>   numbers that are interpreted as being in the past"
>
> I think if you had a more than a 1B updates to your channel (50 updates
> per second for 4 months?) I think you could reset the locktime by rolling
> over to use new update keys. When unilaterally closing you'd need to
> use an extra transaction on-chain to do that roll-over, but you'd save
> a transaction if you did a cooperative close.
>
> ie, rather than:
>
>   [funding] -> [coop close / re-fund] -> [update 23M] -> [HTLCs etc]
> or
>   [funding] -> [coop close / re-fund] -> [coop close]
>
> you could have:
>   [funding] -> [update 1B] -> [update 23,310,561 with key2] -> [HTLCs]
> or
>   [funding] -> [coop close]
>
> You could repeat this when you get another 1B updates, making unilateral
> closes more painful, but keeping cooperative closes cheap.
>
> Cheers,
> aj
>
>
ZmnSCPxj in reply to Christian Decker permalink original

Another way would be to always have two update transactions, effectively creating a larger overall counter:

[anchor] -> [update highbits] -> [update lobits] -> [settlement]

We normally update [update lobits] until it saturates. If lobits saturates we increment [update highbits] and reset [update lobits] to the lowest valid value.

This will provide a single counter with 10^18 possible updates, which should be enough for a while even without reanchoring.

Regards, ZmnSCPxj

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

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Friday, October 12, 2018 1:37 AM, Christian Decker <decker.christian at gmail.com> wrote:

Quoted text (42 lines)
> Thanks Anthony for pointing this out, I was not aware we could
> roll keypairs to reset the state numbers.
>
> I basically thought that 1billion updates is more than I would
> ever do, since with splice-in / splice-out operations we'd be
> re-anchoring on-chain on a regular basis anyway.
>
> On Wed, Oct 10, 2018 at 10:25 AM Anthony Towns <aj at erisian.com.au> wrote:
>
>> On Mon, Apr 30, 2018 at 05:41:38PM +0200, Christian Decker wrote:
>>> eltoo is a drop-in replacement for the penalty based invalidation
>>> mechanism that is used today in the Lightning specification. [...]
>>
>> Maybe this is obvious, but in case it's not, re: the locktime-based
>> sequencing in eltoo:
>>
>>  "any number above 0.500 billion is interpreted as a UNIX timestamp, and
>>   with a current timestamp of ~1.5 billion, that leaves about 1 billion
>>   numbers that are interpreted as being in the past"
>>
>> I think if you had a more than a 1B updates to your channel (50 updates
>> per second for 4 months?) I think you could reset the locktime by rolling
>> over to use new update keys. When unilaterally closing you'd need to
>> use an extra transaction on-chain to do that roll-over, but you'd save
>> a transaction if you did a cooperative close.
>>
>> ie, rather than:
>>
>>   [funding] -> [coop close / re-fund] -> [update 23M] -> [HTLCs etc]
>> or
>>   [funding] -> [coop close / re-fund] -> [coop close]
>>
>> you could have:
>>   [funding] -> [update 1B] -> [update 23,310,561 with key2] -> [HTLCs]
>> or
>>   [funding] -> [coop close]
>>
>> You could repeat this when you get another 1B updates, making unilateral
>> closes more painful, but keeping cooperative closes cheap.
>>
>> Cheers,
>> aj
Christian Decker in reply to ZmnSCPxj permalink original

Great find ZmnSCPxj, we can also have an adaptive scheme here, in which we start with a single update transaction, and then at ~90% of the available range we add a second. This is starting to look a bit like the DMC invalidation tree :-) But realistically speaking I don't think 1B updates is going to be exhausted any time soon, but the adaptive strategy gets the best of both worlds.

Cheers, Christian

On Fri, Oct 12, 2018 at 5:21 AM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (69 lines)
> Another way would be to always have two update transactions, effectively
> creating a larger overall counter:
>
> [anchor] -> [update highbits] -> [update lobits] -> [settlement]
>
> We normally update [update lobits] until it saturates.  If lobits
> saturates we increment [update highbits] and reset [update lobits] to the
> lowest valid value.
>
> This will provide a single counter with 10^18 possible updates, which
> should be enough for a while even without reanchoring.
>
> Regards,
> ZmnSCPxj
>
>
> Sent with ProtonMail <https://protonmail.com> Secure Email.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Friday, October 12, 2018 1:37 AM, Christian Decker <
> decker.christian at gmail.com> wrote:
>
> Thanks Anthony for pointing this out, I was not aware we could
> roll keypairs to reset the state numbers.
>
> I basically thought that 1billion updates is more than I would
> ever do, since with splice-in / splice-out operations we'd be
> re-anchoring on-chain on a regular basis anyway.
>
>
>
> On Wed, Oct 10, 2018 at 10:25 AM Anthony Towns <aj at erisian.com.au> wrote:
>
>> On Mon, Apr 30, 2018 at 05:41:38PM +0200, Christian Decker wrote:
>> > eltoo is a drop-in replacement for the penalty based invalidation
>> > mechanism that is used today in the Lightning specification. [...]
>>
>> Maybe this is obvious, but in case it's not, re: the locktime-based
>> sequencing in eltoo:
>>
>>  "any number above 0.500 billion is interpreted as a UNIX timestamp, and
>>   with a current timestamp of ~1.5 billion, that leaves about 1 billion
>>   numbers that are interpreted as being in the past"
>>
>> I think if you had a more than a 1B updates to your channel (50 updates
>> per second for 4 months?) I think you could reset the locktime by rolling
>> over to use new update keys. When unilaterally closing you'd need to
>> use an extra transaction on-chain to do that roll-over, but you'd save
>> a transaction if you did a cooperative close.
>>
>> ie, rather than:
>>
>>   [funding] -> [coop close / re-fund] -> [update 23M] -> [HTLCs etc]
>> or
>>   [funding] -> [coop close / re-fund] -> [coop close]
>>
>> you could have:
>>   [funding] -> [update 1B] -> [update 23,310,561 with key2] -> [HTLCs]
>> or
>>   [funding] -> [coop close]
>>
>> You could repeat this when you get another 1B updates, making unilateral
>> closes more painful, but keeping cooperative closes cheap.
>>
>> Cheers,
>> aj
>>
>>
>
Anthony Towns in reply to Christian Decker permalink original

On 13 October 2018 7:12:03 pm GMT+09:00, Christian Decker <decker.christian at gmail.com> wrote:

Quoted text (95 lines)
>Great find ZmnSCPxj, we can also have an adaptive scheme here, in which
>we
>start with a single update transaction, and then at ~90% of the
>available
>range we add a second. This is starting to look a bit like the DMC
>invalidation tree :-)
>But realistically speaking I don't think 1B updates is going to be
>exhausted any time soon, but the adaptive strategy gets the best of
>both worlds.
>
>Cheers,
>Christian
>
>On Fri, Oct 12, 2018 at 5:21 AM ZmnSCPxj <ZmnSCPxj at protonmail.com>
>wrote:
>
>> Another way would be to always have two update transactions,
>effectively
>> creating a larger overall counter:
>>
>> [anchor] -> [update highbits] -> [update lobits] -> [settlement]
>>
>> We normally update [update lobits] until it saturates.  If lobits
>> saturates we increment [update highbits] and reset [update lobits] to
>the
>> lowest valid value.
>>
>> This will provide a single counter with 10^18 possible updates, which
>> should be enough for a while even without reanchoring.
>>
>> Regards,
>> ZmnSCPxj
>>
>>
>> Sent with ProtonMail <https://protonmail.com> Secure Email.
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Friday, October 12, 2018 1:37 AM, Christian Decker <
>> decker.christian at gmail.com> wrote:
>>
>> Thanks Anthony for pointing this out, I was not aware we could
>> roll keypairs to reset the state numbers.
>>
>> I basically thought that 1billion updates is more than I would
>> ever do, since with splice-in / splice-out operations we'd be
>> re-anchoring on-chain on a regular basis anyway.
>>
>>
>>
>> On Wed, Oct 10, 2018 at 10:25 AM Anthony Towns <aj at erisian.com.au>
>wrote:
>>
>>> On Mon, Apr 30, 2018 at 05:41:38PM +0200, Christian Decker wrote:
>>> > eltoo is a drop-in replacement for the penalty based invalidation
>>> > mechanism that is used today in the Lightning specification. [...]
>>>
>>> Maybe this is obvious, but in case it's not, re: the locktime-based
>>> sequencing in eltoo:
>>>
>>>  "any number above 0.500 billion is interpreted as a UNIX timestamp,
>and
>>>   with a current timestamp of ~1.5 billion, that leaves about 1
>billion
>>>   numbers that are interpreted as being in the past"
>>>
>>> I think if you had a more than a 1B updates to your channel (50
>updates
>>> per second for 4 months?) I think you could reset the locktime by
>rolling
>>> over to use new update keys. When unilaterally closing you'd need to
>>> use an extra transaction on-chain to do that roll-over, but you'd
>save
>>> a transaction if you did a cooperative close.
>>>
>>> ie, rather than:
>>>
>>>   [funding] -> [coop close / re-fund] -> [update 23M] -> [HTLCs etc]
>>> or
>>>   [funding] -> [coop close / re-fund] -> [coop close]
>>>
>>> you could have:
>>>   [funding] -> [update 1B] -> [update 23,310,561 with key2] ->
>[HTLCs]
>>> or
>>>   [funding] -> [coop close]
>>>
>>> You could repeat this when you get another 1B updates, making
>unilateral
>>> closes more painful, but keeping cooperative closes cheap.
>>>
>>> Cheers,
>>> aj
>>>
>>>
>>

Hmm - the range grows by one every second though, so as long as you don't go through a billion updates per second, you can go to 100% of the range, knowing that by the time you have to increment, you'll have 115% of the original range available, meaning you never need more than two transactions (until locktime overflows anyway) for the commitment, even at 900MHz transaction rates...

Cheers, aj