Skip to content

Commit 8310d94

Browse files
committed
[packages] add sanity checks for package vs mempool limits
1 parent be3ff15 commit 8310d94

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/validation.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101;
6060
static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25;
6161
/** Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants */
6262
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101;
63+
64+
// If a package is submitted, it must be within the mempool's ancestor/descendant limits. Since a
65+
// submitted package must be child-with-unconfirmed-parents (all of the transactions are an ancestor
66+
// of the child), package limits are ultimately bounded by mempool package limits. Ensure that the
67+
// defaults reflect this constraint.
68+
static_assert(DEFAULT_DESCENDANT_LIMIT >= MAX_PACKAGE_COUNT);
69+
static_assert(DEFAULT_ANCESTOR_LIMIT >= MAX_PACKAGE_COUNT);
70+
static_assert(DEFAULT_ANCESTOR_SIZE_LIMIT >= MAX_PACKAGE_SIZE);
71+
static_assert(DEFAULT_DESCENDANT_SIZE_LIMIT >= MAX_PACKAGE_SIZE);
72+
6373
/** Default for -mempoolexpiry, expiration time for mempool transactions in hours */
6474
static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 336;
6575
/** Maximum number of dedicated script-checking threads allowed */

0 commit comments

Comments
 (0)