Skip to content

Commit d59ddc5

Browse files
committed
[packages/doc] define and document package rules
Central place for putting package-related info. This document or parts of it can also be easily ported to other places if deemed appropriate.
1 parent ba26169 commit d59ddc5

File tree

4 files changed

+72
-8
lines changed

4 files changed

+72
-8
lines changed

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The Bitcoin repo's [root README](/README.md) contains relevant information on th
8282
- [Reduce Memory](reduce-memory.md)
8383
- [Reduce Traffic](reduce-traffic.md)
8484
- [Tor Support](tor.md)
85+
- [Transaction Relay Policy](policy/README.md)
8586
- [ZMQ](zmq.md)
8687

8788
License

doc/policy/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Transaction Relay Policy
2+
3+
Policy is a set of validation rules, in addition to consensus, enforced for unconfirmed
4+
transactions.
5+
6+
This documentation is not an exhaustive list of all policy rules.
7+
8+
- [Packages](packages.md)
9+
10+

doc/policy/packages.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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. BIP125 Replace By Fee is
37+
currently disabled for packages. (#20833)
38+
39+
- Package RBF may be enabled in the future.
40+
41+
* When packages are evaluated against ancestor/descendant limits, the union of all transactions'
42+
descendants and ancestors is considered. (#21800)
43+
44+
- *Rationale*: This is essentially a "worst case" heuristic intended for packages that are
45+
heavily connected, i.e. some transaction in the package is the ancestor or descendant of all
46+
the other transactions.
47+
48+
The following rules are only enforced for packages to be submitted to the mempool (not enforced for
49+
test accepts):
50+
51+
* Packages must be child-with-unconfirmed-parents packages. This also means packages must contain at
52+
least 2 transactions. (#22674)
53+
54+
- *Rationale*: This allows for fee-bumping by CPFP. Allowing multiple parents makes it possible
55+
to fee-bump a batch of transactions. Restricting packages to a defined topology is easier to
56+
reason about and simplifies the validation logic greatly.
57+
58+
- Warning: Batched fee-bumping may be unsafe for some use cases. Users and application developers
59+
should take caution if utilizing multi-parent packages.

src/validation.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,8 @@ MempoolAcceptResult AcceptToMemoryPool(CChainState& active_chainstate, CTxMemPoo
216216
bool bypass_limits, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
217217

218218
/**
219-
* Atomically test acceptance of a package. If the package only contains one tx, package rules still
220-
* apply. Package validation does not allow BIP125 replacements, so the transaction(s) cannot spend
221-
* the same inputs as any transaction in the mempool.
222-
* @param[in] txns Group of transactions which may be independent or contain
223-
* parent-child dependencies. The transactions must not conflict
224-
* with each other, i.e., must not spend the same inputs. If any
225-
* dependencies exist, parents must appear anywhere in the list
226-
* before their children.
219+
* Validate (and maybe submit) a package to the mempool. See doc/policy/packages.md for full details
220+
* on package validation rules.
227221
* @returns a PackageMempoolAcceptResult which includes a MempoolAcceptResult for each transaction.
228222
* If a transaction fails, validation will exit early and some results may be missing.
229223
*/

0 commit comments

Comments
 (0)