15
15
#include < set>
16
16
#include < string>
17
17
18
- // This module enforces rules for BIP 431 TRUC transactions (with version=3) which help make
19
- // RBF abilities more robust.
18
+ // This module enforces rules for BIP 431 TRUC transactions which help make
19
+ // RBF abilities more robust. A transaction with version=3 is treated as TRUC.
20
20
static constexpr decltype (CTransaction::version) TRUC_VERSION{3 };
21
21
22
- // v3 only allows 1 parent and 1 child when unconfirmed.
22
+ // TRUC only allows 1 parent and 1 child when unconfirmed. This translates to a descendant set size
23
+ // of 2 and ancestor set size of 2.
23
24
/* * Maximum number of transactions including an unconfirmed tx and its descendants. */
24
25
static constexpr unsigned int V3_DESCENDANT_LIMIT{2 };
25
- /* * Maximum number of transactions including a V3 tx and all its mempool ancestors. */
26
+ /* * Maximum number of transactions including a TRUC tx and all its mempool ancestors. */
26
27
static constexpr unsigned int V3_ANCESTOR_LIMIT{2 };
27
28
28
29
/* * Maximum sigop-adjusted virtual size of all v3 transactions. */
29
30
static constexpr int64_t V3_MAX_VSIZE{10000 };
30
- /* * Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed v3 transaction. */
31
+ /* * Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction. */
31
32
static constexpr int64_t V3_CHILD_MAX_VSIZE{1000 };
32
33
// These limits are within the default ancestor/descendant limits.
33
34
static_assert (V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1000 );
34
35
static_assert (V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1000 );
35
36
36
- /* * Must be called for every transaction, even if not v3 . Not strictly necessary for transactions
37
+ /* * Must be called for every transaction, even if not TRUC . Not strictly necessary for transactions
37
38
* accepted through AcceptMultipleTransactions.
38
39
*
39
40
* Checks the following rules:
40
- * 1. A v3 tx must only have v3 unconfirmed ancestors.
41
- * 2. A non-v3 tx must only have non-v3 unconfirmed ancestors.
42
- * 3. A v3 's ancestor set, including itself, must be within V3_ANCESTOR_LIMIT.
43
- * 4. A v3 's descendant set, including itself, must be within V3_DESCENDANT_LIMIT.
44
- * 5. If a v3 tx has any unconfirmed ancestors, the tx's sigop-adjusted vsize must be within
41
+ * 1. A TRUC tx must only have TRUC unconfirmed ancestors.
42
+ * 2. A non-TRUC tx must only have non-TRUC unconfirmed ancestors.
43
+ * 3. A TRUC 's ancestor set, including itself, must be within V3_ANCESTOR_LIMIT.
44
+ * 4. A TRUC 's descendant set, including itself, must be within V3_DESCENDANT_LIMIT.
45
+ * 5. If a TRUC tx has any unconfirmed ancestors, the tx's sigop-adjusted vsize must be within
45
46
* V3_CHILD_MAX_VSIZE.
46
- * 6. A v3 tx must be within V3_MAX_VSIZE.
47
+ * 6. A TRUC tx must be within V3_MAX_VSIZE.
47
48
*
48
49
*
49
50
* @param[in] mempool_ancestors The in-mempool ancestors of ptx.
@@ -53,35 +54,35 @@ static_assert(V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT
53
54
* @param[in] vsize The sigop-adjusted virtual size of ptx.
54
55
*
55
56
* @returns 3 possibilities:
56
- * - std::nullopt if all v3 checks were applied successfully
57
+ * - std::nullopt if all TRUC checks were applied successfully
57
58
* - debug string + pointer to a mempool sibling if this transaction would be the second child in a
58
59
* 1-parent-1-child cluster; the caller may consider evicting the specified sibling or return an
59
60
* error with the debug string.
60
- * - debug string + nullptr if this transaction violates some v3 rule and sibling eviction is not
61
+ * - debug string + nullptr if this transaction violates some TRUC rule and sibling eviction is not
61
62
* applicable.
62
63
*/
63
64
std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks (const CTransactionRef& ptx,
64
65
const CTxMemPool::setEntries& mempool_ancestors,
65
66
const std::set<Txid>& direct_conflicts,
66
67
int64_t vsize);
67
68
68
- /* * Must be called for every transaction that is submitted within a package, even if not v3 .
69
+ /* * Must be called for every transaction that is submitted within a package, even if not TRUC .
69
70
*
70
71
* For each transaction in a package:
71
- * If it's not a v3 transaction, verify it has no direct v3 parents in the mempool or the package.
72
+ * If it's not a TRUC transaction, verify it has no direct TRUC parents in the mempool or the package.
72
73
73
- * If it is a v3 transaction, verify that any direct parents in the mempool or the package are v3 .
74
+ * If it is a TRUC transaction, verify that any direct parents in the mempool or the package are TRUC .
74
75
* If such a parent exists, verify that parent has no other children in the package or the mempool,
75
76
* and that the transaction itself has no children in the package.
76
77
*
77
- * If any v3 violations in the package exist, this test will fail for one of them:
78
- * - if a v3 transaction T has a parent in the mempool and a child in the package, then PV3C(T) will fail
79
- * - if a v3 transaction T has a parent in the package and a child in the package, then PV3C(T) will fail
80
- * - if a v3 transaction T and a v3 (sibling) transaction U have some parent in the mempool,
78
+ * If any TRUC violations in the package exist, this test will fail for one of them:
79
+ * - if a TRUC transaction T has a parent in the mempool and a child in the package, then PV3C(T) will fail
80
+ * - if a TRUC transaction T has a parent in the package and a child in the package, then PV3C(T) will fail
81
+ * - if a TRUC transaction T and a TRUC (sibling) transaction U have some parent in the mempool,
81
82
* then PV3C(T) and PV3C(U) will fail
82
- * - if a v3 transaction T and a v3 (sibling) transaction U have some parent in the package,
83
+ * - if a TRUC transaction T and a TRUC (sibling) transaction U have some parent in the package,
83
84
* then PV3C(T) and PV3C(U) will fail
84
- * - if a v3 transaction T has a parent P and a grandparent G in the package, then
85
+ * - if a TRUC transaction T has a parent P and a grandparent G in the package, then
85
86
* PV3C(P) will fail (though PV3C(G) and PV3C(T) might succeed).
86
87
*
87
88
* @returns debug string if an error occurs, std::nullopt otherwise.
0 commit comments