diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -778,11 +778,7 @@ } CTxMemPool::setEntries setAncestors; - uint64_t noLimit = std::numeric_limits::max(); - std::string dummy; - mempool.CalculateMemPoolAncestors(*it, setAncestors, noLimit, - noLimit, noLimit, noLimit, dummy, - false); + mempool.CalculateMemPoolAncestors(*it, setAncestors, false); if (!fVerbose) { UniValue o(UniValue::VARR); diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -458,20 +458,12 @@ /** * Helper function to calculate all in-mempool ancestors of staged_ancestors - * and apply ancestor and descendant limits (including staged_ancestors - * themselves, entry_size and entry_count). - * param@[in] entry_size Virtual size to include in the limits. - * param@[in] entry_count How many entries to include in the - * limits. * param@[in] staged_ancestors Should contain entries in the mempool. * param@[out] setAncestors Will be populated with all mempool * ancestors. */ - bool CalculateAncestorsAndCheckLimits( - size_t entry_size, size_t entry_count, setEntries &setAncestors, - CTxMemPoolEntry::Parents &staged_ancestors, uint64_t limitAncestorCount, - uint64_t limitAncestorSize, uint64_t limitDescendantCount, - uint64_t limitDescendantSize, std::string &errString) const + bool CalculateAncestors(setEntries &setAncestors, + CTxMemPoolEntry::Parents &staged_ancestors) const EXCLUSIVE_LOCKS_REQUIRED(cs); public: @@ -570,20 +562,13 @@ /** * Try to calculate all in-mempool ancestors of entry. * (these are all calculated including the tx itself) - * limitAncestorCount = max number of ancestors - * limitAncestorSize = max size of ancestors - * limitDescendantCount = max number of descendants any ancestor can have - * limitDescendantSize = max size of descendants any ancestor can have - * errString = populated with error reason if any limits are hit * fSearchForParents = whether to search a tx's vin for in-mempool parents, * or look up parents from m_parents. Must be true for entries not in the * mempool */ - bool CalculateMemPoolAncestors( - const CTxMemPoolEntry &entry, setEntries &setAncestors, - uint64_t limitAncestorCount, uint64_t limitAncestorSize, - uint64_t limitDescendantCount, uint64_t limitDescendantSize, - std::string &errString, bool fSearchForParents = true) const + bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, + setEntries &setAncestors, + bool fSearchForParents = true) const EXCLUSIVE_LOCKS_REQUIRED(cs); /** diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -30,10 +30,6 @@ #include #include -/// Used in various places in this file to signify "no limit" for -/// CalculateMemPoolAncestors -inline constexpr uint64_t nNoLimit = std::numeric_limits::max(); - // Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index. // Remove after Wellington struct update_descendant_state { @@ -133,42 +129,15 @@ lockPoints = lp; } -bool CTxMemPool::CalculateAncestorsAndCheckLimits( - size_t entry_size, size_t entry_count, setEntries &setAncestors, - CTxMemPoolEntry::Parents &staged_ancestors, uint64_t limitAncestorCount, - uint64_t limitAncestorSize, uint64_t limitDescendantCount, - uint64_t limitDescendantSize, std::string &errString) const { - size_t totalSizeWithAncestors = entry_size; - +bool CTxMemPool::CalculateAncestors( + setEntries &setAncestors, + CTxMemPoolEntry::Parents &staged_ancestors) const { while (!staged_ancestors.empty()) { const CTxMemPoolEntry &stage = staged_ancestors.begin()->get(); txiter stageit = mapTx.iterator_to(stage); setAncestors.insert(stageit); staged_ancestors.erase(staged_ancestors.begin()); - totalSizeWithAncestors += stageit->GetTxSize(); - - if (stageit->GetSizeWithDescendants() + entry_size > - limitDescendantSize) { - errString = strprintf( - "exceeds descendant size limit for tx %s [limit: %u]", - stageit->GetTx().GetId().ToString(), limitDescendantSize); - return false; - } - - if (stageit->GetCountWithDescendants() + entry_count > - limitDescendantCount) { - errString = strprintf("too many descendants for tx %s [limit: %u]", - stageit->GetTx().GetId().ToString(), - limitDescendantCount); - return false; - } - - if (totalSizeWithAncestors > limitAncestorSize) { - errString = strprintf("exceeds ancestor size limit [limit: %u]", - limitAncestorSize); - return false; - } const CTxMemPoolEntry::Parents &parents = stageit->GetMemPoolParentsConst(); @@ -179,13 +148,6 @@ if (setAncestors.count(parent_it) == 0) { staged_ancestors.insert(parent); } - if (staged_ancestors.size() + setAncestors.size() + entry_count > - limitAncestorCount) { - errString = - strprintf("too many unconfirmed ancestors [limit: %u]", - limitAncestorCount); - return false; - } } } @@ -194,9 +156,7 @@ bool CTxMemPool::CalculateMemPoolAncestors( const CTxMemPoolEntry &entry, setEntries &setAncestors, - uint64_t limitAncestorCount, uint64_t limitAncestorSize, - uint64_t limitDescendantCount, uint64_t limitDescendantSize, - std::string &errString, bool fSearchForParents /* = true */) const { + bool fSearchForParents /* = true */) const { CTxMemPoolEntry::Parents staged_ancestors; const CTransaction &tx = entry.GetTx(); @@ -210,12 +170,6 @@ continue; } staged_ancestors.insert(**piter); - if (staged_ancestors.size() + 1 > limitAncestorCount) { - errString = - strprintf("too many unconfirmed parents [limit: %u]", - limitAncestorCount); - return false; - } } } else { // If we're not searching for parents, we require this to be an entry in @@ -223,10 +177,7 @@ staged_ancestors = entry.GetMemPoolParentsConst(); } - return CalculateAncestorsAndCheckLimits( - entry.GetTxSize(), /* entry_count */ 1, setAncestors, staged_ancestors, - limitAncestorCount, limitAncestorSize, limitDescendantCount, - limitDescendantSize, errString); + return CalculateAncestors(setAncestors, staged_ancestors); } void CTxMemPool::UpdateParentsOf(bool add, txiter it) { @@ -586,8 +537,7 @@ setEntries setAncestors; std::string dummy; - const bool ok = CalculateMemPoolAncestors( - entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy); + const bool ok = CalculateMemPoolAncestors(entry, setAncestors); assert(ok); // all ancestors should have entryId < this tx's entryId diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -297,11 +297,7 @@ MemPoolAccept(CTxMemPool &mempool, Chainstate &active_chainstate) : m_pool(mempool), m_view(&m_dummy), m_viewmempool(&active_chainstate.CoinsTip(), m_pool), - m_active_chainstate(active_chainstate), - m_limit_ancestors(DEFAULT_ANCESTOR_LIMIT), - m_limit_ancestor_size(DEFAULT_ANCESTOR_SIZE_LIMIT * 1000), - m_limit_descendants(DEFAULT_DESCENDANT_LIMIT), - m_limit_descendant_size(DEFAULT_DESCENDANT_SIZE_LIMIT * 1000) {} + m_active_chainstate(active_chainstate) {} // We put the arguments we're handed into a struct, so we can pass them // around easier. @@ -488,14 +484,6 @@ CCoinsView m_dummy; Chainstate &m_active_chainstate; - - // The package limits in effect at the time of invocation. - const size_t m_limit_ancestors; - const size_t m_limit_ancestor_size; - // These may be modified while evaluating a transaction (eg to account for - // in-mempool conflicts; see below). - size_t m_limit_descendants; - size_t m_limit_descendant_size; }; bool MemPoolAccept::PreChecks(ATMPArgs &args, Workspace &ws) { @@ -799,10 +787,7 @@ // changed since the last calculation done in PreChecks, since package // ancestors have already been submitted. std::string unused_err_string; - if (!m_pool.CalculateMemPoolAncestors( - *ws.m_entry, ws.m_ancestors, m_limit_ancestors, - m_limit_ancestor_size, m_limit_descendants, - m_limit_descendant_size, unused_err_string)) { + if (!m_pool.CalculateMemPoolAncestors(*ws.m_entry, ws.m_ancestors)) { results.emplace(ws.m_ptx->GetId(), MempoolAcceptResult::Failure(ws.m_state)); all_submitted = Assume(false);