Merge ElementsProject/elements#1510: Merge bitcoin#32530: node: cap -maxmempool and -dbcache for 32 bit systems.

8ea4b7aae9 Merge bitcoin/bitcoin#32530: node: cap `-maxmempool` and `-dbcache` values for 32-bit (merge-script)

Pull request description:

  Backport of https://github.com/bitcoin/bitcoin/pull/32530

ACKs for top commit:
  delta1:
    ACK 8ea4b7aae9

Tree-SHA512: fc8aea76fd49e05ca2499c40e657451890d84b5424c124b594768821a231138eef64d9b331ccbfa7a2f0e224def45f7f4630a15a7a609d32b68ebfcba76ac64b
This commit is contained in:
merge-script 2025-11-19 10:16:33 +02:00
commit 98bd7180c2
No known key found for this signature in database
GPG key ID: DE8F6EA20A661697
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")) {

View file

@ -8,12 +8,16 @@
#include <util/system.h>
#include <validation.h>
//! Maximum dbcache size on 32-bit systems.
static constexpr int64_t MAX_32BIT_DBCACHE = 1ULL << 30; // 1 GiB
namespace node {
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
{
int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20);
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greater than nMaxDbcache
if (sizeof(void*) == 4) nTotalCache = std::min(nTotalCache, MAX_32BIT_DBCACHE);
CacheSizes sizes;
sizes.block_tree_db = std::min(nTotalCache / 8, nMaxBlockDBCache << 20);
nTotalCache -= sizes.block_tree_db;