<oembed><type>rich</type><version>1.0</version><title>Antoine Riard [ARCHIVE] wrote</title><author_name>Antoine Riard [ARCHIVE] (npub1vj…4x8dd)</author_name><author_url>https://yabu.me/npub1vjzmc45k8dgujppapp2ue20h3l9apnsntgv4c0ukncvv549q64gsz4x8dd</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2021-05-27&#xA;📝 Original message:Hi,&#xA;&#xA;This post is pursuing a wider discussion around better fee-bumping&#xA;strategies for second-layer protocols. It draws out a comparison between&#xA;input-based and CPFP fee-bumping techniques, and their apparent trade-offs&#xA;in terms of onchain footprint, tx-relay bandwidth rebroadcast, batching&#xA;opportunity and mempool flexibility.&#xA;&#xA;Thanks to Darosior for reviews, ideas and discussions.&#xA;&#xA;## Child-Pay-For-Parent&#xA;&#xA;CPFP is a mature fee-bumping technique, known and used for a while in the&#xA;Bitcoin ecosystem. However, its usage in contract protocols with&#xA;distrusting counterparties raised some security issues. As mempool&#39;s chain&#xA;of unconfirmed transactions are limited in size, if any output is spendable&#xA;by any contract participant, it can be leveraged as a pinning vector to&#xA;downgrade odds of transaction confirmation [0].&#xA;&#xA;That said, contract transactions interested to be protected under the&#xA;carve-out logic require to add a new output for any contract participant,&#xA;even if ultimately only one of them serves as an anchor to attach a CPFP.&#xA;&#xA;## Input-Based&#xA;&#xA;I think input-based fee-bumping has been less studied as fee-bumping&#xA;primitive for L2s [1]. One variant of input-based fee-bumping usable today&#xA;is the leverage of the SIGHASH_ANYONECANPAY/SIGHASH_SINGLE malleability&#xA;flags. If the transaction is the latest stage of the contract, a bumping&#xA;input can be attached just-in-time, thus increasing the feerate of the&#xA;whole package.&#xA;&#xA;However, as of today, input-based fee-bumping doesn&#39;t work to bump first&#xA;stages of contract transactions as it&#39;s destructive of the txid, and as&#xA;such breaks chain of pre-signed transactions. A first improvement would be&#xA;the deployment of the SIGHASH_ANYPREVOUT softfork proposal. This new&#xA;malleability flag allows a transaction to be signed without reference to&#xA;any specific previous output. That way,  spent transactions can be&#xA;fee-bumped without altering validity of the chain of transactions.&#xA;&#xA;Even assuming SIGHASH_ANYPREVOUT, if the first stage contract transaction&#xA;includes multiple outputs (e.g the LN&#39;s commitment tx has multiple HTLC&#xA;outputs), SIGHASH_SINGLE can&#39;t be used and the fee-bumping input value&#xA;might be wasted. This edge can be smoothed by broadcasting a preliminary&#xA;fan-out transaction with a set of outputs providing a range of feerate&#xA;points for the bumped transaction.&#xA;&#xA;This overhead could be smoothed even further in the future with more&#xA;advanced sighash malleability flags like SIGHASH_IOMAP, allowing&#xA;transaction signers to commit to a map of inputs/outputs [2]. In the&#xA;context of input-based, the overflowed fee value could be redirected to an&#xA;outgoing output.&#xA;&#xA;## Onchain Footprint&#xA;&#xA;CPFP: One anchor output per participant must be included in the commitment&#xA;transaction. To this anchor must be attached a child transaction with 2&#xA;inputs (one for the commitment, one for the bumping utxo) and 1 output.&#xA;Onchain footprint: 2 inputs + 3 outputs.&#xA;&#xA;Input-based (today): If the bumping utxo is offering an adequate feerate&#xA;point in function of network mempools congestion at time of broadcast, only&#xA;1 input. If a preliminary fan-out transaction to adjust feerate point must&#xA;be broadcasted first, 1 input and 2 outputs more must be accounted for.&#xA;Onchain footprint: 2 inputs + 3 outputs.&#xA;&#xA;Input-based (SIGHASH_ANYPREVOUT+SIGHASH_IOMAP): As long as the bumping&#xA;utxo&#39;s value is wide enough to cover the worst-case of mempools congestion,&#xA;the bumped transaction can be attached 1 input and 1 output. Onchain&#xA;footprint: 1 input + 1 output.&#xA;&#xA;## Tx-Relay Bandwidth Rebroadcast&#xA;&#xA;CPFP: In the context of multi-party protocols, we should assume bounded&#xA;rationality of the participants w.r.t to an unconfirmed spend of the&#xA;contract utxo across network mempools. Under this assumption, the bumped&#xA;transaction might have been replaced by a concurrent state. To guarantee&#xA;efficiency of the CPFP the whole chain of transactions should be&#xA;rebroadcast, perhaps wasting bandwidth consumption for a still-identical&#xA;bumped transaction [3]. Rebroadcast footprint: the whole chain of&#xA;transactions.&#xA;&#xA;Input-based (today): In case of rebroadcast, the fee-bumping input is&#xA;attached to the root of the chain of transactions and as such breaks the&#xA;chain validity in itself. Beyond the rebroadcast of the updated root under&#xA;replacement policy, the remaining transactions must be updated and&#xA;rebroadcast. Rebroadcast footprint: the whole chain of transactions.&#xA;&#xA;Input-based(SIGHASH_ANYPREVOUT+SIGHASH_IOMAP): In case of rebroadcast, the&#xA;fee-bumping is attached to the root of the chain of transactions but it&#xA;doesn&#39;t break the chain validity in itself. Assuming a future mempool&#xA;acceptance logic to authorize in-place substitution, the rest of the chain&#xA;could be preserved. Rebroadcast footprint: the root of the chain of&#xA;transactions.&#xA;&#xA;## Fee-Bumping Batching&#xA;&#xA;CPFP: In the context of multi-party protocols, in optimistic scenarios, we&#xA;can assume aggregation of multiple chains of transactions. For e.g, a LN&#xA;operator is desirous to non-cooperatively close multiple channels at the&#xA;same time and would like to combine their fee-bumping. With CPFP, one&#xA;anchor output and one bumping input must be consumed per aggregated chain,&#xA;even if the child transaction fields can be shared. Batching perf: 1&#xA;input/1 output per aggregated chain.&#xA;&#xA;Input-based (today): Unless the contract allows interactivity, multiple&#xA;chains of transactions cannot be aggregated. One bumping input must be&#xA;attached per chain, though if a preliminary fan-out transaction is relied&#xA;on to offer multiple feerate points, transaction fields can be shared.&#xA;Batching perf: 1 input/1 output per aggregated chain.&#xA;&#xA;Input-based (SIGHASH_ANYPREVOUT+SIGHASH_IOMAP): Multiple chains of&#xA;transactions might be aggregated together *non-interactively*. One bumping&#xA;input and outgoing output can be attached to the aggregated root. Batching&#xA;perf: 1 input/1 output per aggregation.&#xA;&#xA;## Fee-Bumping Mempool Flexibility&#xA;&#xA;CPFP: In the context of multi-party protocols, one of your counterparties&#xA;might build a branch of transactions from one of the root outputs thus&#xA;saturating the in-mempool package limits. To avoid these shenanigans, LN&#xA;channels are relying on the carve-out mechanism. Though, the carve-out&#xA;mechanism includes its own limitation and doesn&#39;t scale beyond 2 contract&#xA;participants.&#xA;&#xA;Input-based: The root of the chain of transaction is the package&#39;s oldest&#xA;ancestor, so package limits don&#39;t restrain its acceptance and it works&#xA;whatever the number of contract participants.&#xA;&#xA;To conclude, this post scores 2 fee-bumping primitives for multi-party&#xA;protocols on a range of factors. It hopes to unravel the ground for a real&#xA;feerate performance framework of second-layers protocols .&#xA;&#xA;Beyond that, few points can be highlighted a) future soft forks allow&#xA;significant onchain footprint savings, especially in case of batching, b)&#xA;future package relay bandwidth efficiency should account for rebroadcast&#xA;frequency of CPFPing multi-party protocols. On this latter point one&#xA;follow-up might be to evaluate differing package relay *announcement*&#xA;schemes in function of odds of non-cooperative protocol broadcast/odds of&#xA;concurrent broadcast/rebroadcast frequencies.&#xA;&#xA;Thoughts ?&#xA;&#xA;Cheers,&#xA;Antoine&#xA;&#xA;[0]&#xA;https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html&#xA;[1] Beyond the revault architecture :&#xA;https://github.com/revault/practical-revault/blob/master/revault.pdf&#xA;[2] Already proposed a while back :&#xA;https://bitcointalk.org/index.php?topic=252960.0&#xA;[3] In theory, an already-relayed transaction shouldn&#39;t pass Core&#39;s&#xA;`filterInventoryKnown`. In practice, if the transaction is announced as&#xA;part of a package_id, the child might have changed, not the parent, leading&#xA;to a redundant relay of the latter.&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20210527/73916240/attachment.html&gt;</html></oembed>