aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2022-07-25 16:07:56 -0400
committerCarl Dong <contact@carldong.me>2022-08-03 12:02:31 -0400
commitb370164b319df1a500b70694b077f92265a777fb (patch)
tree4bbaf4169e3cba27d70395c2ecc21c8e0326a852
parent08dbc6ef72db48168dc03991f5f838dae42c8dfd (diff)
validationcaches: Abolish arbitrary limit
1. -maxsigcachesize is a DEBUG_ONLY option 2. Almost 7 years has passed since its semantics change in 830e3f3d027ba5c8121eed0f6a9ce99961352572 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.
-rw-r--r--src/script/sigcache.cpp2
-rw-r--r--src/script/sigcache.h2
-rw-r--r--src/validation.cpp2
3 files changed, 2 insertions, 4 deletions
diff --git a/src/script/sigcache.cpp b/src/script/sigcache.cpp
index 7cee55a431..43b594f3cb 100644
--- a/src/script/sigcache.cpp
+++ b/src/script/sigcache.cpp
@@ -96,7 +96,7 @@ bool InitSignatureCache()
{
// nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
// setup_bytes creates the minimum possible cache (2 elements).
- 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);
+ size_t nMaxCacheSize = std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2) * ((size_t) 1 << 20);
auto setup_results = signatureCache.setup_bytes(nMaxCacheSize);
diff --git a/src/script/sigcache.h b/src/script/sigcache.h
index edcba2543c..0e3f900acf 100644
--- a/src/script/sigcache.h
+++ b/src/script/sigcache.h
@@ -16,8 +16,6 @@
// systems). Due to how we count cache size, actual memory usage is slightly
// more (~32.25 MB)
static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE = 32;
-// Maximum sig cache size allowed
-static const int64_t MAX_MAX_SIG_CACHE_SIZE = 16384;
class CPubKey;
diff --git a/src/validation.cpp b/src/validation.cpp
index d0c84ba317..4d174a4b16 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1666,7 +1666,7 @@ bool InitScriptExecutionCache() {
g_scriptExecutionCacheHasher.Write(nonce.begin(), 32);
// nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
// setup_bytes creates the minimum possible cache (2 elements).
- 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);
+ size_t nMaxCacheSize = std::max((int64_t)0, gArgs.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2) * ((size_t) 1 << 20);
auto setup_results = g_scriptExecutionCache.setup_bytes(nMaxCacheSize);