What changed, and why it matters
This change moves and tightens a limit on how many blocks a Monero node can request at once when syncing. Previously the limit was checked against a larger value (2048) and only logged an error without stopping startup. Now the same limit (100) is enforced earlier and more strictly, returning failure if exceeded. This prevents a node operator from configuring an oversized block-sync request that could strain memory or network handling.
Treat as a low-severity hardening fix. No immediate emergency response is warranted, but operators and downstream packagers should note that --block-sync-size values above 100 will now prevent daemon startup rather than merely logging an error. Review whether any deployments rely on values between 101 and 2048.
Security signals we found
Input validation added for command-line argument --block-sync-size
Enforcement changed from log-only error to startup failure
Limit tightened from 2048 to 100 blocks per request
Constant moved to shared config header for consistent enforcement
Evidence from the diff
The patch relocates the CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT constant from cryptonote_protocol_handler.h to cryptonote_config.h and enforces it during core initialization (init_options) instead of later in init. The previous check compared –block-sync-size against BLOCKS_SYNCHRONIZING_MAX_COUNT (2048) and only emitted MERROR; the new check compares against CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT (100) and returns false, failing startup. A static_assert ensures the new constant remains >= BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 (100).
Changed components
src/cryptonote_config.hsrc/cryptonote_core/cryptonote_core.cppsrc/cryptonote_protocol/cryptonote_protocol_handler.hMonero daemon startup / block synchronization logicInspect captured patch +9 / −7
### src/cryptonote_config.h
@@ -97,6 +97,8 @@
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
#define BLOCKS_SYNCHRONIZING_MAX_COUNT 2048 //must be a power of 2, greater than 128, equal to SEEDHASH_EPOCH_BLOCKS
+#define CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT 100
+static_assert(CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT >= BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4, "Invalid CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT");
#define BATCH_MAX_WEIGHT 10 //by default, maximum size of batch in [mB]
#define BATCH_MAX_ALLOWED_WEIGHT 50 //maximum allowed size of batch in [mB]
#define BLOCKS_MAX_WINDOW CRYPTONOTE_REWARD_BLOCKS_WINDOW //Window to find the historical max block weight (100 blocks)
### src/cryptonote_core/cryptonote_core.cpp
@@ -382,6 +382,13 @@ namespace cryptonote
epee::debug::g_test_dbg_lock_sleep() = command_line::get_arg(vm, arg_test_dbg_lock_sleep);
+ block_sync_size = command_line::get_arg(vm, arg_block_sync_size);
+ if (block_sync_size > CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT)
+ {
+ MERROR("Error --block-sync-size cannot be greater than " << CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT);
+ return false;
+ }
+
return true;
}
//-----------------------------------------------------------------------------------------------
@@ -681,10 +688,6 @@ namespace cryptonote
m_blockchain_storage.set_show_time_stats(show_time_stats);
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
- block_sync_size = command_line::get_arg(vm, arg_block_sync_size);
- if (block_sync_size > BLOCKS_SYNCHRONIZING_MAX_COUNT)
- MERROR("Error --block-sync-size cannot be greater than " << BLOCKS_SYNCHRONIZING_MAX_COUNT);
-
if(block_sync_size)
MWARNING("When --block-sync-size defined, the --batch-max-weight is not going to have any effect.");
### src/cryptonote_protocol/cryptonote_protocol_handler.h
@@ -55,9 +55,6 @@
PUSH_WARNINGS
DISABLE_VS_WARNINGS(4355)
-#define CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT 100
-static_assert(CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT >= BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4, "Invalid CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT");
-
namespace cryptonote
{
Why this scored 40/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.