From 37d5ee494c8c3b5c32f33d90e738b02f79a2b2c4 Mon Sep 17 00:00:00 2001 From: schnibble Date: Wed, 13 Sep 2017 14:00:49 +0300 Subject: [PATCH 1/3] block size related constants adjusted; other minor fixes --- src/net.cpp | 2 +- src/net.h | 2 +- src/validation.cpp | 2 +- src/validation.h | 20 ++++++++++---------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 2f874d753e19..6eb6c8b8c8e4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2557,7 +2557,7 @@ void CConnman::RecordBytesSent(uint64_t bytes) void CConnman::SetMaxOutboundTarget(uint64_t limit) { LOCK(cs_totalBytesSent); - uint64_t recommendedMinimum = (nMaxOutboundTimeframe / 600) * MaxBlockSize(fDIP0001ActiveAtTip); + uint64_t recommendedMinimum = (nMaxOutboundTimeframe / 600) * MaxBlockSize(true); nMaxOutboundLimit = limit; if (limit > 0 && limit < recommendedMinimum) diff --git a/src/net.h b/src/net.h index 4c56aea6d96f..0702d8089552 100644 --- a/src/net.h +++ b/src/net.h @@ -56,7 +56,7 @@ static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; /** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ -static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024; +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 3 * 1024 * 1024; /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; /** Maximum number of outgoing nodes */ diff --git a/src/validation.cpp b/src/validation.cpp index ce9e0752f6ab..e923cdb88de8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4369,7 +4369,7 @@ std::string GetWarnings(const std::string& strFor) ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos) { - LOCK(cs_main); + AssertLockHeld(cs_main); return VersionBitsState(chainActive.Tip(), params, pos, versionbitscache); } diff --git a/src/validation.h b/src/validation.h index 45968f67dd73..2f2e62f4fb6d 100644 --- a/src/validation.h +++ b/src/validation.h @@ -73,11 +73,11 @@ static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101; /** Default for -mempoolexpiry, expiration time for mempool transactions in hours */ static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 72; /** The maximum size of a blk?????.dat file (since 0.8) */ -static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB +static const unsigned int MAX_BLOCKFILE_SIZE = 0x10000000; // 256 MiB /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ -static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB +static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x2000000; // 32 MiB /** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ -static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB +static const unsigned int UNDOFILE_CHUNK_SIZE = 0x200000; // 2 MiB /** Maximum number of script-checking threads allowed */ static const int MAX_SCRIPTCHECK_THREADS = 16; @@ -187,14 +187,14 @@ static const signed int DEFAULT_CHECKBLOCKS = MIN_BLOCKS_TO_KEEP; static const unsigned int DEFAULT_CHECKLEVEL = 3; // Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat) -// At 1MB per block, 288 blocks = 288MB. -// Add 15% for Undo data = 331MB -// Add 20% for Orphan block rate = 397MB -// We want the low water mark after pruning to be at least 397 MB and since we prune in +// At 1MB per block, 288 blocks = 576MB. +// Add 15% for Undo data = 662MB +// Add 20% for Orphan block rate = 794MB +// We want the low water mark after pruning to be at least 794 MB and since we prune in // full block file chunks, we need the high water mark which triggers the prune to be -// one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB -// Setting the target to > than 550MB will make it likely we can respect the target. -static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024; +// one 256MB block file + added 15% undo data = 294MB greater for a total of 1088MB +// Setting the target to > than 1100MB will make it likely we can respect the target. +static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 1100 * 1024 * 1024; /** * Process an incoming block. This only returns after the best known valid From 80100a25dad1fde5211434c8db84d0c479e9238d Mon Sep 17 00:00:00 2001 From: schnibble Date: Wed, 13 Sep 2017 15:38:25 +0300 Subject: [PATCH 2/3] revert constants related to storing blocks on disk --- src/net.h | 2 +- src/validation.h | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/net.h b/src/net.h index 0702d8089552..46789e04cfde 100644 --- a/src/net.h +++ b/src/net.h @@ -55,7 +55,7 @@ static const int FEELER_INTERVAL = 120; static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; -/** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ +/** Maximum length of incoming protocol messages (no message over 3 MiB is currently acceptable). */ static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 3 * 1024 * 1024; /** Maximum length of strSubVer in `version` message */ static const unsigned int MAX_SUBVERSION_LENGTH = 256; diff --git a/src/validation.h b/src/validation.h index 2f2e62f4fb6d..f26e124e0393 100644 --- a/src/validation.h +++ b/src/validation.h @@ -73,11 +73,11 @@ static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101; /** Default for -mempoolexpiry, expiration time for mempool transactions in hours */ static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 72; /** The maximum size of a blk?????.dat file (since 0.8) */ -static const unsigned int MAX_BLOCKFILE_SIZE = 0x10000000; // 256 MiB +static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ -static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x2000000; // 32 MiB +static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB /** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ -static const unsigned int UNDOFILE_CHUNK_SIZE = 0x200000; // 2 MiB +static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB /** Maximum number of script-checking threads allowed */ static const int MAX_SCRIPTCHECK_THREADS = 16; @@ -186,15 +186,15 @@ static const unsigned int MIN_BLOCKS_TO_KEEP = 288; static const signed int DEFAULT_CHECKBLOCKS = MIN_BLOCKS_TO_KEEP; static const unsigned int DEFAULT_CHECKLEVEL = 3; -// Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat) -// At 1MB per block, 288 blocks = 576MB. +// Require that user allocate at least 945MB for block & undo files (blk???.dat and rev???.dat) +// At 2MB per block, 288 blocks = 576MB. // Add 15% for Undo data = 662MB // Add 20% for Orphan block rate = 794MB // We want the low water mark after pruning to be at least 794 MB and since we prune in // full block file chunks, we need the high water mark which triggers the prune to be -// one 256MB block file + added 15% undo data = 294MB greater for a total of 1088MB -// Setting the target to > than 1100MB will make it likely we can respect the target. -static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 1100 * 1024 * 1024; +// one 128MB block file + added 15% undo data = 147MB greater for a total of 941MB +// Setting the target to > than 945MB will make it likely we can respect the target. +static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 945 * 1024 * 1024; /** * Process an incoming block. This only returns after the best known valid From 480b5642ead932cb28479bf955348cce94c7a6c5 Mon Sep 17 00:00:00 2001 From: schnibble Date: Thu, 14 Sep 2017 12:16:21 +0300 Subject: [PATCH 3/3] move AssertLockHeld to a separate PR --- src/validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index e923cdb88de8..ce9e0752f6ab 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4369,7 +4369,7 @@ std::string GetWarnings(const std::string& strFor) ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos) { - AssertLockHeld(cs_main); + LOCK(cs_main); return VersionBitsState(chainActive.Tip(), params, pos, versionbitscache); }