From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id E462EC000B for ; Sun, 13 Jun 2021 05:57:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C276E605E6 for ; Sun, 13 Jun 2021 05:57:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.098 X-Spam-Level: X-Spam-Status: No, score=-2.098 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lMeQl9eU1AQv for ; Sun, 13 Jun 2021 05:57:13 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by smtp3.osuosl.org (Postfix) with ESMTPS id 1BA20605DD for ; Sun, 13 Jun 2021 05:57:13 +0000 (UTC) Received: by mail-lj1-x232.google.com with SMTP id e2so15264881ljk.4 for ; Sat, 12 Jun 2021 22:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aNdcI3HotNjz+HD6YhtaobMXsPQbqp5NaTG1blJwOvs=; b=T/40E9cuvdLvOUK/gaf9U0Z7Mb9aMVp8HzAf3dTSPjBD6Ay9m8J0VDNIlV9GxA9Lda 6T9aVIQjR2kDyPhXOx7dlSJuc5IlpfeOkSWgjF7XPAuNAsuyAElidfM6ZGcHnOINqtBK QPLpAJyyoJHBmJ8qNJtD0AvbyHRumxTe4sqUdObKv0vP9Uyi1d+FXag2E8KFvvreXkLr e6eErV87vj9/KUGHjS3G17lrr9LR8+OCYbpgHyz802bxYLBV/CpANSvoizlwSKV1CEu3 qfq9lbSBbSLfkYdmUbeTlOZ8lDHoP05khKAEQxdwZbi3S2O6XRNxbprEQwGuhEl2CUlk PwFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aNdcI3HotNjz+HD6YhtaobMXsPQbqp5NaTG1blJwOvs=; b=L+TuNnH+SxUQL+b8qwVBvstC4Fbfrl7zmL+IrqLshl8vFSzbT+/eOnarbGznRYMga0 2t+FO5Iz7t7BqDNmUDl9rVYz0f3a1+gi4K8ai42d1Ti4tSgMmqjiZBOJY/oyYfSFBmFM fuxb2SWdoodXDTxI0btJTy0Fs7qkuPVYiO57kuk3EnXAEewjYDxIRIglIkCOgRgr48ae ULc4YeVOQJKRrNzANYips2xh/qyBfbcep/ugwQ4QjbRheVpA/dV7Lh+UOHIMdreoYiYK j4hiRYxRSgkSVApJ1F3otwvDilIKwe63rgEYgSodWO9gd9aIrEw2yIa0gn6yfC+bY96j 8jPg== X-Gm-Message-State: AOAM532yvx5ECb7LybNXCn3Ss34wgbTZQa7tUH9MjUkhPCybDu+puSgu HgySc89jfDBumWPD0/se1GWbVjkfMOIrhnPrl94= X-Google-Smtp-Source: ABdhPJx2vXEwhsH2daPJ9t+AoC8us5IbXkWtFco6tSqzjFDRAzlaElZYZZ6fxFFqHKQuQ2zfiKV10czMUMNpaU3QXDU= X-Received: by 2002:a2e:b5c3:: with SMTP id g3mr9062329ljn.245.1623563830887; Sat, 12 Jun 2021 22:57:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Lloyd Fournier Date: Sun, 13 Jun 2021 15:56:43 +1000 Message-ID: To: Antoine Riard Content-Type: multipart/alternative; boundary="00000000000069057405c49f6916" X-Mailman-Approved-At: Sun, 13 Jun 2021 08:00:22 +0000 Cc: Bitcoin Protocol Discussion Subject: Re: [bitcoin-dev] A Stroll through Fee-Bumping Techniques : Input-Based vs Child-Pay-For-Parent X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jun 2021 05:57:16 -0000 --00000000000069057405c49f6916 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 11 Jun 2021 at 07:45, Antoine Riard wrote= : > Hi Lloyd, > > Thanks for this tx mutation proposal extending the scope of fee-bumping > techniques. IIUC, the serves as a pointer to increase the > output amount by value to recover the recompute the transaction hash > against which the original signature is valid ? > Right. > Let's do a quick analysis of this scheme. > * onchain footprint : one tapleaf per contract participant, with O(log n) > increase of witness size, also one output per contract participant > Yes but we can fix this (see below). * tx-relay bandwidth rebroadcast : assuming aforementioned in-place mempool > substitution policy, the mutated transaction > * batching : fee-bumping value is extract from contract transaction itself, > so O(n) per contract > * mempool flexibility : the mutated transaction > * watchtower key management : to enable outsourcing, the mutating key mus= t > be shared, in theory enabling contract value siphoning to miner fees ? > Yes. You could use OP_LESSTHAN to make sure the value being deducted by the watchtower is not above a threshold. > Further, I think tx mutation scheme can be achieved in another way, with > SIGHASH_ANYAMOUNT. A contract participant tapscript will be the following= : > > > > Where is committed with SIGHASH_ANYAMOUNT, blanking > nValue of one or more outputs. That way, the fee-to-contract-value > distribution can be unilaterally finalized at a later time through the > finalizing key [0]. > Yes, that's also a way to do it. I was trying to preserve the original external key signature in my attempt but this is probably not necessary. L2 protocols could just exchange two signatures instead. One optimistic one on the external key and one pessimistic SIGHASH_ANYAMOUNT one on the . > Note, I think that the tx mutation proposal relies on interactivity in th= e > worst-case scenario where a counterparty wants to increase its fee-bumpin= g > output from the contract balance. This interactivity may lure a > counterparty to alway lock the worst-case fee-bumping reserve in the > output. I believe anchor output enables more "real-time" fee-bumping > reserve adjustment ? > Hmmm well I was hoping that you wouldn't need interaction ever. I can see that my commitment TX example was too contrived because it has balance outputs that go exclusively to one party. Let's take a better example: A PTLC output with both timeout and success pre-signed transactions spending from it. We must only let the person offering the PTLC reduce the output of the timeout tx and the converse for the success tx. Note very carefully that if we naively apply OP_CHECKSIG_MUTATED or SIGHASH_ANYAMOUNT with one tapleaf for each party then we risk one party being able to lower the other party's output by doing a switcharoo on the tapleaf after they see the signature for their counterparty's tx in the mempool. In your example you could fix it by having a different but this means we can't compress by just using the taproot internal/external key. What about this: Instead of party specific "finalizing_alice_key" or p1-fee-bump-key as I denoted it, we just use the key of the output whose value we are reducing. This also solves the O(log(n)) tapleaves for OP_CHECKSIG_MUTATED approach as well -- just have one tapleaf for fee bumping but authorize it under the key of the output we are reducing. Thus we need something like OP_PUSH_TAPROOT_OUTPUT_KEY which takes the taproot external key at that output (fail if not taproot) and puts it on the stack. So to be clear you have the on the witness stack rather than having it fixed in a particular tapleaf (as per my original post) and then use OP_DUP to pass it to both OP_CHECKSIG_MUTATED and OP_PUSH_TAPROOT_OUTPUT_KEY. This makes a lot of sense as it matches the semantics of what we are trying to achieve: allow the owner of an output (whether an individual or group) to reduce that output's value to pay a higher fee. Furthermore this removes all keys from the tapleaf since they are all aliased to either the input we are spending or one of the output keys of the tx we are spending to. This is quite a big improvement over my original idea. This works for lightning commit tx and for the case of a PTLC contract. It also seems to work for the DLC funding output. I'd be interested to know if anyone can think of a protocol where this would be inconvenient or impossible to use as the main pre-signed tx fee bumping system. Cheers, LL Le dim. 6 juin 2021 =C3=A0 22:28, Lloyd Fournier a > =C3=A9crit : > >> Hi Antione, >> >> Thanks for bringing up this important topic. I think there might be >> another class of solutions over input based, CPFP and sponsorship. I'll >> call them tx mutation schemes. The idea is that you can set a key that c= an >> increase the fee by lowering a particular output after the tx is signed >> without invalidating the signature. The premise is that anytime you need= to >> bump the fee of a transaction you must necessarily have funds in an outp= ut >> that are going to you and therefore you can sacrifice some of them to >> increase the fee. This is obviously destructive to txids so child presig= ned >> transactions will have to use ANYPREVOUT as in your proposal. The advant= age >> is that it does not require keeping extra inputs around to bump the fee. >> >> So imagine a new opcode OP_CHECKSIG_MUTATED >> . >> This would check that is valid against if the >> current transaction had the output at reduced by .= To >> make this more efficient, if the public key is one byte: 0x02 it referen= ces >> the taproot *external key* (similar to how ANYPREVOUT uses 0x01 to refer= to >> internal key[1]). >> Now for our protocol we want both parties (p1 and p2) to be able to fee >> bump a commitment transaction. They use MuSig to sign the commitment tx >> under the external key with a decent fee for the current conditions. But= in >> case it proves insufficient they have added the following two leaves to >> their key in the funding output as a backup so that p1 and p2 can >> unilaterally bump the fee of anything they sign spending from the fundin= g >> output: >> >> 1. OP_CHECKSIG_MUTATED(0, 0x02, , ) >> OP_CHECKSIGADD(p1-fee-bump-key, ) OP_2 >> OP_NUMEQUALVERIFY >> 2. OP_CHECKSIG_MUTATED(1, 0x02, , ) >> OP_CHECKSIGADD(p2-fee-bump-key, ) OP_2 >> OP_NUMEQUALVERIFY >> >> where <...> indicates the thing comes from the witness stack. >> So to bump the fee of the commit tx after it has been signed either part= y >> takes the and adds a signature under their >> fee-bump-key for the new tx and reveals their fee bump leaf. >> is checked against the old transaction while the fe= e >> bumped transaction is checked against the fee bump key. >> >> I know I have left out how to change mempool eviction rules to >> accommodate this kind of fee bumping without DoS or pinning attacks but >> hopefully I have demonstrated that this class of solutions also exists. >> >> [1] >> https://github.com/ajtowns/bips/blob/bip-anyprevout/bip-0118.mediawiki >> >> Cheers, >> >> LL >> >> >> >> On Fri, 28 May 2021 at 07:13, Antoine Riard via bitcoin-dev < >> bitcoin-dev@lists.linuxfoundation.org> wrote: >> >>> Hi, >>> >>> This post is pursuing a wider discussion around better fee-bumping >>> strategies for second-layer protocols. It draws out a comparison betwee= n >>> input-based and CPFP fee-bumping techniques, and their apparent trade-o= ffs >>> in terms of onchain footprint, tx-relay bandwidth rebroadcast, batching >>> opportunity and mempool flexibility. >>> >>> Thanks to Darosior for reviews, ideas and discussions. >>> >>> ## Child-Pay-For-Parent >>> >>> CPFP is a mature fee-bumping technique, known and used for a while in >>> the Bitcoin ecosystem. However, its usage in contract protocols with >>> distrusting counterparties raised some security issues. As mempool's ch= ain >>> of unconfirmed transactions are limited in size, if any output is spend= able >>> by any contract participant, it can be leveraged as a pinning vector to >>> downgrade odds of transaction confirmation [0]. >>> >>> That said, contract transactions interested to be protected under the >>> carve-out logic require to add a new output for any contract participan= t, >>> even if ultimately only one of them serves as an anchor to attach a CPF= P. >>> >>> ## Input-Based >>> >>> I think input-based fee-bumping has been less studied as fee-bumping >>> primitive for L2s [1]. One variant of input-based fee-bumping usable to= day >>> is the leverage of the SIGHASH_ANYONECANPAY/SIGHASH_SINGLE malleability >>> flags. If the transaction is the latest stage of the contract, a bumpin= g >>> input can be attached just-in-time, thus increasing the feerate of the >>> whole package. >>> >>> However, as of today, input-based fee-bumping doesn't work to bump firs= t >>> stages of contract transactions as it's destructive of the txid, and as >>> such breaks chain of pre-signed transactions. A first improvement would= be >>> the deployment of the SIGHASH_ANYPREVOUT softfork proposal. This new >>> malleability flag allows a transaction to be signed without reference t= o >>> any specific previous output. That way, spent transactions can be >>> fee-bumped without altering validity of the chain of transactions. >>> >>> Even assuming SIGHASH_ANYPREVOUT, if the first stage contract >>> transaction includes multiple outputs (e.g the LN's commitment tx has >>> multiple HTLC outputs), SIGHASH_SINGLE can't be used and the fee-bumpin= g >>> input value might be wasted. This edge can be smoothed by broadcasting = a >>> preliminary fan-out transaction with a set of outputs providing a range= of >>> feerate points for the bumped transaction. >>> >>> This overhead could be smoothed even further in the future with more >>> advanced sighash malleability flags like SIGHASH_IOMAP, allowing >>> transaction signers to commit to a map of inputs/outputs [2]. In the >>> context of input-based, the overflowed fee value could be redirected to= an >>> outgoing output. >>> >>> ## Onchain Footprint >>> >>> CPFP: One anchor output per participant must be included in the >>> commitment transaction. To this anchor must be attached a child transac= tion >>> with 2 inputs (one for the commitment, one for the bumping utxo) and 1 >>> output. Onchain footprint: 2 inputs + 3 outputs. >>> >>> Input-based (today): If the bumping utxo is offering an adequate feerat= e >>> point in function of network mempools congestion at time of broadcast, = only >>> 1 input. If a preliminary fan-out transaction to adjust feerate point m= ust >>> be broadcasted first, 1 input and 2 outputs more must be accounted for. >>> Onchain footprint: 2 inputs + 3 outputs. >>> >>> Input-based (SIGHASH_ANYPREVOUT+SIGHASH_IOMAP): As long as the bumping >>> utxo's value is wide enough to cover the worst-case of mempools congest= ion, >>> the bumped transaction can be attached 1 input and 1 output. Onchain >>> footprint: 1 input + 1 output. >>> >>> ## Tx-Relay Bandwidth Rebroadcast >>> >>> CPFP: In the context of multi-party protocols, we should assume bounded >>> rationality of the participants w.r.t to an unconfirmed spend of the >>> contract utxo across network mempools. Under this assumption, the bumpe= d >>> transaction might have been replaced by a concurrent state. To guarante= e >>> efficiency of the CPFP the whole chain of transactions should be >>> rebroadcast, perhaps wasting bandwidth consumption for a still-identica= l >>> bumped transaction [3]. Rebroadcast footprint: the whole chain of >>> transactions. >>> >>> Input-based (today): In case of rebroadcast, the fee-bumping input is >>> attached to the root of the chain of transactions and as such breaks th= e >>> chain validity in itself. Beyond the rebroadcast of the updated root un= der >>> replacement policy, the remaining transactions must be updated and >>> rebroadcast. Rebroadcast footprint: the whole chain of transactions. >>> >>> Input-based(SIGHASH_ANYPREVOUT+SIGHASH_IOMAP): In case of rebroadcast, >>> the fee-bumping is attached to the root of the chain of transactions bu= t it >>> doesn't break the chain validity in itself. Assuming a future mempool >>> acceptance logic to authorize in-place substitution, the rest of the ch= ain >>> could be preserved. Rebroadcast footprint: the root of the chain of >>> transactions. >>> >>> ## Fee-Bumping Batching >>> >>> CPFP: In the context of multi-party protocols, in optimistic scenarios, >>> we can assume aggregation of multiple chains of transactions. For e.g, = a LN >>> operator is desirous to non-cooperatively close multiple channels at th= e >>> same time and would like to combine their fee-bumping. With CPFP, one >>> anchor output and one bumping input must be consumed per aggregated cha= in, >>> even if the child transaction fields can be shared. Batching perf: 1 >>> input/1 output per aggregated chain. >>> >>> Input-based (today): Unless the contract allows interactivity, multiple >>> chains of transactions cannot be aggregated. One bumping input must be >>> attached per chain, though if a preliminary fan-out transaction is reli= ed >>> on to offer multiple feerate points, transaction fields can be shared. >>> Batching perf: 1 input/1 output per aggregated chain. >>> >>> Input-based (SIGHASH_ANYPREVOUT+SIGHASH_IOMAP): Multiple chains of >>> transactions might be aggregated together *non-interactively*. One bump= ing >>> input and outgoing output can be attached to the aggregated root. Batch= ing >>> perf: 1 input/1 output per aggregation. >>> >>> ## Fee-Bumping Mempool Flexibility >>> >>> CPFP: In the context of multi-party protocols, one of your >>> counterparties might build a branch of transactions from one of the roo= t >>> outputs thus saturating the in-mempool package limits. To avoid these >>> shenanigans, LN channels are relying on the carve-out mechanism. Though= , >>> the carve-out mechanism includes its own limitation and doesn't scale >>> beyond 2 contract participants. >>> >>> Input-based: The root of the chain of transaction is the package's >>> oldest ancestor, so package limits don't restrain its acceptance and it >>> works whatever the number of contract participants. >>> >>> To conclude, this post scores 2 fee-bumping primitives for multi-party >>> protocols on a range of factors. It hopes to unravel the ground for a r= eal >>> feerate performance framework of second-layers protocols . >>> >>> Beyond that, few points can be highlighted a) future soft forks allow >>> significant onchain footprint savings, especially in case of batching, = b) >>> future package relay bandwidth efficiency should account for rebroadcas= t >>> frequency of CPFPing multi-party protocols. On this latter point one >>> follow-up might be to evaluate differing package relay *announcement* >>> schemes in function of odds of non-cooperative protocol broadcast/odds = of >>> concurrent broadcast/rebroadcast frequencies. >>> >>> Thoughts ? >>> >>> Cheers, >>> Antoine >>> >>> [0] >>> https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/0= 16518.html >>> [1] Beyond the revault architecture : >>> https://github.com/revault/practical-revault/blob/master/revault.pdf >>> [2] Already proposed a while back : >>> https://bitcointalk.org/index.php?topic=3D252960.0 >>> [3] In theory, an already-relayed transaction shouldn't pass Core's >>> `filterInventoryKnown`. In practice, if the transaction is announced as >>> part of a package_id, the child might have changed, not the parent, lea= ding >>> to a redundant relay of the latter. >>> _______________________________________________ >>> bitcoin-dev mailing list >>> bitcoin-dev@lists.linuxfoundation.org >>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev >>> >> --00000000000069057405c49f6916 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On = Fri, 11 Jun 2021 at 07:45, Antoine Riard <antoine.riard@gmail.com> wrote:
Hi Lloyd,

Thanks for this tx mutation p= roposal extending the scope of fee-bumping techniques. IIUC, the <output= _index> serves as a pointer to increase the output amount by value to re= cover the recompute the transaction hash against which the original signatu= re is valid ?

Right.
<= br>

Let'= ;s do a quick analysis of this scheme.
* onchain footprint : one tapleaf= per contract participant, with O(log n) increase of witness size, also one= output per contract participant
=C2=A0
Yes but we can fix this (see below).

* tx-relay bandwidth rebroadcast : a= ssuming aforementioned in-place mempool substitution policy, the mutated tr= ansaction
* batching : fee-bumping value is extract from contract transa= ction itself, so O(n) per contract
* mempool flexibility : the mutated t= ransaction
* watchtower key management : to enable outsourcing, the muta= ting key must be shared, in theory enabling contract value siphoning to min= er fees ?
=C2=A0
Yes. You could use OP_LES= STHAN to make sure the value being deducted by the watchtower is not above = a threshold.


Further, I think tx mutation scheme can be ach= ieved in another way, with SIGHASH_ANYAMOUNT. A contract participant tapscr= ipt will be the following :

<contract_key> <finalizing_alic= e_key>

Where <contract_signature> is committed with SIGHASH= _ANYAMOUNT, blanking nValue of one or more outputs. That way, the fee-to-co= ntract-value distribution can be unilaterally finalized at a later time thr= ough the finalizing key [0].
=C2=A0
Ye= s, that's also a way to do it. I was trying to preserve the original ex= ternal key signature in my attempt but this is probably not necessary. L2 p= rotocols could just exchange two signatures instead. One optimistic one on = the external key and one pessimistic SIGHASH_ANYAMOUNT one on the <contr= act_key>.


Note, I think that the tx mutation proposal re= lies on interactivity in the worst-case scenario where a counterparty wants= to increase its fee-bumping output from the contract balance. This interac= tivity may lure a counterparty to alway lock the worst-case fee-bumping res= erve in the output. I believe anchor output enables more "real-time&qu= ot; fee-bumping reserve adjustment ?

Hmmm well I was hopin= g that you wouldn't need interaction ever. I can see that my commitment= TX example was too contrived because it has balance outputs that go exclus= ively to one party.
Let's take a be= tter example: A PTLC output with both timeout and success pre-signed transa= ctions spending from it. We must only let the person offering the PTLC redu= ce the output of the timeout tx and the converse for the success tx.
Note very carefully that if we naively apply OP_CHECKSIG_MUTATED or SIGHA= SH_ANYAMOUNT with one tapleaf for each party then we risk one party being a= ble to lower the other party's output by doing a switcharoo on the tapl= eaf after they see the signature for their counterparty's tx in the mem= pool. In your example you could fix it by having a different <contract_k= ey> but this means we can't compress <contract_key> by just us= ing the taproot internal/external key.

What ab= out this: Instead of party specific "finalizing_alice_key" or p1-= fee-bump-key as I denoted it, we just use the key of the output whose value= we are reducing. This also solves the O(log(n)) tapleaves for OP_CHECKSIG_= MUTATED approach as well -- just have one tapleaf for fee bumping but autho= rize it under the key of the output we are reducing. Thus we need something= like OP_PUSH_TAPROOT_OUTPUT_KEY <output index> which takes the tapro= ot external key at that output (fail if not taproot) and puts it on the sta= ck. So to be clear you have the <output index> on the witness stack r= ather than having it fixed in a particular tapleaf (as per my original post= ) and then use OP_DUP to pass it to both OP_CHECKSIG_MUTATED and OP_PUSH_TA= PROOT_OUTPUT_KEY.
This makes a lot of sense as it matches the sem= antics of what we are trying to achieve: allow the owner of an output (whet= her an individual or group) to reduce that output's value to pay a high= er fee.
Furthermore this removes all keys from the tapleaf since = they are all aliased to either the input we are spending or one of the outp= ut keys of the tx we are spending to. This is quite a big improvement over = my original idea.

This works for lightning com= mit tx and for the case of a PTLC contract. It also seems to work for the D= LC funding output. I'd be interested to know if anyone can think of a p= rotocol where this would be inconvenient or impossible to use as the main p= re-signed tx fee bumping system.

Cheers,
<= /div>

LL

Le=C2=A0dim. 6 juin 2021 =C3=A0=C2=A022:28, Lloyd Fournier= <lloyd.fourn= @gmail.com> a =C3=A9crit=C2=A0:
Hi Antione,

Thanks for bringing up this important topic. I think there might be = another class of solutions over input based, CPFP and sponsorship. I'll= call them tx mutation schemes. The idea is that you can set a key that can= increase the fee by lowering a particular output after the tx is signed wi= thout invalidating the signature.=20 The premise is that anytime you need to bump the fee of a transaction you = must necessarily have funds in an output that are going to you and therefor= e you can sacrifice some of them to increase the fee. This is obviously des= tructive to txids so child presigned transactions will have to use ANYPREVO= UT as in your proposal. The advantage is that it does not require keeping e= xtra inputs around to bump the fee.

So imagine= a new opcode OP_CHECKSIG_MUTATED <output index>=20 <publickey> <value> <signature>.
This would ch= eck that <signature> is valid against <publickey> if the curren= t transaction had the output at <output index> reduced by <value&g= t;. To make this more efficient, if the public key is one byte: 0x02 it ref= erences the taproot *external key* (similar to how ANYPREVOUT uses 0x01 to = refer to internal key[1]).
Now for our protocol we want both = parties (p1 and p2) to be able to fee bump a commitment transaction. They u= se MuSig to sign the commitment tx under the external key with a decent fee= for the current conditions. But in case it proves insufficient they have a= dded the following two leaves to their key in the funding output as a backu= p so that p1 and p2 can unilaterally bump the fee of anything they sign spe= nding from the funding output:

1. OP_CHECKSIG_= MUTATED(0, 0x02, <fee-bump-value>,=20 <original-signature>) OP_CHECKSIGADD(p1-fee-bump-key, <p1-fee-bump= -signature>)=C2=A0 OP_2 OP_NUMEQUALVERIFY
2.=20 OP_CHECKSIG_MUTATED(1, 0x02, <fee-bump-value>,=20 <original-signature>) OP_CHECKSIGADD(p2-fee-bump-key, <p2-fee-bump= -signature>) OP_2 OP_NUMEQUALVERIFY

where <.= ..> indicates the thing comes from the witness stack.
So to bu= mp the fee of the commit tx after it has been signed either party takes the= <original-signature> and adds a signature under their fee-bump-key f= or the new tx and reveals their fee bump leaf. <original-signature> i= s checked against the old transaction while the fee bumped transaction is c= hecked against the fee bump key.

I know I have left out how to change mempool eviction rules to accommodate = this kind of fee bumping without DoS or pinning attacks but hopefully I hav= e demonstrated that this class of solutions also exists.

=

Cheers,

LL


On Fri, 2= 8 May 2021 at 07:13, Antoine Riard via bitcoin-dev <bitcoin-dev@lists.li= nuxfoundation.org> wrote:
Hi,

This post is pursuing a wider = discussion around better fee-bumping strategies for second-layer protocols.= It draws out a comparison between input-based and CPFP fee-bumping techniq= ues, and their apparent trade-offs in terms of onchain footprint, tx-relay = bandwidth rebroadcast, batching opportunity and mempool flexibility.
Thanks to Darosior for reviews, ideas and discussions.

## Child-Pay= -For-Parent

CPFP is a mature fee-bumping technique, known and used f= or a while in the Bitcoin ecosystem. However, its usage in contract protoco= ls with distrusting counterparties raised some security issues. As mempool&= #39;s chain of unconfirmed transactions are limited in size, if any output = is spendable by any contract participant, it can be leveraged as a pinning = vector to downgrade odds of transaction confirmation [0].

That said,= contract transactions interested to be protected under the carve-out logic= require to add a new output for any contract participant, even if ultimate= ly only one of them serves as an anchor to attach a CPFP.

## Input-B= ased

I think input-based fee-bumping has been less studied as fee-bu= mping primitive for L2s [1]. One variant of input-based fee-bumping usable = today is the leverage of the SIGHASH_ANYONECANPAY/SIGHASH_SINGLE malleabili= ty flags. If the transaction is the latest stage of the contract, a bumping= input can be attached just-in-time, thus increasing the feerate of the who= le package.

However, as of today, input-based fee-bumping doesn'= t work to bump first stages of contract transactions as it's destructiv= e of the txid, and as such breaks chain of pre-signed transactions. A first= improvement would be the deployment of the SIGHASH_ANYPREVOUT softfork pro= posal. This new malleability flag allows a transaction to be signed without= reference to any specific previous output. That way,=C2=A0 spent transacti= ons can be fee-bumped without altering validity of the chain of transaction= s.

Even assuming SIGHASH_ANYPREVOUT, if the first stage contract tra= nsaction includes multiple outputs (e.g the LN's commitment tx has mult= iple HTLC outputs), SIGHASH_SINGLE can't be used and the fee-bumping in= put value might be wasted. This edge can be smoothed by broadcasting a prel= iminary fan-out transaction with a set of outputs providing a range of feer= ate points for the bumped transaction.

This overhead could be smooth= ed even further in the future with more advanced sighash malleability flags= like SIGHASH_IOMAP, allowing transaction signers to commit to a map of inp= uts/outputs [2]. In the context of input-based, the overflowed fee value co= uld be redirected to an outgoing output.

## Onchain Footprint
CPFP: One anchor output per participant must be included in the commitment= transaction. To this anchor must be attached a child transaction with 2 in= puts (one for the commitment, one for the bumping utxo) and 1 output. Oncha= in footprint: 2 inputs + 3 outputs.

Input-based (today): If the bump= ing utxo is offering an adequate feerate point in function of network mempo= ols congestion at time of broadcast, only 1 input. If a preliminary fan-out= transaction to adjust feerate point must be broadcasted first, 1 input and= 2 outputs more must be accounted for. Onchain footprint: 2 inputs + 3 outp= uts.

Input-based (SIGHASH_ANYPREVOUT+SIGHASH_IOMAP): As long as the = bumping utxo's value is wide enough to cover the worst-case of mempools= congestion, the bumped transaction can be attached 1 input and 1 output. O= nchain footprint: 1 input + 1 output.

## Tx-Relay Bandwidth Rebroadc= ast

CPFP: In the context of multi-party protocols, we should assume = bounded rationality of the participants w.r.t to an unconfirmed spend of th= e contract utxo across network mempools. Under this assumption, the bumped = transaction might have been replaced by a concurrent state. To guarantee ef= ficiency of the CPFP the whole chain of transactions should be rebroadcast,= perhaps wasting bandwidth consumption for a still-identical bumped transac= tion [3]. Rebroadcast footprint: the whole chain of transactions.

In= put-based (today): In case of rebroadcast, the fee-bumping input is attache= d to the root of the chain of transactions and as such breaks the chain val= idity in itself. Beyond the rebroadcast of the updated root under replaceme= nt policy, the remaining transactions must be updated and rebroadcast. Rebr= oadcast footprint: the whole chain of transactions.

Input-based(SIGH= ASH_ANYPREVOUT+SIGHASH_IOMAP): In case of rebroadcast, the fee-bumping is a= ttached to the root of the chain of transactions but it doesn't break t= he chain validity in itself. Assuming a future mempool acceptance logic to = authorize in-place substitution, the rest of the chain could be preserved. = Rebroadcast footprint: the root of the chain of transactions.

## Fee= -Bumping Batching

CPFP: In the context of multi-party protocols, in = optimistic scenarios, we can assume aggregation of multiple chains of trans= actions. For e.g, a LN operator is desirous to non-cooperatively close mult= iple channels at the same time and would like to combine their fee-bumping.= With CPFP, one anchor output and one bumping input must be consumed per ag= gregated chain, even if the child transaction fields can be shared. Batchin= g perf: 1 input/1 output per aggregated chain.

Input-based (today): = Unless the contract allows interactivity, multiple chains of transactions c= annot be aggregated. One bumping input must be attached per chain, though i= f a preliminary fan-out transaction is relied on to offer multiple feerate = points, transaction fields can be shared. Batching perf: 1 input/1 output p= er aggregated chain.

Input-based (SIGHASH_ANYPREVOUT+SIGHASH_IOMAP):= Multiple chains of transactions might be aggregated together *non-interact= ively*. One bumping input and outgoing output can be attached to the aggreg= ated root. Batching perf: 1 input/1 output per aggregation.

## Fee-B= umping Mempool Flexibility

CPFP: In the context of multi-party proto= cols, one of your counterparties might build a branch of transactions from = one of the root outputs thus saturating the in-mempool package limits. To a= void these shenanigans, LN channels are relying on the carve-out mechanism.= Though, the carve-out mechanism includes its own limitation and doesn'= t scale beyond 2 contract participants.

Input-based: The root of the= chain of transaction is the package's oldest ancestor, so package limi= ts don't restrain its acceptance and it works whatever the number of co= ntract participants.

To conclude, this post scores 2 fee-bumping pri= mitives for multi-party protocols on a range of factors. It hopes to unrave= l the ground for a real feerate performance framework of second-layers prot= ocols .

Beyond that, few points can be highlighted a) future soft fo= rks allow significant onchain footprint savings, especially in case of batc= hing, b) future package relay bandwidth efficiency should account for rebro= adcast frequency of CPFPing multi-party protocols. On this latter point one= follow-up might be to evaluate differing package relay *announcement* sche= mes in function of odds of non-cooperative protocol broadcast/odds of concu= rrent broadcast/rebroadcast frequencies.

Thoughts ?

Cheers,Antoine

[0] https://lists.lin= uxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
[1]= Beyond the revault architecture : https://github.c= om/revault/practical-revault/blob/master/revault.pdf
[2] Already pro= posed a while back : https://bitcointalk.org/index.php?topic=3D252960= .0
[3] In theory, an already-relayed transaction shouldn't pass = Core's `filterInventoryKnown`. In practice, if the transaction is annou= nced as part of a package_id, the child might have changed, not the parent,= leading to a redundant relay of the latter.
_______________________________________________
bitcoin-dev mailing list
= bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mail= man/listinfo/bitcoin-dev
--00000000000069057405c49f6916--