summaryrefslogtreecommitdiff
path: root/6a/27740501e0db8c26f28d83d419876c695ae111
blob: 57fcea63ad4dc7be0914c676aba402205f091f4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
Return-Path: <gsanders87@gmail.com>
Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138])
 by lists.linuxfoundation.org (Postfix) with ESMTP id 9E3B2C002D
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 23 Sep 2022 18:48:53 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by smtp1.osuosl.org (Postfix) with ESMTP id 6485C81432
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 23 Sep 2022 18:48:53 +0000 (UTC)
DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6485C81432
Authentication-Results: smtp1.osuosl.org;
 dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
 header.a=rsa-sha256 header.s=20210112 header.b=H0zzTFn4
X-Virus-Scanned: amavisd-new at osuosl.org
X-Spam-Flag: NO
X-Spam-Score: -1.848
X-Spam-Level: 
X-Spam-Status: No, score=-1.848 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_ENVFROM_END_DIGIT=0.25, 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 smtp1.osuosl.org ([127.0.0.1])
 by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id sflGOvaZD8y6
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 23 Sep 2022 18:48:51 +0000 (UTC)
X-Greylist: whitelisted by SQLgrey-1.8.0
DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 39C068142B
Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com
 [IPv6:2607:f8b0:4864:20::102c])
 by smtp1.osuosl.org (Postfix) with ESMTPS id 39C068142B
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 23 Sep 2022 18:48:51 +0000 (UTC)
Received: by mail-pj1-x102c.google.com with SMTP id
 q15-20020a17090a304f00b002002ac83485so1066958pjl.0
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Fri, 23 Sep 2022 11:48:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :from:to:cc:subject:date;
 bh=y1XlBdM90N5bnLBnSA/CFe0Us25ZQ2yMK9opwhR5SP4=;
 b=H0zzTFn4oXjz7v9dpwpkVjwqG0FgQQq4U9tqTfS/rEHgbzmOu46fhxf51RvgMnr52F
 AGorZMYI0dGmX+EQXkrxJuUIkxilErnCZFKIKXJ+cudAFjLupzIsLiAo2oSRoBSl9Yoy
 CdtdU76RLbyfbcpa38nmgtKcBqgjPTaaA+/anEJ8ubeOSmJA72sPmh7jiOVpyZPc4CJG
 hmjqUvXGZfDPuFIxld3uU48p+si7JadA3q69ovwHKTNHb13YyCTZ8LyLlg17oKFJD0rt
 TIG6JtTQP7qhAiuWHM57j0JSmQmbmufzfCleavq1RNd+lgYGgo6a9pv4uFJwF9Udf1ND
 PY1g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :x-gm-message-state:from:to:cc:subject:date;
 bh=y1XlBdM90N5bnLBnSA/CFe0Us25ZQ2yMK9opwhR5SP4=;
 b=QCp2QWC6WuzPGJQJAV1EXDA6yrSZmnRwf/bB9eAUVKhgRpdi+vfl3tkNbXSx6+lgSf
 d5GRwHKZoCTg8wwiQcszRTD+OmumMzQueBXX1pqyQCEZAV/v1fr3r9ojNFZJ7S5jx3f7
 SHrP76/yhURWxs14q7DkdmD3OKQYm5Jezd9jjorp0psV2TBS1/cs4wyFRM+z4q8n05ly
 tBOPdhGPbftYb4Oy6JN24YAODBHMKm4gJ6g4tSEQrVeBGmgaWYuUCgxDijw2/nyihVSu
 Pa24UCGFJztYpFoEQlnCh2kzAYVWCyz7nvSteHlDpWvOpQZz+5vza0TK7Tnz7To6eP8J
 Xbkw==
X-Gm-Message-State: ACrzQf1gm8TlWJNydTYJEXi8yOsTAuJOArltFJ4lzwSoTgGp38Ed9jh/
 FZ2IVwSRYvNp/mUHO310h1zxU1L3+etMLLNpYZNeILhaYZw=
X-Google-Smtp-Source: AMsMyM7Fxdnm570CjzNM4EmHxLKzW3OZ33LRnSAOt72xOxze2TN/E10hKbqvLgUc/tU8Ja1uyE7sitmj7n8iLbT8N6o=
X-Received: by 2002:a17:90b:380e:b0:202:d747:a044 with SMTP id
 mq14-20020a17090b380e00b00202d747a044mr11213418pjb.170.1663958930300; Fri, 23
 Sep 2022 11:48:50 -0700 (PDT)
MIME-Version: 1.0
References: <CAFXO6=KDys2_dsrdxE9_q_MVZJOFMbg-MctxiokcicP=wd4Lkw@mail.gmail.com>
In-Reply-To: <CAFXO6=KDys2_dsrdxE9_q_MVZJOFMbg-MctxiokcicP=wd4Lkw@mail.gmail.com>
From: Greg Sanders <gsanders87@gmail.com>
Date: Fri, 23 Sep 2022 14:48:39 -0400
Message-ID: <CAB3F3DtLR97voxBQOjsj_LdyPPYAgq_ACZGGqSa7nc_PqBxaYA@mail.gmail.com>
To: Gloria Zhao <gloriajzhao@gmail.com>, 
 Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Content-Type: multipart/alternative; boundary="000000000000f6237b05e95ca03f"
Subject: Re: [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 <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Fri, 23 Sep 2022 18:48:53 -0000

--000000000000f6237b05e95ca03f
Content-Type: text/plain; charset="UTF-8"

Hello Gloria,

Great work on synthesizing so much feedback into a proposal like this!

Death to carve-out rule.

I'd like to elaborate on some caveats and give a few incomplete thoughts.

There are basically two types of pinning in my estimation today:

1) rule#3 pinning: Make it uneconomical to replace whatever is in mempool
via large in size but low feerate junk that won't get mined anytime soon.
Replacing this with feerate-based policy seems apt, but fraught with DoS
risks.

2) package limit pinning: disallowing transaction propagation by package
limits being hit: size, ancestor count, descendant count. Today it is
mitigated by having all outputs be 1 csv timelocked, and having up to 2
anchor outputs(1 without carve-out rule).

Would kind of be nice if package RBF would detect a "sibling output spend"
conflict, and knock it out of the mempool via the other replacement rules?
Getting rid of the requirement to 1 block csv lock every output would be
quite nice from a smart contracting composability point of view.

> "Does this fix Rule 3 Pinning?"

As you likely know from previous discussions the biggest scenario this does
not fix in my estimation is ANYONECANPAY situations. If the parent
transaction can be "inflated" by tacking on additional inputs, this means
the total weight of the parent tx lowers the effective feerate of the
package. Due to this pinning attack there aren't many(?) deployed schemes
that use the signature type.

To mitigate this we would likely have to opt into a more complex policy
scheme, committing in the annex to "total mempool package weight", which
would allow mempool package limits to be picked at signing time.

Maybe ANYONECANPAY isn't a very useful paradigm in general, I cannot speak
to that, but it came up in eltoo-related designs using BIP118, which adopts
ACP-like signing behavior. This can be mitigated via straight forward
policy updates as well for BIP118 deployment, but off topic so will leave
it there.

The other scenario it doesn't really fix is where HTLC/commitment-like
transactions are being resolved in a batch, but due to relative time
constraints, you may want to accelerate some and not others. Now you must
pay higher rates to replace all of the transaction bumps. This is a
"self-pin" and "get good at utxos noob" type problem, but it's something
that axing rule#3 in favor of a Replace-by-ancestor-feerate system would
get us.

> "Can a V2 transaction replace a V3 transaction and vice versa?"

Circling back to my ACP point, this regime still allows pinning anytime you
are sharing a transaction with someone else where you don't have control
over *all* the inputs. So anytime you are doing a coinjoin-like
transaction, someone else's inputs can be self-double-spent, requiring you
to satisfy rule#3 when replacing theirs, if they're bip125-signaling. If
they're not bip125 signaling, you'll have to somehow detect this and/or
double-spend your input back to yourself.


Finally, a couple suggestions I've already made elsewhere:

1) I do think that we should seriously consider allowing OP_TRUE to become
a standard script type as part of this policy update. If pinning is solved,
then there's no reason to require all those extra bytes for "binding" an
anchor to a specific wallet/user. We can save quite a few bytes by having
the input be empty of witness data.

2) If we allow for a single dust-value(0 on up) output which is immediately
spent by the package, anchors become even easier to to design. No value has
to be "sapped" from contract participants to make an anchor output. There's
more complications for this, such as making sure the parent transaction is
dropped if the child spend is dropped, but maybe it's worth the squeeze. I
do think that any L2 uptake of these new rules will take significant
time... maybe we should be a bit more ambitious?

Cheers,
Greg

On Fri, Sep 23, 2022 at 11:27 AM Gloria Zhao via bitcoin-dev <
bitcoin-dev@lists.linuxfoundation.org> wrote:

> 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
> _______________________________________________
> bitcoin-dev mailing list
> bitcoin-dev@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>

--000000000000f6237b05e95ca03f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello Gloria,<div><br></div><div>Great work on synthesizin=
g so much feedback into a proposal like this!</div><div><br></div><div>Deat=
h to carve-out=C2=A0rule.</div><div><br></div><div>I&#39;d like to elaborat=
e on some caveats and give a few incomplete thoughts.</div><div><br></div><=
div>There are basically two types of pinning in my estimation today:</div><=
div><br></div><div>1) rule#3 pinning: Make it uneconomical to replace whate=
ver is in mempool via large in size but low feerate junk that won&#39;t get=
 mined anytime soon. Replacing this with feerate-based policy seems apt, bu=
t fraught with DoS risks.</div><div><br></div><div>2) package limit pinning=
: disallowing transaction propagation by package limits being hit: size, an=
cestor count, descendant count. Today it is mitigated by having all outputs=
 be 1 csv timelocked, and having up to 2 anchor outputs(1 without carve-out=
 rule).</div><div><br></div><div>Would kind of be nice if package RBF would=
 detect a &quot;sibling output spend&quot; conflict, and knock it out of th=
e mempool via the other replacement rules? Getting rid of the requirement t=
o 1 block csv lock every output would be quite nice from a smart contractin=
g composability point of view.</div><div><br></div><div>&gt;=C2=A0<span sty=
le=3D"color:rgb(0,0,0);white-space:pre-wrap">&quot;Does this fix Rule 3 Pin=
ning?&quot;</span></div><div><span style=3D"color:rgb(0,0,0);white-space:pr=
e-wrap"><br></span></div><div><font color=3D"#000000"><span style=3D"white-=
space:pre-wrap">As you likely know from previous discussions the biggest sc=
enario this does not fix in my estimation is ANYONECANPAY situations. If th=
e parent transaction can be &quot;inflated&quot; by tacking on additional i=
nputs, this means the total weight of the parent tx lowers the effective fe=
erate of the package. Due to this pinning attack there aren&#39;t many(?) d=
eployed schemes that use the signature type.</span></font></div><div><font =
color=3D"#000000"><span style=3D"white-space:pre-wrap"><br></span></font></=
div><div><font color=3D"#000000"><span style=3D"white-space:pre-wrap">To mi=
tigate this we would likely have to opt into a more complex policy scheme, =
committing in the annex to &quot;total  mempool package weight&quot;, which=
 would allow mempool package limits to be picked at signing time.</span></f=
ont></div><div><font color=3D"#000000"><span style=3D"white-space:pre-wrap"=
><br></span></font></div><div><font color=3D"#000000"><span style=3D"white-=
space:pre-wrap">Maybe ANYONECANPAY isn&#39;t a very useful paradigm in gene=
ral, I cannot speak to that, but it came up in eltoo-related designs using =
BIP118, which adopts ACP-like signing behavior. This can be mitigated via s=
traight forward policy updates as well for BIP118 deployment, but off topic=
 so will leave it there.</span></font></div><div><font color=3D"#000000"><s=
pan style=3D"white-space:pre-wrap"><br></span></font></div><div><font color=
=3D"#000000"><span style=3D"white-space:pre-wrap">The other scenario it doe=
sn&#39;t really fix is where HTLC/commitment-like transactions are being re=
solved in a batch, but due to relative time constraints, you may want to ac=
celerate some and not others. Now you must pay higher rates to replace all =
of the transaction bumps. This is a &quot;self-pin&quot; and &quot;get good=
 at utxos noob&quot; type problem, but it&#39;s something that axing rule#3=
 in favor of a Replace-by-ancestor-feerate system would get us.</span></fon=
t></div><div><font color=3D"#000000"><span style=3D"white-space:pre-wrap"><=
br></span></font></div><div><font color=3D"#000000"><span style=3D"white-sp=
ace:pre-wrap">&gt; </span></font><span style=3D"color:rgb(0,0,0);white-spac=
e:pre-wrap">&quot;Can a V2 transaction replace a V3 transaction and vice ve=
rsa?&quot;</span></div><div><span style=3D"color:rgb(0,0,0);white-space:pre=
-wrap"><br></span></div><div><span style=3D"color:rgb(0,0,0);white-space:pr=
e-wrap">Circling back to my ACP point, this regime still allows pinning any=
time you are sharing a transaction with someone else where you don&#39;t ha=
ve control over *all* the inputs. So anytime you are doing a coinjoin-like =
transaction, someone else&#39;s inputs can be self-double-spent, requiring =
you to satisfy rule#3 when replacing theirs, if they&#39;re bip125-signalin=
g. If they&#39;re not bip125 signaling, you&#39;ll have to somehow detect t=
his and/or double-spend your input back to yourself.</span></div><div><span=
 style=3D"color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><spa=
n style=3D"color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><fo=
nt color=3D"#000000"><span style=3D"white-space:pre-wrap">Finally, a couple=
 suggestions I&#39;ve already made elsewhere:</span></font></div><div><font=
 color=3D"#000000"><span style=3D"white-space:pre-wrap"><br></span></font><=
/div><div><font color=3D"#000000"><span style=3D"white-space:pre-wrap">1) I=
 do think that we should seriously consider allowing OP_TRUE to become a st=
andard script type as part of this policy update. If pinning is solved, the=
n there&#39;s no reason to require all those extra bytes for &quot;binding&=
quot; an anchor to a specific wallet/user. We can save quite a few bytes by=
 having the input be empty of witness data.</span></font></div><div><font c=
olor=3D"#000000"><span style=3D"white-space:pre-wrap"><br></span></font></d=
iv><div>2) If we allow for a single dust-value(0 on up) output which is imm=
ediately spent by the package, anchors become even easier to to design. No =
value has to be &quot;sapped&quot; from contract participants to make an an=
chor output. There&#39;s more complications for this, such as making sure t=
he parent transaction is dropped if the child spend is dropped, but maybe i=
t&#39;s worth the squeeze. I do think that any L2 uptake of these new rules=
 will take significant time... maybe we should be a bit more ambitious?</di=
v><div><span style=3D"color:rgb(0,0,0);white-space:pre-wrap"><br></span></d=
iv><div><font color=3D"#000000"><span style=3D"white-space:pre-wrap">Cheers=
,</span></font></div><div><font color=3D"#000000"><span style=3D"white-spac=
e:pre-wrap">Greg</span></font></div></div><br><div class=3D"gmail_quote"><d=
iv dir=3D"ltr" class=3D"gmail_attr">On Fri, Sep 23, 2022 at 11:27 AM Gloria=
 Zhao via bitcoin-dev &lt;<a href=3D"mailto:bitcoin-dev@lists.linuxfoundati=
on.org">bitcoin-dev@lists.linuxfoundation.org</a>&gt; wrote:<br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Hi everyone,<=
br><br>I&#39;m writing to propose a very simple set of mempool/transaction =
relay<br>policies intended to aid L2/contract protocols. I realized that<br=
>the previously proposed Package Mempool Accept package RBF [1]<br><div>had=
 a few remaining problems after digging into the RBF logic more [2].</div><=
div>This additional set of policies solves them without requiring a huge RB=
F overhaul.<br></div><br>I&#39;ve written an implementation (and docs) for =
Bitcoin Core:<br><a href=3D"https://github.com/bitcoin/bitcoin/pull/25038" =
target=3D"_blank">https://github.com/bitcoin/bitcoin/pull/25038</a><br><br>=
(You may notice that this proposal incorporates feedback on the PR - thanks=
 Suhas Daftuar, Gregory Sanders, Bastien Teinturier, Anthony Towns, and oth=
ers.)<br><br>If you are interested in using package RBF/relay to bump presi=
gned<br>transactions, I think you may be interested in reviewing this propo=
sal.<br>This should solve Rule 3 pinning and perhaps allow us<br>to get rid=
 of CPFP carve-out (yay!). I&#39;m keen to hear if people find<br>the 1-anc=
hor-output, 1000vB child limit too restrictive. Also, if you find a<br>pinn=
ing attack or something that makes it unusable for you, I would<br>really r=
eally like to know.<br><br>Note that transactions with nVersion=3D3 (&quot;=
V3 transactions&quot;) are<br>currently non-standard in Bitcoin Core. That =
means **anything that was<br>standard before this policy change would still=
 be standard<br>afterwards.** If you don&#39;t want your transactions to be=
 subject to<br>these rules, just continue whatever you&#39;re doing and don=
&#39;t use<br>nVersion=3D3. AFAICT this shouldn&#39;t break anything, but l=
et me know if<br>this would be disruptive for you?<br><br>**New Policies:**=
<br><br>This includes:<br>- a set of additional policy rules applying to V3=
 transactions<br>- modifications to package RBF rules<br><br>**V3 transacti=
ons:**<br><br>Existing standardness rules apply to V3 (e.g. min/max tx weig=
ht,<br>standard output types, cleanstack, etc.). The following additional<b=
r>rules apply to V3:<br><br>1. A V3 transaction can be replaced, even if it=
 does not signal BIP125<br>=C2=A0 =C2=A0replaceability. (It must also meet =
the other RBF rules around fees,<br>etc. for replacement to happen).<br><br=
>2. Any descendant of an unconfirmed V3 transaction must also be V3.<br><br=
>*Rationale*: Combined with Rule 1, this gives us the property of<br>&quot;=
inherited&quot; replaceability signaling when descendants of unconfirmed<br=
>transactions are created. Additionally, checking whether a transaction<br>=
signals replaceability this way does not require mempool traversal,<br>and =
does not change based on what transactions are mined. It also<br>makes subs=
equent rules about descendant limits much easier to check.<br><br>*Note*: T=
he descendant of a *confirmed* V3 transaction does not need to be V3.<br><b=
r>3. An unconfirmed V3 transaction cannot have more than 1 descendant.<br><=
br>*Rationale*: (Upper bound) the larger the descendant limit, the more<br>=
transactions may need to be replaced. This is a problematic pinning<br>atta=
ck, i.e., a malicious counterparty prevents the transaction from<br>being r=
eplaced by adding many descendant transactions that aren&#39;t<br>fee-bumpi=
ng.<br><br>(Lower bound) at least 1 descendant is required to allow CPFP of=
 the<br>presigned transaction. The contract protocol can create presigned<b=
r>transactions paying 0 fees and 1 output for attaching a CPFP at<br>broadc=
ast time (&quot;anchor output&quot;). Without package RBF, multiple anchor<=
br>outputs would be required to allow each counterparty to fee-bump any<br>=
presigned transaction. With package RBF, since the presigned<br>transaction=
s can replace each other, 1 anchor output is sufficient.<br><br>4. A V3 tra=
nsaction that has an unconfirmed V3 ancestor cannot be<br>=C2=A0 =C2=A0larg=
er than 1000 virtual bytes.<br><br>*Rationale*: (Upper bound) the larger th=
e descendant size limit, the<br>more vbytes may need to be replaced. With d=
efault limits, if the child<br>is e.g. 100,000vB, that might be an addition=
al 100,000sats (at<br>1sat/vbyte) or more, depending on the feerate.<br><br=
>(Lower bound) the smaller this limit, the fewer UTXOs a child may use<br>t=
o fund this fee-bump. For example, only allowing the V3 child to have<br>2 =
inputs would require L2 protocols to manage a wallet with high-value<br>UTX=
Os and make batched fee-bumping impossible. However, as the<br>fee-bumping =
child only needs to fund fees (as opposed to payments),<br>just a few UTXOs=
 should suffice.<br><br>With a limit of 1000 virtual bytes, depending on th=
e output types, the<br>child can have 6-15 UTXOs, which should be enough to=
 fund a fee-bump<br>without requiring a carefully-managed UTXO pool. With 1=
000 virtual<br>bytes as the descendant limit, the cost to replace a V3 tran=
saction<br>has much lower variance.<br><br>*Rationale*: This makes the rule=
 very easily &quot;tacked on&quot; to existing<br>logic for policy and wall=
ets. A transaction may be up to 100KvB on its<br>own (`MAX_STANDARD_TX_WEIG=
HT`) and 101KvB with descendants<br>(`DEFAULT_DESCENDANT_SIZE_LIMIT_KVB`). =
If an existing V3 transaction<br>in the mempool is 100KvB, its descendant c=
an only be 1000vB, even if<br>the policy is 10KvB.<br><br>**Package RBF mod=
ifications:**<br><br>1. The rule around unconfirmed inputs was<br>originall=
y &quot;A package may include new unconfirmed inputs, but the<br>ancestor f=
eerate of the child must be at least as high as the ancestor<br>feerates of=
 every transaction being replaced.&quot;<br><br>The package may still inclu=
de new unconfirmed inputs. However,<br>the new rule is modified to be &quot=
;The minimum between package feerate<br>and ancestor feerate of the child i=
s not lower than the individual<br>feerates of all directly conflicting tra=
nsactions and the ancestor<br>feerates of all original transactions.&quot;<=
br><br>*Rationale*: We are attempting to ensure that the replacement<br>tra=
nsactions are not less incentive-compatible to mine. However, a<br>package/=
transaction&#39;s ancestor feerate is not perfectly representative<br>of it=
s incentive compatibility; it may overestimate (some subset of<br>the ances=
tors could be included by itself if it has other high-feerate<br>descendant=
s or are themselves higher feerate than this<br>package/transaction). Inste=
ad, we use the minimum between the package<br>feerate and ancestor feerate =
of the child as a more conservative value<br>than what was proposed origina=
lly.<br><br>2. A new rule is added, requiring that all package transactions=
 with<br>mempool conflicts to be V3. This also means the &quot;sponsoring&q=
uot;<br>child transaction must be V3.<br><br>*Note*: Combined with the V3 r=
ules, this means the package must be<br>a child-with-parents package. Since=
 package validation is only<br>attempted if the transactions do not pay suf=
ficient fees to be<br>accepted on their own, this effectively means that on=
ly V3<br>transactions can pay to replace their ancestors&#39; conflicts, an=
d only<br>V3 transactions&#39; replacements may be paid for by a descendant=
.<br><br>*Rationale*: The fee-related rules are economically rational for<b=
r>ancestor packages, but not necessarily other types of packages.<br>A chil=
d-with-parents package is a type of ancestor package. It<br>may be fine to =
allow any ancestor package, but it&#39;s more difficult<br>to account for a=
ll of the possibilities. For example, it gets much<br>harder to see that we=
&#39;re applying the descendant limits correctly if<br>the package has a gn=
arly, many-generation, non-tree shape. I&#39;m also<br>not sure if this pol=
icy is 100% incentive-compatible if the sponsor<br>is not a direct descenda=
nt of the sponsee.<br><br>Please see doc/policy/version3_transactions.md an=
d<br>doc/policy/packages.md in the PR for the full set of rules.<br><br>**I=
ntended usage for LN:**<br><br>Commitment transactions should be V3 and hav=
e 1 anchor output. They<br>can be signed with 0 fees (or 1sat/vbyte) once p=
ackage relay is deployed<br>on a significant portion of the network. If the=
 commitment tx must<br>be broadcast, determine the desired feerate at broad=
cast time and<br>spend the anchor output in a high feerate transaction. I&#=
39;m going to<br>call the broadcasted commitment tx &quot;the parent&quot; =
and the attached<br>fee-bumping tx &quot;the child.&quot;<br><br>- This chi=
ld must be V3.<br>- This child must be at most 1000vB. Note this restricts =
the<br>=C2=A0 number of inputs you can use to fund the fee bump. Depending<=
br>on the output types, this is around 6-15.<br>- One child may fund fees f=
or multiple commitment tx (&quot;batched<br>=C2=A0 fee-bumping&quot;).<br>-=
 To do a second fee-bump to add more fees, replace the<br>=C2=A0 *child* wi=
th a higher-feerate tx. Do not try to attach a grandchild.<br><br>Otherwise=
, never try to spend from an unconfirmed V3 transaction. The<br>descendant =
limits for V3 transactions are very restrictive.<br><br>**Expected Question=
s:**<br><br>&quot;Does this fix Rule 3 Pinning?&quot;<br>Yes. The V3 descen=
dant limit restricts both you and your counterparty.<br>Assuming nodes adop=
ted this policy, you may reasonably assume that you<br>only need to replace=
 the commitment transaction + up to 1000vB.<br><br>&quot;Only 1 anchor outp=
ut? What if I need to bump counterparty&#39;s commitment tx in mempool?&quo=
t;<br><div>You won&#39;t need to fee-bump a counterparty&#39;s commitment t=
x using CPFP.</div><div>You would just package RBF it by attaching a high-f=
eerate child to</div>your commitment tx.<br><br>&quot;Is this a privacy iss=
ue, i.e. doesn&#39;t it allow fingerprinting LN<br>transactions based on nV=
ersion?&quot;<br>Indeed it may be unrealistic to assume V3 transactions wil=
l be in<br>widespread use outside of L2. IIUC, unilateral closes are alread=
y<br>obvious LN transactions because of the HTLC inputs. For e.g.<br>cooper=
ative closes and opens, I think it makes sense to continue using<br>V2. So,=
 unless I&#39;m missing something, this shouldn&#39;t make it worse.<br><br=
>&quot;So a V3 transaction that doesn&#39;t signal BIP125 replaceability is=
<br>replaceable? Is that a backward compatibility issue?&quot;<br>Yes it&#3=
9;s replaceable. It&#39;s not an issue AFAICT because,<br>under previous po=
licy, the V3 transaction wouldn&#39;t have been<br>in the mempool in the fi=
rst place.<br><br>&quot;Can a V2 transaction replace a V3 transaction and v=
ice versa?&quot;<br>Yes, otherwise someone can use V3 transactions to censo=
r V2<br>transactions spending shared inputs. Note if the<br>original V3 tra=
nsaction has an unconfirmed V3 parent, this would<br>violate the &quot;inhe=
rited V3&quot; rule and would be rejected.<br><br>Thanks for reading! Feedb=
ack and review would be much appreciated.<br><br>[1]: <a href=3D"https://li=
sts.linuxfoundation.org/pipermail/bitcoin-dev/2021-September/019464.html" t=
arget=3D"_blank">https://lists.linuxfoundation.org/pipermail/bitcoin-dev/20=
21-September/019464.html</a><br><div>[2]: <a href=3D"https://lists.linuxfou=
ndation.org/pipermail/bitcoin-dev/2022-January/019817.html" target=3D"_blan=
k">https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-January/019=
817.html</a></div><div><br></div>Best,<br>Gloria</div>
_______________________________________________<br>
bitcoin-dev mailing list<br>
<a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org" target=3D"_blank">=
bitcoin-dev@lists.linuxfoundation.org</a><br>
<a href=3D"https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev" =
rel=3D"noreferrer" target=3D"_blank">https://lists.linuxfoundation.org/mail=
man/listinfo/bitcoin-dev</a><br>
</blockquote></div>

--000000000000f6237b05e95ca03f--