summaryrefslogtreecommitdiff
path: root/13/da4b82e266f03bf698f998548f7b8853d2ed5b
blob: 73670524d8eff860af4d9f806a747db553eac712 (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
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
Return-Path: <gloriajzhao@gmail.com>
Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137])
 by lists.linuxfoundation.org (Postfix) with ESMTP id 23118C000D
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Sep 2021 11:56:43 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by smtp4.osuosl.org (Postfix) with ESMTP id 07A034163C
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Sep 2021 11:56:43 +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: smtp4.osuosl.org (amavisd-new);
 dkim=pass (2048-bit key) header.d=gmail.com
Received: from smtp4.osuosl.org ([127.0.0.1])
 by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id D5LHoPt_r7jn
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Sep 2021 11:56:38 +0000 (UTC)
X-Greylist: whitelisted by SQLgrey-1.8.0
Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com
 [IPv6:2607:f8b0:4864:20::b2a])
 by smtp4.osuosl.org (Postfix) with ESMTPS id C44724162E
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Sep 2021 11:56:37 +0000 (UTC)
Received: by mail-yb1-xb2a.google.com with SMTP id 71so4721290ybe.6
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Sep 2021 04:56:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=5dRrZ2h1odOCcg3PmQbAqcepP8jmz+VUm4gTrMv3bXI=;
 b=iafCYtF6XtXaWaGnTmbyIifzu7BRlrj50jiEOmRsFvR8X2B6ekTG/3Z/vc3CeCCJBV
 yXBjZrHCNkdb8gyPeGd9u6nzchtk34FlW8uUxlUfoQPMsoMiHACIEpsfm6BDORbWJzkJ
 duYE3LpIdTbjuxcLioZocdP6rCnif+2l0bJa9jdliOh9hHB1ToqPj58hnLKCbX7Ivxem
 /NXCKzslzS6EuSvAdodWYxvU5AblRz+g3WdR0yJEb00/mxlb+MacC62d9zcXafcYF4Sn
 agSGSXW3AIXUvm2EaQqZtzAwqiOAFRmzPUXafKU4j0UXGwG89IgDKFjxlvbr2oiWeAmN
 PeWA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=5dRrZ2h1odOCcg3PmQbAqcepP8jmz+VUm4gTrMv3bXI=;
 b=l1/Jels0JTQlmgWmfzb8zkZx1jrY8sm/G9bN8tM6RlXdyJBFJZ8iyDgHgTjwHaxebh
 6hQw/ns8CmXz1yCq2emlay20wPZzIP+ewFnvqIjvTybZUapKd8dGF9QVJt68NUKSV03q
 iOOdeFheG19huiSknAayEMajIrzVCwBNz2qpeTdzPCy8cAhfCOal387m2nG9bM4WyJy8
 ZM3szXf4r7WE9JCaBwyhdoPHOXUMVklqW5ITmT522bbtG0/gUJCiRa3UtrKouZ1MGv3e
 Jv+rw7HHvezWXTmoINoC3uTGPHIpErCs0J9VnbvVRKY4Pr545ksTKVRXKwYObDpL4R3m
 OxJA==
X-Gm-Message-State: AOAM531A883Dk+lH+YSDpF+Ov7hJqLddsBiL5x5/A6h4JuQbD6Gt7X0l
 r3VoVAE24pxHv3UuQAW+0Jb6lJarZPduvVRJSODGJEHb4t0=
X-Google-Smtp-Source: ABdhPJwdXDK4yuZ3NAujlFVoFAvvR/yVDcg5Ez7YHU4+rn9yC4tW6zuoDNZV4wsrIhmA+z9tZyH+dyevpk8EeYoxPBQ=
X-Received: by 2002:a25:bd7:: with SMTP id 206mr4654367ybl.408.1632916595867; 
 Wed, 29 Sep 2021 04:56:35 -0700 (PDT)
MIME-Version: 1.0
References: <CAFXO6=+cHyQKM2n9yn4EhwLZO+AUB0ZD81qWPxmpN27rjUoU3w@mail.gmail.com>
 <CALZpt+HpvmEHUEOgye34T6pVQ+wnKKn-_8cTJTQXYQb9t1jOTA@mail.gmail.com>
 <CAFXO6=JzsYgiXJE2geSKMpfgPo+GGNX_+Pw0JQx1QQxAfhCdBQ@mail.gmail.com>
 <CALZpt+HQpdrebhWGXv_yLqiSCB5Ur71L1K13bd7w5TZb9DwJEQ@mail.gmail.com>
 <CAFXO6=Lvcr7Pwn_ZD1CZohYUFKY-cC5sGRxdTOiP2MgnTvFnYA@mail.gmail.com>
 <CALZpt+FFSk-+BBxu7SSdjw580UCFfkdo1DTa1Yj9K81M4E1vPg@mail.gmail.com>
 <CACdvm3Pgia5mn60HmZmi4t0U5coc13WBuDkh+QgQBAHZz+Ufow@mail.gmail.com>
 <CALZpt+G4Z3PaWDxAAcTi9FUC+CBF-_42iU-aBuarPvPh8Vqmfw@mail.gmail.com>
In-Reply-To: <CALZpt+G4Z3PaWDxAAcTi9FUC+CBF-_42iU-aBuarPvPh8Vqmfw@mail.gmail.com>
From: Gloria Zhao <gloriajzhao@gmail.com>
Date: Wed, 29 Sep 2021 12:56:24 +0100
Message-ID: <CAFXO6=Kn2GttDWQO2n76O-RGEUYP_7a556t58R3TXoSN859Y-w@mail.gmail.com>
To: Antoine Riard <antoine.riard@gmail.com>
Content-Type: multipart/alternative; boundary="000000000000a502f005cd2105e8"
X-Mailman-Approved-At: Wed, 29 Sep 2021 12:05:36 +0000
Cc: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Subject: Re: [bitcoin-dev] Proposal: Package Mempool Accept and Package RBF
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: Wed, 29 Sep 2021 11:56:43 -0000

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

Hi Antoine and Bastien,

> Yes 1) it would be good to have inputs of more potential users of package
acceptance . And 2) I think it's more a matter of clearer wording of the
proposal.

(1) I'm leaning towards multi-parent-1-child and offering [#22674][0] up
for review. If somebody feels very strongly about 1-parent-1-child, please
let me know.

(2) I'm glad this turned out to just be a wording problem. I've updated the
proposal to [say][1] "If it meets feerate requirements, the package can
replace mempool transactions if any of the parents conflict with mempool
transactions. The child cannot conflict with any mempool transactions."
Hopefully that is more *univoque*.

Side note: I've also updated the proposal to contain a [section][2] on why
submitting transactions individually before package validation is
incentive-compatible. I think it's relevant to our conversation, but for
those who just want to _use_ packages, it's just an implementation detail.

On restricting packages to confirmed inputs only:

> I think we could restrain package acceptance to only confirmed inputs for
now and revisit later this point ? For LN-anchor, you can assume that the
fee-bumping UTXO feeding the CPFP is already
confirmed. Or are there currently-deployed use-cases which would benefit
from your proposed Rule #2 ?

I thought about this a lot this week, and wrote up a summary of why I don't
think BIP125#2 helps us at all [here][3] on #23121. I see that you've
already come across it :)

> IIRC, the carve-out tolerance is only 2txn/10_000 vb. If one of your
counterparties attach a junk branch on her own anchor output, are you
allowed to chain your self-owned unconfirmed CPFP ?

Yes, if your counterparty attaches a bunch of descendants to their anchor
output to dominate the descendant limit of your shared commitment
transaction, CPFP carve out allows you to add 1 extra transaction under
10KvB to your own anchor output. It's fine if it spends an unconfirmed
input, as long as you aren't exceeding the descendant limits of that
transaction. This shouldn't be the case; I think something is seriously
wrong if all of your UTXOs are tied up in mempool transactions with big
ancestor/descendant trees.

I don't know much about L2 development so I'm just going to quote this:

> I think constraining package acceptance to only confirmed inputs is very
limiting and quite dangerous for L2 protocols.

Since the restriction isn't helpful in simplifying the mempool code, makes
things more complicated for application developers, and can be dangerous
for L2, I'd prefer not to add this restriction for packages.

On Antoine's question about our miner model:

> Can you describe what miner model we are using ? Like the block
construction strategy implemented by `addPackagesTxs` or also encompassing
our current mempool acceptance policy, which I think rely on absolute fee
over ancestor score in case of replacement ?

Our current model for block construction is this: we sort our mempool by
package ancestor score (total modified fees of a tx and its unconfirmed
ancestors / total vsize as seen by our mempool) and add packages to a block
until it's full. That's not to say this is the perfect miner policy, but
mempool acceptance logic follows this model as closely as possible because
it is, fundamentally, a cache that aids in block assembly performance. As
another way of looking at this, imagine if our mempool was so small it
could only store ~1 block's worth of transactions. It should always try to
keep the highest-fees-within-1-block transactions, and obviously wouldn't
evict small-but-valuable transations in favor or giant ones paying mediocre
feerates. All fee-related mempool policies, including RBF, consider
feerate. BIP125#3 is a rule on absolute fees, but it is always combined
with BIP125#4, a rule on feerates. AFAIK, the reason it doesn't use
ancestor score is that information wasn't cached in mempool entries at the
time, and thus not readily available to use in mempool validation.

That's why I don't think this is relevant to package validation. Commenting
on the model itself:

> Is this compatible with a model where a miner prioritizes absolute fees
over ancestor score, in the case that mempools aren't full-enough to
fulfill a block ?
>> Yes, A+C+D pays 2500sat more in fees, but it is also 1000vB larger. A
miner should prefer to utilize their block space more effectively.
> If your mempool is empty and only composed of A+C+D or A+B, I think
taking A+C+D is the most efficient block construction you can come up with
as a miner ?
> I think this point is worthy to discuss as otherwise we might downgrade
the efficiency of our current block construction strategy in periods of
near-empty mempools. A knowledge which could be discreetly leveraged by a
miner to gain an advantage on the rest of the mining ecosystem.

I believe this is suggesting "if our mempool has so few transactions that
it wouldn't reach block capacity, prioritize any increase in absolute fees,
even if the feerate is lower." I can see how this may result in a
higher-fee block in a specific scenario such as the one highlighted above,
but I don't think it is a sound model in general. It would be impossible to
tell when we should use this model: we could simply be in IBD, restarted a
node with an old/empty mempool.dat, and even if it's a
low-transaction-volume time, we never know what transactions will trickle
in between now and the next block. Going back to the tiny 1-block mempool
scenario, i.e., if you _never_ wanted to keep transactions that you
wouldn't put in the next block, would you ever switch strategies?

Thanks again to everyone who's given their attention to the package mempool
accept proposal.

Best,
Gloria

[0]: https://github.com/bitcoin/bitcoin/pull/22674
[1]:
https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#package-rbf
[2]:
https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#always-try-=
individual-submission-first
[3]: https://github.com/bitcoin/bitcoin/pull/23121#issuecomment-929475999

On Tue, Sep 28, 2021 at 11:59 PM Antoine Riard <antoine.riard@gmail.com>
wrote:

> Hi Bastien
>
> > In the case of LN, an attacker can game this and heavily restrict
> your RBF attempts if you're only allowed to use confirmed inputs
> and have many channels (and a limited number of confirmed inputs).
> Otherwise you'll need node operators to pre-emptively split their
> utxos into many small utxos just for fee bumping, which is inefficient...
>
> I share the concern about splitting utxos into smaller ones.
> IIRC, the carve-out tolerance is only 2txn/10_000 vb. If one of your
> counterparties attach a junk branch on her own anchor output, are you
> allowed to chain your self-owned unconfirmed CPFP ?
> I'm thinking about the topology "Chained CPFPs" exposed here :
> https://github.com/rust-bitcoin/rust-lightning/issues/989.
> Or if you have another L2 broadcast topology which could be safe w.r.t ou=
r
> current mempool logic :) ?
>
>
> Le lun. 27 sept. 2021 =C3=A0 03:15, Bastien TEINTURIER <bastien@acinq.fr>=
 a
> =C3=A9crit :
>
>> I think we could restrain package acceptance to only confirmed inputs fo=
r
>>> now and revisit later this point ? For LN-anchor, you can assume that t=
he
>>> fee-bumping UTXO feeding the CPFP is already
>>> confirmed. Or are there currently-deployed use-cases which would benefi=
t
>>> from your proposed Rule #2 ?
>>>
>>
>> I think constraining package acceptance to only confirmed inputs
>> is very limiting and quite dangerous for L2 protocols.
>>
>> In the case of LN, an attacker can game this and heavily restrict
>> your RBF attempts if you're only allowed to use confirmed inputs
>> and have many channels (and a limited number of confirmed inputs).
>> Otherwise you'll need node operators to pre-emptively split their
>> utxos into many small utxos just for fee bumping, which is inefficient..=
.
>>
>> Bastien
>>
>> Le lun. 27 sept. 2021 =C3=A0 00:27, Antoine Riard via bitcoin-dev <
>> bitcoin-dev@lists.linuxfoundation.org> a =C3=A9crit :
>>
>>> Hi Gloria,
>>>
>>> Thanks for your answers,
>>>
>>> > In summary, it seems that the decisions that might still need
>>> > attention/input from devs on this mailing list are:
>>> > 1. Whether we should start with multiple-parent-1-child or
>>> 1-parent-1-child.
>>> > 2. Whether it's ok to require that the child not have conflicts with
>>> > mempool transactions.
>>>
>>> Yes 1) it would be good to have inputs of more potential users of
>>> package acceptance . And 2) I think it's more a matter of clearer wordi=
ng
>>> of the proposal.
>>>
>>> However, see my final point on the relaxation around "unconfirmed
>>> inputs" which might in fact alter our current block construction strate=
gy.
>>>
>>> > Right, the fact that we essentially always choose the first-seen
>>> witness is
>>> > an unfortunate limitation that exists already. Adding package mempool
>>> > accept doesn't worsen this, but the procedure in the future is to
>>> replace
>>> > the witness when it makes sense economically. We can also add logic t=
o
>>> > allow package feerate to pay for witness replacements as well. This i=
s
>>> > pretty far into the future, though.
>>>
>>> Yes I agree package mempool doesn't worsen this. And it's not an issue
>>> for current LN as you can't significantly inflate a spending witness fo=
r
>>> the 2-of-2 funding output.
>>> However, it might be an issue for multi-party protocol where the
>>> spending script has alternative branches with asymmetric valid witness
>>> weights. Taproot should ease that kind of script so hopefully we would
>>> deploy wtxid-replacement not too far in the future.
>>>
>>> > I could be misunderstanding, but an attacker wouldn't be able to
>>> > batch-attack like this. Alice's package only conflicts with A' + D',
>>> not A'
>>> > + B' + C' + D'. She only needs to pay for evicting 2 transactions.
>>>
>>> Yeah I can be clearer, I think you have 2 pinning attacks scenarios to
>>> consider.
>>>
>>> In LN, if you're trying to confirm a commitment transaction to time-out
>>> or claim on-chain a HTLC and the timelock is near-expiration, you shoul=
d be
>>> ready to pay in commitment+2nd-stage HTLC transaction fees as much as t=
he
>>> value offered by the HTLC.
>>>
>>> Following this security assumption, an attacker can exploit it by
>>> targeting together commitment transactions from different channels by
>>> blocking them under a high-fee child, of which the fee value
>>> is equal to the top-value HTLC + 1. Victims's fee-bumping logics won't
>>> overbid as it's not worthy to offer fees beyond their competed HTLCs. A=
part
>>> from observing mempools state, victims can't learn they're targeted by =
the
>>> same attacker.
>>>
>>> To draw from the aforementioned topology, Mallory broadcasts A' + B' +
>>> C' + D', where A' conflicts with Alice's P1, B' conflicts with Bob's P2=
, C'
>>> conflicts with Caroll's P3. Let's assume P1 is confirming the top-value
>>> HTLC of the set. If D' fees is higher than P1 + 1, it won't be rational=
 for
>>> Alice or Bob or Caroll to keep offering competing feerates. Mallory wil=
l be
>>> at loss on stealing P1, as she has paid more in fees but will realize a
>>> gain on P2+P3.
>>>
>>> In this model, Alice is allowed to evict those 2 transactions (A' + D')
>>> but as she is economically-bounded she won't succeed.
>>>
>>> Mallory is maliciously exploiting RBF rule 3 on absolute fee. I think
>>> this 1st pinning scenario is correct and "lucractive" when you sum the
>>> global gain/loss.
>>>
>>> There is a 2nd attack scenario where A + B + C + D, where D is the chil=
d
>>> of A,B,C. All those transactions are honestly issued by Alice. Once A +=
 B +
>>> C + D are propagated in network mempools, Mallory is able to replace A =
+ D
>>> with  A' + D' where D' is paying a higher fee. This package A' + D' wil=
l
>>> confirm soon if D feerate was compelling but Mallory succeeds in delayi=
ng
>>> the confirmation
>>> of B + C for one or more blocks. As B + C are pre-signed commitments
>>> with a low-fee rate they won't confirm without Alice issuing a new chil=
d E.
>>> Mallory can repeat the same trick by broadcasting
>>> B' + E' and delay again the confirmation of C.
>>>
>>> If the remaining package pending HTLC has a higher-value than all the
>>> malicious fees over-bid, Mallory should realize a gain. With this 2nd
>>> pinning attack, the malicious entity buys confirmation delay of your
>>> packaged-together commitments.
>>>
>>> Assuming those attacks are correct, I'm leaning towards being
>>> conservative with the LDK broadcast backend. Though once again, other L=
2
>>> devs have likely other use-cases and opinions :)
>>>
>>> >  B' only needs to pay for itself in this case.
>>>
>>> Yes I think it's a nice discount when UTXO is single-owned. In the
>>> context of shared-owned UTXO (e.g LN), you might not if there is an
>>> in-mempool package already spending the UTXO and have to assume the
>>> worst-case scenario. I.e have B' committing enough fee to pay for A'
>>> replacement bandwidth. I think we can't do that much for this case...
>>>
>>> > If a package meets feerate requirements as a
>>> package, the parents in the transaction are allowed to replace-by-fee
>>> mempool transactions. The child cannot replace mempool transactions."
>>>
>>> I agree with the Mallory-vs-Alice case. Though if Alice broadcasts A+B'
>>> to replace A+B because the first broadcast isn't satisfying anymore due=
 to
>>> mempool spikes ? Assuming B' fees is enough, I think that case as child=
 B'
>>> replacing in-mempool transaction B. Which I understand going against  "=
The
>>> child cannot replace mempool transactions".
>>>
>>> Maybe wording could be a bit clearer ?
>>>
>>> > While it would be nice to have full RBF, malleability of the child
>>> won't
>>> > block RBF here. If we're trying to replace A', we only require that A=
'
>>> > signals replaceability, and don't mind if its child doesn't.
>>>
>>> Yes, it sounds good.
>>>
>>> > Yes, A+C+D pays 2500sat more in fees, but it is also 1000vB larger. A
>>> miner
>>> > should prefer to utilize their block space more effectively.
>>>
>>> If your mempool is empty and only composed of A+C+D or A+B, I think
>>> taking A+C+D is the most efficient block construction you can come up w=
ith
>>> as a miner ?
>>>
>>> > No, because we don't use that model.
>>>
>>> Can you describe what miner model we are using ? Like the block
>>> construction strategy implemented by `addPackagesTxs` or also encompass=
ing
>>> our current mempool acceptance policy, which I think rely on absolute f=
ee
>>> over ancestor score in case of replacement ?
>>>
>>> I think this point is worthy to discuss as otherwise we might downgrade
>>> the efficiency of our current block construction strategy in periods of
>>> near-empty mempools. A knowledge which could be discreetly leveraged by=
 a
>>> miner to gain an advantage on the rest of the mining ecosystem.
>>>
>>> Note, I think we *might* have to go in this direction if we want to
>>> replace replace-by-fee by replace-by-feerate or replace-by-ancestor and
>>> solve in-depth pinning attacks. Though if we do so,
>>> IMO we would need more thoughts.
>>>
>>> I think we could restrain package acceptance to only confirmed inputs
>>> for now and revisit later this point ? For LN-anchor, you can assume th=
at
>>> the fee-bumping UTXO feeding the CPFP is already
>>> confirmed. Or are there currently-deployed use-cases which would benefi=
t
>>> from your proposed Rule #2 ?
>>>
>>> Antoine
>>>
>>> Le jeu. 23 sept. 2021 =C3=A0 11:36, Gloria Zhao <gloriajzhao@gmail.com>=
 a
>>> =C3=A9crit :
>>>
>>>> Hi Antoine,
>>>>
>>>> Thanks as always for your input. I'm glad we agree on so much!
>>>>
>>>> In summary, it seems that the decisions that might still need
>>>> attention/input from devs on this mailing list are:
>>>> 1. Whether we should start with multiple-parent-1-child or
>>>> 1-parent-1-child.
>>>> 2. Whether it's ok to require that the child not have conflicts with
>>>> mempool transactions.
>>>>
>>>> Responding to your comments...
>>>>
>>>> > IIUC, you have package A+B, during the dedup phase early in
>>>> `AcceptMultipleTransactions` if you observe same-txid-different-wtixd =
A'
>>>> and A' is higher feerate than A, you trim A and replace by A' ?
>>>>
>>>> > I think this approach is safe, the one who appears unsafe to me is
>>>> when A' has a _lower_ feerate, even if A' is already accepted by our
>>>> mempool ? In that case iirc that would be a pinning.
>>>>
>>>> Right, the fact that we essentially always choose the first-seen
>>>> witness is an unfortunate limitation that exists already. Adding packa=
ge
>>>> mempool accept doesn't worsen this, but the procedure in the future is=
 to
>>>> replace the witness when it makes sense economically. We can also add =
logic
>>>> to allow package feerate to pay for witness replacements as well. This=
 is
>>>> pretty far into the future, though.
>>>>
>>>> > It sounds uneconomical for an attacker but I think it's not when you
>>>> consider than you can "batch" attack against multiple honest
>>>> counterparties. E.g, Mallory broadcast A' + B' + C' + D' where A' conf=
licts
>>>> with Alice's honest package P1, B' conflicts with Bob's honest package=
 P2,
>>>> C' conflicts with Caroll's honest package P3. And D' is a high-fee chi=
ld of
>>>> A' + B' + C'.
>>>>
>>>> > If D' is higher-fee than P1 or P2 or P3 but inferior to the sum of
>>>> HTLCs confirmed by P1+P2+P3, I think it's lucrative for the attacker ?
>>>>
>>>> I could be misunderstanding, but an attacker wouldn't be able to
>>>> batch-attack like this. Alice's package only conflicts with A' + D', n=
ot A'
>>>> + B' + C' + D'. She only needs to pay for evicting 2 transactions.
>>>>
>>>> > Do we assume that broadcasted packages are "honest" by default and
>>>> that the parent(s) always need the child to pass the fee checks, that =
way
>>>> saving the processing of individual transactions which are expected to=
 fail
>>>> in 99% of cases or more ad hoc composition of packages at relay ?
>>>> > I think this point is quite dependent on the p2p packages
>>>> format/logic we'll end up on and that we should feel free to revisit i=
t
>>>> later ?
>>>>
>>>> I think it's the opposite; there's no way for us to assume that p2p
>>>> packages will be "honest." I'd like to have two things before we expos=
e on
>>>> P2P: (1) ensure that the amount of resources potentially allocated for
>>>> package validation isn't disproportionately higher than that of single
>>>> transaction validation and (2) only use package validation when we're
>>>> unsatisifed with the single validation result, e.g. we might get bette=
r
>>>> fees.
>>>> Yes, let's revisit this later :)
>>>>
>>>>  > Yes, if you receive A+B, and A is already in-mempoo, I agree you ca=
n
>>>> discard its feerate as B should pay for all fees checked on its own. W=
here
>>>> I'm unclear is when you have in-mempool A+B and receive A+B'. Should B=
'
>>>> have a fee high enough to cover the bandwidth penalty replacement
>>>> (`PaysForRBF`, 2nd check) of both A+B' or only B' ?
>>>>
>>>>  B' only needs to pay for itself in this case.
>>>>
>>>> > > Do we want the child to be able to replace mempool transactions as
>>>> well?
>>>>
>>>> > If we mean when you have replaceable A+B then A'+B' try to replace
>>>> with a higher-feerate ? I think that's exactly the case we need for
>>>> Lightning as A+B is coming from Alice and A'+B' is coming from Bob :/
>>>>
>>>> Let me clarify this because I can see that my wording was ambiguous,
>>>> and then please let me know if it fits Lightning's needs?
>>>>
>>>> In my proposal, I wrote "If a package meets feerate requirements as a
>>>> package, the parents in the transaction are allowed to replace-by-fee
>>>> mempool transactions. The child cannot replace mempool transactions." =
What
>>>> I meant was: the package can replace mempool transactions if any of th=
e
>>>> parents conflict with mempool transactions. The child cannot not confl=
ict
>>>> with any mempool transactions.
>>>> The Lightning use case this attempts to address is: Alice and Mallory
>>>> are LN counterparties, and have packages A+B and A'+B', respectively. =
A and
>>>> A' are their commitment transactions and conflict with each other; the=
y
>>>> have shared inputs and different txids.
>>>> B spends Alice's anchor output from A. B' spends Mallory's anchor
>>>> output from A'. Thus, B and B' do not conflict with each other.
>>>> Alice can broadcast her package, A+B, to replace Mallory's package,
>>>> A'+B', since B doesn't conflict with the mempool.
>>>>
>>>> Would this be ok?
>>>>
>>>> > The second option, a child of A', In the LN case I think the CPFP is
>>>> attached on one's anchor output.
>>>>
>>>> While it would be nice to have full RBF, malleability of the child
>>>> won't block RBF here. If we're trying to replace A', we only require t=
hat
>>>> A' signals replaceability, and don't mind if its child doesn't.
>>>>
>>>> > > B has an ancestor score of 10sat/vb and D has an
>>>> > > ancestor score of ~2.9sat/vb. Since D's ancestor score is lower
>>>> than B's,
>>>> > > it fails the proposed package RBF Rule #2, so this package would b=
e
>>>> > > rejected. Does this meet your expectations?
>>>>
>>>> > Well what sounds odd to me, in my example, we fail D even if it has =
a
>>>> higher-fee than B. Like A+B absolute fees are 2000 sats and A+C+D abso=
lute
>>>> fees are 4500 sats ?
>>>>
>>>> Yes, A+C+D pays 2500sat more in fees, but it is also 1000vB larger. A
>>>> miner should prefer to utilize their block space more effectively.
>>>>
>>>> > Is this compatible with a model where a miner prioritizes absolute
>>>> fees over ancestor score, in the case that mempools aren't full-enough=
 to
>>>> fulfill a block ?
>>>>
>>>> No, because we don't use that model.
>>>>
>>>> Thanks,
>>>> Gloria
>>>>
>>>> On Thu, Sep 23, 2021 at 5:29 AM Antoine Riard <antoine.riard@gmail.com=
>
>>>> wrote:
>>>>
>>>>> > Correct, if B+C is too low feerate to be accepted, we will reject
>>>>> it. I
>>>>> > prefer this because it is incentive compatible: A can be mined by
>>>>> itself,
>>>>> > so there's no reason to prefer A+B+C instead of A.
>>>>> > As another way of looking at this, consider the case where we do
>>>>> accept
>>>>> > A+B+C and it sits at the "bottom" of our mempool. If our mempool
>>>>> reaches
>>>>> > capacity, we evict the lowest descendant feerate transactions, whic=
h
>>>>> are
>>>>> > B+C in this case. This gives us the same resulting mempool, with A
>>>>> and not
>>>>> > B+C.
>>>>>
>>>>> I agree here. Doing otherwise, we might evict other transactions
>>>>> mempool in `MempoolAccept::Finalize` with a higher-feerate than B+C w=
hile
>>>>> those evicted transactions are the most compelling for block construc=
tion.
>>>>>
>>>>> I thought at first missing this acceptance requirement would break a
>>>>> fee-bumping scheme like Parent-Pay-For-Child where a high-fee parent =
is
>>>>> attached to a child signed with SIGHASH_ANYONECANPAY but in this case=
 the
>>>>> child fee is capturing the parent value. I can't think of other fee-b=
umping
>>>>> schemes potentially affected. If they do exist I would say they're wr=
ong in
>>>>> their design assumptions.
>>>>>
>>>>> > If or when we have witness replacement, the logic is: if the
>>>>> individual
>>>>> > transaction is enough to replace the mempool one, the replacement
>>>>> will
>>>>> > happen during the preceding individual transaction acceptance, and
>>>>> > deduplication logic will work. Otherwise, we will try to deduplicat=
e
>>>>> by
>>>>> > wtxid, see that we need a package witness replacement, and use the
>>>>> package
>>>>> > feerate to evaluate whether this is economically rational.
>>>>>
>>>>> IIUC, you have package A+B, during the dedup phase early in
>>>>> `AcceptMultipleTransactions` if you observe same-txid-different-wtixd=
 A'
>>>>> and A' is higher feerate than A, you trim A and replace by A' ?
>>>>>
>>>>> I think this approach is safe, the one who appears unsafe to me is
>>>>> when A' has a _lower_ feerate, even if A' is already accepted by our
>>>>> mempool ? In that case iirc that would be a pinning.
>>>>>
>>>>> Good to see progress on witness replacement before we see usage of
>>>>> Taproot tree in the context of multi-party, where a malicious counter=
party
>>>>> inflates its witness to jam a honest spending.
>>>>>
>>>>> (Note, the commit linked currently points nowhere :))
>>>>>
>>>>>
>>>>> > Please note that A may replace A' even if A' has higher fees than A
>>>>> > individually, because the proposed package RBF utilizes the fees an=
d
>>>>> size
>>>>> > of the entire package. This just requires E to pay enough fees,
>>>>> although
>>>>> > this can be pretty high if there are also potential B' and C'
>>>>> competing
>>>>> > commitment transactions that we don't know about.
>>>>>
>>>>> Ah right, if the package acceptance waives `PaysMoreThanConflicts` fo=
r
>>>>> the individual check on A, the honest package should replace the pinn=
ing
>>>>> attempt. I've not fully parsed the proposed implementation yet.
>>>>>
>>>>> Though note, I think it's still unsafe for a Lightning
>>>>> multi-commitment-broadcast-as-one-package as a malicious A' might hav=
e an
>>>>> absolute fee higher than E. It sounds uneconomical for
>>>>> an attacker but I think it's not when you consider than you can
>>>>> "batch" attack against multiple honest counterparties. E.g, Mallory
>>>>> broadcast A' + B' + C' + D' where A' conflicts with Alice's honest pa=
ckage
>>>>> P1, B' conflicts with Bob's honest package P2, C' conflicts with Caro=
ll's
>>>>> honest package P3. And D' is a high-fee child of A' + B' + C'.
>>>>>
>>>>> If D' is higher-fee than P1 or P2 or P3 but inferior to the sum of
>>>>> HTLCs confirmed by P1+P2+P3, I think it's lucrative for the attacker =
?
>>>>>
>>>>> > So far, my understanding is that multi-parent-1-child is desired fo=
r
>>>>> > batched fee-bumping (
>>>>> > https://github.com/bitcoin/bitcoin/pull/22674#issuecomment-89795128=
9)
>>>>> and
>>>>> > I've also seen your response which I have less context on (
>>>>> > https://github.com/bitcoin/bitcoin/pull/22674#issuecomment-90035220=
2).
>>>>> That
>>>>> > being said, I am happy to create a new proposal for 1 parent + 1
>>>>> child
>>>>> > (which would be slightly simpler) and plan for moving to
>>>>> > multi-parent-1-child later if that is preferred. I am very
>>>>> interested in
>>>>> > hearing feedback on that approach.
>>>>>
>>>>> I think batched fee-bumping is okay as long as you don't have
>>>>> time-sensitive outputs encumbering your commitment transactions. For =
the
>>>>> reasons mentioned above, I think that's unsafe.
>>>>>
>>>>> What I'm worried about is  L2 developers, potentially not aware about
>>>>> all the mempool subtleties blurring the difference and always batchin=
g
>>>>> their broadcast by default.
>>>>>
>>>>> IMO, a good thing by restraining to 1-parent + 1 child,  we
>>>>> artificially constraint L2 design space for now and minimize risks of
>>>>> unsafe usage of the package API :)
>>>>>
>>>>> I think that's a point where it would be relevant to have the opinion
>>>>> of more L2 devs.
>>>>>
>>>>> > I think there is a misunderstanding here - let me describe what I'm
>>>>> > proposing we'd do in this situation: we'll try individual submissio=
n
>>>>> for A,
>>>>> > see that it fails due to "insufficient fees." Then, we'll try packa=
ge
>>>>> > validation for A+B and use package RBF. If A+B pays enough, it can
>>>>> still
>>>>> > replace A'. If A fails for a bad signature, we won't look at B or
>>>>> A+B. Does
>>>>> > this meet your expectations?
>>>>>
>>>>> Yes there was a misunderstanding, I think this approach is correct,
>>>>> it's more a question of performance. Do we assume that broadcasted pa=
ckages
>>>>> are "honest" by default and that the parent(s) always need the child =
to
>>>>> pass the fee checks, that way saving the processing of individual
>>>>> transactions which are expected to fail in 99% of cases or more ad ho=
c
>>>>> composition of packages at relay ?
>>>>>
>>>>> I think this point is quite dependent on the p2p packages format/logi=
c
>>>>> we'll end up on and that we should feel free to revisit it later ?
>>>>>
>>>>>
>>>>> > What problem are you trying to solve by the package feerate *after*
>>>>> dedup
>>>>> rule ?
>>>>> > My understanding is that an in-package transaction might be already
>>>>> in
>>>>> the mempool. Therefore, to compute a correct RBF penalty replacement,
>>>>> the
>>>>> vsize of this transaction could be discarded lowering the cost of
>>>>> package
>>>>> RBF.
>>>>>
>>>>> > I'm proposing that, when a transaction has already been submitted t=
o
>>>>> > mempool, we would ignore both its fees and vsize when calculating
>>>>> package
>>>>> > feerate.
>>>>>
>>>>> Yes, if you receive A+B, and A is already in-mempoo, I agree you can
>>>>> discard its feerate as B should pay for all fees checked on its own. =
Where
>>>>> I'm unclear is when you have in-mempool A+B and receive A+B'. Should =
B'
>>>>> have a fee high enough to cover the bandwidth penalty replacement
>>>>> (`PaysForRBF`, 2nd check) of both A+B' or only B' ?
>>>>>
>>>>> If you have a second-layer like current Lightning, you might have a
>>>>> counterparty commitment to replace and should always expect to have t=
o pay
>>>>> for parent replacement bandwidth.
>>>>>
>>>>> Where a potential discount sounds interesting is when you have an
>>>>> univoque state on the first-stage of transactions. E.g DLC's funding
>>>>> transaction which might be CPFP by any participant iirc.
>>>>>
>>>>> > Note that, if C' conflicts with C, it also conflicts with D, since =
D
>>>>> is a
>>>>> > descendant of C and would thus need to be evicted along with it.
>>>>>
>>>>> Ah once again I think it's a misunderstanding without the code under
>>>>> my eyes! If we do C' `PreChecks`, solve the conflicts provoked by it,=
 i.e
>>>>> mark for potential eviction D and don't consider it for future confli=
cts in
>>>>> the rest of the package, I think D' `PreChecks` should be good ?
>>>>>
>>>>> > More generally, this example is surprising to me because I didn't
>>>>> think
>>>>> > packages would be used to fee-bump replaceable transactions. Do we
>>>>> want the
>>>>> > child to be able to replace mempool transactions as well?
>>>>>
>>>>> If we mean when you have replaceable A+B then A'+B' try to replace
>>>>> with a higher-feerate ? I think that's exactly the case we need for
>>>>> Lightning as A+B is coming from Alice and A'+B' is coming from Bob :/
>>>>>
>>>>> > I'm not sure what you mean? Let's say we have a package of parent A
>>>>> + child
>>>>> > B, where A is supposed to replace a mempool transaction A'. Are you
>>>>> saying
>>>>> > that counterparties are able to malleate the package child B, or a
>>>>> child of
>>>>> > A'?
>>>>>
>>>>> The second option, a child of A', In the LN case I think the CPFP is
>>>>> attached on one's anchor output.
>>>>>
>>>>> I think it's good if we assume the
>>>>> solve-conflicts-after-parent's`'PreChecks` mentioned above or fixing
>>>>> inherited signaling or full-rbf ?
>>>>>
>>>>> > Sorry, I don't understand what you mean by "preserve the package
>>>>> > integrity?" Could you elaborate?
>>>>>
>>>>> After thinking the relaxation about the "new" unconfirmed input is no=
t
>>>>> linked to trimming but I would say more to the multi-parent support.
>>>>>
>>>>> Let's say you have A+B trying to replace C+D where B is also spending
>>>>> already in-mempool E. To succeed, you need to waive the no-new-unconf=
irmed
>>>>> input as D isn't spending E.
>>>>>
>>>>> So good, I think we agree on the problem description here.
>>>>>
>>>>> > I am in agreement with your calculations but unsure if we disagree
>>>>> on the
>>>>> > expected outcome. Yes, B has an ancestor score of 10sat/vb and D ha=
s
>>>>> an
>>>>> > ancestor score of ~2.9sat/vb. Since D's ancestor score is lower tha=
n
>>>>> B's,
>>>>> > it fails the proposed package RBF Rule #2, so this package would be
>>>>> > rejected. Does this meet your expectations?
>>>>>
>>>>> Well what sounds odd to me, in my example, we fail D even if it has a
>>>>> higher-fee than B. Like A+B absolute fees are 2000 sats and A+C+D abs=
olute
>>>>> fees are 4500 sats ?
>>>>>
>>>>> Is this compatible with a model where a miner prioritizes absolute
>>>>> fees over ancestor score, in the case that mempools aren't full-enoug=
h to
>>>>> fulfill a block ?
>>>>>
>>>>> Let me know if I can clarify a point.
>>>>>
>>>>> Antoine
>>>>>
>>>>> Le lun. 20 sept. 2021 =C3=A0 11:10, Gloria Zhao <gloriajzhao@gmail.co=
m> a
>>>>> =C3=A9crit :
>>>>>
>>>>>>
>>>>>> Hi Antoine,
>>>>>>
>>>>>> First of all, thank you for the thorough review. I appreciate your
>>>>>> insight on LN requirements.
>>>>>>
>>>>>> > IIUC, you have a package A+B+C submitted for acceptance and A is
>>>>>> already in your mempool. You trim out A from the package and then ev=
aluate
>>>>>> B+C.
>>>>>>
>>>>>> > I think this might be an issue if A is the higher-fee element of
>>>>>> the ABC package. B+C package fees might be under the mempool min fee=
 and
>>>>>> will be rejected, potentially breaking the acceptance expectations o=
f the
>>>>>> package issuer ?
>>>>>>
>>>>>> Correct, if B+C is too low feerate to be accepted, we will reject it=
.
>>>>>> I prefer this because it is incentive compatible: A can be mined by =
itself,
>>>>>> so there's no reason to prefer A+B+C instead of A.
>>>>>> As another way of looking at this, consider the case where we do
>>>>>> accept A+B+C and it sits at the "bottom" of our mempool. If our memp=
ool
>>>>>> reaches capacity, we evict the lowest descendant feerate transaction=
s,
>>>>>> which are B+C in this case. This gives us the same resulting mempool=
, with
>>>>>> A and not B+C.
>>>>>>
>>>>>>
>>>>>> > Further, I think the dedup should be done on wtxid, as you might
>>>>>> have multiple valid witnesses. Though with varying vsizes and as suc=
h
>>>>>> offering different feerates.
>>>>>>
>>>>>> I agree that variations of the same package with different witnesses
>>>>>> is a case that must be handled. I consider witness replacement to be=
 a
>>>>>> project that can be done in parallel to package mempool acceptance b=
ecause
>>>>>> being able to accept packages does not worsen the problem of a
>>>>>> same-txid-different-witness "pinning" attack.
>>>>>>
>>>>>> If or when we have witness replacement, the logic is: if the
>>>>>> individual transaction is enough to replace the mempool one, the
>>>>>> replacement will happen during the preceding individual transaction
>>>>>> acceptance, and deduplication logic will work. Otherwise, we will tr=
y to
>>>>>> deduplicate by wtxid, see that we need a package witness replacement=
, and
>>>>>> use the package feerate to evaluate whether this is economically rat=
ional.
>>>>>>
>>>>>> See the #22290 "handle package transactions already in mempool"
>>>>>> commit (
>>>>>> https://github.com/bitcoin/bitcoin/pull/22290/commits/fea75a2237b46c=
f76145242fecad7e274bfcb5ff),
>>>>>> which handles the case of same-txid-different-witness by simply usin=
g the
>>>>>> transaction in the mempool for now, with TODOs for what I just descr=
ibed.
>>>>>>
>>>>>>
>>>>>> > I'm not clearly understanding the accepted topologies. By "parent
>>>>>> and child to share a parent", do you mean the set of transactions A,=
 B, C,
>>>>>> where B is spending A and C is spending A and B would be correct ?
>>>>>>
>>>>>> Yes, that is what I meant. Yes, that would a valid package under
>>>>>> these rules.
>>>>>>
>>>>>> > If yes, is there a width-limit introduced or we fallback on
>>>>>> MAX_PACKAGE_COUNT=3D25 ?
>>>>>>
>>>>>> No, there is no limit on connectivity other than "child with all
>>>>>> unconfirmed parents." We will enforce MAX_PACKAGE_COUNT=3D25 and chi=
ld's
>>>>>> in-mempool + in-package ancestor limits.
>>>>>>
>>>>>>
>>>>>> > Considering the current Core's mempool acceptance rules, I think
>>>>>> CPFP batching is unsafe for LN time-sensitive closure. A malicious t=
x-relay
>>>>>> jamming successful on one channel commitment transaction would conta=
mine
>>>>>> the remaining commitments sharing the same package.
>>>>>>
>>>>>> > E.g, you broadcast the package A+B+C+D+E where A,B,C,D are
>>>>>> commitment transactions and E a shared CPFP. If a malicious A' trans=
action
>>>>>> has a better feerate than A, the whole package acceptance will fail.=
 Even
>>>>>> if A' confirms in the following block,
>>>>>> the propagation and confirmation of B+C+D have been delayed. This
>>>>>> could carry on a loss of funds.
>>>>>>
>>>>>> Please note that A may replace A' even if A' has higher fees than A
>>>>>> individually, because the proposed package RBF utilizes the fees and=
 size
>>>>>> of the entire package. This just requires E to pay enough fees, alth=
ough
>>>>>> this can be pretty high if there are also potential B' and C' compet=
ing
>>>>>> commitment transactions that we don't know about.
>>>>>>
>>>>>>
>>>>>> > IMHO, I'm leaning towards deploying during a first phase
>>>>>> 1-parent/1-child. I think it's the most conservative step still impr=
oving
>>>>>> second-layer safety.
>>>>>>
>>>>>> So far, my understanding is that multi-parent-1-child is desired for
>>>>>> batched fee-bumping (
>>>>>> https://github.com/bitcoin/bitcoin/pull/22674#issuecomment-897951289=
)
>>>>>> and I've also seen your response which I have less context on (
>>>>>> https://github.com/bitcoin/bitcoin/pull/22674#issuecomment-900352202=
).
>>>>>> That being said, I am happy to create a new proposal for 1 parent + =
1 child
>>>>>> (which would be slightly simpler) and plan for moving to
>>>>>> multi-parent-1-child later if that is preferred. I am very intereste=
d in
>>>>>> hearing feedback on that approach.
>>>>>>
>>>>>>
>>>>>> > If A+B is submitted to replace A', where A pays 0 sats, B pays 200
>>>>>> sats and A' pays 100 sats. If we apply the individual RBF on A, A+B
>>>>>> acceptance fails. For this reason I think the individual RBF should =
be
>>>>>> bypassed and only the package RBF apply ?
>>>>>>
>>>>>> I think there is a misunderstanding here - let me describe what I'm
>>>>>> proposing we'd do in this situation: we'll try individual submission=
 for A,
>>>>>> see that it fails due to "insufficient fees." Then, we'll try packag=
e
>>>>>> validation for A+B and use package RBF. If A+B pays enough, it can s=
till
>>>>>> replace A'. If A fails for a bad signature, we won't look at B or A+=
B. Does
>>>>>> this meet your expectations?
>>>>>>
>>>>>>
>>>>>> > What problem are you trying to solve by the package feerate *after=
*
>>>>>> dedup rule ?
>>>>>> > My understanding is that an in-package transaction might be alread=
y
>>>>>> in the mempool. Therefore, to compute a correct RBF penalty replacem=
ent,
>>>>>> the vsize of this transaction could be discarded lowering the cost o=
f
>>>>>> package RBF.
>>>>>>
>>>>>> I'm proposing that, when a transaction has already been submitted to
>>>>>> mempool, we would ignore both its fees and vsize when calculating pa=
ckage
>>>>>> feerate. In example G2, we shouldn't count M1 fees after its submiss=
ion to
>>>>>> mempool, since M1's fees have already been used to pay for its indiv=
idual
>>>>>> bandwidth, and it shouldn't be used again to pay for P2 and P3's ban=
dwidth.
>>>>>> We also shouldn't count its vsize, since it has already been paid fo=
r.
>>>>>>
>>>>>>
>>>>>> > I think this is a footgunish API, as if a package issuer send the
>>>>>> multiple-parent-one-child package A,B,C,D where D is the child of A,=
B,C.
>>>>>> Then try to broadcast the higher-feerate C'+D' package, it should be
>>>>>> rejected. So it's breaking the naive broadcaster assumption that a
>>>>>> higher-feerate/higher-fee package always replaces ?
>>>>>>
>>>>>> Note that, if C' conflicts with C, it also conflicts with D, since D
>>>>>> is a descendant of C and would thus need to be evicted along with it=
.
>>>>>> Implicitly, D' would not be in conflict with D.
>>>>>> More generally, this example is surprising to me because I didn't
>>>>>> think packages would be used to fee-bump replaceable transactions. D=
o we
>>>>>> want the child to be able to replace mempool transactions as well? T=
his can
>>>>>> be implemented with a bit of additional logic.
>>>>>>
>>>>>> > I think this is unsafe for L2s if counterparties have malleability
>>>>>> of the child transaction. They can block your package replacement by
>>>>>> opting-out from RBF signaling. IIRC, LN's "anchor output" presents s=
uch an
>>>>>> ability.
>>>>>>
>>>>>> I'm not sure what you mean? Let's say we have a package of parent A =
+
>>>>>> child B, where A is supposed to replace a mempool transaction A'. Ar=
e you
>>>>>> saying that counterparties are able to malleate the package child B,=
 or a
>>>>>> child of A'? If they can malleate a child of A', that shouldn't matt=
er as
>>>>>> long as A' is signaling replacement. This would be handled identical=
ly with
>>>>>> full RBF and what Core currently implements.
>>>>>>
>>>>>> > I think this is an issue brought by the trimming during the dedup
>>>>>> phase. If we preserve the package integrity, only re-using the tx-le=
vel
>>>>>> checks results of already in-mempool transactions to gain in CPU tim=
e we
>>>>>> won't have this issue. Package childs can add unconfirmed inputs as =
long as
>>>>>> they're in-package, the bip125 rule2 is only evaluated against paren=
ts ?
>>>>>>
>>>>>> Sorry, I don't understand what you mean by "preserve the package
>>>>>> integrity?" Could you elaborate?
>>>>>>
>>>>>> > Let's say you have in-mempool A, B where A pays 10 sat/vb for 100
>>>>>> vbytes and B pays 10 sat/vb for 100 vbytes. You have the candidate
>>>>>> replacement D spending both A and C where D pays 15sat/vb for 100 vb=
ytes
>>>>>> and C pays 1 sat/vb for 1000 vbytes.
>>>>>>
>>>>>> > Package A + B ancestor score is 10 sat/vb.
>>>>>>
>>>>>> > D has a higher feerate/absolute fee than B.
>>>>>>
>>>>>> > Package A + C + D ancestor score is ~ 3 sat/vb ((A's 1000 sats +
>>>>>> C's 1000 sats + D's 1500 sats) / A's 100 vb + C's 1000 vb + D's 100 =
vb)
>>>>>>
>>>>>> I am in agreement with your calculations but unsure if we disagree o=
n
>>>>>> the expected outcome. Yes, B has an ancestor score of 10sat/vb and D=
 has an
>>>>>> ancestor score of ~2.9sat/vb. Since D's ancestor score is lower than=
 B's,
>>>>>> it fails the proposed package RBF Rule #2, so this package would be
>>>>>> rejected. Does this meet your expectations?
>>>>>>
>>>>>> Thank you for linking to projects that might be interested in packag=
e
>>>>>> relay :)
>>>>>>
>>>>>> Thanks,
>>>>>> Gloria
>>>>>>
>>>>>> On Mon, Sep 20, 2021 at 12:16 AM Antoine Riard <
>>>>>> antoine.riard@gmail.com> wrote:
>>>>>>
>>>>>>> Hi Gloria,
>>>>>>>
>>>>>>> > A package may contain transactions that are already in the
>>>>>>> mempool. We
>>>>>>> > remove
>>>>>>> > ("deduplicate") those transactions from the package for the
>>>>>>> purposes of
>>>>>>> > package
>>>>>>> > mempool acceptance. If a package is empty after deduplication, we
>>>>>>> do
>>>>>>> > nothing.
>>>>>>>
>>>>>>> IIUC, you have a package A+B+C submitted for acceptance and A is
>>>>>>> already in your mempool. You trim out A from the package and then e=
valuate
>>>>>>> B+C.
>>>>>>>
>>>>>>> I think this might be an issue if A is the higher-fee element of th=
e
>>>>>>> ABC package. B+C package fees might be under the mempool min fee an=
d will
>>>>>>> be rejected, potentially breaking the acceptance expectations of th=
e
>>>>>>> package issuer ?
>>>>>>>
>>>>>>> Further, I think the dedup should be done on wtxid, as you might
>>>>>>> have multiple valid witnesses. Though with varying vsizes and as su=
ch
>>>>>>> offering different feerates.
>>>>>>>
>>>>>>> E.g you're going to evaluate the package A+B and A' is already in
>>>>>>> your mempool with a bigger valid witness. You trim A based on txid,=
 then
>>>>>>> you evaluate A'+B, which fails the fee checks. However, evaluating =
A+B
>>>>>>> would have been a success.
>>>>>>>
>>>>>>> AFAICT, the dedup rationale would be to save on CPU time/IO disk, t=
o
>>>>>>> avoid repeated signatures verification and parent UTXOs fetches ? C=
an we
>>>>>>> achieve the same goal by bypassing tx-level checks for already-in t=
xn while
>>>>>>> conserving the package integrity for package-level checks ?
>>>>>>>
>>>>>>> > Note that it's possible for the parents to be
>>>>>>> > indirect
>>>>>>> > descendants/ancestors of one another, or for parent and child to
>>>>>>> share a
>>>>>>> > parent,
>>>>>>> > so we cannot make any other topology assumptions.
>>>>>>>
>>>>>>> I'm not clearly understanding the accepted topologies. By "parent
>>>>>>> and child to share a parent", do you mean the set of transactions A=
, B, C,
>>>>>>> where B is spending A and C is spending A and B would be correct ?
>>>>>>>
>>>>>>> If yes, is there a width-limit introduced or we fallback on
>>>>>>> MAX_PACKAGE_COUNT=3D25 ?
>>>>>>>
>>>>>>> IIRC, one rationale to come with this topology limitation was to
>>>>>>> lower the DoS risks when potentially deploying p2p packages.
>>>>>>>
>>>>>>> Considering the current Core's mempool acceptance rules, I think
>>>>>>> CPFP batching is unsafe for LN time-sensitive closure. A malicious =
tx-relay
>>>>>>> jamming successful on one channel commitment transaction would cont=
amine
>>>>>>> the remaining commitments sharing the same package.
>>>>>>>
>>>>>>> E.g, you broadcast the package A+B+C+D+E where A,B,C,D are
>>>>>>> commitment transactions and E a shared CPFP. If a malicious A' tran=
saction
>>>>>>> has a better feerate than A, the whole package acceptance will fail=
. Even
>>>>>>> if A' confirms in the following block,
>>>>>>> the propagation and confirmation of B+C+D have been delayed. This
>>>>>>> could carry on a loss of funds.
>>>>>>>
>>>>>>> That said, if you're broadcasting commitment transactions without
>>>>>>> time-sensitive HTLC outputs, I think the batching is effectively a =
fee
>>>>>>> saving as you don't have to duplicate the CPFP.
>>>>>>>
>>>>>>> IMHO, I'm leaning towards deploying during a first phase
>>>>>>> 1-parent/1-child. I think it's the most conservative step still imp=
roving
>>>>>>> second-layer safety.
>>>>>>>
>>>>>>> > *Rationale*:  It would be incorrect to use the fees of
>>>>>>> transactions that are
>>>>>>> > already in the mempool, as we do not want a transaction's fees to
>>>>>>> be
>>>>>>> > double-counted for both its individual RBF and package RBF.
>>>>>>>
>>>>>>> I'm unsure about the logical order of the checks proposed.
>>>>>>>
>>>>>>> If A+B is submitted to replace A', where A pays 0 sats, B pays 200
>>>>>>> sats and A' pays 100 sats. If we apply the individual RBF on A, A+B
>>>>>>> acceptance fails. For this reason I think the individual RBF should=
 be
>>>>>>> bypassed and only the package RBF apply ?
>>>>>>>
>>>>>>> Note this situation is plausible, with current LN design, your
>>>>>>> counterparty can have a commitment transaction with a better fee ju=
st by
>>>>>>> selecting a higher `dust_limit_satoshis` than yours.
>>>>>>>
>>>>>>> > Examples F and G [14] show the same package, but P1 is submitted
>>>>>>> > individually before
>>>>>>> > the package in example G. In example F, we can see that the 300vB
>>>>>>> package
>>>>>>> > pays
>>>>>>> > an additional 200sat in fees, which is not enough to pay for its
>>>>>>> own
>>>>>>> > bandwidth
>>>>>>> > (BIP125#4). In example G, we can see that P1 pays enough to
>>>>>>> replace M1, but
>>>>>>> > using P1's fees again during package submission would make it loo=
k
>>>>>>> like a
>>>>>>> > 300sat
>>>>>>> > increase for a 200vB package. Even including its fees and size
>>>>>>> would not be
>>>>>>> > sufficient in this example, since the 300sat looks like enough fo=
r
>>>>>>> the 300vB
>>>>>>> > package. The calculcation after deduplication is 100sat increase
>>>>>>> for a
>>>>>>> > package
>>>>>>> > of size 200vB, which correctly fails BIP125#4. Assume all
>>>>>>> transactions have
>>>>>>> > a
>>>>>>> > size of 100vB.
>>>>>>>
>>>>>>> What problem are you trying to solve by the package feerate *after*
>>>>>>> dedup rule ?
>>>>>>>
>>>>>>> My understanding is that an in-package transaction might be already
>>>>>>> in the mempool. Therefore, to compute a correct RBF penalty replace=
ment,
>>>>>>> the vsize of this transaction could be discarded lowering the cost =
of
>>>>>>> package RBF.
>>>>>>>
>>>>>>> If we keep a "safe" dedup mechanism (see my point above), I think
>>>>>>> this discount is justified, as the validation cost of node operator=
s is
>>>>>>> paid for ?
>>>>>>>
>>>>>>> > The child cannot replace mempool transactions.
>>>>>>>
>>>>>>> Let's say you issue package A+B, then package C+B', where B' is a
>>>>>>> child of both A and C. This rule fails the acceptance of C+B' ?
>>>>>>>
>>>>>>> I think this is a footgunish API, as if a package issuer send the
>>>>>>> multiple-parent-one-child package A,B,C,D where D is the child of A=
,B,C.
>>>>>>> Then try to broadcast the higher-feerate C'+D' package, it should b=
e
>>>>>>> rejected. So it's breaking the naive broadcaster assumption that a
>>>>>>> higher-feerate/higher-fee package always replaces ? And it might be=
 unsafe
>>>>>>> in protocols where states are symmetric. E.g a malicious counterpar=
ty
>>>>>>> broadcasts first S+A, then you honestly broadcast S+B, where B pays=
 better
>>>>>>> fees.
>>>>>>>
>>>>>>> > All mempool transactions to be replaced must signal replaceabilit=
y.
>>>>>>>
>>>>>>> I think this is unsafe for L2s if counterparties have malleability
>>>>>>> of the child transaction. They can block your package replacement b=
y
>>>>>>> opting-out from RBF signaling. IIRC, LN's "anchor output" presents =
such an
>>>>>>> ability.
>>>>>>>
>>>>>>> I think it's better to either fix inherited signaling or move
>>>>>>> towards full-rbf.
>>>>>>>
>>>>>>> > if a package parent has already been submitted, it would
>>>>>>> > look
>>>>>>> >like the child is spending a "new" unconfirmed input.
>>>>>>>
>>>>>>> I think this is an issue brought by the trimming during the dedup
>>>>>>> phase. If we preserve the package integrity, only re-using the tx-l=
evel
>>>>>>> checks results of already in-mempool transactions to gain in CPU ti=
me we
>>>>>>> won't have this issue. Package childs can add unconfirmed inputs as=
 long as
>>>>>>> they're in-package, the bip125 rule2 is only evaluated against pare=
nts ?
>>>>>>>
>>>>>>> > However, we still achieve the same goal of requiring the
>>>>>>> > replacement
>>>>>>> > transactions to have a ancestor score at least as high as the
>>>>>>> original
>>>>>>> > ones.
>>>>>>>
>>>>>>> I'm not sure if this holds...
>>>>>>>
>>>>>>> Let's say you have in-mempool A, B where A pays 10 sat/vb for 100
>>>>>>> vbytes and B pays 10 sat/vb for 100 vbytes. You have the candidate
>>>>>>> replacement D spending both A and C where D pays 15sat/vb for 100 v=
bytes
>>>>>>> and C pays 1 sat/vb for 1000 vbytes.
>>>>>>>
>>>>>>> Package A + B ancestor score is 10 sat/vb.
>>>>>>>
>>>>>>> D has a higher feerate/absolute fee than B.
>>>>>>>
>>>>>>> Package A + C + D ancestor score is ~ 3 sat/vb ((A's 1000 sats + C'=
s
>>>>>>> 1000 sats + D's 1500 sats) /
>>>>>>> A's 100 vb + C's 1000 vb + D's 100 vb)
>>>>>>>
>>>>>>> Overall, this is a review through the lenses of LN requirements. I
>>>>>>> think other L2 protocols/applications
>>>>>>> could be candidates to using package accept/relay such as:
>>>>>>> * https://github.com/lightninglabs/pool
>>>>>>> * https://github.com/discreetlogcontracts/dlcspecs
>>>>>>> * https://github.com/bitcoin-teleport/teleport-transactions/
>>>>>>> * https://github.com/sapio-lang/sapio
>>>>>>> *
>>>>>>> https://github.com/commerceblock/mercury/blob/master/doc/statechain=
s.md
>>>>>>> * https://github.com/revault/practical-revault
>>>>>>>
>>>>>>> Thanks for rolling forward the ball on this subject.
>>>>>>>
>>>>>>> Antoine
>>>>>>>
>>>>>>> Le jeu. 16 sept. 2021 =C3=A0 03:55, Gloria Zhao via bitcoin-dev <
>>>>>>> bitcoin-dev@lists.linuxfoundation.org> a =C3=A9crit :
>>>>>>>
>>>>>>>> Hi there,
>>>>>>>>
>>>>>>>> I'm writing to propose a set of mempool policy changes to enable
>>>>>>>> package
>>>>>>>> validation (in preparation for package relay) in Bitcoin Core.
>>>>>>>> These would not
>>>>>>>> be consensus or P2P protocol changes. However, since mempool polic=
y
>>>>>>>> significantly affects transaction propagation, I believe this is
>>>>>>>> relevant for
>>>>>>>> the mailing list.
>>>>>>>>
>>>>>>>> My proposal enables packages consisting of multiple parents and 1
>>>>>>>> child. If you
>>>>>>>> develop software that relies on specific transaction relay
>>>>>>>> assumptions and/or
>>>>>>>> are interested in using package relay in the future, I'm very
>>>>>>>> interested to hear
>>>>>>>> your feedback on the utility or restrictiveness of these package
>>>>>>>> policies for
>>>>>>>> your use cases.
>>>>>>>>
>>>>>>>> A draft implementation of this proposal can be found in [Bitcoin
>>>>>>>> Core
>>>>>>>> PR#22290][1].
>>>>>>>>
>>>>>>>> An illustrated version of this post can be found at
>>>>>>>> https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a.
>>>>>>>> I have also linked the images below.
>>>>>>>>
>>>>>>>> ## Background
>>>>>>>>
>>>>>>>> Feel free to skip this section if you are already familiar with
>>>>>>>> mempool policy
>>>>>>>> and package relay terminology.
>>>>>>>>
>>>>>>>> ### Terminology Clarifications
>>>>>>>>
>>>>>>>> * Package =3D an ordered list of related transactions, representab=
le
>>>>>>>> by a Directed
>>>>>>>>   Acyclic Graph.
>>>>>>>> * Package Feerate =3D the total modified fees divided by the total
>>>>>>>> virtual size of
>>>>>>>>   all transactions in the package.
>>>>>>>>     - Modified fees =3D a transaction's base fees + fee delta appl=
ied
>>>>>>>> by the user
>>>>>>>>       with `prioritisetransaction`. As such, we expect this to var=
y
>>>>>>>> across
>>>>>>>> mempools.
>>>>>>>>     - Virtual Size =3D the maximum of virtual sizes calculated usi=
ng
>>>>>>>> [BIP141
>>>>>>>>       virtual size][2] and sigop weight. [Implemented here in
>>>>>>>> Bitcoin Core][3].
>>>>>>>>     - Note that feerate is not necessarily based on the base fees
>>>>>>>> and serialized
>>>>>>>>       size.
>>>>>>>>
>>>>>>>> * Fee-Bumping =3D user/wallet actions that take advantage of miner
>>>>>>>> incentives to
>>>>>>>>   boost a transaction's candidacy for inclusion in a block,
>>>>>>>> including Child Pays
>>>>>>>> for Parent (CPFP) and [BIP125][12] Replace-by-Fee (RBF). Our
>>>>>>>> intention in
>>>>>>>> mempool policy is to recognize when the new transaction is more
>>>>>>>> economical to
>>>>>>>> mine than the original one(s) but not open DoS vectors, so there
>>>>>>>> are some
>>>>>>>> limitations.
>>>>>>>>
>>>>>>>> ### Policy
>>>>>>>>
>>>>>>>> The purpose of the mempool is to store the best (to be most
>>>>>>>> incentive-compatible
>>>>>>>> with miners, highest feerate) candidates for inclusion in a block.
>>>>>>>> Miners use
>>>>>>>> the mempool to build block templates. The mempool is also useful a=
s
>>>>>>>> a cache for
>>>>>>>> boosting block relay and validation performance, aiding transactio=
n
>>>>>>>> relay, and
>>>>>>>> generating feerate estimations.
>>>>>>>>
>>>>>>>> Ideally, all consensus-valid transactions paying reasonable fees
>>>>>>>> should make it
>>>>>>>> to miners through normal transaction relay, without any special
>>>>>>>> connectivity or
>>>>>>>> relationships with miners. On the other hand, nodes do not have
>>>>>>>> unlimited
>>>>>>>> resources, and a P2P network designed to let any honest node
>>>>>>>> broadcast their
>>>>>>>> transactions also exposes the transaction validation engine to DoS
>>>>>>>> attacks from
>>>>>>>> malicious peers.
>>>>>>>>
>>>>>>>> As such, for unconfirmed transactions we are considering for our
>>>>>>>> mempool, we
>>>>>>>> apply a set of validation rules in addition to consensus, primaril=
y
>>>>>>>> to protect
>>>>>>>> us from resource exhaustion and aid our efforts to keep the highes=
t
>>>>>>>> fee
>>>>>>>> transactions. We call this mempool _policy_: a set of (configurabl=
e,
>>>>>>>> node-specific) rules that transactions must abide by in order to b=
e
>>>>>>>> accepted
>>>>>>>> into our mempool. Transaction "Standardness" rules and mempool
>>>>>>>> restrictions such
>>>>>>>> as "too-long-mempool-chain" are both examples of policy.
>>>>>>>>
>>>>>>>> ### Package Relay and Package Mempool Accept
>>>>>>>>
>>>>>>>> In transaction relay, we currently consider transactions one at a
>>>>>>>> time for
>>>>>>>> submission to the mempool. This creates a limitation in the node's
>>>>>>>> ability to
>>>>>>>> determine which transactions have the highest feerates, since we
>>>>>>>> cannot take
>>>>>>>> into account descendants (i.e. cannot use CPFP) until all the
>>>>>>>> transactions are
>>>>>>>> in the mempool. Similarly, we cannot use a transaction's
>>>>>>>> descendants when
>>>>>>>> considering it for RBF. When an individual transaction does not
>>>>>>>> meet the mempool
>>>>>>>> minimum feerate and the user isn't able to create a replacement
>>>>>>>> transaction
>>>>>>>> directly, it will not be accepted by mempools.
>>>>>>>>
>>>>>>>> This limitation presents a security issue for applications and
>>>>>>>> users relying on
>>>>>>>> time-sensitive transactions. For example, Lightning and other
>>>>>>>> protocols create
>>>>>>>> UTXOs with multiple spending paths, where one counterparty's
>>>>>>>> spending path opens
>>>>>>>> up after a timelock, and users are protected from cheating
>>>>>>>> scenarios as long as
>>>>>>>> they redeem on-chain in time. A key security assumption is that al=
l
>>>>>>>> parties'
>>>>>>>> transactions will propagate and confirm in a timely manner. This
>>>>>>>> assumption can
>>>>>>>> be broken if fee-bumping does not work as intended.
>>>>>>>>
>>>>>>>> The end goal for Package Relay is to consider multiple transaction=
s
>>>>>>>> at the same
>>>>>>>> time, e.g. a transaction with its high-fee child. This may help us
>>>>>>>> better
>>>>>>>> determine whether transactions should be accepted to our mempool,
>>>>>>>> especially if
>>>>>>>> they don't meet fee requirements individually or are better RBF
>>>>>>>> candidates as a
>>>>>>>> package. A combination of changes to mempool validation logic,
>>>>>>>> policy, and
>>>>>>>> transaction relay allows us to better propagate the transactions
>>>>>>>> with the
>>>>>>>> highest package feerates to miners, and makes fee-bumping tools
>>>>>>>> more powerful
>>>>>>>> for users.
>>>>>>>>
>>>>>>>> The "relay" part of Package Relay suggests P2P messaging changes,
>>>>>>>> but a large
>>>>>>>> part of the changes are in the mempool's package validation logic.
>>>>>>>> We call this
>>>>>>>> *Package Mempool Accept*.
>>>>>>>>
>>>>>>>> ### Previous Work
>>>>>>>>
>>>>>>>> * Given that mempool validation is DoS-sensitive and complex, it
>>>>>>>> would be
>>>>>>>>   dangerous to haphazardly tack on package validation logic. Many
>>>>>>>> efforts have
>>>>>>>> been made to make mempool validation less opaque (see [#16400][4],
>>>>>>>> [#21062][5],
>>>>>>>> [#22675][6], [#22796][7]).
>>>>>>>> * [#20833][8] Added basic capabilities for package validation, tes=
t
>>>>>>>> accepts only
>>>>>>>>   (no submission to mempool).
>>>>>>>> * [#21800][9] Implemented package ancestor/descendant limit checks
>>>>>>>> for arbitrary
>>>>>>>>   packages. Still test accepts only.
>>>>>>>> * Previous package relay proposals (see [#16401][10], [#19621][11]=
).
>>>>>>>>
>>>>>>>> ### Existing Package Rules
>>>>>>>>
>>>>>>>> These are in master as introduced in [#20833][8] and [#21800][9].
>>>>>>>> I'll consider
>>>>>>>> them as "given" in the rest of this document, though they can be
>>>>>>>> changed, since
>>>>>>>> package validation is test-accept only right now.
>>>>>>>>
>>>>>>>> 1. A package cannot exceed `MAX_PACKAGE_COUNT=3D25` count and
>>>>>>>> `MAX_PACKAGE_SIZE=3D101KvB` total size [8]
>>>>>>>>
>>>>>>>>    *Rationale*: This is already enforced as mempool
>>>>>>>> ancestor/descendant limits.
>>>>>>>> Presumably, transactions in a package are all related, so exceedin=
g
>>>>>>>> this limit
>>>>>>>> would mean that the package can either be split up or it wouldn't
>>>>>>>> pass this
>>>>>>>> mempool policy.
>>>>>>>>
>>>>>>>> 2. Packages must be topologically sorted: if any dependencies exis=
t
>>>>>>>> between
>>>>>>>> transactions, parents must appear somewhere before children. [8]
>>>>>>>>
>>>>>>>> 3. A package cannot have conflicting transactions, i.e. none of
>>>>>>>> them can spend
>>>>>>>> the same inputs. This also means there cannot be duplicate
>>>>>>>> transactions. [8]
>>>>>>>>
>>>>>>>> 4. When packages are evaluated against ancestor/descendant limits
>>>>>>>> in a test
>>>>>>>> accept, the union of all of their descendants and ancestors is
>>>>>>>> considered. This
>>>>>>>> is essentially a "worst case" heuristic where every transaction in
>>>>>>>> the package
>>>>>>>> is treated as each other's ancestor and descendant. [8]
>>>>>>>> Packages for which ancestor/descendant limits are accurately
>>>>>>>> captured by this
>>>>>>>> heuristic: [19]
>>>>>>>>
>>>>>>>> There are also limitations such as the fact that CPFP carve out is
>>>>>>>> not applied
>>>>>>>> to package transactions. #20833 also disables RBF in package
>>>>>>>> validation; this
>>>>>>>> proposal overrides that to allow packages to use RBF.
>>>>>>>>
>>>>>>>> ## Proposed Changes
>>>>>>>>
>>>>>>>> The next step in the Package Mempool Accept project is to implemen=
t
>>>>>>>> submission
>>>>>>>> to mempool, initially through RPC only. This allows us to test the
>>>>>>>> submission
>>>>>>>> logic before exposing it on P2P.
>>>>>>>>
>>>>>>>> ### Summary
>>>>>>>>
>>>>>>>> - Packages may contain already-in-mempool transactions.
>>>>>>>> - Packages are 2 generations, Multi-Parent-1-Child.
>>>>>>>> - Fee-related checks use the package feerate. This means that
>>>>>>>> wallets can
>>>>>>>> create a package that utilizes CPFP.
>>>>>>>> - Parents are allowed to RBF mempool transactions with a set of
>>>>>>>> rules similar
>>>>>>>>   to BIP125. This enables a combination of CPFP and RBF, where a
>>>>>>>> transaction's descendant fees pay for replacing mempool conflicts.
>>>>>>>>
>>>>>>>> There is a draft implementation in [#22290][1]. It is WIP, but
>>>>>>>> feedback is
>>>>>>>> always welcome.
>>>>>>>>
>>>>>>>> ### Details
>>>>>>>>
>>>>>>>> #### Packages May Contain Already-in-Mempool Transactions
>>>>>>>>
>>>>>>>> A package may contain transactions that are already in the mempool=
.
>>>>>>>> We remove
>>>>>>>> ("deduplicate") those transactions from the package for the
>>>>>>>> purposes of package
>>>>>>>> mempool acceptance. If a package is empty after deduplication, we
>>>>>>>> do nothing.
>>>>>>>>
>>>>>>>> *Rationale*: Mempools vary across the network. It's possible for a
>>>>>>>> parent to be
>>>>>>>> accepted to the mempool of a peer on its own due to differences in
>>>>>>>> policy and
>>>>>>>> fee market fluctuations. We should not reject or penalize the
>>>>>>>> entire package for
>>>>>>>> an individual transaction as that could be a censorship vector.
>>>>>>>>
>>>>>>>> #### Packages Are Multi-Parent-1-Child
>>>>>>>>
>>>>>>>> Only packages of a specific topology are permitted. Namely, a
>>>>>>>> package is exactly
>>>>>>>> 1 child with all of its unconfirmed parents. After deduplication,
>>>>>>>> the package
>>>>>>>> may be exactly the same, empty, 1 child, 1 child with just some of
>>>>>>>> its
>>>>>>>> unconfirmed parents, etc. Note that it's possible for the parents
>>>>>>>> to be indirect
>>>>>>>> descendants/ancestors of one another, or for parent and child to
>>>>>>>> share a parent,
>>>>>>>> so we cannot make any other topology assumptions.
>>>>>>>>
>>>>>>>> *Rationale*: This allows for fee-bumping by CPFP. Allowing multipl=
e
>>>>>>>> parents
>>>>>>>> makes it possible to fee-bump a batch of transactions. Restricting
>>>>>>>> packages to a
>>>>>>>> defined topology is also easier to reason about and simplifies the
>>>>>>>> validation
>>>>>>>> logic greatly. Multi-parent-1-child allows us to think of the
>>>>>>>> package as one big
>>>>>>>> transaction, where:
>>>>>>>>
>>>>>>>> - Inputs =3D all the inputs of parents + inputs of the child that
>>>>>>>> come from
>>>>>>>>   confirmed UTXOs
>>>>>>>> - Outputs =3D all the outputs of the child + all outputs of the
>>>>>>>> parents that
>>>>>>>>   aren't spent by other transactions in the package
>>>>>>>>
>>>>>>>> Examples of packages that follow this rule (variations of example =
A
>>>>>>>> show some
>>>>>>>> possibilities after deduplication): ![image][15]
>>>>>>>>
>>>>>>>> #### Fee-Related Checks Use Package Feerate
>>>>>>>>
>>>>>>>> Package Feerate =3D the total modified fees divided by the total
>>>>>>>> virtual size of
>>>>>>>> all transactions in the package.
>>>>>>>>
>>>>>>>> To meet the two feerate requirements of a mempool, i.e., the
>>>>>>>> pre-configured
>>>>>>>> minimum relay feerate (`minRelayTxFee`) and dynamic mempool minimu=
m
>>>>>>>> feerate, the
>>>>>>>> total package feerate is used instead of the individual feerate.
>>>>>>>> The individual
>>>>>>>> transactions are allowed to be below feerate requirements if the
>>>>>>>> package meets
>>>>>>>> the feerate requirements. For example, the parent(s) in the packag=
e
>>>>>>>> can have 0
>>>>>>>> fees but be paid for by the child.
>>>>>>>>
>>>>>>>> *Rationale*: This can be thought of as "CPFP within a package,"
>>>>>>>> solving the
>>>>>>>> issue of a parent not meeting minimum fees on its own. This allows
>>>>>>>> L2
>>>>>>>> applications to adjust their fees at broadcast time instead of
>>>>>>>> overshooting or
>>>>>>>> risking getting stuck/pinned.
>>>>>>>>
>>>>>>>> We use the package feerate of the package *after deduplication*.
>>>>>>>>
>>>>>>>> *Rationale*:  It would be incorrect to use the fees of transaction=
s
>>>>>>>> that are
>>>>>>>> already in the mempool, as we do not want a transaction's fees to =
be
>>>>>>>> double-counted for both its individual RBF and package RBF.
>>>>>>>>
>>>>>>>> Examples F and G [14] show the same package, but P1 is submitted
>>>>>>>> individually before
>>>>>>>> the package in example G. In example F, we can see that the 300vB
>>>>>>>> package pays
>>>>>>>> an additional 200sat in fees, which is not enough to pay for its
>>>>>>>> own bandwidth
>>>>>>>> (BIP125#4). In example G, we can see that P1 pays enough to replac=
e
>>>>>>>> M1, but
>>>>>>>> using P1's fees again during package submission would make it look
>>>>>>>> like a 300sat
>>>>>>>> increase for a 200vB package. Even including its fees and size
>>>>>>>> would not be
>>>>>>>> sufficient in this example, since the 300sat looks like enough for
>>>>>>>> the 300vB
>>>>>>>> package. The calculcation after deduplication is 100sat increase
>>>>>>>> for a package
>>>>>>>> of size 200vB, which correctly fails BIP125#4. Assume all
>>>>>>>> transactions have a
>>>>>>>> size of 100vB.
>>>>>>>>
>>>>>>>> #### Package RBF
>>>>>>>>
>>>>>>>> If a package meets feerate requirements as a package, the parents
>>>>>>>> in the
>>>>>>>> transaction are allowed to replace-by-fee mempool transactions. Th=
e
>>>>>>>> child cannot
>>>>>>>> replace mempool transactions. Multiple transactions can replace th=
e
>>>>>>>> same
>>>>>>>> transaction, but in order to be valid, none of the transactions ca=
n
>>>>>>>> try to
>>>>>>>> replace an ancestor of another transaction in the same package
>>>>>>>> (which would thus
>>>>>>>> make its inputs unavailable).
>>>>>>>>
>>>>>>>> *Rationale*: Even if we are using package feerate, a package will
>>>>>>>> not propagate
>>>>>>>> as intended if RBF still requires each individual transaction to
>>>>>>>> meet the
>>>>>>>> feerate requirements.
>>>>>>>>
>>>>>>>> We use a set of rules slightly modified from BIP125 as follows:
>>>>>>>>
>>>>>>>> ##### Signaling (Rule #1)
>>>>>>>>
>>>>>>>> All mempool transactions to be replaced must signal replaceability=
.
>>>>>>>>
>>>>>>>> *Rationale*: Package RBF signaling logic should be the same for
>>>>>>>> package RBF and
>>>>>>>> single transaction acceptance. This would be updated if single
>>>>>>>> transaction
>>>>>>>> validation moves to full RBF.
>>>>>>>>
>>>>>>>> ##### New Unconfirmed Inputs (Rule #2)
>>>>>>>>
>>>>>>>> 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. This is contrary to BIP125#2, which states "The
>>>>>>>> replacement
>>>>>>>> transaction may only include an unconfirmed input if that input wa=
s
>>>>>>>> included in
>>>>>>>> one of the original transactions. (An unconfirmed input spends an
>>>>>>>> output from a
>>>>>>>> currently-unconfirmed transaction.)"
>>>>>>>>
>>>>>>>> *Rationale*: The purpose of BIP125#2 is to ensure that the
>>>>>>>> replacement
>>>>>>>> transaction has a higher ancestor score than the original
>>>>>>>> transaction(s) (see
>>>>>>>> [comment][13]). Example H [16] shows how adding a new unconfirmed
>>>>>>>> input can lower the
>>>>>>>> ancestor score of the replacement transaction. P1 is trying to
>>>>>>>> replace M1, and
>>>>>>>> spends an unconfirmed output of M2. P1 pays 800sat, M1 pays 600sat=
,
>>>>>>>> and M2 pays
>>>>>>>> 100sat. Assume all transactions have a size of 100vB. While, in
>>>>>>>> isolation, P1
>>>>>>>> looks like a better mining candidate than M1, it must be mined wit=
h
>>>>>>>> M2, so its
>>>>>>>> ancestor feerate is actually 4.5sat/vB.  This is lower than M1's
>>>>>>>> ancestor
>>>>>>>> feerate, which is 6sat/vB.
>>>>>>>>
>>>>>>>> In package RBF, the rule analogous to BIP125#2 would be "none of t=
he
>>>>>>>> transactions in the package can spend new unconfirmed inputs."
>>>>>>>> Example J [17] shows
>>>>>>>> why, if any of the package transactions have ancestors, package
>>>>>>>> feerate is no
>>>>>>>> longer accurate. Even though M2 and M3 are not ancestors of P1
>>>>>>>> (which is the
>>>>>>>> replacement transaction in an RBF), we're actually interested in
>>>>>>>> the entire
>>>>>>>> package. A miner should mine M1 which is 5sat/vB instead of M2, M3=
,
>>>>>>>> P1, P2, and
>>>>>>>> P3, which is only 4sat/vB. The Package RBF rule cannot be loosened
>>>>>>>> to only allow
>>>>>>>> the child to have new unconfirmed inputs, either, because it can
>>>>>>>> still cause us
>>>>>>>> to overestimate the package's ancestor score.
>>>>>>>>
>>>>>>>> However, enforcing a rule analogous to BIP125#2 would not only mak=
e
>>>>>>>> Package RBF
>>>>>>>> less useful, but would also break Package RBF for packages with
>>>>>>>> parents already
>>>>>>>> in the mempool: if a package parent has already been submitted, it
>>>>>>>> would look
>>>>>>>> like the child is spending a "new" unconfirmed input. In example K
>>>>>>>> [18], we're
>>>>>>>> looking to replace M1 with the entire package including P1, P2, an=
d
>>>>>>>> P3. We must
>>>>>>>> consider the case where one of the parents is already in the
>>>>>>>> mempool (in this
>>>>>>>> case, P2), which means we must allow P3 to have new unconfirmed
>>>>>>>> inputs. However,
>>>>>>>> M2 lowers the ancestor score of P3 to 4.3sat/vB, so we should not
>>>>>>>> replace M1
>>>>>>>> with this package.
>>>>>>>>
>>>>>>>> Thus, the package RBF rule regarding new unconfirmed inputs is les=
s
>>>>>>>> strict than
>>>>>>>> BIP125#2. However, we still achieve the same goal of requiring the
>>>>>>>> replacement
>>>>>>>> transactions to have a ancestor score at least as high as the
>>>>>>>> original ones. As
>>>>>>>> a result, the entire package is required to be a higher feerate
>>>>>>>> mining candidate
>>>>>>>> than each of the replaced transactions.
>>>>>>>>
>>>>>>>> Another note: the [comment][13] above the BIP125#2 code in the
>>>>>>>> original RBF
>>>>>>>> implementation suggests that the rule was intended to be temporary=
.
>>>>>>>>
>>>>>>>> ##### Absolute Fee (Rule #3)
>>>>>>>>
>>>>>>>> The package must increase the absolute fee of the mempool, i.e. th=
e
>>>>>>>> total fees
>>>>>>>> of the package must be higher than the absolute fees of the mempoo=
l
>>>>>>>> transactions
>>>>>>>> it replaces. Combined with the CPFP rule above, this differs from
>>>>>>>> BIP125 Rule #3
>>>>>>>> - an individual transaction in the package may have lower fees tha=
n
>>>>>>>> the
>>>>>>>>   transaction(s) it is replacing. In fact, it may have 0 fees, and
>>>>>>>> the child
>>>>>>>> pays for RBF.
>>>>>>>>
>>>>>>>> ##### Feerate (Rule #4)
>>>>>>>>
>>>>>>>> The package must pay for its own bandwidth; the package feerate
>>>>>>>> must be higher
>>>>>>>> than the replaced transactions by at least minimum relay feerate
>>>>>>>> (`incrementalRelayFee`). Combined with the CPFP rule above, this
>>>>>>>> differs from
>>>>>>>> BIP125 Rule #4 - an individual transaction in the package can have
>>>>>>>> a lower
>>>>>>>> feerate than the transaction(s) it is replacing. In fact, it may
>>>>>>>> have 0 fees,
>>>>>>>> and the child pays for RBF.
>>>>>>>>
>>>>>>>> ##### Total Number of Replaced Transactions (Rule #5)
>>>>>>>>
>>>>>>>> The package cannot replace more than 100 mempool transactions. Thi=
s
>>>>>>>> is identical
>>>>>>>> to BIP125 Rule #5.
>>>>>>>>
>>>>>>>> ### Expected FAQs
>>>>>>>>
>>>>>>>> 1. Is it possible for only some of the package to make it into the
>>>>>>>> mempool?
>>>>>>>>
>>>>>>>>    Yes, it is. However, since we evict transactions from the
>>>>>>>> mempool by
>>>>>>>> descendant score and the package child is supposed to be sponsorin=
g
>>>>>>>> the fees of
>>>>>>>> its parents, the most common scenario would be all-or-nothing. Thi=
s
>>>>>>>> is
>>>>>>>> incentive-compatible. In fact, to be conservative, package
>>>>>>>> validation should
>>>>>>>> begin by trying to submit all of the transactions individually, an=
d
>>>>>>>> only use the
>>>>>>>> package mempool acceptance logic if the parents fail due to low
>>>>>>>> feerate.
>>>>>>>>
>>>>>>>> 2. Should we allow packages to contain already-confirmed
>>>>>>>> transactions?
>>>>>>>>
>>>>>>>>     No, for practical reasons. In mempool validation, we actually
>>>>>>>> aren't able to
>>>>>>>> tell with 100% confidence if we are looking at a transaction that
>>>>>>>> has already
>>>>>>>> confirmed, because we look up inputs using a UTXO set. If we have
>>>>>>>> historical
>>>>>>>> block data, it's possible to look for it, but this is inefficient,
>>>>>>>> not always
>>>>>>>> possible for pruning nodes, and unnecessary because we're not goin=
g
>>>>>>>> to do
>>>>>>>> anything with the transaction anyway. As such, we already have the
>>>>>>>> expectation
>>>>>>>> that transaction relay is somewhat "stateful" i.e. nobody should b=
e
>>>>>>>> relaying
>>>>>>>> transactions that have already been confirmed. Similarly, we
>>>>>>>> shouldn't be
>>>>>>>> relaying packages that contain already-confirmed transactions.
>>>>>>>>
>>>>>>>> [1]: https://github.com/bitcoin/bitcoin/pull/22290
>>>>>>>> [2]:
>>>>>>>> https://github.com/bitcoin/bips/blob/1f0b563738199ca60d32b4ba77979=
7fc97d040fe/bip-0141.mediawiki#transaction-size-calculations
>>>>>>>> [3]:
>>>>>>>> https://github.com/bitcoin/bitcoin/blob/94f83534e4b771944af7d9ed0f=
40746f392eb75e/src/policy/policy.cpp#L282
>>>>>>>> [4]: https://github.com/bitcoin/bitcoin/pull/16400
>>>>>>>> [5]: https://github.com/bitcoin/bitcoin/pull/21062
>>>>>>>> [6]: https://github.com/bitcoin/bitcoin/pull/22675
>>>>>>>> [7]: https://github.com/bitcoin/bitcoin/pull/22796
>>>>>>>> [8]: https://github.com/bitcoin/bitcoin/pull/20833
>>>>>>>> [9]: https://github.com/bitcoin/bitcoin/pull/21800
>>>>>>>> [10]: https://github.com/bitcoin/bitcoin/pull/16401
>>>>>>>> [11]: https://github.com/bitcoin/bitcoin/pull/19621
>>>>>>>> [12]:
>>>>>>>> https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki
>>>>>>>> [13]:
>>>>>>>> https://github.com/bitcoin/bitcoin/pull/6871/files#diff-34d21af3c6=
14ea3cee120df276c9c4ae95053830d7f1d3deaf009a4625409ad2R1101-R1104
>>>>>>>> [14]:
>>>>>>>> https://user-images.githubusercontent.com/25183001/133567078-075a9=
71c-0619-4339-9168-b41fd2b90c28.png
>>>>>>>> [15]:
>>>>>>>> https://user-images.githubusercontent.com/25183001/132856734-fc17d=
a75-f875-44bb-b954-cb7a1725cc0d.png
>>>>>>>> [16]:
>>>>>>>> https://user-images.githubusercontent.com/25183001/133567347-a3e2e=
4a8-ae9c-49f8-abb9-81e8e0aba224.png
>>>>>>>> [17]:
>>>>>>>> https://user-images.githubusercontent.com/25183001/133567370-21566=
d0e-36c8-4831-b1a8-706634540af3.png
>>>>>>>> [18]:
>>>>>>>> https://user-images.githubusercontent.com/25183001/133567444-bfff1=
142-439f-4547-800a-2ba2b0242bcb.png
>>>>>>>> [19]:
>>>>>>>> https://user-images.githubusercontent.com/25183001/133456219-0bb44=
7cb-dcb4-4a31-b9c1-7d86205b68bc.png
>>>>>>>> [20]:
>>>>>>>> https://user-images.githubusercontent.com/25183001/132857787-7b7c6=
f56-af96-44c8-8d78-983719888c19.png
>>>>>>>> _______________________________________________
>>>>>>>> bitcoin-dev mailing list
>>>>>>>> bitcoin-dev@lists.linuxfoundation.org
>>>>>>>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>>>>>>>>
>>>>>>> _______________________________________________
>>> bitcoin-dev mailing list
>>> bitcoin-dev@lists.linuxfoundation.org
>>> https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev
>>>
>>

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

<div dir=3D"ltr">Hi Antoine and Bastien,<br><br>&gt; Yes 1) it would be goo=
d to have inputs of more potential users of package acceptance . And 2) I t=
hink it&#39;s more a matter of clearer wording of the proposal.<br><br>(1) =
I&#39;m leaning towards multi-parent-1-child and offering [#22674][0] up fo=
r review. If somebody feels very strongly about 1-parent-1-child, please le=
t me know.<br><br>(2) I&#39;m glad this turned out to just be a wording pro=
blem. I&#39;ve updated the proposal to [say][1] &quot;If it meets feerate r=
equirements, the package can replace mempool transactions if any of the par=
ents conflict with mempool transactions. The child cannot conflict with any=
 mempool transactions.&quot; Hopefully that is more *univoque*.<br><br>Side=
 note: I&#39;ve also updated the proposal to contain a [section][2] on why =
submitting transactions individually before package validation is incentive=
-compatible. I think it&#39;s relevant to our conversation, but for those w=
ho just want to _use_ packages, it&#39;s just an implementation detail.<br>=
<br>On restricting packages to confirmed inputs only:<br><br>&gt; I think w=
e could restrain package acceptance to only confirmed inputs for now and re=
visit later this point ? For LN-anchor, you can assume that the fee-bumping=
 UTXO feeding the CPFP is already<br>confirmed. Or are there currently-depl=
oyed use-cases which would benefit from your proposed Rule #2 ?<br><br>I th=
ought about this a lot this week, and wrote up a summary of why I don&#39;t=
 think BIP125#2 helps us at all [here][3] on #23121. I see that you&#39;ve =
already come across it :)<br><div><br></div><div>&gt; IIRC, the carve-out t=
olerance is only 2txn/10_000 vb. If one of your=20
counterparties attach a junk branch on her own anchor output, are you=20
allowed to chain your self-owned unconfirmed CPFP ?</div><div><br></div><di=
v>Yes, if your counterparty attaches a bunch of descendants to their anchor=
 output to dominate the descendant limit of your shared commitment transact=
ion, CPFP carve out allows you to add 1 extra transaction under 10KvB to yo=
ur own anchor output. It&#39;s fine if it spends an unconfirmed input, as l=
ong as you aren&#39;t exceeding the descendant limits of that transaction. =
This shouldn&#39;t be the case; I think something is seriously wrong if all=
 of your UTXOs are tied up in mempool transactions with big ancestor/descen=
dant trees.<br></div><div><br></div><div>I don&#39;t know much about L2 dev=
elopment so I&#39;m just going to quote this:<br><br>&gt; I think constrain=
ing package acceptance to only confirmed inputs is very limiting and quite =
dangerous for L2 protocols.</div><div><br></div>Since the restriction isn&#=
39;t helpful in simplifying the mempool code, makes things more complicated=
 for application developers, and can be dangerous for L2, I&#39;d prefer no=
t to add this restriction for packages.<br><br>On Antoine&#39;s question ab=
out our miner model:<br><br>&gt; Can you describe what miner model we are u=
sing ? Like the block construction strategy implemented by `addPackagesTxs`=
 or also encompassing our current mempool acceptance policy, which I think =
rely on absolute fee over ancestor score in case of replacement ?<br><br>Ou=
r current model for block construction is this: we sort our mempool by pack=
age ancestor score (total modified fees of a tx and its unconfirmed ancesto=
rs / total vsize as seen by our mempool) and add packages to a block until =
it&#39;s full. That&#39;s not to say this is the perfect miner policy, but =
mempool acceptance logic follows this model as closely as possible because =
it is, fundamentally, a cache that aids in block assembly performance. As a=
nother way of looking at this, imagine if our mempool was so small it could=
 only store ~1 block&#39;s worth of transactions. It should always try to k=
eep the highest-fees-within-1-block transactions, and obviously wouldn&#39;=
t evict small-but-valuable transations in favor or giant ones paying medioc=
re feerates. All fee-related mempool policies, including RBF, consider feer=
ate. BIP125#3 is a rule on absolute fees, but it is always combined with BI=
P125#4, a rule on feerates. AFAIK, the reason it doesn&#39;t use ancestor s=
core is that information wasn&#39;t cached in mempool entries at the time, =
and thus not readily available to use in mempool validation.<br><br>That&#3=
9;s why I don&#39;t think this is relevant to package validation. Commentin=
g on the model itself:<br><br>&gt; Is this compatible with a model where a =
miner prioritizes absolute fees over ancestor score, in the case that mempo=
ols aren&#39;t full-enough to fulfill a block ?<br>&gt;&gt; Yes, A+C+D pays=
 2500sat more in fees, but it is also 1000vB larger. A miner should prefer =
to utilize their block space more effectively.<br>&gt; If your mempool is e=
mpty and only composed of A+C+D or A+B, I think taking A+C+D is the most ef=
ficient block construction you can come up with as a miner ?<br>&gt; I thin=
k this point is worthy to discuss as otherwise we might downgrade the effic=
iency of our current block construction strategy in periods of near-empty m=
empools. A knowledge which could be discreetly leveraged by a miner to gain=
 an advantage on the rest of the mining ecosystem.<br><br>I believe this is=
 suggesting &quot;if our mempool has so few transactions that it wouldn&#39=
;t reach block capacity, prioritize any increase in absolute fees, even if =
the feerate is lower.&quot; I can see how this may result in a higher-fee b=
lock in a specific scenario such as the one highlighted above, but I don&#3=
9;t think it is a sound model in general. It would be impossible to tell wh=
en we should use this model: we could simply be in IBD, restarted a node wi=
th an old/empty mempool.dat, and even if it&#39;s a low-transaction-volume =
time, we never know what transactions will trickle in between now and the n=
ext block. Going back to the tiny 1-block mempool scenario, i.e., if you _n=
ever_ wanted to keep transactions that you wouldn&#39;t put in the next blo=
ck, would you ever switch strategies?<br><br>Thanks again to everyone who&#=
39;s given their attention to the package mempool accept proposal.<br><br>B=
est,<br>Gloria<br><br>[0]: <a href=3D"https://github.com/bitcoin/bitcoin/pu=
ll/22674">https://github.com/bitcoin/bitcoin/pull/22674</a><br>[1]: <a href=
=3D"https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#package=
-rbf">https://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#packa=
ge-rbf</a><br>[2]: <a href=3D"https://gist.github.com/glozow/dc4e9d5c5b14ad=
e7cdfac40f43adb18a#always-try-individual-submission-first">https://gist.git=
hub.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a#always-try-individual-submi=
ssion-first</a><br>[3]: <a href=3D"https://github.com/bitcoin/bitcoin/pull/=
23121#issuecomment-929475999">https://github.com/bitcoin/bitcoin/pull/23121=
#issuecomment-929475999</a></div><br><div class=3D"gmail_quote"><div dir=3D=
"ltr" class=3D"gmail_attr">On Tue, Sep 28, 2021 at 11:59 PM Antoine Riard &=
lt;<a href=3D"mailto:antoine.riard@gmail.com">antoine.riard@gmail.com</a>&g=
t; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div d=
ir=3D"ltr">Hi Bastien<br><div><br>&gt; In the case of LN, an attacker can g=
ame this and heavily restrict<div>your RBF attempts if you&#39;re only allo=
wed to use confirmed inputs</div><div>and have many channels (and a limited=
 number of confirmed inputs).</div><div>Otherwise you&#39;ll need node oper=
ators to pre-emptively split their</div><div>utxos into many small utxos ju=
st for fee bumping, which is inefficient...<br><br></div><div>I share the c=
oncern about splitting utxos into smaller ones.<br>IIRC, the carve-out tole=
rance is only 2txn/10_000 vb. If one of your counterparties attach a junk b=
ranch on her own anchor output, are you allowed to chain your self-owned un=
confirmed CPFP ?<br>I&#39;m thinking about the topology &quot;Chained CPFPs=
&quot; exposed here : <a href=3D"https://github.com/rust-bitcoin/rust-light=
ning/issues/989" target=3D"_blank">https://github.com/rust-bitcoin/rust-lig=
htning/issues/989</a>.<br></div><div>Or if you have another L2 broadcast to=
pology which could be safe w.r.t our current mempool logic :) ?<br> </div><=
div><br></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" c=
lass=3D"gmail_attr">Le=C2=A0lun. 27 sept. 2021 =C3=A0=C2=A003:15, Bastien T=
EINTURIER &lt;<a href=3D"mailto:bastien@acinq.fr" target=3D"_blank">bastien=
@acinq.fr</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,2=
04);padding-left:1ex"><div dir=3D"ltr"><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex">I think we could restrain package acceptance to only confirme=
d inputs for now and revisit later this point ? For LN-anchor, you can assu=
me that the fee-bumping UTXO feeding the CPFP is already<br>confirmed. Or a=
re there currently-deployed use-cases which would benefit from your propose=
d Rule #2 ?<br></blockquote><div><br></div><div>I think constraining packag=
e acceptance to only confirmed inputs</div><div>is very limiting and quite =
dangerous for L2 protocols.</div><div><br></div><div>In the case of LN, an =
attacker can game this and heavily restrict</div><div>your RBF attempts if =
you&#39;re only allowed to use confirmed inputs</div><div>and have many cha=
nnels (and a limited number of confirmed inputs).</div><div>Otherwise you&#=
39;ll need node operators to pre-emptively split their</div><div>utxos into=
 many small utxos just for fee bumping, which is inefficient...</div><div><=
br></div><div>Bastien</div></div><br><div class=3D"gmail_quote"><div dir=3D=
"ltr" class=3D"gmail_attr">Le=C2=A0lun. 27 sept. 2021 =C3=A0=C2=A000:27, An=
toine Riard via bitcoin-dev &lt;<a href=3D"mailto:bitcoin-dev@lists.linuxfo=
undation.org" target=3D"_blank">bitcoin-dev@lists.linuxfoundation.org</a>&g=
t; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex"><div dir=3D"ltr">Hi Gloria,<br><br>Thanks for your answers,<br><br>&=
gt; In summary, it seems that the decisions that might still need<br>&gt; a=
ttention/input from devs on this mailing list are:<br>&gt; 1. Whether we sh=
ould start with multiple-parent-1-child or 1-parent-1-child.<br>&gt; 2. Whe=
ther it&#39;s ok to require that the child not have conflicts with<br>&gt; =
mempool transactions.<br><br>Yes 1) it would be good to have inputs of more=
 potential users of package acceptance . And 2) I think it&#39;s more a mat=
ter of clearer wording of the proposal.<br><br>However, see my final point =
on the relaxation around &quot;unconfirmed inputs&quot; which might in fact=
 alter our current block construction strategy.<br><br>&gt; Right, the fact=
 that we essentially always choose the first-seen witness is<br>&gt; an unf=
ortunate limitation that exists already. Adding package mempool<br>&gt; acc=
ept doesn&#39;t worsen this, but the procedure in the future is to replace<=
br>&gt; the witness when it makes sense economically. We can also add logic=
 to<br>&gt; allow package feerate to pay for witness replacements as well. =
This is<br>&gt; pretty far into the future, though.<br><br>Yes I agree pack=
age mempool doesn&#39;t worsen this. And it&#39;s not an issue for current =
LN as you can&#39;t significantly inflate a spending witness for the 2-of-2=
 funding output.<br>However, it might be an issue for multi-party protocol =
where the spending script has alternative branches with asymmetric valid wi=
tness weights. Taproot should ease that kind of script so hopefully we woul=
d deploy wtxid-replacement not too far in the future.<br><br>&gt; I could b=
e misunderstanding, but an attacker wouldn&#39;t be able to<br>&gt; batch-a=
ttack like this. Alice&#39;s package only conflicts with A&#39; + D&#39;, n=
ot A&#39;<br>&gt; + B&#39; + C&#39; + D&#39;. She only needs to pay for evi=
cting 2 transactions.<br><br>Yeah I can be clearer, I think you have 2 pinn=
ing attacks scenarios to consider.<br><br>In LN, if you&#39;re trying to co=
nfirm a commitment transaction to time-out or claim on-chain a HTLC and the=
 timelock is near-expiration, you should be ready to pay in commitment+2nd-=
stage HTLC transaction fees as much as the value offered by the HTLC.<br><b=
r>Following this security assumption, an attacker can exploit it by targeti=
ng together commitment transactions from different channels by blocking the=
m under a high-fee child, of which the fee value<br>is equal to the top-val=
ue HTLC + 1. Victims&#39;s fee-bumping logics won&#39;t overbid as it&#39;s=
 not worthy to offer fees beyond their competed HTLCs. Apart from observing=
 mempools state, victims can&#39;t learn they&#39;re targeted by the same a=
ttacker.<br><br>To draw from the aforementioned topology, Mallory broadcast=
s A&#39; + B&#39; + C&#39; + D&#39;, where A&#39; conflicts with Alice&#39;=
s P1, B&#39; conflicts with Bob&#39;s P2, C&#39; conflicts with Caroll&#39;=
s P3. Let&#39;s assume P1 is confirming the top-value HTLC of the set. If D=
&#39; fees is higher than P1 + 1, it won&#39;t be rational for Alice or Bob=
 or Caroll to keep offering competing feerates. Mallory will be at loss on =
stealing P1, as she has paid more in fees but will realize a gain on P2+P3.=
<br><br>In this model, Alice is allowed to evict those 2 transactions (A&#3=
9; + D&#39;) but as she is economically-bounded she won&#39;t succeed.<br><=
br>Mallory is maliciously exploiting RBF rule 3 on absolute fee. I think th=
is 1st pinning scenario is correct and &quot;lucractive&quot; when you sum =
the global gain/loss.<br><br>There is a 2nd attack scenario where A + B + C=
 + D, where D is the child of A,B,C. All those transactions are honestly is=
sued by Alice. Once A + B + C + D are propagated in network mempools, Mallo=
ry is able to replace A + D with =C2=A0A&#39; + D&#39; where D&#39; is payi=
ng a higher fee. This package A&#39; + D&#39; will confirm soon if D feerat=
e was compelling but Mallory succeeds in delaying the confirmation<br>of B =
+ C for one or more blocks. As B + C are pre-signed commitments with a low-=
fee rate they won&#39;t confirm without Alice issuing a new child E. Mallor=
y can repeat the same trick by broadcasting<br>B&#39; + E&#39; and delay ag=
ain the confirmation of C.<br><br>If the remaining package pending HTLC has=
 a higher-value than all the malicious fees over-bid, Mallory should realiz=
e a gain. With this 2nd pinning attack, the malicious entity buys confirmat=
ion delay of your packaged-together commitments.<br><br>Assuming those atta=
cks are correct, I&#39;m leaning towards being conservative with the LDK br=
oadcast backend. Though once again, other L2 devs have likely other use-cas=
es and opinions :)<br><br>&gt; =C2=A0B&#39; only needs to pay for itself in=
 this case.<br><br>Yes I think it&#39;s a nice discount when UTXO is single=
-owned. In the context of shared-owned UTXO (e.g LN), you might not if ther=
e is an in-mempool package already spending the UTXO and have to assume the=
 worst-case scenario. I.e have B&#39; committing enough fee to pay for A&#3=
9; replacement bandwidth. I think we can&#39;t do that much for this case..=
.<br><br>&gt; If a package meets feerate requirements as a<br>package, the =
parents in the transaction are allowed to replace-by-fee<br>mempool transac=
tions. The child cannot replace mempool transactions.&quot;<br><br>I agree =
with the Mallory-vs-Alice case. Though if Alice broadcasts A+B&#39; to repl=
ace A+B because the first broadcast isn&#39;t satisfying anymore due to mem=
pool spikes ? Assuming B&#39; fees is enough, I think that case as child B&=
#39; replacing in-mempool transaction B. Which I understand going against=
=C2=A0 &quot;The child cannot replace mempool transactions&quot;.<br><br>Ma=
ybe wording could be a bit clearer ?<br><br>&gt; While it would be nice to =
have full RBF, malleability of the child won&#39;t<br>&gt; block RBF here. =
If we&#39;re trying to replace A&#39;, we only require that A&#39;<br>&gt; =
signals replaceability, and don&#39;t mind if its child doesn&#39;t.<br><br=
>Yes, it sounds good.<br><br>&gt; Yes, A+C+D pays 2500sat more in fees, but=
 it is also 1000vB larger. A miner<br>&gt; should prefer to utilize their b=
lock space more effectively.<br><br>If your mempool is empty and only compo=
sed of A+C+D or A+B, I think taking A+C+D is the most efficient block const=
ruction you can come up with as a miner ?<br><br>&gt; No, because we don&#3=
9;t use that model.<br><br>Can you describe what miner model we are using ?=
 Like the block construction strategy implemented by `addPackagesTxs` or al=
so encompassing our current mempool acceptance policy, which I think rely o=
n absolute fee over ancestor score in case of replacement ?<br><br>I think =
this point is worthy to discuss as otherwise we might downgrade the efficie=
ncy of our current block construction strategy in periods of near-empty mem=
pools. A knowledge which could be discreetly leveraged by a miner to gain a=
n advantage on the rest of the mining ecosystem.<br><br>Note, I think we *m=
ight* have to go in this direction if we want to replace replace-by-fee by =
replace-by-feerate or replace-by-ancestor and solve in-depth pinning attack=
s. Though if we do so, <br>IMO we would need more thoughts.<br><br>I think =
we could restrain package acceptance to only confirmed inputs for now and r=
evisit later this point ? For LN-anchor, you can assume that the fee-bumpin=
g UTXO feeding the CPFP is already<br>confirmed. Or are there currently-dep=
loyed use-cases which would benefit from your proposed Rule #2 ?<br><br>Ant=
oine<br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmai=
l_attr">Le=C2=A0jeu. 23 sept. 2021 =C3=A0=C2=A011:36, Gloria Zhao &lt;<a hr=
ef=3D"mailto:gloriajzhao@gmail.com" target=3D"_blank">gloriajzhao@gmail.com=
</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex"><div dir=3D"ltr">Hi Antoine,<br><br><div>Thanks as always for =
your input. I&#39;m glad we agree on so much!</div><div><br></div><div>In s=
ummary, it seems that the decisions that might still need attention/input f=
rom devs on this mailing list are:</div>1. Whether we should start with mul=
tiple-parent-1-child or 1-parent-1-child.<br>2. Whether it&#39;s ok to requ=
ire that the child not have conflicts with mempool transactions.<br><br><di=
v>Responding to your comments...</div><div><br></div>&gt; IIUC, you have pa=
ckage A+B, during the dedup phase early in `AcceptMultipleTransactions` if =
you observe same-txid-different-wtixd A&#39; and A&#39; is higher feerate t=
han A, you trim A and replace by A&#39; ?<br><br>&gt; I think this approach=
 is safe, the one who appears unsafe to me is when A&#39; has a _lower_ fee=
rate, even if A&#39; is already accepted by our mempool ? In that case iirc=
 that would be a pinning.<br><br>Right, the fact that we essentially always=
 choose the first-seen witness is an unfortunate limitation that exists alr=
eady. Adding package mempool accept doesn&#39;t worsen this, but the proced=
ure in the future is to replace the witness when it makes sense economicall=
y. We can also add logic to allow package feerate to pay for witness replac=
ements as well. This is pretty far into the future, though.<br><br>&gt; It =
sounds uneconomical for an attacker but I think it&#39;s not when you consi=
der than you can &quot;batch&quot; attack against multiple honest counterpa=
rties. E.g, Mallory broadcast A&#39; + B&#39; + C&#39; + D&#39; where A&#39=
; conflicts with Alice&#39;s honest package P1, B&#39; conflicts with Bob&#=
39;s honest package P2, C&#39; conflicts with Caroll&#39;s honest package P=
3. And D&#39; is a high-fee child of A&#39; + B&#39; + C&#39;.<br><br>&gt; =
If D&#39; is higher-fee than P1 or P2 or P3 but inferior to the sum of HTLC=
s confirmed by P1+P2+P3, I think it&#39;s lucrative for the attacker ?<br><=
br>I could be misunderstanding, but an attacker wouldn&#39;t be able to bat=
ch-attack like this. Alice&#39;s package only conflicts with A&#39; + D&#39=
;, not A&#39; + B&#39; + C&#39; + D&#39;. She only needs to pay for evictin=
g 2 transactions.<br><br>&gt; Do we assume that broadcasted packages are &q=
uot;honest&quot; by default and that the parent(s) always need the child to=
 pass the fee checks, that way saving the processing of individual transact=
ions which are expected to fail in 99% of cases or more ad hoc composition =
of packages at relay ?<br>&gt; I think this point is quite dependent on the=
 p2p packages format/logic we&#39;ll end up on and that we should feel free=
 to revisit it later ?<br><br>I think it&#39;s the opposite; there&#39;s no=
 way for us to assume that p2p packages will be &quot;honest.&quot; I&#39;d=
 like to have two things before we expose on P2P: (1) ensure that the amoun=
t of resources potentially allocated for package validation isn&#39;t dispr=
oportionately higher than that of single transaction validation and (2) onl=
y use package validation when we&#39;re unsatisifed with the single validat=
ion result, e.g. we might get better fees.<br>Yes, let&#39;s revisit this l=
ater :)<br>=C2=A0<br>=C2=A0&gt; Yes, if you receive A+B, and A is already i=
n-mempoo, I agree you can discard its feerate as B should pay for all fees =
checked on its own. Where I&#39;m unclear is when you have in-mempool A+B a=
nd receive A+B&#39;. Should B&#39; have a fee high enough to cover the band=
width penalty replacement (`PaysForRBF`, 2nd check) of both A+B&#39; or onl=
y B&#39; ?<br>=C2=A0<br>=C2=A0B&#39; only needs to pay for itself in this c=
ase.<br>=C2=A0<br>&gt; &gt; Do we want the child to be able to replace memp=
ool transactions as well?<br><br>&gt; If we mean when you have replaceable =
A+B then A&#39;+B&#39; try to replace with a higher-feerate ? I think that&=
#39;s exactly the case we need for Lightning as A+B is coming from Alice an=
d A&#39;+B&#39; is coming from Bob :/<br><br><div>Let me clarify this becau=
se I can see that my wording was ambiguous, and then please let me know if =
it fits Lightning&#39;s needs?</div><div><br></div>In my proposal, I wrote =
&quot;If a package meets feerate requirements as a package, the parents in =
the transaction are allowed to replace-by-fee mempool transactions. The chi=
ld cannot replace mempool transactions.&quot; What I meant was: the package=
 can replace mempool transactions if any of the parents conflict with mempo=
ol transactions. The child cannot not conflict with any mempool transaction=
s.<br>The Lightning use case this attempts to address is: Alice and Mallory=
 are LN counterparties, and have packages A+B and A&#39;+B&#39;, respective=
ly. A and A&#39; are their commitment transactions and conflict with each o=
ther; they have shared inputs and different txids.<br>B spends Alice&#39;s =
anchor output from A. B&#39; spends Mallory&#39;s anchor output from A&#39;=
. Thus, B and B&#39; do not conflict with each other.<br>Alice can broadcas=
t her package, A+B, to replace Mallory&#39;s package, A&#39;+B&#39;, since =
B doesn&#39;t conflict with the mempool.<br><br>Would this be ok?<br><br>&g=
t; The second option, a child of A&#39;, In the LN case I think the CPFP is=
 attached on one&#39;s anchor output.<br><br>While it would be nice to have=
 full RBF, malleability of the child won&#39;t block RBF here. If we&#39;re=
 trying to replace A&#39;, we only require that A&#39; signals replaceabili=
ty, and don&#39;t mind if its child doesn&#39;t.<br><br>&gt; &gt; B has an =
ancestor score of 10sat/vb and D has an<br>&gt; &gt; ancestor score of ~2.9=
sat/vb. Since D&#39;s ancestor score is lower than B&#39;s,<br>&gt; &gt; it=
 fails the proposed package RBF Rule #2, so this package would be<br>&gt; &=
gt; rejected. Does this meet your expectations?<br><br>&gt; Well what sound=
s odd to me, in my example, we fail D even if it has a higher-fee than B. L=
ike A+B absolute fees are 2000 sats and A+C+D absolute fees are 4500 sats ?=
<br><br>Yes, A+C+D pays 2500sat more in fees, but it is also 1000vB larger.=
 A miner should prefer to utilize their block space more effectively.<br><b=
r>&gt; Is this compatible with a model where a miner prioritizes absolute f=
ees over ancestor score, in the case that mempools aren&#39;t full-enough t=
o fulfill a block ?<br><br>No, because we don&#39;t use that model.<br><br>=
Thanks,<br>Gloria</div><br><div class=3D"gmail_quote"><div dir=3D"ltr" clas=
s=3D"gmail_attr">On Thu, Sep 23, 2021 at 5:29 AM Antoine Riard &lt;<a href=
=3D"mailto:antoine.riard@gmail.com" target=3D"_blank">antoine.riard@gmail.c=
om</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex=
"><div dir=3D"ltr">&gt; Correct, if B+C is too low feerate to be accepted, =
we will reject it. I<br>&gt; prefer this because it is incentive compatible=
: A can be mined by itself,<br>&gt; so there&#39;s no reason to prefer A+B+=
C instead of A.<br>&gt; As another way of looking at this, consider the cas=
e where we do accept<br>&gt; A+B+C and it sits at the &quot;bottom&quot; of=
 our mempool. If our mempool reaches<br>&gt; capacity, we evict the lowest =
descendant feerate transactions, which are<br>&gt; B+C in this case. This g=
ives us the same resulting mempool, with A and not<br>&gt; B+C.<br><br>I ag=
ree here. Doing otherwise, we might evict other transactions mempool in `Me=
mpoolAccept::Finalize` with a higher-feerate than B+C while those evicted t=
ransactions are the most compelling for block construction.<br><br>I though=
t at first missing this acceptance requirement would break a fee-bumping sc=
heme like Parent-Pay-For-Child where a high-fee parent is attached to a chi=
ld signed with SIGHASH_ANYONECANPAY but in this case the child fee is captu=
ring the parent value. I can&#39;t think of other fee-bumping schemes poten=
tially affected. If they do exist I would say they&#39;re wrong in their de=
sign assumptions.<br><br>&gt; If or when we have witness replacement, the l=
ogic is: if the individual<br>&gt; transaction is enough to replace the mem=
pool one, the replacement will<br>&gt; happen during the preceding individu=
al transaction acceptance, and<br>&gt; deduplication logic will work. Other=
wise, we will try to deduplicate by<br>&gt; wtxid, see that we need a packa=
ge witness replacement, and use the package<br>&gt; feerate to evaluate whe=
ther this is economically rational.<br><br>IIUC, you have package A+B, duri=
ng the dedup phase early in `AcceptMultipleTransactions` if you observe sam=
e-txid-different-wtixd A&#39; and A&#39; is higher feerate than A, you trim=
 A and replace by A&#39; ?<br><br>I think this approach is safe, the one wh=
o appears unsafe to me is when A&#39; has a _lower_ feerate, even if A&#39;=
 is already accepted by our mempool ? In that case iirc that would be a pin=
ning.<br><br>Good to see progress on witness replacement before we see usag=
e of Taproot tree in the context of multi-party, where a malicious counterp=
arty inflates its witness to jam a honest spending.<br><br>(Note, the commi=
t linked currently points nowhere :))<br><br><br>&gt; Please note that A ma=
y replace A&#39; even if A&#39; has higher fees than A<br>&gt; individually=
, because the proposed package RBF utilizes the fees and size<br>&gt; of th=
e entire package. This just requires E to pay enough fees, although<br>&gt;=
 this can be pretty high if there are also potential B&#39; and C&#39; comp=
eting<br>&gt; commitment transactions that we don&#39;t know about.<br><br>=
Ah right, if the package acceptance waives `PaysMoreThanConflicts` for the =
individual check on A, the honest package should replace the pinning attemp=
t. I&#39;ve not fully parsed the proposed implementation yet.<br><br>Though=
 note, I think it&#39;s still unsafe for a Lightning multi-commitment-broad=
cast-as-one-package as a malicious A&#39; might have an absolute fee higher=
 than E. It sounds uneconomical for<br>an attacker but I think it&#39;s not=
 when you consider than you can &quot;batch&quot; attack against multiple h=
onest counterparties. E.g, Mallory broadcast A&#39; + B&#39; + C&#39; + D&#=
39; where A&#39; conflicts with Alice&#39;s honest package P1, B&#39; confl=
icts with Bob&#39;s honest package P2, C&#39; conflicts with Caroll&#39;s h=
onest package P3. And D&#39; is a high-fee child of A&#39; + B&#39; + C&#39=
;.<br><br>If D&#39; is higher-fee than P1 or P2 or P3 but inferior to the s=
um of HTLCs confirmed by P1+P2+P3, I think it&#39;s lucrative for the attac=
ker ?<br><br>&gt; So far, my understanding is that multi-parent-1-child is =
desired for<br>&gt; batched fee-bumping (<br>&gt; <a href=3D"https://github=
.com/bitcoin/bitcoin/pull/22674#issuecomment-897951289" target=3D"_blank">h=
ttps://github.com/bitcoin/bitcoin/pull/22674#issuecomment-897951289</a>) an=
d<br>&gt; I&#39;ve also seen your response which I have less context on (<b=
r>&gt; <a href=3D"https://github.com/bitcoin/bitcoin/pull/22674#issuecommen=
t-900352202" target=3D"_blank">https://github.com/bitcoin/bitcoin/pull/2267=
4#issuecomment-900352202</a>). That<br>&gt; being said, I am happy to creat=
e a new proposal for 1 parent + 1 child<br>&gt; (which would be slightly si=
mpler) and plan for moving to<br>&gt; multi-parent-1-child later if that is=
 preferred. I am very interested in<br>&gt; hearing feedback on that approa=
ch.<br><br>I think batched fee-bumping is okay as long as you don&#39;t hav=
e time-sensitive outputs encumbering your commitment transactions. For the =
reasons mentioned above, I think that&#39;s unsafe.<br><br>What I&#39;m wor=
ried about is=C2=A0 L2 developers, potentially not aware about all the memp=
ool subtleties blurring the difference and always batching their broadcast =
by default.<br><br>IMO, a good thing by restraining to 1-parent + 1 child, =
=C2=A0we artificially constraint L2 design space for now and minimize risks=
 of unsafe usage of the package API :)<br><br>I think that&#39;s a point wh=
ere it would be relevant to have the opinion of more L2 devs.<br><br>&gt; I=
 think there is a misunderstanding here - let me describe what I&#39;m<br>&=
gt; proposing we&#39;d do in this situation: we&#39;ll try individual submi=
ssion for A,<br>&gt; see that it fails due to &quot;insufficient fees.&quot=
; Then, we&#39;ll try package<br>&gt; validation for A+B and use package RB=
F. If A+B pays enough, it can still<br>&gt; replace A&#39;. If A fails for =
a bad signature, we won&#39;t look at B or A+B. Does<br>&gt; this meet your=
 expectations?<br><br>Yes there was a misunderstanding, I think this approa=
ch is correct, it&#39;s more a question of performance. Do we assume that b=
roadcasted packages are &quot;honest&quot; by default and that the parent(s=
) always need the child to pass the fee checks, that way saving the process=
ing of individual transactions which are expected to fail in 99% of cases o=
r more ad hoc composition of packages at relay ?<br><br>I think this point =
is quite dependent on the p2p packages format/logic we&#39;ll end up on and=
 that we should feel free to revisit it later ?<br><br><br>&gt; What proble=
m are you trying to solve by the package feerate *after* dedup<br>rule ?<br=
>&gt; My understanding is that an in-package transaction might be already i=
n<br>the mempool. Therefore, to compute a correct RBF penalty replacement, =
the<br>vsize of this transaction could be discarded lowering the cost of pa=
ckage<br>RBF.<br><br>&gt; I&#39;m proposing that, when a transaction has al=
ready been submitted to<br>&gt; mempool, we would ignore both its fees and =
vsize when calculating package<br>&gt; feerate. <br><br>Yes, if you receive=
 A+B, and A is already in-mempoo, I agree you can discard its feerate as B =
should pay for all fees checked on its own. Where I&#39;m unclear is when y=
ou have in-mempool A+B and receive A+B&#39;. Should B&#39; have a fee high =
enough to cover the bandwidth penalty replacement (`PaysForRBF`, 2nd check)=
 of both A+B&#39; or only B&#39; ?<br><br>If you have a second-layer like c=
urrent Lightning, you might have a counterparty commitment to replace and s=
hould always expect to have to pay for parent replacement bandwidth.<br><br=
>Where a potential discount sounds interesting is when you have an univoque=
 state on the first-stage of transactions. E.g DLC&#39;s funding transactio=
n which might be CPFP by any participant iirc.<br><br>&gt; Note that, if C&=
#39; conflicts with C, it also conflicts with D, since D is a<br>&gt; desce=
ndant of C and would thus need to be evicted along with it.<br><br>Ah once =
again I think it&#39;s a misunderstanding without the code under my eyes! I=
f we do C&#39; `PreChecks`, solve the conflicts provoked by it, i.e mark fo=
r potential eviction D and don&#39;t consider it for future conflicts in th=
e rest of the package, I think D&#39; `PreChecks` should be good ?<br><br>&=
gt; More generally, this example is surprising to me because I didn&#39;t t=
hink<br>&gt; packages would be used to fee-bump replaceable transactions. D=
o we want the<br>&gt; child to be able to replace mempool transactions as w=
ell?<br><br>If we mean when you have replaceable A+B then A&#39;+B&#39; try=
 to replace with a higher-feerate ? I think that&#39;s exactly the case we =
need for Lightning as A+B is coming from Alice and A&#39;+B&#39; is coming =
from Bob :/<br><br>&gt; I&#39;m not sure what you mean? Let&#39;s say we ha=
ve a package of parent A + child<br>&gt; B, where A is supposed to replace =
a mempool transaction A&#39;. Are you saying<br>&gt; that counterparties ar=
e able to malleate the package child B, or a child of<br>&gt; A&#39;? <br><=
br>The second option, a child of A&#39;, In the LN case I think the CPFP is=
 attached on one&#39;s anchor output.<br><br>I think it&#39;s good if we as=
sume the solve-conflicts-after-parent&#39;s`&#39;PreChecks` mentioned above=
 or fixing inherited signaling or full-rbf ?<br><br>&gt; Sorry, I don&#39;t=
 understand what you mean by &quot;preserve the package<br>&gt; integrity?&=
quot; Could you elaborate?<br><br>After thinking the relaxation about the &=
quot;new&quot; unconfirmed input is not linked to trimming but I would say =
more to the multi-parent support.<br><br>Let&#39;s say you have A+B trying =
to replace C+D where B is also spending already in-mempool E. To succeed, y=
ou need to waive the no-new-unconfirmed input as D isn&#39;t spending E.<br=
><br>So good, I think we agree on the problem description here.<br><br>&gt;=
 I am in agreement with your calculations but unsure if we disagree on the<=
br>&gt; expected outcome. Yes, B has an ancestor score of 10sat/vb and D ha=
s an<br>&gt; ancestor score of ~2.9sat/vb. Since D&#39;s ancestor score is =
lower than B&#39;s,<br>&gt; it fails the proposed package RBF Rule #2, so t=
his package would be<br>&gt; rejected. Does this meet your expectations?<br=
><br>Well what sounds odd to me, in my example, we fail D even if it has a =
higher-fee than B. Like A+B absolute fees are 2000 sats and A+C+D absolute =
fees are 4500 sats ?<br><br>Is this compatible with a model where a miner p=
rioritizes absolute fees over ancestor score, in the case that mempools are=
n&#39;t full-enough to fulfill a block ?<br><br>Let me know if I can clarif=
y a point.<br><br>Antoine<br></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr" class=3D"gmail_attr">Le=C2=A0lun. 20 sept. 2021 =C3=A0=C2=A011:10,=
 Gloria Zhao &lt;<a href=3D"mailto:gloriajzhao@gmail.com" target=3D"_blank"=
>gloriajzhao@gmail.com</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockquote cla=
ss=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"><br>Hi Antoine,<br><br>=
First of all, thank you for the thorough review. I appreciate your insight =
on LN requirements.<br><br>&gt; IIUC, you have a package A+B+C submitted fo=
r acceptance and A is already in your mempool. You trim out A from the pack=
age and then evaluate B+C.<br><br>&gt; I think this might be an issue if A =
is the higher-fee element of the ABC package. B+C package fees might be und=
er the mempool min fee and will be rejected, potentially breaking the accep=
tance expectations of the package issuer ?<br><br>Correct, if B+C is too lo=
w feerate to be accepted, we will reject it. I prefer this because it is in=
centive compatible: A can be mined by itself, so there&#39;s no reason to p=
refer A+B+C instead of A.<br>As another way of looking at this, consider th=
e case where we do accept A+B+C and it sits at the &quot;bottom&quot; of ou=
r mempool. If our mempool reaches capacity, we evict the lowest descendant =
feerate transactions, which are B+C in this case. This gives us the same re=
sulting mempool, with A and not B+C.<br><div><br></div><div><br></div>&gt; =
Further, I think the dedup should be done on wtxid, as you might have multi=
ple valid witnesses. Though with varying vsizes and as such offering differ=
ent feerates.<br><br>I agree that variations of the same package with diffe=
rent witnesses is a case that must be handled. I consider witness replaceme=
nt to be a project that can be done in parallel to package mempool acceptan=
ce because being able to accept packages does not worsen the problem of a s=
ame-txid-different-witness &quot;pinning&quot; attack.<br><br>If or when we=
 have witness replacement, the logic is: if the individual transaction is e=
nough to replace the mempool one, the replacement will happen during the pr=
eceding individual transaction acceptance, and deduplication logic will wor=
k. Otherwise, we will try to deduplicate by wtxid, see that we need a packa=
ge witness replacement, and use the package feerate to evaluate whether thi=
s is economically rational.<br><br>See the #22290 &quot;handle package tran=
sactions already in mempool&quot; commit (<a href=3D"https://github.com/bit=
coin/bitcoin/pull/22290/commits/fea75a2237b46cf76145242fecad7e274bfcb5ff" t=
arget=3D"_blank">https://github.com/bitcoin/bitcoin/pull/22290/commits/fea7=
5a2237b46cf76145242fecad7e274bfcb5ff</a>), which handles the case of same-t=
xid-different-witness by simply using the transaction in the mempool for no=
w, with TODOs for what I just described.<br><br><br>&gt; I&#39;m not clearl=
y understanding the accepted topologies. By &quot;parent and child to share=
 a parent&quot;, do you mean the set of transactions A, B, C, where B is sp=
ending A and C is spending A and B would be correct ?<br><br>Yes, that is w=
hat I meant. Yes, that would a valid package under these rules.<br><br>&gt;=
 If yes, is there a width-limit introduced or we fallback on MAX_PACKAGE_CO=
UNT=3D25 ?<br><br>No, there is no limit on connectivity other than &quot;ch=
ild with all unconfirmed parents.&quot; We will enforce MAX_PACKAGE_COUNT=
=3D25 and child&#39;s in-mempool + in-package ancestor limits.<br><br><br>&=
gt; Considering the current Core&#39;s mempool acceptance rules, I think CP=
FP batching is unsafe for LN time-sensitive closure. A malicious tx-relay j=
amming successful on one channel commitment transaction would contamine the=
 remaining commitments sharing the same package.<br><br>&gt; E.g, you broad=
cast the package A+B+C+D+E where A,B,C,D are commitment transactions and E =
a shared CPFP. If a malicious A&#39; transaction has a better feerate than =
A, the whole package acceptance will fail. Even if A&#39; confirms in the f=
ollowing block,<br>the propagation and confirmation of B+C+D have been dela=
yed. This could carry on a loss of funds.<br><br>Please note that A may rep=
lace A&#39; even if A&#39; has higher fees than A individually, because the=
 proposed package RBF utilizes the fees and size of the entire package. Thi=
s just requires E to pay enough fees, although this can be pretty high if t=
here are also potential B&#39; and C&#39; competing commitment transactions=
 that we don&#39;t know about.<br><br><br>&gt; IMHO, I&#39;m leaning toward=
s deploying during a first phase 1-parent/1-child. I think it&#39;s the mos=
t conservative step still improving second-layer safety.<br><br>So far, my =
understanding is that multi-parent-1-child is desired for batched fee-bumpi=
ng (<a href=3D"https://github.com/bitcoin/bitcoin/pull/22674#issuecomment-8=
97951289" target=3D"_blank">https://github.com/bitcoin/bitcoin/pull/22674#i=
ssuecomment-897951289</a>) and I&#39;ve also seen your response which I hav=
e less context on (<a href=3D"https://github.com/bitcoin/bitcoin/pull/22674=
#issuecomment-900352202" target=3D"_blank">https://github.com/bitcoin/bitco=
in/pull/22674#issuecomment-900352202</a>). That being said, I am happy to c=
reate a new proposal for 1 parent + 1 child (which would be slightly simple=
r) and plan for moving to multi-parent-1-child later if that is preferred. =
I am very interested in hearing feedback on that approach.<br><br><br>&gt; =
If A+B is submitted to replace A&#39;, where A pays 0 sats, B pays 200 sats=
 and A&#39; pays 100 sats. If we apply the individual RBF on A, A+B accepta=
nce fails. For this reason I think the individual RBF should be bypassed an=
d only the package RBF apply ?<br><br>I think there is a misunderstanding h=
ere - let me describe what I&#39;m proposing we&#39;d do in this situation:=
 we&#39;ll try individual submission for A, see that it fails due to &quot;=
insufficient fees.&quot; Then, we&#39;ll try package validation for A+B and=
 use package RBF. If A+B pays enough, it can still replace A&#39;. If A fai=
ls for a bad signature, we won&#39;t look at B or A+B. Does this meet your =
expectations?<br><br><br>&gt; What problem are you trying to solve by the p=
ackage feerate *after* dedup rule ?<br>&gt; My understanding is that an in-=
package transaction might be already in the mempool. Therefore, to compute =
a correct RBF penalty replacement, the vsize of this transaction could be d=
iscarded lowering the cost of package RBF.<br><br>I&#39;m proposing that, w=
hen a transaction has already been submitted to mempool, we would ignore bo=
th its fees and vsize when calculating package feerate. In example G2, we s=
houldn&#39;t count M1 fees after its submission to mempool, since M1&#39;s =
fees have already been used to pay for its individual bandwidth, and it sho=
uldn&#39;t be used again to pay for P2 and P3&#39;s bandwidth. We also shou=
ldn&#39;t count its vsize, since it has already been paid for.<br><br><br>&=
gt; I think this is a footgunish API, as if a package issuer send the multi=
ple-parent-one-child package A,B,C,D where D is the child of A,B,C. Then tr=
y to broadcast the higher-feerate C&#39;+D&#39; package, it should be rejec=
ted. So it&#39;s breaking the naive broadcaster assumption that a higher-fe=
erate/higher-fee package always replaces ?<br><br><div>Note that, if C&#39;=
 conflicts with C, it also conflicts with D, since D is a descendant of C a=
nd would thus need to be evicted along with it. Implicitly, D&#39; would no=
t be in conflict with D.<br></div><div>More generally, this example is surp=
rising to me because I didn&#39;t think packages would be used to fee-bump =
replaceable transactions. Do we want the child to be able to replace mempoo=
l transactions as well? This can be implemented with a bit of additional lo=
gic.</div><br>&gt; I think this is unsafe for L2s if counterparties have ma=
lleability of the child transaction. They can block your package replacemen=
t by opting-out from RBF signaling. IIRC, LN&#39;s &quot;anchor output&quot=
; presents such an ability.<br><br>I&#39;m not sure what you mean? Let&#39;=
s say we have a package of parent A + child B, where A is supposed to repla=
ce a mempool transaction A&#39;. Are you saying that counterparties are abl=
e to malleate the package child B, or a child of A&#39;? If they can mallea=
te a child of A&#39;, that shouldn&#39;t matter as long as A&#39; is signal=
ing replacement. This would be handled identically with full RBF and what C=
ore currently implements.<br><br>&gt; I think this is an issue brought by t=
he trimming during the dedup phase. If we preserve the package integrity, o=
nly re-using the tx-level checks results of already in-mempool transactions=
 to gain in CPU time we won&#39;t have this issue. Package childs can add u=
nconfirmed inputs as long as they&#39;re in-package, the bip125 rule2 is on=
ly evaluated against parents ?<br><br>Sorry, I don&#39;t understand what yo=
u mean by &quot;preserve the package integrity?&quot; Could you elaborate?<=
br><br>&gt; Let&#39;s say you have in-mempool A, B where A pays 10 sat/vb f=
or 100 vbytes and B pays 10 sat/vb for 100 vbytes. You have the candidate r=
eplacement D spending both A and C where D pays 15sat/vb for 100 vbytes and=
 C pays 1 sat/vb for 1000 vbytes.<br><br>&gt; Package A + B ancestor score =
is 10 sat/vb.<br><br>&gt; D has a higher feerate/absolute fee than B.<br><b=
r>&gt; Package A + C + D ancestor score is ~ 3 sat/vb ((A&#39;s 1000 sats +=
 C&#39;s 1000 sats + D&#39;s 1500 sats) / A&#39;s 100 vb + C&#39;s 1000 vb =
+ D&#39;s 100 vb)<br><br><div>I am in agreement with your calculations but =
unsure if we disagree on the expected outcome. Yes, B has an ancestor score=
 of 10sat/vb and D has an ancestor score of ~2.9sat/vb. Since D&#39;s ances=
tor score is lower than B&#39;s, it fails the proposed package RBF Rule #2,=
 so this package would be rejected. Does this meet your expectations?</div>=
<div><br></div><div>Thank you for linking to projects that might be interes=
ted in package relay :)<br></div><br>Thanks,<br>Gloria<br></div><br><div cl=
ass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, Sep 20, 2=
021 at 12:16 AM Antoine Riard &lt;<a href=3D"mailto:antoine.riard@gmail.com=
" target=3D"_blank">antoine.riard@gmail.com</a>&gt; wrote:<br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Hi Gloria,<br><=
br>&gt; A package may contain transactions that are already in the mempool.=
 We<br>&gt; remove<br>&gt; (&quot;deduplicate&quot;) those transactions fro=
m the package for the purposes of<br>&gt; package<br>&gt; mempool acceptanc=
e. If a package is empty after deduplication, we do<br>&gt; nothing.<br><br=
>IIUC, you have a package A+B+C submitted for acceptance and A is already i=
n your mempool. You trim out A from the package and then evaluate B+C.<br><=
br>I think this might be an issue if A is the higher-fee element of the ABC=
 package. B+C package fees might be under the mempool min fee and will be r=
ejected, potentially breaking the acceptance expectations of the package is=
suer ?<br><br>Further, I think the dedup should be done on wtxid, as you mi=
ght have multiple valid witnesses. Though with varying vsizes and as such o=
ffering different feerates.<br><br>E.g you&#39;re going to evaluate the pac=
kage A+B and A&#39; is already in your mempool with a bigger valid witness.=
 You trim A based on txid, then you evaluate A&#39;+B, which fails the fee =
checks. However, evaluating A+B would have been a success.<br><br>AFAICT, t=
he dedup rationale would be to save on CPU time/IO disk, to avoid repeated =
signatures verification and parent UTXOs fetches ? Can we achieve the same =
goal by bypassing tx-level checks for already-in txn while conserving the p=
ackage integrity for package-level checks ?<br><br>&gt; Note that it&#39;s =
possible for the parents to be<br>&gt; indirect<br>&gt; descendants/ancesto=
rs of one another, or for parent and child to share a<br>&gt; parent,<br>&g=
t; so we cannot make any other topology assumptions.<br><br>I&#39;m not cle=
arly understanding the accepted topologies. By &quot;parent and child to sh=
are a parent&quot;, do you mean the set of transactions A, B, C, where B is=
 spending A and C is spending A and B would be correct ?<br><br>If yes, is =
there a width-limit introduced or we fallback on MAX_PACKAGE_COUNT=3D25 ?<b=
r><br>IIRC, one rationale to come with this topology limitation was to lowe=
r the DoS risks when potentially deploying p2p packages.<br><br>Considering=
 the current Core&#39;s mempool acceptance rules, I think CPFP batching is =
unsafe for LN time-sensitive closure. A malicious tx-relay jamming successf=
ul on one channel commitment transaction would contamine the remaining comm=
itments sharing the same package.<br><br>E.g, you broadcast the package A+B=
+C+D+E where A,B,C,D are commitment transactions and E a shared CPFP. If a =
malicious A&#39; transaction has a better feerate than A, the whole package=
 acceptance will fail. Even if A&#39; confirms in the following block, <br>=
the propagation and confirmation of B+C+D have been delayed. This could car=
ry on a loss of funds.<br><br>That said, if you&#39;re broadcasting commitm=
ent transactions without time-sensitive HTLC outputs, I think the batching =
is effectively a fee saving as you don&#39;t have to duplicate the CPFP.<br=
><br>IMHO, I&#39;m leaning towards deploying during a first phase 1-parent/=
1-child. I think it&#39;s the most conservative step still improving second=
-layer safety.<br><br>&gt; *Rationale*: =C2=A0It would be incorrect to use =
the fees of transactions that are<br>&gt; already in the mempool, as we do =
not want a transaction&#39;s fees to be<br>&gt; double-counted for both its=
 individual RBF and package RBF.<br><br>I&#39;m unsure about the logical or=
der of the checks proposed.<br><br>If A+B is submitted to replace A&#39;, w=
here A pays 0 sats, B pays 200 sats and A&#39; pays 100 sats. If we apply t=
he individual RBF on A, A+B acceptance fails. For this reason I think the i=
ndividual RBF should be bypassed and only the package RBF apply ? <br><br>N=
ote this situation is plausible, with current LN design, your counterparty =
can have a commitment transaction with a better fee just by selecting a hig=
her `dust_limit_satoshis` than yours.<br><br>&gt; Examples F and G [14] sho=
w the same package, but P1 is submitted<br>&gt; individually before<br>&gt;=
 the package in example G. In example F, we can see that the 300vB package<=
br>&gt; pays<br>&gt; an additional 200sat in fees, which is not enough to p=
ay for its own<br>&gt; bandwidth<br>&gt; (BIP125#4). In example G, we can s=
ee that P1 pays enough to replace M1, but<br>&gt; using P1&#39;s fees again=
 during package submission would make it look like a<br>&gt; 300sat<br>&gt;=
 increase for a 200vB package. Even including its fees and size would not b=
e<br>&gt; sufficient in this example, since the 300sat looks like enough fo=
r the 300vB<br>&gt; package. The calculcation after deduplication is 100sat=
 increase for a<br>&gt; package<br>&gt; of size 200vB, which correctly fail=
s BIP125#4. Assume all transactions have<br>&gt; a<br>&gt; size of 100vB.<b=
r><br>What problem are you trying to solve by the package feerate *after* d=
edup rule ?<br><br>My understanding is that an in-package transaction might=
 be already in the mempool. Therefore, to compute a correct RBF penalty rep=
lacement, the vsize of this transaction could be discarded lowering the cos=
t of package RBF.<br><br>If we keep a &quot;safe&quot; dedup mechanism (see=
 my point above), I think this discount is justified, as the validation cos=
t of node operators is paid for ?<br><br>&gt; The child cannot replace memp=
ool transactions.<br><br>Let&#39;s say you issue package A+B, then package =
C+B&#39;, where B&#39; is a child of both A and C. This rule fails the acce=
ptance of C+B&#39; ?<br><br>I think this is a footgunish API, as if a packa=
ge issuer send the multiple-parent-one-child package A,B,C,D where D is the=
 child of A,B,C. Then try to broadcast the higher-feerate C&#39;+D&#39; pac=
kage, it should be rejected. So it&#39;s breaking the naive broadcaster ass=
umption that a higher-feerate/higher-fee package always replaces ? And it m=
ight be unsafe in protocols where states are symmetric. E.g a malicious cou=
nterparty broadcasts first S+A, then you honestly broadcast S+B, where B pa=
ys better fees.<br><br>&gt; All mempool transactions to be replaced must si=
gnal replaceability.<br><br>I think this is unsafe for L2s if counterpartie=
s have malleability of the child transaction. They can block your package r=
eplacement by opting-out from RBF signaling. IIRC, LN&#39;s &quot;anchor ou=
tput&quot; presents such an ability.<br><br>I think it&#39;s better to eith=
er fix inherited signaling or move towards full-rbf.<br><br>&gt; if a packa=
ge parent has already been submitted, it would<br>&gt; look<br>&gt;like the=
 child is spending a &quot;new&quot; unconfirmed input.<br><br>I think this=
 is an issue brought by the trimming during the dedup phase. If we preserve=
 the package integrity, only re-using the tx-level checks results of alread=
y in-mempool transactions to gain in CPU time we won&#39;t have this issue.=
 Package childs can add unconfirmed inputs as long as they&#39;re in-packag=
e, the bip125 rule2 is only evaluated against parents ?<br><br>&gt; However=
, we still achieve the same goal of requiring the<br>&gt; replacement<br>&g=
t; transactions to have a ancestor score at least as high as the original<b=
r>&gt; ones.<br><br>I&#39;m not sure if this holds...<br><br>Let&#39;s say =
you have in-mempool A, B where A pays 10 sat/vb for 100 vbytes and B pays 1=
0 sat/vb for 100 vbytes. You have the candidate replacement D spending both=
 A and C where D pays 15sat/vb for 100 vbytes and C pays 1 sat/vb for 1000 =
vbytes.<br><br>Package A + B ancestor score is 10 sat/vb.<br><br>D has a hi=
gher feerate/absolute fee than B.<br><br>Package A + C + D ancestor score i=
s ~ 3 sat/vb ((A&#39;s 1000 sats + C&#39;s 1000 sats + D&#39;s 1500 sats) /=
 <br>A&#39;s 100 vb + C&#39;s 1000 vb + D&#39;s 100 vb)<br><br>Overall, thi=
s is a review through the lenses of LN requirements. I think other L2 proto=
cols/applications<br>could be candidates to using package accept/relay such=
 as:<br>* <a href=3D"https://github.com/lightninglabs/pool" target=3D"_blan=
k">https://github.com/lightninglabs/pool</a><br>* <a href=3D"https://github=
.com/discreetlogcontracts/dlcspecs" target=3D"_blank">https://github.com/di=
screetlogcontracts/dlcspecs</a><br>* <a href=3D"https://github.com/bitcoin-=
teleport/teleport-transactions/" target=3D"_blank">https://github.com/bitco=
in-teleport/teleport-transactions/</a><br>* <a href=3D"https://github.com/s=
apio-lang/sapio" target=3D"_blank">https://github.com/sapio-lang/sapio</a><=
br>* <a href=3D"https://github.com/commerceblock/mercury/blob/master/doc/st=
atechains.md" target=3D"_blank">https://github.com/commerceblock/mercury/bl=
ob/master/doc/statechains.md</a><br>* <a href=3D"https://github.com/revault=
/practical-revault" target=3D"_blank">https://github.com/revault/practical-=
revault</a><br><br>Thanks for rolling forward the ball on this subject.<br>=
<br>Antoine<br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=
=3D"gmail_attr">Le=C2=A0jeu. 16 sept. 2021 =C3=A0=C2=A003:55, Gloria Zhao v=
ia bitcoin-dev &lt;<a href=3D"mailto:bitcoin-dev@lists.linuxfoundation.org"=
 target=3D"_blank">bitcoin-dev@lists.linuxfoundation.org</a>&gt; a =C3=A9cr=
it=C2=A0:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div d=
ir=3D"ltr">Hi there,<br><br>I&#39;m writing to propose a set of mempool pol=
icy changes to enable package<br>validation (in preparation for package rel=
ay) in Bitcoin Core. These would not<br>be consensus or P2P protocol change=
s. However, since mempool policy<br>significantly affects transaction propa=
gation, I believe this is relevant for<br>the mailing list.<br><br>My propo=
sal enables packages consisting of multiple parents and 1 child. If you<br>=
develop software that relies on specific transaction relay assumptions and/=
or<br>are interested in using package relay in the future, I&#39;m very int=
erested to hear<br>your feedback on the utility or restrictiveness of these=
 package policies for<br>your use cases.<br><br>A draft implementation of t=
his proposal can be found in [Bitcoin Core<br>PR#22290][1].<br><br>An illus=
trated version of this post can be found at<br><div><a href=3D"https://gist=
.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a" target=3D"_blank">http=
s://gist.github.com/glozow/dc4e9d5c5b14ade7cdfac40f43adb18a</a>.</div><div>=
I have also linked the images below.</div><br>## Background<br><br>Feel fre=
e to skip this section if you are already familiar with mempool policy<br>a=
nd package relay terminology.<br><br>### Terminology Clarifications<br><br>=
* Package =3D an ordered list of related transactions, representable by a D=
irected<br>=C2=A0 Acyclic Graph.<br>* Package Feerate =3D the total modifie=
d fees divided by the total virtual size of<br>=C2=A0 all transactions in t=
he package.<br>=C2=A0 =C2=A0 - Modified fees =3D a transaction&#39;s base f=
ees + fee delta applied by the user<br>=C2=A0 =C2=A0 =C2=A0 with `prioritis=
etransaction`. As such, we expect this to vary across<br>mempools.<br>=C2=
=A0 =C2=A0 - Virtual Size =3D the maximum of virtual sizes calculated using=
 [BIP141<br>=C2=A0 =C2=A0 =C2=A0 virtual size][2] and sigop weight. [Implem=
ented here in Bitcoin Core][3].<br>=C2=A0 =C2=A0 - Note that feerate is not=
 necessarily based on the base fees and serialized<br>=C2=A0 =C2=A0 =C2=A0 =
size.<br><br>* Fee-Bumping =3D user/wallet actions that take advantage of m=
iner incentives to<br>=C2=A0 boost a transaction&#39;s candidacy for inclus=
ion in a block, including Child Pays<br>for Parent (CPFP) and [BIP125][12] =
Replace-by-Fee (RBF). Our intention in<br>mempool policy is to recognize wh=
en the new transaction is more economical to<br>mine than the original one(=
s) but not open DoS vectors, so there are some<br>limitations.<br><br>### P=
olicy<br><br>The purpose of the mempool is to store the best (to be most in=
centive-compatible<br>with miners, highest feerate) candidates for inclusio=
n in a block. Miners use<br>the mempool to build block templates. The mempo=
ol is also useful as a cache for<br>boosting block relay and validation per=
formance, aiding transaction relay, and<br>generating feerate estimations.<=
br><br>Ideally, all consensus-valid transactions paying reasonable fees sho=
uld make it<br>to miners through normal transaction relay, without any spec=
ial connectivity or<br>relationships with miners. On the other hand, nodes =
do not have unlimited<br>resources, and a P2P network designed to let any h=
onest node broadcast their<br>transactions also exposes the transaction val=
idation engine to DoS attacks from<br>malicious peers.<br><br>As such, for =
unconfirmed transactions we are considering for our mempool, we<br>apply a =
set of validation rules in addition to consensus, primarily to protect<br>u=
s from resource exhaustion and aid our efforts to keep the highest fee<br>t=
ransactions. We call this mempool _policy_: a set of (configurable,<br>node=
-specific) rules that transactions must abide by in order to be accepted<br=
>into our mempool. Transaction &quot;Standardness&quot; rules and mempool r=
estrictions such<br>as &quot;too-long-mempool-chain&quot; are both examples=
 of policy.<br><br>### Package Relay and Package Mempool Accept<br><br>In t=
ransaction relay, we currently consider transactions one at a time for<br>s=
ubmission to the mempool. This creates a limitation in the node&#39;s abili=
ty to<br>determine which transactions have the highest feerates, since we c=
annot take<br>into account descendants (i.e. cannot use CPFP) until all the=
 transactions are<br>in the mempool. Similarly, we cannot use a transaction=
&#39;s descendants when<br>considering it for RBF. When an individual trans=
action does not meet the mempool<br>minimum feerate and the user isn&#39;t =
able to create a replacement transaction<br>directly, it will not be accept=
ed by mempools.<br><br>This limitation presents a security issue for applic=
ations and users relying on<br>time-sensitive transactions. For example, Li=
ghtning and other protocols create<br>UTXOs with multiple spending paths, w=
here one counterparty&#39;s spending path opens<br>up after a timelock, and=
 users are protected from cheating scenarios as long as<br>they redeem on-c=
hain in time. A key security assumption is that all parties&#39;<br>transac=
tions will propagate and confirm in a timely manner. This assumption can<br=
>be broken if fee-bumping does not work as intended.<br><br>The end goal fo=
r Package Relay is to consider multiple transactions at the same<br>time, e=
.g. a transaction with its high-fee child. This may help us better<br>deter=
mine whether transactions should be accepted to our mempool, especially if<=
br>they don&#39;t meet fee requirements individually or are better RBF cand=
idates as a<br>package. A combination of changes to mempool validation logi=
c, policy, and<br>transaction relay allows us to better propagate the trans=
actions with the<br>highest package feerates to miners, and makes fee-bumpi=
ng tools more powerful<br>for users.<br><br>The &quot;relay&quot; part of P=
ackage Relay suggests P2P messaging changes, but a large<br>part of the cha=
nges are in the mempool&#39;s package validation logic. We call this<br>*Pa=
ckage Mempool Accept*.<br><br>### Previous Work<br><br>* Given that mempool=
 validation is DoS-sensitive and complex, it would be<br>=C2=A0 dangerous t=
o haphazardly tack on package validation logic. Many efforts have<br>been m=
ade to make mempool validation less opaque (see [#16400][4], [#21062][5],<b=
r>[#22675][6], [#22796][7]).<br>* [#20833][8] Added basic capabilities for =
package validation, test accepts only<br>=C2=A0 (no submission to mempool).=
<br>* [#21800][9] Implemented package ancestor/descendant limit checks for =
arbitrary<br>=C2=A0 packages. Still test accepts only.<br>* Previous packag=
e relay proposals (see [#16401][10], [#19621][11]).<br><br>### Existing Pac=
kage Rules<br><br>These are in master as introduced in [#20833][8] and [#21=
800][9]. I&#39;ll consider<br>them as &quot;given&quot; in the rest of this=
 document, though they can be changed, since<br>package validation is test-=
accept only right now.<br><br>1. A package cannot exceed `MAX_PACKAGE_COUNT=
=3D25` count and<br>`MAX_PACKAGE_SIZE=3D101KvB` total size [8]<br><br>=C2=
=A0 =C2=A0*Rationale*: This is already enforced as mempool ancestor/descend=
ant limits.<br>Presumably, transactions in a package are all related, so ex=
ceeding this limit<br>would mean that the package can either be split up or=
 it wouldn&#39;t pass this<br>mempool policy.<br><br>2. Packages must be to=
pologically sorted: if any dependencies exist between<br>transactions, pare=
nts must appear somewhere before children. [8]<br><br>3. A package cannot h=
ave conflicting transactions, i.e. none of them can spend<br><div>the same =
inputs. This also means there cannot be duplicate transactions. [8]</div><d=
iv><br></div>4. When packages are evaluated against ancestor/descendant lim=
its in a test<br>accept, the union of all of their descendants and ancestor=
s is considered. This<br>is essentially a &quot;worst case&quot; heuristic =
where every transaction in the package<br>is treated as each other&#39;s an=
cestor and descendant.  [8]<br>Packages for which ancestor/descendant limit=
s are accurately captured by this<br><div>heuristic: [19]</div><br>There ar=
e also limitations such as the fact that CPFP carve out is not applied<br>t=
o package transactions. #20833 also disables RBF in package validation; thi=
s<br>proposal overrides that to allow packages to use RBF.<br><br>## Propos=
ed Changes<br><br>The next step in the Package Mempool Accept project is to=
 implement submission<br>to mempool, initially through RPC only. This allow=
s us to test the submission<br>logic before exposing it on P2P.<br><br>### =
Summary<br><br>- Packages may contain already-in-mempool transactions.<br>-=
 Packages are 2 generations, Multi-Parent-1-Child.<br>- Fee-related checks =
use the package feerate. This means that wallets can<br>create a package th=
at utilizes CPFP.<br>- Parents are allowed to RBF mempool transactions with=
 a set of rules similar<br>=C2=A0 to BIP125. This enables a combination of =
CPFP and RBF, where a<br>transaction&#39;s descendant fees pay for replacin=
g mempool conflicts.<br><br>There is a draft implementation in [#22290][1].=
 It is WIP, but feedback is<br>always welcome.<br><br>### Details<br><br>##=
## Packages May Contain Already-in-Mempool Transactions<br><br>A package ma=
y contain transactions that are already in the mempool. We remove<br>(&quot=
;deduplicate&quot;) those transactions from the package for the purposes of=
 package<br>mempool acceptance. If a package is empty after deduplication, =
we do nothing.<br><br>*Rationale*: Mempools vary across the network. It&#39=
;s possible for a parent to be<br>accepted to the mempool of a peer on its =
own due to differences in policy and<br>fee market fluctuations. We should =
not reject or penalize the entire package for<br>an individual transaction =
as that could be a censorship vector.<br><br>#### Packages Are Multi-Parent=
-1-Child<br><br>Only packages of a specific topology are permitted. Namely,=
 a package is exactly<br>1 child with all of its unconfirmed parents. After=
 deduplication, the package<br>may be exactly the same, empty, 1 child, 1 c=
hild with just some of its<br>unconfirmed parents, etc. Note that it&#39;s =
possible for the parents to be indirect<br>descendants/ancestors of one ano=
ther, or for parent and child to share a parent,<br>so we cannot make any o=
ther topology assumptions.<br><br>*Rationale*: This allows for fee-bumping =
by CPFP. Allowing multiple parents<br>makes it possible to fee-bump a batch=
 of transactions. Restricting packages to a<br>defined topology is also eas=
ier to reason about and simplifies the validation<br>logic greatly. Multi-p=
arent-1-child allows us to think of the package as one big<br>transaction, =
where:<br><br>- Inputs =3D all the inputs of parents + inputs of the child =
that come from<br>=C2=A0 confirmed UTXOs<br>- Outputs =3D all the outputs o=
f the child + all outputs of the parents that<br>=C2=A0 aren&#39;t spent by=
 other transactions in the package<br><br>Examples of packages that follow =
this rule (variations of example A show some<br>possibilities after dedupli=
cation): ![image][15]<br><br>#### Fee-Related Checks Use Package Feerate<br=
><br>Package Feerate =3D the total modified fees divided by the total virtu=
al size of<br>all transactions in the package.<br><br>To meet the two feera=
te requirements of a mempool, i.e., the pre-configured<br>minimum relay fee=
rate (`minRelayTxFee`) and dynamic mempool minimum feerate, the<br>total pa=
ckage feerate is used instead of the individual feerate. The individual<br>=
transactions are allowed to be below feerate requirements if the package me=
ets<br>the feerate requirements. For example, the parent(s) in the package =
can have 0<br>fees but be paid for by the child.<br><br>*Rationale*: This c=
an be thought of as &quot;CPFP within a package,&quot; solving the<br>issue=
 of a parent not meeting minimum fees on its own. This allows L2<br>applica=
tions to adjust their fees at broadcast time instead of overshooting or<br>=
risking getting stuck/pinned.<br><br>We use the package feerate of the pack=
age *after deduplication*.<br><br>*Rationale*: =C2=A0It would be incorrect =
to use the fees of transactions that are<br>already in the mempool, as we d=
o not want a transaction&#39;s fees to be<br>double-counted for both its in=
dividual RBF and package RBF.<br><br>Examples F and G [14] show the same pa=
ckage, but P1 is submitted individually before<br>the package in example G.=
 In example F, we can see that the 300vB package pays<br>an additional 200s=
at in fees, which is not enough to pay for its own bandwidth<br>(BIP125#4).=
 In example G, we can see that P1 pays enough to replace M1, but<br>using P=
1&#39;s fees again during package submission would make it look like a 300s=
at<br>increase for a 200vB package. Even including its fees and size would =
not be<br>sufficient in this example, since the 300sat looks like enough fo=
r the 300vB<br>package. The calculcation after deduplication is 100sat incr=
ease for a package<br>of size 200vB, which correctly fails BIP125#4. Assume=
 all transactions have a<br>size of 100vB.<br><br>#### Package RBF<br><br>I=
f a package meets feerate requirements as a package, the parents in the<br>=
transaction are allowed to replace-by-fee mempool transactions. The child c=
annot<br>replace mempool transactions. Multiple transactions can replace th=
e same<br>transaction, but in order to be valid, none of the transactions c=
an try to<br>replace an ancestor of another transaction in the same package=
 (which would thus<br>make its inputs unavailable).<br><br>*Rationale*: Eve=
n if we are using package feerate, a package will not propagate<br>as inten=
ded if RBF still requires each individual transaction to meet the<br>feerat=
e requirements.<br><br>We use a set of rules slightly modified from BIP125 =
as follows:<br><br>##### Signaling (Rule #1)<br><br>All mempool transaction=
s to be replaced must signal replaceability.<br><br>*Rationale*: Package RB=
F signaling logic should be the same for package RBF and<br>single transact=
ion acceptance. This would be updated if single transaction<br>validation m=
oves to full RBF.<br><br>##### New Unconfirmed Inputs (Rule #2)<br><br>A pa=
ckage may include new unconfirmed inputs, but the ancestor feerate of the<b=
r>child must be at least as high as the ancestor feerates of every transact=
ion<br>being replaced. This is contrary to BIP125#2, which states &quot;The=
 replacement<br>transaction may only include an unconfirmed input if that i=
nput was included in<br>one of the original transactions. (An unconfirmed i=
nput spends an output from a<br>currently-unconfirmed transaction.)&quot;<b=
r><br>*Rationale*: The purpose of BIP125#2 is to ensure that the replacemen=
t<br>transaction has a higher ancestor score than the original transaction(=
s) (see<br>[comment][13]). Example H [16] shows how adding a new unconfirme=
d input can lower the<br>ancestor score of the replacement transaction. P1 =
is trying to replace M1, and<br>spends an unconfirmed output of M2. P1 pays=
 800sat, M1 pays 600sat, and M2 pays<br>100sat. Assume all transactions hav=
e a size of 100vB. While, in isolation, P1<br>looks like a better mining ca=
ndidate than M1, it must be mined with M2, so its<br>ancestor feerate is ac=
tually 4.5sat/vB.=C2=A0 This is lower than M1&#39;s ancestor<br>feerate, wh=
ich is 6sat/vB.<br><br>In package RBF, the rule analogous to BIP125#2 would=
 be &quot;none of the<br>transactions in the package can spend new unconfir=
med inputs.&quot; Example J [17] shows<br>why, if any of the package transa=
ctions have ancestors, package feerate is no<br>longer accurate. Even thoug=
h M2 and M3 are not ancestors of P1 (which is the<br>replacement transactio=
n in an RBF), we&#39;re actually interested in the entire<br>package. A min=
er should mine M1 which is 5sat/vB instead of M2, M3, P1, P2, and<br>P3, wh=
ich is only 4sat/vB. The Package RBF rule cannot be loosened to only allow<=
br>the child to have new unconfirmed inputs, either, because it can still c=
ause us<br>to overestimate the package&#39;s ancestor score.<br><br>However=
, enforcing a rule analogous to BIP125#2 would not only make Package RBF<br=
>less useful, but would also break Package RBF for packages with parents al=
ready<br>in the mempool: if a package parent has already been submitted, it=
 would look<br>like the child is spending a &quot;new&quot; unconfirmed inp=
ut. In example K [18], we&#39;re<br>looking to replace M1 with the entire p=
ackage including P1, P2, and P3. We must<br>consider the case where one of =
the parents is already in the mempool (in this<br>case, P2), which means we=
 must allow P3 to have new unconfirmed inputs. However,<br>M2 lowers the an=
cestor score of P3 to 4.3sat/vB, so we should not replace M1<br>with this p=
ackage.<br><br>Thus, the package RBF rule regarding new unconfirmed inputs =
is less strict than<br>BIP125#2. However, we still achieve the same goal of=
 requiring the replacement<br>transactions to have a ancestor score at leas=
t as high as the original ones. As<br>a result, the entire package is requi=
red to be a higher feerate mining candidate<br>than each of the replaced tr=
ansactions.<br><br>Another note: the [comment][13] above the BIP125#2 code =
in the original RBF<br>implementation suggests that the rule was intended t=
o be temporary.<br><br>##### Absolute Fee (Rule #3)<br><br>The package must=
 increase the absolute fee of the mempool, i.e. the total fees<br>of the pa=
ckage must be higher than the absolute fees of the mempool transactions<br>=
it replaces. Combined with the CPFP rule above, this differs from BIP125 Ru=
le #3<br>- an individual transaction in the package may have lower fees tha=
n the<br>=C2=A0 transaction(s) it is replacing. In fact, it may have 0 fees=
, and the child<br>pays for RBF.<br><br>##### Feerate (Rule #4)<br><br>The =
package must pay for its own bandwidth; the package feerate must be higher<=
br>than the replaced transactions by at least minimum relay feerate<br>(`in=
crementalRelayFee`). Combined with the CPFP rule above, this differs from<b=
r>BIP125 Rule #4 - an individual transaction in the package can have a lowe=
r<br>feerate than the transaction(s) it is replacing. In fact, it may have =
0 fees,<br>and the child pays for RBF.<br><br>##### Total Number of Replace=
d Transactions (Rule #5)<br><br>The package cannot replace more than 100 me=
mpool transactions. This is identical<br>to BIP125 Rule #5.<br><br>### Expe=
cted FAQs<br><br>1. Is it possible for only some of the package to make it =
into the mempool?<br><br>=C2=A0 =C2=A0Yes, it is. However, since we evict t=
ransactions from the mempool by<br>descendant score and the package child i=
s supposed to be sponsoring the fees of<br>its parents, the most common sce=
nario would be all-or-nothing. This is<br>incentive-compatible. In fact, to=
 be conservative, package validation should<br>begin by trying to submit al=
l of the transactions individually, and only use the<br>package mempool acc=
eptance logic if the parents fail due to low feerate.<br><br>2. Should we a=
llow packages to contain already-confirmed transactions?<br><br>=C2=A0 =C2=
=A0 No, for practical reasons. In mempool validation, we actually aren&#39;=
t able to<br>tell with 100% confidence if we are looking at a transaction t=
hat has already<br>confirmed, because we look up inputs using a UTXO set. I=
f we have historical<br>block data, it&#39;s possible to look for it, but t=
his is inefficient, not always<br>possible for pruning nodes, and unnecessa=
ry because we&#39;re not going to do<br>anything with the transaction anywa=
y. As such, we already have the expectation<br>that transaction relay is so=
mewhat &quot;stateful&quot; i.e. nobody should be relaying<br>transactions =
that have already been confirmed. Similarly, we shouldn&#39;t be<br>relayin=
g packages that contain already-confirmed transactions.<br><br>[1]: <a href=
=3D"https://github.com/bitcoin/bitcoin/pull/22290" target=3D"_blank">https:=
//github.com/bitcoin/bitcoin/pull/22290</a><br>[2]: <a href=3D"https://gith=
ub.com/bitcoin/bips/blob/1f0b563738199ca60d32b4ba779797fc97d040fe/bip-0141.=
mediawiki#transaction-size-calculations" target=3D"_blank">https://github.c=
om/bitcoin/bips/blob/1f0b563738199ca60d32b4ba779797fc97d040fe/bip-0141.medi=
awiki#transaction-size-calculations</a><br>[3]: <a href=3D"https://github.c=
om/bitcoin/bitcoin/blob/94f83534e4b771944af7d9ed0f40746f392eb75e/src/policy=
/policy.cpp#L282" target=3D"_blank">https://github.com/bitcoin/bitcoin/blob=
/94f83534e4b771944af7d9ed0f40746f392eb75e/src/policy/policy.cpp#L282</a><br=
>[4]: <a href=3D"https://github.com/bitcoin/bitcoin/pull/16400" target=3D"_=
blank">https://github.com/bitcoin/bitcoin/pull/16400</a><br>[5]: <a href=3D=
"https://github.com/bitcoin/bitcoin/pull/21062" target=3D"_blank">https://g=
ithub.com/bitcoin/bitcoin/pull/21062</a><br>[6]: <a href=3D"https://github.=
com/bitcoin/bitcoin/pull/22675" target=3D"_blank">https://github.com/bitcoi=
n/bitcoin/pull/22675</a><br>[7]: <a href=3D"https://github.com/bitcoin/bitc=
oin/pull/22796" target=3D"_blank">https://github.com/bitcoin/bitcoin/pull/2=
2796</a><br>[8]: <a href=3D"https://github.com/bitcoin/bitcoin/pull/20833" =
target=3D"_blank">https://github.com/bitcoin/bitcoin/pull/20833</a><br>[9]:=
 <a href=3D"https://github.com/bitcoin/bitcoin/pull/21800" target=3D"_blank=
">https://github.com/bitcoin/bitcoin/pull/21800</a><br>[10]: <a href=3D"htt=
ps://github.com/bitcoin/bitcoin/pull/16401" target=3D"_blank">https://githu=
b.com/bitcoin/bitcoin/pull/16401</a><br>[11]: <a href=3D"https://github.com=
/bitcoin/bitcoin/pull/19621" target=3D"_blank">https://github.com/bitcoin/b=
itcoin/pull/19621</a><br>[12]: <a href=3D"https://github.com/bitcoin/bips/b=
lob/master/bip-0125.mediawiki" target=3D"_blank">https://github.com/bitcoin=
/bips/blob/master/bip-0125.mediawiki</a><br>[13]: <a href=3D"https://github=
.com/bitcoin/bitcoin/pull/6871/files#diff-34d21af3c614ea3cee120df276c9c4ae9=
5053830d7f1d3deaf009a4625409ad2R1101-R1104" target=3D"_blank">https://githu=
b.com/bitcoin/bitcoin/pull/6871/files#diff-34d21af3c614ea3cee120df276c9c4ae=
95053830d7f1d3deaf009a4625409ad2R1101-R1104</a><br>[14]: <a href=3D"https:/=
/user-images.githubusercontent.com/25183001/133567078-075a971c-0619-4339-91=
68-b41fd2b90c28.png" target=3D"_blank">https://user-images.githubuserconten=
t.com/25183001/133567078-075a971c-0619-4339-9168-b41fd2b90c28.png</a><br>[1=
5]: <a href=3D"https://user-images.githubusercontent.com/25183001/132856734=
-fc17da75-f875-44bb-b954-cb7a1725cc0d.png" target=3D"_blank">https://user-i=
mages.githubusercontent.com/25183001/132856734-fc17da75-f875-44bb-b954-cb7a=
1725cc0d.png</a><br>[16]: <a href=3D"https://user-images.githubusercontent.=
com/25183001/133567347-a3e2e4a8-ae9c-49f8-abb9-81e8e0aba224.png" target=3D"=
_blank">https://user-images.githubusercontent.com/25183001/133567347-a3e2e4=
a8-ae9c-49f8-abb9-81e8e0aba224.png</a><br>[17]: <a href=3D"https://user-ima=
ges.githubusercontent.com/25183001/133567370-21566d0e-36c8-4831-b1a8-706634=
540af3.png" target=3D"_blank">https://user-images.githubusercontent.com/251=
83001/133567370-21566d0e-36c8-4831-b1a8-706634540af3.png</a><br>[18]: <a hr=
ef=3D"https://user-images.githubusercontent.com/25183001/133567444-bfff1142=
-439f-4547-800a-2ba2b0242bcb.png" target=3D"_blank">https://user-images.git=
hubusercontent.com/25183001/133567444-bfff1142-439f-4547-800a-2ba2b0242bcb.=
png</a><br>[19]: <a href=3D"https://user-images.githubusercontent.com/25183=
001/133456219-0bb447cb-dcb4-4a31-b9c1-7d86205b68bc.png" target=3D"_blank">h=
ttps://user-images.githubusercontent.com/25183001/133456219-0bb447cb-dcb4-4=
a31-b9c1-7d86205b68bc.png</a><br>[20]: <a href=3D"https://user-images.githu=
busercontent.com/25183001/132857787-7b7c6f56-af96-44c8-8d78-983719888c19.pn=
g" target=3D"_blank">https://user-images.githubusercontent.com/25183001/132=
857787-7b7c6f56-af96-44c8-8d78-983719888c19.png</a><br></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>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></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>
</blockquote></div>
</blockquote></div>

--000000000000a502f005cd2105e8--