Skip to content

Commit 881fac8

Browse files
committed
scripted-diff: change names from V3 to TRUC
-BEGIN VERIFY SCRIPT- sed -i 's/SingleV3Checks/SingleTRUCChecks/g' $(git grep -l 'SingleV3Checks') sed -i 's/PackageV3Checks/PackageTRUCChecks/g' $(git grep -l 'PackageV3Checks') sed -i 's/PV3C/PTRUCC/g' src/policy/truc_policy.h sed -i 's/V3_MAX_VSIZE/TRUC_MAX_VSIZE/g' $(git grep -l 'V3_MAX_VSIZE') sed -i 's/V3_CHILD_MAX_VSIZE/TRUC_CHILD_MAX_VSIZE/g' $(git grep -l 'V3_CHILD_MAX_VSIZE') sed -i 's/V3_DESCENDANT_LIMIT/TRUC_DESCENDANT_LIMIT/g' $(git grep -l 'V3_DESCENDANT_LIMIT') sed -i 's/V3_ANCESTOR_LIMIT/TRUC_ANCESTOR_LIMIT/g' $(git grep -l 'V3_ANCESTOR_LIMIT') sed -i 's/CheckMempoolV3Invariants/CheckMempoolTRUCInvariants/g' $(git grep -l 'CheckMempoolV3Invariants') -END VERIFY SCRIPT-
1 parent a573dd2 commit 881fac8

File tree

9 files changed

+98
-98
lines changed

9 files changed

+98
-98
lines changed

src/policy/truc_policy.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <numeric>
1515
#include <vector>
1616

17-
/** Helper for PackageV3Checks: Returns a vector containing the indices of transactions (within
17+
/** Helper for PackageTRUCChecks: Returns a vector containing the indices of transactions (within
1818
* package) that are direct parents of ptx. */
1919
std::vector<size_t> FindInPackageParents(const Package& package, const CTransactionRef& ptx)
2020
{
@@ -37,7 +37,7 @@ std::vector<size_t> FindInPackageParents(const Package& package, const CTransact
3737
return in_package_parents;
3838
}
3939

40-
/** Helper for PackageV3Checks, storing info for a mempool or package parent. */
40+
/** Helper for PackageTRUCChecks, storing info for a mempool or package parent. */
4141
struct ParentInfo {
4242
/** Txid used to identify this parent by prevout */
4343
const Txid& m_txid;
@@ -55,36 +55,36 @@ struct ParentInfo {
5555
{}
5656
};
5757

58-
std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t vsize,
58+
std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t vsize,
5959
const Package& package,
6060
const CTxMemPool::setEntries& mempool_ancestors)
6161
{
6262
// This function is specialized for these limits, and must be reimplemented if they ever change.
63-
static_assert(V3_ANCESTOR_LIMIT == 2);
64-
static_assert(V3_DESCENDANT_LIMIT == 2);
63+
static_assert(TRUC_ANCESTOR_LIMIT == 2);
64+
static_assert(TRUC_DESCENDANT_LIMIT == 2);
6565

6666
const auto in_package_parents{FindInPackageParents(package, ptx)};
6767

6868
// Now we have all ancestors, so we can start checking TRUC rules.
6969
if (ptx->version == TRUC_VERSION) {
70-
// SingleV3Checks should have checked this already.
71-
if (!Assume(vsize <= V3_MAX_VSIZE)) {
70+
// SingleTRUCChecks should have checked this already.
71+
if (!Assume(vsize <= TRUC_MAX_VSIZE)) {
7272
return strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
73-
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, V3_MAX_VSIZE);
73+
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_MAX_VSIZE);
7474
}
7575

76-
if (mempool_ancestors.size() + in_package_parents.size() + 1 > V3_ANCESTOR_LIMIT) {
76+
if (mempool_ancestors.size() + in_package_parents.size() + 1 > TRUC_ANCESTOR_LIMIT) {
7777
return strprintf("tx %s (wtxid=%s) would have too many ancestors",
7878
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString());
7979
}
8080

8181
const bool has_parent{mempool_ancestors.size() + in_package_parents.size() > 0};
8282
if (has_parent) {
8383
// A TRUC child cannot be too large.
84-
if (vsize > V3_CHILD_MAX_VSIZE) {
84+
if (vsize > TRUC_CHILD_MAX_VSIZE) {
8585
return strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
8686
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
87-
vsize, V3_CHILD_MAX_VSIZE);
87+
vsize, TRUC_CHILD_MAX_VSIZE);
8888
}
8989

9090
// Exactly 1 parent exists, either in mempool or package. Find it.
@@ -118,7 +118,7 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
118118

119119
for (auto& input : package_tx->vin) {
120120
// Fail if we find another tx with the same parent. We don't check whether the
121-
// sibling is to-be-replaced (done in SingleV3Checks) because these transactions
121+
// sibling is to-be-replaced (done in SingleTRUCChecks) because these transactions
122122
// are within the same package.
123123
if (input.prevout.hash == parent_info.m_txid) {
124124
return strprintf("tx %s (wtxid=%s) would exceed descendant count limit",
@@ -161,7 +161,7 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
161161
return std::nullopt;
162162
}
163163

164-
std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTransactionRef& ptx,
164+
std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CTransactionRef& ptx,
165165
const CTxMemPool::setEntries& mempool_ancestors,
166166
const std::set<Txid>& direct_conflicts,
167167
int64_t vsize)
@@ -182,20 +182,20 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
182182
}
183183

184184
// This function is specialized for these limits, and must be reimplemented if they ever change.
185-
static_assert(V3_ANCESTOR_LIMIT == 2);
186-
static_assert(V3_DESCENDANT_LIMIT == 2);
185+
static_assert(TRUC_ANCESTOR_LIMIT == 2);
186+
static_assert(TRUC_DESCENDANT_LIMIT == 2);
187187

188188
// The rest of the rules only apply to transactions with version=3.
189189
if (ptx->version != TRUC_VERSION) return std::nullopt;
190190

191-
if (vsize > V3_MAX_VSIZE) {
191+
if (vsize > TRUC_MAX_VSIZE) {
192192
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
193-
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, V3_MAX_VSIZE),
193+
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_MAX_VSIZE),
194194
nullptr);
195195
}
196196

197-
// Check that V3_ANCESTOR_LIMIT would not be violated.
198-
if (mempool_ancestors.size() + 1 > V3_ANCESTOR_LIMIT) {
197+
// Check that TRUC_ANCESTOR_LIMIT would not be violated.
198+
if (mempool_ancestors.size() + 1 > TRUC_ANCESTOR_LIMIT) {
199199
return std::make_pair(strprintf("tx %s (wtxid=%s) would have too many ancestors",
200200
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString()),
201201
nullptr);
@@ -204,9 +204,9 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
204204
// Remaining checks only pertain to transactions with unconfirmed ancestors.
205205
if (mempool_ancestors.size() > 0) {
206206
// If this transaction spends TRUC parents, it cannot be too large.
207-
if (vsize > V3_CHILD_MAX_VSIZE) {
207+
if (vsize > TRUC_CHILD_MAX_VSIZE) {
208208
return std::make_pair(strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
209-
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, V3_CHILD_MAX_VSIZE),
209+
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_CHILD_MAX_VSIZE),
210210
nullptr);
211211
}
212212

@@ -222,7 +222,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
222222
const bool child_will_be_replaced = !children.empty() &&
223223
std::any_of(children.cbegin(), children.cend(),
224224
[&direct_conflicts](const CTxMemPoolEntry& child){return direct_conflicts.count(child.GetTx().GetHash()) > 0;});
225-
if (parent_entry->GetCountWithDescendants() + 1 > V3_DESCENDANT_LIMIT && !child_will_be_replaced) {
225+
if (parent_entry->GetCountWithDescendants() + 1 > TRUC_DESCENDANT_LIMIT && !child_will_be_replaced) {
226226
// Allow sibling eviction for TRUC transaction: if another child already exists, even if
227227
// we don't conflict inputs with it, consider evicting it under RBF rules. We rely on TRUC rules
228228
// only permitting 1 descendant, as otherwise we would need to have logic for deciding

src/policy/truc_policy.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,29 @@ static constexpr decltype(CTransaction::version) TRUC_VERSION{3};
2222
// TRUC only allows 1 parent and 1 child when unconfirmed. This translates to a descendant set size
2323
// of 2 and ancestor set size of 2.
2424
/** Maximum number of transactions including an unconfirmed tx and its descendants. */
25-
static constexpr unsigned int V3_DESCENDANT_LIMIT{2};
25+
static constexpr unsigned int TRUC_DESCENDANT_LIMIT{2};
2626
/** Maximum number of transactions including a TRUC tx and all its mempool ancestors. */
27-
static constexpr unsigned int V3_ANCESTOR_LIMIT{2};
27+
static constexpr unsigned int TRUC_ANCESTOR_LIMIT{2};
2828

2929
/** Maximum sigop-adjusted virtual size of all v3 transactions. */
30-
static constexpr int64_t V3_MAX_VSIZE{10000};
30+
static constexpr int64_t TRUC_MAX_VSIZE{10000};
3131
/** Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction. */
32-
static constexpr int64_t V3_CHILD_MAX_VSIZE{1000};
32+
static constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000};
3333
// These limits are within the default ancestor/descendant limits.
34-
static_assert(V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1000);
35-
static_assert(V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1000);
34+
static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1000);
35+
static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1000);
3636

3737
/** Must be called for every transaction, even if not TRUC. Not strictly necessary for transactions
3838
* accepted through AcceptMultipleTransactions.
3939
*
4040
* Checks the following rules:
4141
* 1. A TRUC tx must only have TRUC unconfirmed ancestors.
4242
* 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.
43+
* 3. A TRUC's ancestor set, including itself, must be within TRUC_ANCESTOR_LIMIT.
44+
* 4. A TRUC's descendant set, including itself, must be within TRUC_DESCENDANT_LIMIT.
4545
* 5. If a TRUC tx has any unconfirmed ancestors, the tx's sigop-adjusted vsize must be within
46-
* V3_CHILD_MAX_VSIZE.
47-
* 6. A TRUC tx must be within V3_MAX_VSIZE.
46+
* TRUC_CHILD_MAX_VSIZE.
47+
* 6. A TRUC tx must be within TRUC_MAX_VSIZE.
4848
*
4949
*
5050
* @param[in] mempool_ancestors The in-mempool ancestors of ptx.
@@ -61,7 +61,7 @@ static_assert(V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT
6161
* - debug string + nullptr if this transaction violates some TRUC rule and sibling eviction is not
6262
* applicable.
6363
*/
64-
std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTransactionRef& ptx,
64+
std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CTransactionRef& ptx,
6565
const CTxMemPool::setEntries& mempool_ancestors,
6666
const std::set<Txid>& direct_conflicts,
6767
int64_t vsize);
@@ -76,18 +76,18 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
7676
* and that the transaction itself has no children in the package.
7777
*
7878
* 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
79+
* - if a TRUC transaction T has a parent in the mempool and a child in the package, then PTRUCC(T) will fail
80+
* - if a TRUC transaction T has a parent in the package and a child in the package, then PTRUCC(T) will fail
8181
* - if a TRUC transaction T and a TRUC (sibling) transaction U have some parent in the mempool,
82-
* then PV3C(T) and PV3C(U) will fail
82+
* then PTRUCC(T) and PTRUCC(U) will fail
8383
* - if a TRUC transaction T and a TRUC (sibling) transaction U have some parent in the package,
84-
* then PV3C(T) and PV3C(U) will fail
84+
* then PTRUCC(T) and PTRUCC(U) will fail
8585
* - if a TRUC transaction T has a parent P and a grandparent G in the package, then
86-
* PV3C(P) will fail (though PV3C(G) and PV3C(T) might succeed).
86+
* PTRUCC(P) will fail (though PTRUCC(G) and PTRUCC(T) might succeed).
8787
*
8888
* @returns debug string if an error occurs, std::nullopt otherwise.
8989
* */
90-
std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t vsize,
90+
std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t vsize,
9191
const Package& package,
9292
const CTxMemPool::setEntries& mempool_ancestors);
9393

src/test/fuzz/package_eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
320320
Assert(result_package.m_tx_results.size() == txs.size() || result_package.m_tx_results.empty());
321321
}
322322

323-
CheckMempoolV3Invariants(tx_pool);
323+
CheckMempoolTRUCInvariants(tx_pool);
324324
}
325325

326326
node.validation_signals->UnregisterSharedValidationInterface(outpoints_updater);

src/test/fuzz/tx_pool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
320320
if (accepted) {
321321
Assert(added.size() == 1); // For now, no package acceptance
322322
Assert(tx == *added.begin());
323-
CheckMempoolV3Invariants(tx_pool);
323+
CheckMempoolTRUCInvariants(tx_pool);
324324
} else {
325325
// Do not consider rejected transaction removed
326326
removed.erase(tx);
@@ -413,7 +413,7 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
413413
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
414414
if (accepted) {
415415
txids.push_back(tx->GetHash());
416-
CheckMempoolV3Invariants(tx_pool);
416+
CheckMempoolTRUCInvariants(tx_pool);
417417
}
418418
}
419419
Finish(fuzzed_data_provider, tx_pool, chainstate);

0 commit comments

Comments
 (0)