From 1a579f9d01256b0b2570168496d129a8b2009b35 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Mon, 11 Sep 2023 09:55:39 -0400 Subject: [PATCH] Handle over-sized (in virtual bytes) packages with no in-mempool ancestors --- src/txmempool.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 960be428c65..e021cfb06e3 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -200,6 +200,23 @@ bool CTxMemPool::CheckPackageLimits(const Package& package, const int64_t total_vsize, std::string &errString) const { + size_t pack_count = package.size(); + + // Package itself is busting mempool limits; should be rejected even if no staged_ancestors exist + if (pack_count > static_cast(m_limits.ancestor_count)) { + errString = strprintf("package count %u exceeds ancestor count limit [limit: %u]", pack_count, m_limits.ancestor_count); + return false; + } else if (pack_count > static_cast(m_limits.descendant_count)) { + errString = strprintf("package count %u exceeds descendant count limit [limit: %u]", pack_count, m_limits.descendant_count); + return false; + } else if (total_vsize > m_limits.ancestor_size_vbytes) { + errString = strprintf("package size %u exceeds ancestor size limit [limit: %u]", total_vsize, m_limits.ancestor_size_vbytes); + return false; + } else if (total_vsize > m_limits.descendant_size_vbytes) { + errString = strprintf("package size %u exceeds descendant size limit [limit: %u]", total_vsize, m_limits.descendant_size_vbytes); + return false; + } + CTxMemPoolEntry::Parents staged_ancestors; for (const auto& tx : package) { for (const auto& input : tx->vin) {