Require mempool lock to be held when invoking TRUC checks

This commit is contained in:
Suhas Daftuar
2025-11-25 13:03:46 -05:00
parent 957ae23241
commit bc2eb931da
2 changed files with 4 additions and 3 deletions

View File

@@ -59,6 +59,7 @@ std::optional<std::string> PackageTRUCChecks(const CTxMemPool& pool, const CTran
const Package& package,
const std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef>& mempool_parents)
{
AssertLockHeld(pool.cs);
// This function is specialized for these limits, and must be reimplemented if they ever change.
static_assert(TRUC_ANCESTOR_LIMIT == 2);
static_assert(TRUC_DESCENDANT_LIMIT == 2);
@@ -173,7 +174,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
const std::set<Txid>& direct_conflicts,
int64_t vsize)
{
LOCK(pool.cs);
AssertLockHeld(pool.cs);
// Check TRUC and non-TRUC inheritance.
for (const auto& entry_ref : mempool_parents) {
const auto& entry = &entry_ref.get();

View File

@@ -66,7 +66,7 @@ static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_CLUSTER_SIZE_LIMI
std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CTxMemPool& pool, const CTransactionRef& ptx,
const std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef>& mempool_parents,
const std::set<Txid>& direct_conflicts,
int64_t vsize);
int64_t vsize) EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
/** Must be called for every transaction that is submitted within a package, even if not TRUC.
*
@@ -91,6 +91,6 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
* */
std::optional<std::string> PackageTRUCChecks(const CTxMemPool& pool, const CTransactionRef& ptx, int64_t vsize,
const Package& package,
const std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef>& mempool_parents);
const std::vector<CTxMemPoolEntry::CTxMemPoolEntryRef>& mempool_parents) EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
#endif // BITCOIN_POLICY_TRUC_POLICY_H