mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
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-
This commit is contained in:
parent
a573dd2617
commit
881fac8e60
9 changed files with 98 additions and 98 deletions
|
@ -14,7 +14,7 @@
|
|||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
/** Helper for PackageV3Checks: Returns a vector containing the indices of transactions (within
|
||||
/** Helper for PackageTRUCChecks: Returns a vector containing the indices of transactions (within
|
||||
* package) that are direct parents of ptx. */
|
||||
std::vector<size_t> FindInPackageParents(const Package& package, const CTransactionRef& ptx)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ std::vector<size_t> FindInPackageParents(const Package& package, const CTransact
|
|||
return in_package_parents;
|
||||
}
|
||||
|
||||
/** Helper for PackageV3Checks, storing info for a mempool or package parent. */
|
||||
/** Helper for PackageTRUCChecks, storing info for a mempool or package parent. */
|
||||
struct ParentInfo {
|
||||
/** Txid used to identify this parent by prevout */
|
||||
const Txid& m_txid;
|
||||
|
@ -55,25 +55,25 @@ struct ParentInfo {
|
|||
{}
|
||||
};
|
||||
|
||||
std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t vsize,
|
||||
std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t vsize,
|
||||
const Package& package,
|
||||
const CTxMemPool::setEntries& mempool_ancestors)
|
||||
{
|
||||
// This function is specialized for these limits, and must be reimplemented if they ever change.
|
||||
static_assert(V3_ANCESTOR_LIMIT == 2);
|
||||
static_assert(V3_DESCENDANT_LIMIT == 2);
|
||||
static_assert(TRUC_ANCESTOR_LIMIT == 2);
|
||||
static_assert(TRUC_DESCENDANT_LIMIT == 2);
|
||||
|
||||
const auto in_package_parents{FindInPackageParents(package, ptx)};
|
||||
|
||||
// Now we have all ancestors, so we can start checking TRUC rules.
|
||||
if (ptx->version == TRUC_VERSION) {
|
||||
// SingleV3Checks should have checked this already.
|
||||
if (!Assume(vsize <= V3_MAX_VSIZE)) {
|
||||
// SingleTRUCChecks should have checked this already.
|
||||
if (!Assume(vsize <= TRUC_MAX_VSIZE)) {
|
||||
return strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, V3_MAX_VSIZE);
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_MAX_VSIZE);
|
||||
}
|
||||
|
||||
if (mempool_ancestors.size() + in_package_parents.size() + 1 > V3_ANCESTOR_LIMIT) {
|
||||
if (mempool_ancestors.size() + in_package_parents.size() + 1 > TRUC_ANCESTOR_LIMIT) {
|
||||
return strprintf("tx %s (wtxid=%s) would have too many ancestors",
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString());
|
||||
}
|
||||
|
@ -81,10 +81,10 @@ std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t v
|
|||
const bool has_parent{mempool_ancestors.size() + in_package_parents.size() > 0};
|
||||
if (has_parent) {
|
||||
// A TRUC child cannot be too large.
|
||||
if (vsize > V3_CHILD_MAX_VSIZE) {
|
||||
if (vsize > TRUC_CHILD_MAX_VSIZE) {
|
||||
return strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
|
||||
vsize, V3_CHILD_MAX_VSIZE);
|
||||
vsize, TRUC_CHILD_MAX_VSIZE);
|
||||
}
|
||||
|
||||
// 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
|
|||
|
||||
for (auto& input : package_tx->vin) {
|
||||
// Fail if we find another tx with the same parent. We don't check whether the
|
||||
// sibling is to-be-replaced (done in SingleV3Checks) because these transactions
|
||||
// sibling is to-be-replaced (done in SingleTRUCChecks) because these transactions
|
||||
// are within the same package.
|
||||
if (input.prevout.hash == parent_info.m_txid) {
|
||||
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
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTransactionRef& ptx,
|
||||
std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CTransactionRef& ptx,
|
||||
const CTxMemPool::setEntries& mempool_ancestors,
|
||||
const std::set<Txid>& direct_conflicts,
|
||||
int64_t vsize)
|
||||
|
@ -182,20 +182,20 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
|
|||
}
|
||||
|
||||
// This function is specialized for these limits, and must be reimplemented if they ever change.
|
||||
static_assert(V3_ANCESTOR_LIMIT == 2);
|
||||
static_assert(V3_DESCENDANT_LIMIT == 2);
|
||||
static_assert(TRUC_ANCESTOR_LIMIT == 2);
|
||||
static_assert(TRUC_DESCENDANT_LIMIT == 2);
|
||||
|
||||
// The rest of the rules only apply to transactions with version=3.
|
||||
if (ptx->version != TRUC_VERSION) return std::nullopt;
|
||||
|
||||
if (vsize > V3_MAX_VSIZE) {
|
||||
if (vsize > TRUC_MAX_VSIZE) {
|
||||
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, V3_MAX_VSIZE),
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_MAX_VSIZE),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
// Check that V3_ANCESTOR_LIMIT would not be violated.
|
||||
if (mempool_ancestors.size() + 1 > V3_ANCESTOR_LIMIT) {
|
||||
// Check that TRUC_ANCESTOR_LIMIT would not be violated.
|
||||
if (mempool_ancestors.size() + 1 > TRUC_ANCESTOR_LIMIT) {
|
||||
return std::make_pair(strprintf("tx %s (wtxid=%s) would have too many ancestors",
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString()),
|
||||
nullptr);
|
||||
|
@ -204,9 +204,9 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
|
|||
// Remaining checks only pertain to transactions with unconfirmed ancestors.
|
||||
if (mempool_ancestors.size() > 0) {
|
||||
// If this transaction spends TRUC parents, it cannot be too large.
|
||||
if (vsize > V3_CHILD_MAX_VSIZE) {
|
||||
if (vsize > TRUC_CHILD_MAX_VSIZE) {
|
||||
return std::make_pair(strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, V3_CHILD_MAX_VSIZE),
|
||||
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_CHILD_MAX_VSIZE),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
|
|||
const bool child_will_be_replaced = !children.empty() &&
|
||||
std::any_of(children.cbegin(), children.cend(),
|
||||
[&direct_conflicts](const CTxMemPoolEntry& child){return direct_conflicts.count(child.GetTx().GetHash()) > 0;});
|
||||
if (parent_entry->GetCountWithDescendants() + 1 > V3_DESCENDANT_LIMIT && !child_will_be_replaced) {
|
||||
if (parent_entry->GetCountWithDescendants() + 1 > TRUC_DESCENDANT_LIMIT && !child_will_be_replaced) {
|
||||
// Allow sibling eviction for TRUC transaction: if another child already exists, even if
|
||||
// we don't conflict inputs with it, consider evicting it under RBF rules. We rely on TRUC rules
|
||||
// only permitting 1 descendant, as otherwise we would need to have logic for deciding
|
||||
|
|
|
@ -22,17 +22,17 @@ static constexpr decltype(CTransaction::version) TRUC_VERSION{3};
|
|||
// TRUC only allows 1 parent and 1 child when unconfirmed. This translates to a descendant set size
|
||||
// of 2 and ancestor set size of 2.
|
||||
/** Maximum number of transactions including an unconfirmed tx and its descendants. */
|
||||
static constexpr unsigned int V3_DESCENDANT_LIMIT{2};
|
||||
static constexpr unsigned int TRUC_DESCENDANT_LIMIT{2};
|
||||
/** Maximum number of transactions including a TRUC tx and all its mempool ancestors. */
|
||||
static constexpr unsigned int V3_ANCESTOR_LIMIT{2};
|
||||
static constexpr unsigned int TRUC_ANCESTOR_LIMIT{2};
|
||||
|
||||
/** Maximum sigop-adjusted virtual size of all v3 transactions. */
|
||||
static constexpr int64_t V3_MAX_VSIZE{10000};
|
||||
static constexpr int64_t TRUC_MAX_VSIZE{10000};
|
||||
/** Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction. */
|
||||
static constexpr int64_t V3_CHILD_MAX_VSIZE{1000};
|
||||
static constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000};
|
||||
// These limits are within the default ancestor/descendant limits.
|
||||
static_assert(V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1000);
|
||||
static_assert(V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1000);
|
||||
static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1000);
|
||||
static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1000);
|
||||
|
||||
/** Must be called for every transaction, even if not TRUC. Not strictly necessary for transactions
|
||||
* accepted through AcceptMultipleTransactions.
|
||||
|
@ -40,11 +40,11 @@ static_assert(V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE <= DEFAULT_DESCENDANT_SIZE_LIMIT
|
|||
* Checks the following rules:
|
||||
* 1. A TRUC tx must only have TRUC unconfirmed ancestors.
|
||||
* 2. A non-TRUC tx must only have non-TRUC unconfirmed ancestors.
|
||||
* 3. A TRUC's ancestor set, including itself, must be within V3_ANCESTOR_LIMIT.
|
||||
* 4. A TRUC's descendant set, including itself, must be within V3_DESCENDANT_LIMIT.
|
||||
* 3. A TRUC's ancestor set, including itself, must be within TRUC_ANCESTOR_LIMIT.
|
||||
* 4. A TRUC's descendant set, including itself, must be within TRUC_DESCENDANT_LIMIT.
|
||||
* 5. If a TRUC tx has any unconfirmed ancestors, the tx's sigop-adjusted vsize must be within
|
||||
* V3_CHILD_MAX_VSIZE.
|
||||
* 6. A TRUC tx must be within V3_MAX_VSIZE.
|
||||
* TRUC_CHILD_MAX_VSIZE.
|
||||
* 6. A TRUC tx must be within TRUC_MAX_VSIZE.
|
||||
*
|
||||
*
|
||||
* @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
|
|||
* - debug string + nullptr if this transaction violates some TRUC rule and sibling eviction is not
|
||||
* applicable.
|
||||
*/
|
||||
std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTransactionRef& ptx,
|
||||
std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CTransactionRef& ptx,
|
||||
const CTxMemPool::setEntries& mempool_ancestors,
|
||||
const std::set<Txid>& direct_conflicts,
|
||||
int64_t vsize);
|
||||
|
@ -76,18 +76,18 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTra
|
|||
* and that the transaction itself has no children in the package.
|
||||
*
|
||||
* If any TRUC violations in the package exist, this test will fail for one of them:
|
||||
* - if a TRUC transaction T has a parent in the mempool and a child in the package, then PV3C(T) will fail
|
||||
* - if a TRUC transaction T has a parent in the package and a child in the package, then PV3C(T) will fail
|
||||
* - if a TRUC transaction T has a parent in the mempool and a child in the package, then PTRUCC(T) will fail
|
||||
* - if a TRUC transaction T has a parent in the package and a child in the package, then PTRUCC(T) will fail
|
||||
* - if a TRUC transaction T and a TRUC (sibling) transaction U have some parent in the mempool,
|
||||
* then PV3C(T) and PV3C(U) will fail
|
||||
* then PTRUCC(T) and PTRUCC(U) will fail
|
||||
* - if a TRUC transaction T and a TRUC (sibling) transaction U have some parent in the package,
|
||||
* then PV3C(T) and PV3C(U) will fail
|
||||
* then PTRUCC(T) and PTRUCC(U) will fail
|
||||
* - if a TRUC transaction T has a parent P and a grandparent G in the package, then
|
||||
* PV3C(P) will fail (though PV3C(G) and PV3C(T) might succeed).
|
||||
* PTRUCC(P) will fail (though PTRUCC(G) and PTRUCC(T) might succeed).
|
||||
*
|
||||
* @returns debug string if an error occurs, std::nullopt otherwise.
|
||||
* */
|
||||
std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t vsize,
|
||||
std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t vsize,
|
||||
const Package& package,
|
||||
const CTxMemPool::setEntries& mempool_ancestors);
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
|||
Assert(result_package.m_tx_results.size() == txs.size() || result_package.m_tx_results.empty());
|
||||
}
|
||||
|
||||
CheckMempoolV3Invariants(tx_pool);
|
||||
CheckMempoolTRUCInvariants(tx_pool);
|
||||
}
|
||||
|
||||
node.validation_signals->UnregisterSharedValidationInterface(outpoints_updater);
|
||||
|
|
|
@ -320,7 +320,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
|
|||
if (accepted) {
|
||||
Assert(added.size() == 1); // For now, no package acceptance
|
||||
Assert(tx == *added.begin());
|
||||
CheckMempoolV3Invariants(tx_pool);
|
||||
CheckMempoolTRUCInvariants(tx_pool);
|
||||
} else {
|
||||
// Do not consider rejected transaction removed
|
||||
removed.erase(tx);
|
||||
|
@ -413,7 +413,7 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
|
|||
const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
|
||||
if (accepted) {
|
||||
txids.push_back(tx->GetHash());
|
||||
CheckMempoolV3Invariants(tx_pool);
|
||||
CheckMempoolTRUCInvariants(tx_pool);
|
||||
}
|
||||
}
|
||||
Finish(fuzzed_data_provider, tx_pool, chainstate);
|
||||
|
|
|
@ -115,14 +115,14 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
const auto expected_error_str{strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
|
||||
tx_v2_from_v3->GetHash().ToString(), tx_v2_from_v3->GetWitnessHash().ToString(),
|
||||
mempool_tx_v3->GetHash().ToString(), mempool_tx_v3->GetWitnessHash().ToString())};
|
||||
auto result_v2_from_v3{SingleV3Checks(tx_v2_from_v3, *ancestors_v2_from_v3, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v3))};
|
||||
auto result_v2_from_v3{SingleTRUCChecks(tx_v2_from_v3, *ancestors_v2_from_v3, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v3))};
|
||||
BOOST_CHECK_EQUAL(result_v2_from_v3->first, expected_error_str);
|
||||
BOOST_CHECK_EQUAL(result_v2_from_v3->second, nullptr);
|
||||
|
||||
Package package_v3_v2{mempool_tx_v3, tx_v2_from_v3};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v2_from_v3, GetVirtualTransactionSize(*tx_v2_from_v3), package_v3_v2, empty_ancestors), expected_error_str);
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v2_from_v3, GetVirtualTransactionSize(*tx_v2_from_v3), package_v3_v2, empty_ancestors), expected_error_str);
|
||||
CTxMemPool::setEntries entries_mempool_v3{pool.GetIter(mempool_tx_v3->GetHash().ToUint256()).value()};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v2_from_v3, GetVirtualTransactionSize(*tx_v2_from_v3), {tx_v2_from_v3}, entries_mempool_v3), expected_error_str);
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v2_from_v3, GetVirtualTransactionSize(*tx_v2_from_v3), {tx_v2_from_v3}, entries_mempool_v3), expected_error_str);
|
||||
|
||||
// mempool_tx_v3 mempool_tx_v2
|
||||
// ^ ^
|
||||
|
@ -132,12 +132,12 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
const auto expected_error_str_2{strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
|
||||
tx_v2_from_v2_and_v3->GetHash().ToString(), tx_v2_from_v2_and_v3->GetWitnessHash().ToString(),
|
||||
mempool_tx_v3->GetHash().ToString(), mempool_tx_v3->GetWitnessHash().ToString())};
|
||||
auto result_v2_from_both{SingleV3Checks(tx_v2_from_v2_and_v3, *ancestors_v2_from_both, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v2_and_v3))};
|
||||
auto result_v2_from_both{SingleTRUCChecks(tx_v2_from_v2_and_v3, *ancestors_v2_from_both, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v2_and_v3))};
|
||||
BOOST_CHECK_EQUAL(result_v2_from_both->first, expected_error_str_2);
|
||||
BOOST_CHECK_EQUAL(result_v2_from_both->second, nullptr);
|
||||
|
||||
Package package_v3_v2_v2{mempool_tx_v3, mempool_tx_v2, tx_v2_from_v2_and_v3};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v2_from_v2_and_v3, GetVirtualTransactionSize(*tx_v2_from_v2_and_v3), package_v3_v2_v2, empty_ancestors), expected_error_str_2);
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v2_from_v2_and_v3, GetVirtualTransactionSize(*tx_v2_from_v2_and_v3), package_v3_v2_v2, empty_ancestors), expected_error_str_2);
|
||||
}
|
||||
|
||||
// TRUC cannot spend from an unconfirmed non-TRUC transaction.
|
||||
|
@ -150,14 +150,14 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
const auto expected_error_str{strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
|
||||
tx_v3_from_v2->GetHash().ToString(), tx_v3_from_v2->GetWitnessHash().ToString(),
|
||||
mempool_tx_v2->GetHash().ToString(), mempool_tx_v2->GetWitnessHash().ToString())};
|
||||
auto result_v3_from_v2{SingleV3Checks(tx_v3_from_v2, *ancestors_v3_from_v2, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v2))};
|
||||
auto result_v3_from_v2{SingleTRUCChecks(tx_v3_from_v2, *ancestors_v3_from_v2, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v2))};
|
||||
BOOST_CHECK_EQUAL(result_v3_from_v2->first, expected_error_str);
|
||||
BOOST_CHECK_EQUAL(result_v3_from_v2->second, nullptr);
|
||||
|
||||
Package package_v2_v3{mempool_tx_v2, tx_v3_from_v2};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v3_from_v2, GetVirtualTransactionSize(*tx_v3_from_v2), package_v2_v3, empty_ancestors), expected_error_str);
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_from_v2, GetVirtualTransactionSize(*tx_v3_from_v2), package_v2_v3, empty_ancestors), expected_error_str);
|
||||
CTxMemPool::setEntries entries_mempool_v2{pool.GetIter(mempool_tx_v2->GetHash().ToUint256()).value()};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v3_from_v2, GetVirtualTransactionSize(*tx_v3_from_v2), {tx_v3_from_v2}, entries_mempool_v2), expected_error_str);
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_from_v2, GetVirtualTransactionSize(*tx_v3_from_v2), {tx_v3_from_v2}, entries_mempool_v2), expected_error_str);
|
||||
|
||||
// mempool_tx_v3 mempool_tx_v2
|
||||
// ^ ^
|
||||
|
@ -167,15 +167,15 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
const auto expected_error_str_2{strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
|
||||
tx_v3_from_v2_and_v3->GetHash().ToString(), tx_v3_from_v2_and_v3->GetWitnessHash().ToString(),
|
||||
mempool_tx_v2->GetHash().ToString(), mempool_tx_v2->GetWitnessHash().ToString())};
|
||||
auto result_v3_from_both{SingleV3Checks(tx_v3_from_v2_and_v3, *ancestors_v3_from_both, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v2_and_v3))};
|
||||
auto result_v3_from_both{SingleTRUCChecks(tx_v3_from_v2_and_v3, *ancestors_v3_from_both, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v2_and_v3))};
|
||||
BOOST_CHECK_EQUAL(result_v3_from_both->first, expected_error_str_2);
|
||||
BOOST_CHECK_EQUAL(result_v3_from_both->second, nullptr);
|
||||
|
||||
// tx_v3_from_v2_and_v3 also violates V3_ANCESTOR_LIMIT.
|
||||
// tx_v3_from_v2_and_v3 also violates TRUC_ANCESTOR_LIMIT.
|
||||
const auto expected_error_str_3{strprintf("tx %s (wtxid=%s) would have too many ancestors",
|
||||
tx_v3_from_v2_and_v3->GetHash().ToString(), tx_v3_from_v2_and_v3->GetWitnessHash().ToString())};
|
||||
Package package_v3_v2_v3{mempool_tx_v3, mempool_tx_v2, tx_v3_from_v2_and_v3};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v3_from_v2_and_v3, GetVirtualTransactionSize(*tx_v3_from_v2_and_v3), package_v3_v2_v3, empty_ancestors), expected_error_str_3);
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_from_v2_and_v3, GetVirtualTransactionSize(*tx_v3_from_v2_and_v3), package_v3_v2_v3, empty_ancestors), expected_error_str_3);
|
||||
}
|
||||
// V3 from V3 is ok, and non-V3 from non-V3 is ok.
|
||||
{
|
||||
|
@ -184,22 +184,22 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
// tx_v3_from_v3
|
||||
auto tx_v3_from_v3 = make_tx({COutPoint{mempool_tx_v3->GetHash(), 0}}, /*version=*/3);
|
||||
auto ancestors_v3{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_from_v3), m_limits)};
|
||||
BOOST_CHECK(SingleV3Checks(tx_v3_from_v3, *ancestors_v3, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v3))
|
||||
BOOST_CHECK(SingleTRUCChecks(tx_v3_from_v3, *ancestors_v3, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v3))
|
||||
== std::nullopt);
|
||||
|
||||
Package package_v3_v3{mempool_tx_v3, tx_v3_from_v3};
|
||||
BOOST_CHECK(PackageV3Checks(tx_v3_from_v3, GetVirtualTransactionSize(*tx_v3_from_v3), package_v3_v3, empty_ancestors) == std::nullopt);
|
||||
BOOST_CHECK(PackageTRUCChecks(tx_v3_from_v3, GetVirtualTransactionSize(*tx_v3_from_v3), package_v3_v3, empty_ancestors) == std::nullopt);
|
||||
|
||||
// mempool_tx_v2
|
||||
// ^
|
||||
// tx_v2_from_v2
|
||||
auto tx_v2_from_v2 = make_tx({COutPoint{mempool_tx_v2->GetHash(), 0}}, /*version=*/2);
|
||||
auto ancestors_v2{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v2_from_v2), m_limits)};
|
||||
BOOST_CHECK(SingleV3Checks(tx_v2_from_v2, *ancestors_v2, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v2))
|
||||
BOOST_CHECK(SingleTRUCChecks(tx_v2_from_v2, *ancestors_v2, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v2))
|
||||
== std::nullopt);
|
||||
|
||||
Package package_v2_v2{mempool_tx_v2, tx_v2_from_v2};
|
||||
BOOST_CHECK(PackageV3Checks(tx_v2_from_v2, GetVirtualTransactionSize(*tx_v2_from_v2), package_v2_v2, empty_ancestors) == std::nullopt);
|
||||
BOOST_CHECK(PackageTRUCChecks(tx_v2_from_v2, GetVirtualTransactionSize(*tx_v2_from_v2), package_v2_v2, empty_ancestors) == std::nullopt);
|
||||
}
|
||||
|
||||
// Tx spending TRUC cannot have too many mempool ancestors
|
||||
|
@ -221,11 +221,11 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
BOOST_CHECK_EQUAL(ancestors->size(), 3);
|
||||
const auto expected_error_str{strprintf("tx %s (wtxid=%s) would have too many ancestors",
|
||||
tx_v3_multi_parent->GetHash().ToString(), tx_v3_multi_parent->GetWitnessHash().ToString())};
|
||||
auto result{SingleV3Checks(tx_v3_multi_parent, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_multi_parent))};
|
||||
auto result{SingleTRUCChecks(tx_v3_multi_parent, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_multi_parent))};
|
||||
BOOST_CHECK_EQUAL(result->first, expected_error_str);
|
||||
BOOST_CHECK_EQUAL(result->second, nullptr);
|
||||
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v3_multi_parent, GetVirtualTransactionSize(*tx_v3_multi_parent), package_multi_parents, empty_ancestors),
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_multi_parent, GetVirtualTransactionSize(*tx_v3_multi_parent), package_multi_parents, empty_ancestors),
|
||||
expected_error_str);
|
||||
}
|
||||
|
||||
|
@ -246,13 +246,13 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
auto ancestors{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_multi_gen), m_limits)};
|
||||
const auto expected_error_str{strprintf("tx %s (wtxid=%s) would have too many ancestors",
|
||||
tx_v3_multi_gen->GetHash().ToString(), tx_v3_multi_gen->GetWitnessHash().ToString())};
|
||||
auto result{SingleV3Checks(tx_v3_multi_gen, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_multi_gen))};
|
||||
auto result{SingleTRUCChecks(tx_v3_multi_gen, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_multi_gen))};
|
||||
BOOST_CHECK_EQUAL(result->first, expected_error_str);
|
||||
BOOST_CHECK_EQUAL(result->second, nullptr);
|
||||
|
||||
// Middle tx is what triggers a failure for the grandchild:
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(middle_tx, GetVirtualTransactionSize(*middle_tx), package_multi_gen, empty_ancestors), expected_error_str);
|
||||
BOOST_CHECK(PackageV3Checks(tx_v3_multi_gen, GetVirtualTransactionSize(*tx_v3_multi_gen), package_multi_gen, empty_ancestors) == std::nullopt);
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(middle_tx, GetVirtualTransactionSize(*middle_tx), package_multi_gen, empty_ancestors), expected_error_str);
|
||||
BOOST_CHECK(PackageTRUCChecks(tx_v3_multi_gen, GetVirtualTransactionSize(*tx_v3_multi_gen), package_multi_gen, empty_ancestors) == std::nullopt);
|
||||
}
|
||||
|
||||
// Tx spending TRUC cannot be too large in virtual size.
|
||||
|
@ -263,13 +263,13 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
const auto vsize{GetVirtualTransactionSize(*tx_v3_child_big)};
|
||||
auto ancestors{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_child_big), m_limits)};
|
||||
const auto expected_error_str{strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
|
||||
tx_v3_child_big->GetHash().ToString(), tx_v3_child_big->GetWitnessHash().ToString(), vsize, V3_CHILD_MAX_VSIZE)};
|
||||
auto result{SingleV3Checks(tx_v3_child_big, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_child_big))};
|
||||
tx_v3_child_big->GetHash().ToString(), tx_v3_child_big->GetWitnessHash().ToString(), vsize, TRUC_CHILD_MAX_VSIZE)};
|
||||
auto result{SingleTRUCChecks(tx_v3_child_big, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_child_big))};
|
||||
BOOST_CHECK_EQUAL(result->first, expected_error_str);
|
||||
BOOST_CHECK_EQUAL(result->second, nullptr);
|
||||
|
||||
Package package_child_big{mempool_tx_v3, tx_v3_child_big};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v3_child_big, GetVirtualTransactionSize(*tx_v3_child_big), package_child_big, empty_ancestors),
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_child_big, GetVirtualTransactionSize(*tx_v3_child_big), package_child_big, empty_ancestors),
|
||||
expected_error_str);
|
||||
}
|
||||
|
||||
|
@ -302,31 +302,31 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
BOOST_CHECK_EQUAL(total_sigops, tx_many_sigops->vin.size() * MAX_PUBKEYS_PER_MULTISIG);
|
||||
const int64_t bip141_vsize{GetVirtualTransactionSize(*tx_many_sigops)};
|
||||
// Weight limit is not reached...
|
||||
BOOST_CHECK(SingleV3Checks(tx_many_sigops, *ancestors, empty_conflicts_set, bip141_vsize) == std::nullopt);
|
||||
BOOST_CHECK(SingleTRUCChecks(tx_many_sigops, *ancestors, empty_conflicts_set, bip141_vsize) == std::nullopt);
|
||||
// ...but sigop limit is.
|
||||
const auto expected_error_str{strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
|
||||
tx_many_sigops->GetHash().ToString(), tx_many_sigops->GetWitnessHash().ToString(),
|
||||
total_sigops * DEFAULT_BYTES_PER_SIGOP / WITNESS_SCALE_FACTOR, V3_CHILD_MAX_VSIZE)};
|
||||
auto result{SingleV3Checks(tx_many_sigops, *ancestors, empty_conflicts_set,
|
||||
total_sigops * DEFAULT_BYTES_PER_SIGOP / WITNESS_SCALE_FACTOR, TRUC_CHILD_MAX_VSIZE)};
|
||||
auto result{SingleTRUCChecks(tx_many_sigops, *ancestors, empty_conflicts_set,
|
||||
GetVirtualTransactionSize(*tx_many_sigops, /*nSigOpCost=*/total_sigops, /*bytes_per_sigop=*/ DEFAULT_BYTES_PER_SIGOP))};
|
||||
BOOST_CHECK_EQUAL(result->first, expected_error_str);
|
||||
BOOST_CHECK_EQUAL(result->second, nullptr);
|
||||
|
||||
Package package_child_sigops{mempool_tx_v3, tx_many_sigops};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_many_sigops, total_sigops * DEFAULT_BYTES_PER_SIGOP / WITNESS_SCALE_FACTOR, package_child_sigops, empty_ancestors),
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_many_sigops, total_sigops * DEFAULT_BYTES_PER_SIGOP / WITNESS_SCALE_FACTOR, package_child_sigops, empty_ancestors),
|
||||
expected_error_str);
|
||||
}
|
||||
|
||||
// Parent + child with TRUC in the mempool. Child is allowed as long as it is under V3_CHILD_MAX_VSIZE.
|
||||
// Parent + child with TRUC in the mempool. Child is allowed as long as it is under TRUC_CHILD_MAX_VSIZE.
|
||||
auto tx_mempool_v3_child = make_tx({COutPoint{mempool_tx_v3->GetHash(), 0}}, /*version=*/3);
|
||||
{
|
||||
BOOST_CHECK(GetTransactionWeight(*tx_mempool_v3_child) <= V3_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR);
|
||||
BOOST_CHECK(GetTransactionWeight(*tx_mempool_v3_child) <= TRUC_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR);
|
||||
auto ancestors{pool.CalculateMemPoolAncestors(entry.FromTx(tx_mempool_v3_child), m_limits)};
|
||||
BOOST_CHECK(SingleV3Checks(tx_mempool_v3_child, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_mempool_v3_child)) == std::nullopt);
|
||||
BOOST_CHECK(SingleTRUCChecks(tx_mempool_v3_child, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_mempool_v3_child)) == std::nullopt);
|
||||
pool.addUnchecked(entry.FromTx(tx_mempool_v3_child));
|
||||
|
||||
Package package_v3_1p1c{mempool_tx_v3, tx_mempool_v3_child};
|
||||
BOOST_CHECK(PackageV3Checks(tx_mempool_v3_child, GetVirtualTransactionSize(*tx_mempool_v3_child), package_v3_1p1c, empty_ancestors) == std::nullopt);
|
||||
BOOST_CHECK(PackageTRUCChecks(tx_mempool_v3_child, GetVirtualTransactionSize(*tx_mempool_v3_child), package_v3_1p1c, empty_ancestors) == std::nullopt);
|
||||
}
|
||||
|
||||
// A TRUC transaction cannot have more than 1 descendant. Sibling is returned when exactly 1 exists.
|
||||
|
@ -337,17 +337,17 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
auto ancestors_1sibling{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_child2), m_limits)};
|
||||
const auto expected_error_str{strprintf("tx %s (wtxid=%s) would exceed descendant count limit",
|
||||
mempool_tx_v3->GetHash().ToString(), mempool_tx_v3->GetWitnessHash().ToString())};
|
||||
auto result_with_sibling_eviction{SingleV3Checks(tx_v3_child2, *ancestors_1sibling, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_child2))};
|
||||
auto result_with_sibling_eviction{SingleTRUCChecks(tx_v3_child2, *ancestors_1sibling, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_child2))};
|
||||
BOOST_CHECK_EQUAL(result_with_sibling_eviction->first, expected_error_str);
|
||||
// The other mempool child is returned to allow for sibling eviction.
|
||||
BOOST_CHECK_EQUAL(result_with_sibling_eviction->second, tx_mempool_v3_child);
|
||||
|
||||
// If directly replacing the child, make sure there is no double-counting.
|
||||
BOOST_CHECK(SingleV3Checks(tx_v3_child2, *ancestors_1sibling, {tx_mempool_v3_child->GetHash()}, GetVirtualTransactionSize(*tx_v3_child2))
|
||||
BOOST_CHECK(SingleTRUCChecks(tx_v3_child2, *ancestors_1sibling, {tx_mempool_v3_child->GetHash()}, GetVirtualTransactionSize(*tx_v3_child2))
|
||||
== std::nullopt);
|
||||
|
||||
Package package_v3_1p2c{mempool_tx_v3, tx_mempool_v3_child, tx_v3_child2};
|
||||
BOOST_CHECK_EQUAL(*PackageV3Checks(tx_v3_child2, GetVirtualTransactionSize(*tx_v3_child2), package_v3_1p2c, empty_ancestors),
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_child2, GetVirtualTransactionSize(*tx_v3_child2), package_v3_1p2c, empty_ancestors),
|
||||
expected_error_str);
|
||||
|
||||
// Configuration where parent already has 2 other children in mempool (no sibling eviction allowed). This may happen as the result of a reorg.
|
||||
|
@ -357,7 +357,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
BOOST_CHECK_EQUAL(entry_mempool_parent->GetCountWithDescendants(), 3);
|
||||
auto ancestors_2siblings{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_child3), m_limits)};
|
||||
|
||||
auto result_2children{SingleV3Checks(tx_v3_child3, *ancestors_2siblings, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_child3))};
|
||||
auto result_2children{SingleTRUCChecks(tx_v3_child3, *ancestors_2siblings, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_child3))};
|
||||
BOOST_CHECK_EQUAL(result_2children->first, expected_error_str);
|
||||
// The other mempool child is not returned because sibling eviction is not allowed.
|
||||
BOOST_CHECK_EQUAL(result_2children->second, nullptr);
|
||||
|
@ -377,7 +377,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
auto ancestors_3gen{pool.CalculateMemPoolAncestors(entry.FromTx(tx_to_submit), m_limits)};
|
||||
const auto expected_error_str{strprintf("tx %s (wtxid=%s) would exceed descendant count limit",
|
||||
tx_mempool_grandparent->GetHash().ToString(), tx_mempool_grandparent->GetWitnessHash().ToString())};
|
||||
auto result_3gen{SingleV3Checks(tx_to_submit, *ancestors_3gen, empty_conflicts_set, GetVirtualTransactionSize(*tx_to_submit))};
|
||||
auto result_3gen{SingleTRUCChecks(tx_to_submit, *ancestors_3gen, empty_conflicts_set, GetVirtualTransactionSize(*tx_to_submit))};
|
||||
BOOST_CHECK_EQUAL(result_3gen->first, expected_error_str);
|
||||
// The other mempool child is not returned because sibling eviction is not allowed.
|
||||
BOOST_CHECK_EQUAL(result_3gen->second, nullptr);
|
||||
|
|
|
@ -141,24 +141,24 @@ std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
void CheckMempoolV3Invariants(const CTxMemPool& tx_pool)
|
||||
void CheckMempoolTRUCInvariants(const CTxMemPool& tx_pool)
|
||||
{
|
||||
LOCK(tx_pool.cs);
|
||||
for (const auto& tx_info : tx_pool.infoAll()) {
|
||||
const auto& entry = *Assert(tx_pool.GetEntry(tx_info.tx->GetHash()));
|
||||
if (tx_info.tx->version == TRUC_VERSION) {
|
||||
// Check that special maximum virtual size is respected
|
||||
Assert(entry.GetTxSize() <= V3_MAX_VSIZE);
|
||||
Assert(entry.GetTxSize() <= TRUC_MAX_VSIZE);
|
||||
|
||||
// Check that special TRUC ancestor/descendant limits and rules are always respected
|
||||
Assert(entry.GetCountWithDescendants() <= V3_DESCENDANT_LIMIT);
|
||||
Assert(entry.GetCountWithAncestors() <= V3_ANCESTOR_LIMIT);
|
||||
Assert(entry.GetSizeWithDescendants() <= V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE);
|
||||
Assert(entry.GetSizeWithAncestors() <= V3_MAX_VSIZE + V3_CHILD_MAX_VSIZE);
|
||||
Assert(entry.GetCountWithDescendants() <= TRUC_DESCENDANT_LIMIT);
|
||||
Assert(entry.GetCountWithAncestors() <= TRUC_ANCESTOR_LIMIT);
|
||||
Assert(entry.GetSizeWithDescendants() <= TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE);
|
||||
Assert(entry.GetSizeWithAncestors() <= TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE);
|
||||
|
||||
// If this transaction has at least 1 ancestor, it's a "child" and has restricted weight.
|
||||
if (entry.GetCountWithAncestors() > 1) {
|
||||
Assert(entry.GetTxSize() <= V3_CHILD_MAX_VSIZE);
|
||||
Assert(entry.GetTxSize() <= TRUC_CHILD_MAX_VSIZE);
|
||||
// All TRUC transactions must only have TRUC unconfirmed parents.
|
||||
const auto& parents = entry.GetMemPoolParentsConst();
|
||||
Assert(parents.begin()->get().GetSharedTx()->version == TRUC_VERSION);
|
||||
|
|
|
@ -48,12 +48,12 @@ std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
|
|||
const CTxMemPool* mempool);
|
||||
|
||||
/** For every transaction in tx_pool, check TRUC invariants:
|
||||
* - a TRUC tx's ancestor count must be within V3_ANCESTOR_LIMIT
|
||||
* - a TRUC tx's descendant count must be within V3_DESCENDANT_LIMIT
|
||||
* - if a TRUC tx has ancestors, its sigop-adjusted vsize must be within V3_CHILD_MAX_VSIZE
|
||||
* - a TRUC tx's ancestor count must be within TRUC_ANCESTOR_LIMIT
|
||||
* - a TRUC tx's descendant count must be within TRUC_DESCENDANT_LIMIT
|
||||
* - if a TRUC tx has ancestors, its sigop-adjusted vsize must be within TRUC_CHILD_MAX_VSIZE
|
||||
* - any non-TRUC tx must only have non-TRUC parents
|
||||
* - any TRUC tx must only have TRUC parents
|
||||
* */
|
||||
void CheckMempoolV3Invariants(const CTxMemPool& tx_pool);
|
||||
void CheckMempoolTRUCInvariants(const CTxMemPool& tx_pool);
|
||||
|
||||
#endif // BITCOIN_TEST_UTIL_TXMEMPOOL_H
|
||||
|
|
|
@ -1032,7 +1032,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
// Even though just checking direct mempool parents for inheritance would be sufficient, we
|
||||
// check using the full ancestor set here because it's more convenient to use what we have
|
||||
// already calculated.
|
||||
if (const auto err{SingleV3Checks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) {
|
||||
if (const auto err{SingleTRUCChecks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) {
|
||||
// Single transaction contexts only.
|
||||
if (args.m_allow_sibling_eviction && err->second != nullptr) {
|
||||
// We should only be considering where replacement is considered valid as well.
|
||||
|
@ -1043,7 +1043,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
|||
ws.m_conflicts.insert(err->second->GetHash());
|
||||
// Adding the sibling to m_iters_conflicting here means that it doesn't count towards
|
||||
// RBF Carve Out above. This is correct, since removing to-be-replaced transactions from
|
||||
// the descendant count is done separately in SingleV3Checks for TRUC transactions.
|
||||
// the descendant count is done separately in SingleTRUCChecks for TRUC transactions.
|
||||
ws.m_iters_conflicting.insert(m_pool.GetIter(err->second->GetHash()).value());
|
||||
ws.m_sibling_eviction = true;
|
||||
// The sibling will be treated as part of the to-be-replaced set in ReplacementChecks.
|
||||
|
@ -1547,7 +1547,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
|||
// At this point we have all in-mempool ancestors, and we know every transaction's vsize.
|
||||
// Run the TRUC checks on the package.
|
||||
for (Workspace& ws : workspaces) {
|
||||
if (auto err{PackageV3Checks(ws.m_ptx, ws.m_vsize, txns, ws.m_ancestors)}) {
|
||||
if (auto err{PackageTRUCChecks(ws.m_ptx, ws.m_vsize, txns, ws.m_ancestors)}) {
|
||||
package_state.Invalid(PackageValidationResult::PCKG_POLICY, "TRUC-violation", err.value());
|
||||
return PackageMempoolAcceptResult(package_state, {});
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ from test_framework.wallet import (
|
|||
)
|
||||
|
||||
MAX_REPLACEMENT_CANDIDATES = 100
|
||||
V3_MAX_VSIZE = 10000
|
||||
TRUC_MAX_VSIZE = 10000
|
||||
|
||||
def cleanup(extra_args=None):
|
||||
def decorator(func):
|
||||
|
@ -55,14 +55,14 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
def test_truc_max_vsize(self):
|
||||
node = self.nodes[0]
|
||||
self.log.info("Test TRUC-specific maximum transaction vsize")
|
||||
tx_v3_heavy = self.wallet.create_self_transfer(target_weight=(V3_MAX_VSIZE + 1) * WITNESS_SCALE_FACTOR, version=3)
|
||||
assert_greater_than_or_equal(tx_v3_heavy["tx"].get_vsize(), V3_MAX_VSIZE)
|
||||
tx_v3_heavy = self.wallet.create_self_transfer(target_weight=(TRUC_MAX_VSIZE + 1) * WITNESS_SCALE_FACTOR, version=3)
|
||||
assert_greater_than_or_equal(tx_v3_heavy["tx"].get_vsize(), TRUC_MAX_VSIZE)
|
||||
expected_error_heavy = f"TRUC-violation, v3 tx {tx_v3_heavy['txid']} (wtxid={tx_v3_heavy['wtxid']}) is too big"
|
||||
assert_raises_rpc_error(-26, expected_error_heavy, node.sendrawtransaction, tx_v3_heavy["hex"])
|
||||
self.check_mempool([])
|
||||
|
||||
# Ensure we are hitting the TRUC-specific limit and not something else
|
||||
tx_v2_heavy = self.wallet.send_self_transfer(from_node=node, target_weight=(V3_MAX_VSIZE + 1) * WITNESS_SCALE_FACTOR, version=2)
|
||||
tx_v2_heavy = self.wallet.send_self_transfer(from_node=node, target_weight=(TRUC_MAX_VSIZE + 1) * WITNESS_SCALE_FACTOR, version=2)
|
||||
self.check_mempool([tx_v2_heavy["txid"]])
|
||||
|
||||
@cleanup(extra_args=["-datacarriersize=1000"])
|
||||
|
@ -231,7 +231,7 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
)
|
||||
|
||||
# Parent and child are within v3 limits, but parent's 10kvB descendant limit is exceeded
|
||||
assert_greater_than_or_equal(V3_MAX_VSIZE, tx_v3_parent_large1["tx"].get_vsize())
|
||||
assert_greater_than_or_equal(TRUC_MAX_VSIZE, tx_v3_parent_large1["tx"].get_vsize())
|
||||
assert_greater_than_or_equal(1000, tx_v3_child_large1["tx"].get_vsize())
|
||||
assert_greater_than(tx_v3_parent_large1["tx"].get_vsize() + tx_v3_child_large1["tx"].get_vsize(), 10000)
|
||||
|
||||
|
@ -254,7 +254,7 @@ class MempoolTRUC(BitcoinTestFramework):
|
|||
)
|
||||
|
||||
# Parent and child are within TRUC limits
|
||||
assert_greater_than_or_equal(V3_MAX_VSIZE, tx_v3_parent_large2["tx"].get_vsize())
|
||||
assert_greater_than_or_equal(TRUC_MAX_VSIZE, tx_v3_parent_large2["tx"].get_vsize())
|
||||
assert_greater_than_or_equal(1000, tx_v3_child_large2["tx"].get_vsize())
|
||||
assert_greater_than(tx_v3_parent_large2["tx"].get_vsize() + tx_v3_child_large2["tx"].get_vsize(), 10000)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue