|
| 1 | +# Package Mempool Accept |
| 2 | + |
| 3 | +## Definitions |
| 4 | + |
| 5 | +A **package** is an ordered list of transactions, representable by a connected Directed Acyclic |
| 6 | +Graph (a directed edge exists between a transaction that spends the output of another transaction). |
| 7 | + |
| 8 | +For every transaction `t` in a **topologically sorted** package, if any of its parents are present |
| 9 | +in the package, they appear somewhere in the list before `t`. |
| 10 | + |
| 11 | +A **child-with-unconfirmed-parents** package is a topologically sorted package that consists of |
| 12 | +exactly one child and all of its unconfirmed parents (no other transactions may be present). |
| 13 | +The last transaction in the package is the child, and its package can be canonically defined based |
| 14 | +on the current state: each of its inputs must be available in the UTXO set as of the current chain |
| 15 | +tip or some preceding transaction in the package. |
| 16 | + |
| 17 | +## Package Mempool Acceptance Rules |
| 18 | + |
| 19 | +The following rules are enforced for all packages: |
| 20 | + |
| 21 | +* Packages cannot exceed `MAX_PACKAGE_COUNT=25` count and `MAX_PACKAGE_SIZE=101KvB` total size |
| 22 | + (#20833) |
| 23 | + |
| 24 | + - *Rationale*: This is already enforced as mempool ancestor/descendant limits. If |
| 25 | + transactions in a package are all related, exceeding this limit would mean that the package |
| 26 | + can either be split up or it wouldn't pass individual mempool policy. |
| 27 | + |
| 28 | + - Note that, if these mempool limits change, package limits should be reconsidered. Users may |
| 29 | + also configure their mempool limits differently. |
| 30 | + |
| 31 | +* Packages must be topologically sorted. (#20833) |
| 32 | + |
| 33 | +* Packages cannot have conflicting transactions, i.e. no two transactions in a package can spend |
| 34 | + the same inputs. Packages cannot have duplicate transactions. (#20833) |
| 35 | + |
| 36 | +* No transaction in a package can conflict with a mempool transaction. |
| 37 | + |
| 38 | +* When packages are evaluated against ancestor/descendant limits, the union of all transactions' |
| 39 | + descendants and ancestors is considered. (#21800) |
| 40 | + |
| 41 | + - *Rationale*: This is essentially a "worst case" heuristic intended for packages that are |
| 42 | + heavily connected, i.e. some transaction in the package is the ancestor or descendant of all |
| 43 | + the other transactions. |
| 44 | + |
| 45 | +The following rules are only enforced for packages to be submitted to the mempool (not enforced for |
| 46 | +test accepts): |
| 47 | + |
| 48 | +* Packages must be child-with-unconfirmed-parents packages. This also means packages must contain at |
| 49 | + least 2 transactions. (#22674) |
| 50 | + |
| 51 | +* Transactions in the package that have the same txid as another transaction already in the mempool |
| 52 | + will be removed from the package prior to submission ("deduplication"). |
| 53 | + |
| 54 | + - *Rationale*: Node operators are free to set their mempool policies however they please, nodes |
| 55 | + may receive transactions in different orders, and malicious counterparties may try to take |
| 56 | + advantage of policy differences to pin or delay propagation of transactions. As such, it's |
| 57 | + possible for some package transaction(s) to already be in the mempool, and there is no need to |
| 58 | + repeat validation for those transactions or double-count them in fees. |
| 59 | + |
| 60 | + - *Rationale*: We want to prevent potential censorship vectors. We should not reject entire |
| 61 | + packages because we already have one of the transactions. Also, if an attacker first broadcasts |
| 62 | + a competing package, the honest package should still be considered for acceptance. |
0 commit comments