1515#include < set>
1616#include < string>
1717
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.
2020static constexpr decltype (CTransaction::version) TRUC_VERSION{3 };
2121
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.
2324/* * Maximum number of transactions including an unconfirmed tx and its descendants. */
2425static 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. */
2627static constexpr unsigned int V3_ANCESTOR_LIMIT{2 };
2728
2829/* * Maximum sigop-adjusted virtual size of all v3 transactions. */
2930static 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. */
3132static constexpr int64_t V3_CHILD_MAX_VSIZE{1000 };
3233// These limits are within the default ancestor/descendant limits.
3334static_assert (V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1000 );
3435static_assert (V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1000 );
3536
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
3738 * accepted through AcceptMultipleTransactions.
3839 *
3940 * 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
4546 * 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.
4748 *
4849 *
4950 * @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
5354 * @param[in] vsize The sigop-adjusted virtual size of ptx.
5455 *
5556 * @returns 3 possibilities:
56- * - std::nullopt if all v3 checks were applied successfully
57+ * - std::nullopt if all TRUC checks were applied successfully
5758 * - debug string + pointer to a mempool sibling if this transaction would be the second child in a
5859 * 1-parent-1-child cluster; the caller may consider evicting the specified sibling or return an
5960 * 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
6162 * applicable.
6263 */
6364std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks (const CTransactionRef& ptx,
6465 const CTxMemPool::setEntries& mempool_ancestors,
6566 const std::set<Txid>& direct_conflicts,
6667 int64_t vsize);
6768
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 .
6970 *
7071 * 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.
7273
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 .
7475 * If such a parent exists, verify that parent has no other children in the package or the mempool,
7576 * and that the transaction itself has no children in the package.
7677 *
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,
8182 * 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,
8384 * 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
8586 * PV3C(P) will fail (though PV3C(G) and PV3C(T) might succeed).
8687 *
8788 * @returns debug string if an error occurs, std::nullopt otherwise.
0 commit comments