Merge bitcoin/bitcoin#32530: node: cap -maxmempool and -dbcache values for 32-bit

9f8e7b0b3b787b873045a4a8194e77d0b0a2b3b6 node: cap -dbcache to 1GiB on 32-bit architectures (Antoine Poinsot)
2c43b6adebbfabb3c8dd82fe821ce0a5d6173b3b init: cap -maxmempool to 500 MB on 32-bit systems (Antoine Poinsot)

Pull request description:

  32-bit architecture is limited to 4GiB of RAM, so it doesn't make sense to set a too high value. A too high value could cause an OOM unbeknownst to the user a while after startup as mempool / dbcache fills.

ACKs for top commit:
  achow101:
    ACK 9f8e7b0b3b787b873045a4a8194e77d0b0a2b3b6
  instagibbs:
    utACK 9f8e7b0b3b787b873045a4a8194e77d0b0a2b3b6
  dergoegge:
    Code review ACK 9f8e7b0b3b787b873045a4a8194e77d0b0a2b3b6
  glozow:
    utACK 9f8e7b0b3b787b873045a4a8194e77d0b0a2b3b6

Tree-SHA512: cc7541b2c0040fc21a43916caec464dfb443af808f4e85deffa1187448ffff6edb0d69f9ebdb43915d145b8b4694d8465afe548f88da53ccebc9ce4b7c34b735
This commit is contained in:
merge-script 2025-06-26 17:33:23 +01:00 committed by Tom Trevethan
parent 4929fec91a
commit 8ea4b7aae9
2 changed files with 9 additions and 0 deletions

View file

@ -131,6 +131,7 @@ static const bool DEFAULT_REST_ENABLE = false;
#endif
static const char* DEFAULT_ASMAP_FILENAME="ip_asn.map";
static constexpr int MAX_32BIT_MEMPOOL_MB{500};
/**
* The PID file facilities.
@ -976,6 +977,10 @@ bool AppInitParameterInteraction(const ArgsManager& args)
int64_t nMempoolSizeMin = args.GetIntArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
constexpr bool is_32bit{sizeof(void*) == 4};
if (is_32bit && nMempoolSizeMax > MAX_32BIT_MEMPOOL_MB * 1000000) {
return InitError(strprintf(_("-maxmempool is set to %i but can't be over %i MB on 32-bit systems"), std::ceil(nMempoolSizeMax / 1000000.0), MAX_32BIT_MEMPOOL_MB));
}
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
if (args.IsArgSet("-incrementalrelayfee")) {