|
| 1 | +# Mempool Limits |
| 2 | + |
| 3 | +## Definitions |
| 4 | + |
| 5 | +Given any two transactions Tx0 and Tx1 where Tx1 spends an output of Tx0, |
| 6 | +Tx0 is a *parent* of Tx1 and Tx1 is a *child* of Tx0. |
| 7 | + |
| 8 | +A transaction's *ancestors* include, recursively, its parents, the parents of its parents, etc. |
| 9 | +A transaction's *descendants* include, recursively, its children, the children of its children, etc. |
| 10 | + |
| 11 | +A mempool entry's *ancestor count* is the total number of in-mempool (unconfirmed) transactions in |
| 12 | +its ancestor set, including itself. |
| 13 | +A mempool entry's *descendant count* is the total number of in-mempool (unconfirmed) transactions in |
| 14 | +its descendant set, including itself. |
| 15 | + |
| 16 | +A mempool entry's *ancestor size* is the aggregated virtual size of in-mempool (unconfirmed) |
| 17 | +transactions in its ancestor set, including itself. |
| 18 | +A mempool entry's *descendant size* is the aggregated virtual size of in-mempool (unconfirmed) |
| 19 | +transactions in its descendant set, including itself. |
| 20 | + |
| 21 | +Transactions submitted to the mempool must not exceed the ancestor and descendant limits (aka |
| 22 | +mempool *package limits*) set by the node (see `-limitancestorcount`, `-limitancestorsize`, |
| 23 | +`-limitdescendantcount`, `-limitdescendantsize`). |
| 24 | + |
| 25 | +## Exemptions |
| 26 | + |
| 27 | +### CPFP Carve Out |
| 28 | + |
| 29 | +**CPFP Carve Out** if a transaction candidate for submission to the |
| 30 | +mempool would cause some mempool entry to exceed its descendant limits, an exemption is made if all |
| 31 | +of the following conditions are met: |
| 32 | + |
| 33 | +1. The candidate transaction is no more than 10,000 virtual bytes. |
| 34 | + |
| 35 | +2. The candidate transaction has an ancestor count of 2 (itself and exactly 1 ancestor). |
| 36 | + |
| 37 | +3. The in-mempool transaction's descendant count, including the candidate transaction, would only |
| 38 | + exceed the limit by 1. |
| 39 | + |
| 40 | +*Rationale*: this rule was introduced to prevent pinning by domination of a transaction's descendant |
| 41 | +limits in two-party contract protocols such as LN. Also see the [mailing list |
| 42 | +post](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html). |
| 43 | + |
| 44 | +This rule was introduced in [PR #15681](https://github.com/bitcoin/bitcoin/pull/15681). |
| 45 | + |
| 46 | +### Single-Conflict RBF Carve Out |
| 47 | + |
| 48 | +When a candidate transaction for submission to the mempool would replace mempool entries, it may |
| 49 | +also decrease the descendant count of other mempool entries. Since ancestor/descendant limits are |
| 50 | +calculated prior to removing the would-be-replaced transactions, they may be overestimated. |
| 51 | + |
| 52 | +An exemption is given for a candidate transaction that would replace mempool transactions and meets |
| 53 | +all of the following conditions: |
| 54 | + |
| 55 | +1. The candidate transaction has exactly 1 directly conflicting transaction. |
| 56 | + |
| 57 | +2. The candidate transaction does not spend any unconfirmed inputs that are not also spent by the |
| 58 | + directly conflicting transaction. |
| 59 | + |
| 60 | +The following discounts are given to account for the would-be-replaced transaction(s): |
| 61 | + |
| 62 | +1. The descendant count limit is temporarily increased by 1. |
| 63 | + |
| 64 | +2. The descendant size limit temporarily is increased by the virtual size of the to-be-replaced |
| 65 | + directly conflicting transaction. |
0 commit comments