Skip to content

Commit b370164

Browse files
committed
validationcaches: Abolish arbitrary limit
1. -maxsigcachesize is a DEBUG_ONLY option 2. Almost 7 years has passed since its semantics change in 830e3f3 from "number of entries" to "number of mebibytes" 3. A std::new_handler was added to the codebase after the original PR which introduced this limit, which will terminate immediately instead of causing trouble by being caught somewhere unexpected.
1 parent 08dbc6e commit b370164

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

src/script/sigcache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool InitSignatureCache()
9696
{
9797
// nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
9898
// setup_bytes creates the minimum possible cache (2 elements).
99-
size_t nMaxCacheSize = std::min(std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
99+
size_t nMaxCacheSize = std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2) * ((size_t) 1 << 20);
100100

101101
auto setup_results = signatureCache.setup_bytes(nMaxCacheSize);
102102

src/script/sigcache.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// systems). Due to how we count cache size, actual memory usage is slightly
1717
// more (~32.25 MB)
1818
static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE = 32;
19-
// Maximum sig cache size allowed
20-
static const int64_t MAX_MAX_SIG_CACHE_SIZE = 16384;
2119

2220
class CPubKey;
2321

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ bool InitScriptExecutionCache() {
16661666
g_scriptExecutionCacheHasher.Write(nonce.begin(), 32);
16671667
// nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
16681668
// setup_bytes creates the minimum possible cache (2 elements).
1669-
size_t nMaxCacheSize = std::min(std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
1669+
size_t nMaxCacheSize = std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2) * ((size_t) 1 << 20);
16701670

16711671
auto setup_results = g_scriptExecutionCache.setup_bytes(nMaxCacheSize);
16721672

0 commit comments

Comments
 (0)