Skip to content

Commit

Permalink
Handle over-sized (in virtual bytes) packages with no in-mempool ance…
Browse files Browse the repository at this point in the history
…stors
  • Loading branch information
instagibbs committed Sep 15, 2023
1 parent c729219 commit 1769041
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,23 @@ bool CTxMemPool::CheckPackageLimits(const Package& package,
const Limits& limits,
std::string &errString) const
{
size_t pack_size = package.size();

// Package itself is busting mempool limits; should be rejected even if no staged_ancestors exist
if (pack_size > static_cast<uint64_t>(limits.ancestor_count)) {
errString = strprintf("package count %u exceeds ancestor count limit [limit: %u]", pack_size, limits.ancestor_count);
return false;
} else if (pack_size > static_cast<uint64_t>(limits.descendant_count)) {
errString = strprintf("package count %u exceeds descendant count limit [limit: %u]", pack_size, limits.descendant_count);
return false;
} else if (total_vsize > limits.ancestor_size_vbytes) {
errString = strprintf("package size %u exceeds ancestor size limit [limit: %u]", total_vsize, limits.ancestor_size_vbytes);
return false;
} else if (total_vsize > limits.descendant_size_vbytes) {
errString = strprintf("package size %u exceeds descendant size limit [limit: %u]", total_vsize, limits.descendant_size_vbytes);
return false;
}

CTxMemPoolEntry::Parents staged_ancestors;
for (const auto& tx : package) {
for (const auto& input : tx->vin) {
Expand Down

0 comments on commit 1769041

Please sign in to comment.