From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 17CA5C0032 for ; Fri, 23 Sep 2022 15:18:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D3E3D40A12 for ; Fri, 23 Sep 2022 15:18:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D3E3D40A12 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=AfR7+564 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 Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lkMQEq0O3j3x for ; Fri, 23 Sep 2022 15:18:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0ED87409D7 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0ED87409D7 for ; Fri, 23 Sep 2022 15:18:33 +0000 (UTC) Received: by mail-pl1-x635.google.com with SMTP id l10so445481plb.10 for ; Fri, 23 Sep 2022 08:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date; bh=H1M22LPSZF5vzFDhhnYEkFBkYj/DwVqk7Q41S+kkj5o=; b=AfR7+564MGxiBsWVexf6Y9aTmFBUNyOkKvKq++hkpbQ2zRMwB/CKlgTEkMq/3lvAoy wfe7IYgIYpnyJlsTEVgRmFjcTN+eBXpSBWinG3Oonw9MVgWIhLR8saAwBsXi7MECXNyH dEHIgpggsuj0woBwRw/yQTFLhefMhcvVtGOkWsVWtPoPEpHLoFwdL7igouI1rjDzDyRe EsSqiVDghCr8/zDaOzhvWtDj4LbSW27gjSUVCRoCkE56Vfb6mX4BCUc2Qb6REW29FkBA T4/yJdN/gRCS4EgnB72e8drqr4mHnP7DgtUzBI030OIUGTYbjV51KzyG77tNAg6xoCUj 3TjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date; bh=H1M22LPSZF5vzFDhhnYEkFBkYj/DwVqk7Q41S+kkj5o=; b=LlzDIr2tqexgA66Lzwbboiq8Kn9cqwqzWMw6BSjBIjGSg8L/WCtNqi/Shk1SR0uDfy JkbvPQzpvFa9j8Bzy8xM9KkKWmWKiWXMNelfG+QmuxR5rhJoGdlRu9K7O+BzNntTDhjd S+lHDM/UaMX1LJ8PHPpQkRp9zghmedAln3yBIgm8JxAGbfUM07Gbehp8RBRaTMUQ/xr4 9yPunE4Ssb3FyWWPkhzs1nv9Nce08WCvqwJbp952Pk7XcsoJn4ZOGFsTe3S7wPUTwnrD zJndwcQpkRLDp4IRx6RpYppvh8R7iy9KDgKfpVt4RMTXpZlwIZG1JAqO0HQStVFNKwKz s0AA== X-Gm-Message-State: ACrzQf3feB4FlladVwHC392h8YQs8TjeTgCp/vwBtmpOh8DXNi/tc6rD L1JpxZ60HmfZbWx7m950UmwaPq/BiKfki076iNFABtAAknI= X-Google-Smtp-Source: AMsMyM7jaZk+VV44vWoOerMaB1L5kA3k8Gbjs+wlzaZeF1nXDD1tlLuuL3VDjYSn01AdKJBNaCVzFoaDW0HfgvLtEk4= X-Received: by 2002:a17:902:e805:b0:178:230b:57e3 with SMTP id u5-20020a170902e80500b00178230b57e3mr9187872plg.102.1663946312963; Fri, 23 Sep 2022 08:18:32 -0700 (PDT) MIME-Version: 1.0 From: Gloria Zhao Date: Fri, 23 Sep 2022 16:18:21 +0100 Message-ID: To: Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="000000000000e8db4a05e959b07b" X-Mailman-Approved-At: Fri, 23 Sep 2022 15:26:41 +0000 Subject: [bitcoin-dev] New transaction policies (nVersion=3) for contracting protocols 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: Fri, 23 Sep 2022 15:18:36 -0000 --000000000000e8db4a05e959b07b Content-Type: text/plain; charset="UTF-8" Hi everyone, I'm writing to propose a very simple set of mempool/transaction relay policies intended to aid L2/contract protocols. I realized that the previously proposed Package Mempool Accept package RBF [1] had a few remaining problems after digging into the RBF logic more [2]. This additional set of policies solves them without requiring a huge RBF overhaul. I've written an implementation (and docs) for Bitcoin Core: https://github.com/bitcoin/bitcoin/pull/25038 (You may notice that this proposal incorporates feedback on the PR - thanks Suhas Daftuar, Gregory Sanders, Bastien Teinturier, Anthony Towns, and others.) If you are interested in using package RBF/relay to bump presigned transactions, I think you may be interested in reviewing this proposal. This should solve Rule 3 pinning and perhaps allow us to get rid of CPFP carve-out (yay!). I'm keen to hear if people find the 1-anchor-output, 1000vB child limit too restrictive. Also, if you find a pinning attack or something that makes it unusable for you, I would really really like to know. Note that transactions with nVersion=3 ("V3 transactions") are currently non-standard in Bitcoin Core. That means **anything that was standard before this policy change would still be standard afterwards.** If you don't want your transactions to be subject to these rules, just continue whatever you're doing and don't use nVersion=3. AFAICT this shouldn't break anything, but let me know if this would be disruptive for you? **New Policies:** This includes: - a set of additional policy rules applying to V3 transactions - modifications to package RBF rules **V3 transactions:** Existing standardness rules apply to V3 (e.g. min/max tx weight, standard output types, cleanstack, etc.). The following additional rules apply to V3: 1. A V3 transaction can be replaced, even if it does not signal BIP125 replaceability. (It must also meet the other RBF rules around fees, etc. for replacement to happen). 2. Any descendant of an unconfirmed V3 transaction must also be V3. *Rationale*: Combined with Rule 1, this gives us the property of "inherited" replaceability signaling when descendants of unconfirmed transactions are created. Additionally, checking whether a transaction signals replaceability this way does not require mempool traversal, and does not change based on what transactions are mined. It also makes subsequent rules about descendant limits much easier to check. *Note*: The descendant of a *confirmed* V3 transaction does not need to be V3. 3. An unconfirmed V3 transaction cannot have more than 1 descendant. *Rationale*: (Upper bound) the larger the descendant limit, the more transactions may need to be replaced. This is a problematic pinning attack, i.e., a malicious counterparty prevents the transaction from being replaced by adding many descendant transactions that aren't fee-bumping. (Lower bound) at least 1 descendant is required to allow CPFP of the presigned transaction. The contract protocol can create presigned transactions paying 0 fees and 1 output for attaching a CPFP at broadcast time ("anchor output"). Without package RBF, multiple anchor outputs would be required to allow each counterparty to fee-bump any presigned transaction. With package RBF, since the presigned transactions can replace each other, 1 anchor output is sufficient. 4. A V3 transaction that has an unconfirmed V3 ancestor cannot be larger than 1000 virtual bytes. *Rationale*: (Upper bound) the larger the descendant size limit, the more vbytes may need to be replaced. With default limits, if the child is e.g. 100,000vB, that might be an additional 100,000sats (at 1sat/vbyte) or more, depending on the feerate. (Lower bound) the smaller this limit, the fewer UTXOs a child may use to fund this fee-bump. For example, only allowing the V3 child to have 2 inputs would require L2 protocols to manage a wallet with high-value UTXOs and make batched fee-bumping impossible. However, as the fee-bumping child only needs to fund fees (as opposed to payments), just a few UTXOs should suffice. With a limit of 1000 virtual bytes, depending on the output types, the child can have 6-15 UTXOs, which should be enough to fund a fee-bump without requiring a carefully-managed UTXO pool. With 1000 virtual bytes as the descendant limit, the cost to replace a V3 transaction has much lower variance. *Rationale*: This makes the rule very easily "tacked on" to existing logic for policy and wallets. A transaction may be up to 100KvB on its own (`MAX_STANDARD_TX_WEIGHT`) and 101KvB with descendants (`DEFAULT_DESCENDANT_SIZE_LIMIT_KVB`). If an existing V3 transaction in the mempool is 100KvB, its descendant can only be 1000vB, even if the policy is 10KvB. **Package RBF modifications:** 1. The rule around unconfirmed inputs was originally "A package may include new unconfirmed inputs, but the ancestor feerate of the child must be at least as high as the ancestor feerates of every transaction being replaced." The package may still include new unconfirmed inputs. However, the new rule is modified to be "The minimum between package feerate and ancestor feerate of the child is not lower than the individual feerates of all directly conflicting transactions and the ancestor feerates of all original transactions." *Rationale*: We are attempting to ensure that the replacement transactions are not less incentive-compatible to mine. However, a package/transaction's ancestor feerate is not perfectly representative of its incentive compatibility; it may overestimate (some subset of the ancestors could be included by itself if it has other high-feerate descendants or are themselves higher feerate than this package/transaction). Instead, we use the minimum between the package feerate and ancestor feerate of the child as a more conservative value than what was proposed originally. 2. A new rule is added, requiring that all package transactions with mempool conflicts to be V3. This also means the "sponsoring" child transaction must be V3. *Note*: Combined with the V3 rules, this means the package must be a child-with-parents package. Since package validation is only attempted if the transactions do not pay sufficient fees to be accepted on their own, this effectively means that only V3 transactions can pay to replace their ancestors' conflicts, and only V3 transactions' replacements may be paid for by a descendant. *Rationale*: The fee-related rules are economically rational for ancestor packages, but not necessarily other types of packages. A child-with-parents package is a type of ancestor package. It may be fine to allow any ancestor package, but it's more difficult to account for all of the possibilities. For example, it gets much harder to see that we're applying the descendant limits correctly if the package has a gnarly, many-generation, non-tree shape. I'm also not sure if this policy is 100% incentive-compatible if the sponsor is not a direct descendant of the sponsee. Please see doc/policy/version3_transactions.md and doc/policy/packages.md in the PR for the full set of rules. **Intended usage for LN:** Commitment transactions should be V3 and have 1 anchor output. They can be signed with 0 fees (or 1sat/vbyte) once package relay is deployed on a significant portion of the network. If the commitment tx must be broadcast, determine the desired feerate at broadcast time and spend the anchor output in a high feerate transaction. I'm going to call the broadcasted commitment tx "the parent" and the attached fee-bumping tx "the child." - This child must be V3. - This child must be at most 1000vB. Note this restricts the number of inputs you can use to fund the fee bump. Depending on the output types, this is around 6-15. - One child may fund fees for multiple commitment tx ("batched fee-bumping"). - To do a second fee-bump to add more fees, replace the *child* with a higher-feerate tx. Do not try to attach a grandchild. Otherwise, never try to spend from an unconfirmed V3 transaction. The descendant limits for V3 transactions are very restrictive. **Expected Questions:** "Does this fix Rule 3 Pinning?" Yes. The V3 descendant limit restricts both you and your counterparty. Assuming nodes adopted this policy, you may reasonably assume that you only need to replace the commitment transaction + up to 1000vB. "Only 1 anchor output? What if I need to bump counterparty's commitment tx in mempool?" You won't need to fee-bump a counterparty's commitment tx using CPFP. You would just package RBF it by attaching a high-feerate child to your commitment tx. "Is this a privacy issue, i.e. doesn't it allow fingerprinting LN transactions based on nVersion?" Indeed it may be unrealistic to assume V3 transactions will be in widespread use outside of L2. IIUC, unilateral closes are already obvious LN transactions because of the HTLC inputs. For e.g. cooperative closes and opens, I think it makes sense to continue using V2. So, unless I'm missing something, this shouldn't make it worse. "So a V3 transaction that doesn't signal BIP125 replaceability is replaceable? Is that a backward compatibility issue?" Yes it's replaceable. It's not an issue AFAICT because, under previous policy, the V3 transaction wouldn't have been in the mempool in the first place. "Can a V2 transaction replace a V3 transaction and vice versa?" Yes, otherwise someone can use V3 transactions to censor V2 transactions spending shared inputs. Note if the original V3 transaction has an unconfirmed V3 parent, this would violate the "inherited V3" rule and would be rejected. Thanks for reading! Feedback and review would be much appreciated. [1]: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-September/019464.html [2]: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-January/019817.html Best, Gloria --000000000000e8db4a05e959b07b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi everyone,

I'm writing to propose a very simp= le set of mempool/transaction relay
policies intended to aid L2/contract= protocols. I realized that
the previously proposed Package Mempool Acce= pt package RBF [1]
had a few remaining problems after digging into = the RBF logic more [2].
This additional set of policies solves th= em without requiring a huge RBF overhaul.

I've written an = implementation (and docs) for Bitcoin Core:
https://github.com/bitcoin/bitcoin/pull/25038=

(You may notice that this proposal incorporates feedback on the= PR - thanks Suhas Daftuar, Gregory Sanders, Bastien Teinturier, Anthony To= wns, and others.)

If you are interested in using package RBF/relay t= o bump presigned
transactions, I think you may be interested in reviewin= g this proposal.
This should solve Rule 3 pinning and perhaps allow usto get rid of CPFP carve-out (yay!). I'm keen to hear if people find<= br>the 1-anchor-output, 1000vB child limit too restrictive. Also, if you fi= nd a
pinning attack or something that makes it unusable for you, I would=
really really like to know.

Note that transactions with nVersion= =3D3 ("V3 transactions") are
currently non-standard in Bitcoin= Core. That means **anything that was
standard before this policy change= would still be standard
afterwards.** If you don't want your transa= ctions to be subject to
these rules, just continue whatever you're d= oing and don't use
nVersion=3D3. AFAICT this shouldn't break any= thing, but let me know if
this would be disruptive for you?

**New= Policies:**

This includes:
- a set of additional policy rules ap= plying to V3 transactions
- modifications to package RBF rules

**= V3 transactions:**

Existing standardness rules apply to V3 (e.g. min= /max tx weight,
standard output types, cleanstack, etc.). The following = additional
rules apply to V3:

1. A V3 transaction can be replaced= , even if it does not signal BIP125
=C2=A0 =C2=A0replaceability. (It mus= t also meet the other RBF rules around fees,
etc. for replacement to hap= pen).

2. Any descendant of an unconfirmed V3 transaction must also b= e V3.

*Rationale*: Combined with Rule 1, this gives us the property = of
"inherited" replaceability signaling when descendants of un= confirmed
transactions are created. Additionally, checking whether a tra= nsaction
signals replaceability this way does not require mempool traver= sal,
and does not change based on what transactions are mined. It alsomakes subsequent rules about descendant limits much easier to check.
<= br>*Note*: The descendant of a *confirmed* V3 transaction does not need to = be V3.

3. An unconfirmed V3 transaction cannot have more than 1 desc= endant.

*Rationale*: (Upper bound) the larger the descendant limit, = the more
transactions may need to be replaced. This is a problematic pin= ning
attack, i.e., a malicious counterparty prevents the transaction fro= m
being replaced by adding many descendant transactions that aren't<= br>fee-bumping.

(Lower bound) at least 1 descendant is required to a= llow CPFP of the
presigned transaction. The contract protocol can create= presigned
transactions paying 0 fees and 1 output for attaching a CPFP = at
broadcast time ("anchor output"). Without package RBF, mult= iple anchor
outputs would be required to allow each counterparty to fee-= bump any
presigned transaction. With package RBF, since the presignedtransactions can replace each other, 1 anchor output is sufficient.
4. A V3 transaction that has an unconfirmed V3 ancestor cannot be
=C2= =A0 =C2=A0larger than 1000 virtual bytes.

*Rationale*: (Upper bound)= the larger the descendant size limit, the
more vbytes may need to be re= placed. With default limits, if the child
is e.g. 100,000vB, that might = be an additional 100,000sats (at
1sat/vbyte) or more, depending on the f= eerate.

(Lower bound) the smaller this limit, the fewer UTXOs a chil= d may use
to fund this fee-bump. For example, only allowing the V3 child= to have
2 inputs would require L2 protocols to manage a wallet with hig= h-value
UTXOs and make batched fee-bumping impossible. However, as thefee-bumping child only needs to fund fees (as opposed to payments),
ju= st a few UTXOs should suffice.

With a limit of 1000 virtual bytes, d= epending on the output types, the
child can have 6-15 UTXOs, which shoul= d be enough to fund a fee-bump
without requiring a carefully-managed UTX= O pool. With 1000 virtual
bytes as the descendant limit, the cost to rep= lace a V3 transaction
has much lower variance.

*Rationale*: This = makes the rule very easily "tacked on" to existing
logic for p= olicy and wallets. A transaction may be up to 100KvB on its
own (`MAX_ST= ANDARD_TX_WEIGHT`) and 101KvB with descendants
(`DEFAULT_DESCENDANT_SIZE= _LIMIT_KVB`). If an existing V3 transaction
in the mempool is 100KvB, it= s descendant can only be 1000vB, even if
the policy is 10KvB.

**P= ackage RBF modifications:**

1. The rule around unconfirmed inputs wa= s
originally "A package may include new unconfirmed inputs, but the=
ancestor feerate of the child must be at least as high as the ancestor<= br>feerates of every transaction being replaced."

The package m= ay still include new unconfirmed inputs. However,
the new rule is modifi= ed to be "The minimum between package feerate
and ancestor feerate = of the child is not lower than the individual
feerates of all directly c= onflicting transactions and the ancestor
feerates of all original transa= ctions."

*Rationale*: We are attempting to ensure that the repl= acement
transactions are not less incentive-compatible to mine. However,= a
package/transaction's ancestor feerate is not perfectly represent= ative
of its incentive compatibility; it may overestimate (some subset o= f
the ancestors could be included by itself if it has other high-feerate=
descendants or are themselves higher feerate than this
package/trans= action). Instead, we use the minimum between the package
feerate and anc= estor feerate of the child as a more conservative value
than what was pr= oposed originally.

2. A new rule is added, requiring that all packag= e transactions with
mempool conflicts to be V3. This also means the &quo= t;sponsoring"
child transaction must be V3.

*Note*: Combined= with the V3 rules, this means the package must be
a child-with-parents = package. Since package validation is only
attempted if the transactions = do not pay sufficient fees to be
accepted on their own, this effectively= means that only V3
transactions can pay to replace their ancestors'= conflicts, and only
V3 transactions' replacements may be paid for b= y a descendant.

*Rationale*: The fee-related rules are economically = rational for
ancestor packages, but not necessarily other types of packa= ges.
A child-with-parents package is a type of ancestor package. It
m= ay be fine to allow any ancestor package, but it's more difficult
to= account for all of the possibilities. For example, it gets much
harder = to see that we're applying the descendant limits correctly if
the pa= ckage has a gnarly, many-generation, non-tree shape. I'm also
not su= re if this policy is 100% incentive-compatible if the sponsor
is not a d= irect descendant of the sponsee.

Please see doc/policy/version3_tran= sactions.md and
doc/policy/packages.md in the PR for the full set of rul= es.

**Intended usage for LN:**

Commitment transactions should= be V3 and have 1 anchor output. They
can be signed with 0 fees (or 1sat= /vbyte) once package relay is deployed
on a significant portion of the n= etwork. If the commitment tx must
be broadcast, determine the desired fe= erate at broadcast time and
spend the anchor output in a high feerate tr= ansaction. I'm going to
call the broadcasted commitment tx "the= parent" and the attached
fee-bumping tx "the child."
=
- This child must be V3.
- This child must be at most 1000vB. Note t= his restricts the
=C2=A0 number of inputs you can use to fund the fee bu= mp. Depending
on the output types, this is around 6-15.
- One child m= ay fund fees for multiple commitment tx ("batched
=C2=A0 fee-bumpin= g").
- To do a second fee-bump to add more fees, replace the
=C2= =A0 *child* with a higher-feerate tx. Do not try to attach a grandchild.
Otherwise, never try to spend from an unconfirmed V3 transaction. The<= br>descendant limits for V3 transactions are very restrictive.

**Exp= ected Questions:**

"Does this fix Rule 3 Pinning?"
Yes.= The V3 descendant limit restricts both you and your counterparty.
Assum= ing nodes adopted this policy, you may reasonably assume that you
only n= eed to replace the commitment transaction + up to 1000vB.

"Only= 1 anchor output? What if I need to bump counterparty's commitment tx i= n mempool?"
You won't need to fee-bump a counterparty'= s commitment tx using CPFP.
You would just package RBF it by atta= ching a high-feerate child to
your commitment tx.

"Is this= a privacy issue, i.e. doesn't it allow fingerprinting LN
transactio= ns based on nVersion?"
Indeed it may be unrealistic to assume V3 tr= ansactions will be in
widespread use outside of L2. IIUC, unilateral clo= ses are already
obvious LN transactions because of the HTLC inputs. For = e.g.
cooperative closes and opens, I think it makes sense to continue us= ing
V2. So, unless I'm missing something, this shouldn't make it= worse.

"So a V3 transaction that doesn't signal BIP125 rep= laceability is
replaceable? Is that a backward compatibility issue?"= ;
Yes it's replaceable. It's not an issue AFAICT because,
und= er previous policy, the V3 transaction wouldn't have been
in the mem= pool in the first place.

"Can a V2 transaction replace a V3 tra= nsaction and vice versa?"
Yes, otherwise someone can use V3 transac= tions to censor V2
transactions spending shared inputs. Note if the
o= riginal V3 transaction has an unconfirmed V3 parent, this would
violate = the "inherited V3" rule and would be rejected.

Thanks for = reading! Feedback and review would be much appreciated.

[1]: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-S= eptember/019464.html

Best,
Gloria --000000000000e8db4a05e959b07b--