From 72d7263e1458eb01da79b4acaff144eae6509be9 Mon Sep 17 00:00:00 2001 From: Matt Hess Date: Mon, 22 Dec 2025 22:45:35 +0000 Subject: [PATCH] Fixed consensus ID format mismatch, riscv64 SIGSEGV, shadow variable --- cppcheck/suppressions.txt | 4 ++++ src/carrot_crypto.cpp | 2 +- src/side_chain.cpp | 11 +++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cppcheck/suppressions.txt b/cppcheck/suppressions.txt index 9cc7320..45f6baa 100644 --- a/cppcheck/suppressions.txt +++ b/cppcheck/suppressions.txt @@ -2,3 +2,7 @@ unmatchedSuppression missingIncludeSystem unusedFunction useStlAlgorithm +constParameterReference +constVariableReference +functionStatic +constParameter diff --git a/src/carrot_crypto.cpp b/src/carrot_crypto.cpp index d77df63..06bc662 100644 --- a/src/carrot_crypto.cpp +++ b/src/carrot_crypto.cpp @@ -87,7 +87,7 @@ static size_t build_transcript(uint8_t* buf, const char (&domain_sep)[N]) // Debug helper to print hex static void debug_hex(const char* label, const uint8_t* data, size_t len) { - static constexpr char log_category_prefix[] = "CarrotCrypto "; + // Uses log_category_prefix from LOG_CATEGORY(CarrotCrypto) macro char hex[130] = {0}; for (size_t i = 0; i < len && i < 64; ++i) { snprintf(hex + i*2, 3, "%02x", data[i]); diff --git a/src/side_chain.cpp b/src/side_chain.cpp index 7c63768..86848c2 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -59,7 +59,8 @@ static constexpr uint64_t MONERO_BLOCK_TIME = 120; namespace p2pool { -static constexpr uint8_t default_consensus_id[HASH_SIZE] = { 83,65,76,86,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24 }; +// Consensus ID for salvium_main: computed from "mainnet\0salvium_main\0\010\0100000\02160\020\0" +static constexpr uint8_t default_consensus_id[HASH_SIZE] = { 4,45,231,71,15,85,219,190,194,167,8,240,43,43,125,49,227,192,250,144,117,138,59,226,222,163,164,69,170,215,106,74 }; static constexpr uint8_t mini_consensus_id[HASH_SIZE] = { 83,65,76,77,149,174,199,250,66,80,189,18,108,216,194,220,136,23,63,24,64,113,221,44,219,86,39,163,53,24,126,196 }; static constexpr uint8_t nano_consensus_id[HASH_SIZE] = { 83,65,76,78,210,226,114,99,250,145,221,96,13,216,23,63,104,53,129,168,244,80,141,138,157,250,50,54,37,189,5,89 }; @@ -129,9 +130,11 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name, cons << m_chainWindowSize << '\0' << m_unclePenalty << '\0'; - constexpr char default_config[] = "salvium_main\0" "salvium_main\0" "\0" "10\0" "100000\0" "2160\0" "20\0"; - constexpr char mini_config[] = "salvium_mini\0" "salvium_mini\0" "\0" "10\0" "100000\0" "2160\0" "20\0"; - constexpr char nano_config[] = "salvium_nano\0" "salvium_nano\0" "\0" "30\0" "100000\0" "2160\0" "10\0"; + // Format: network_type\0pool_name\0password\0block_time\0min_diff\0window_size\0uncle_penalty\0 + // Note: Network type is serialized as "mainnet"/"testnet"/"stagenet" by log::Stream::Entry + constexpr char default_config[] = "mainnet\0" "salvium_main\0" "\0" "10\0" "100000\0" "2160\0" "20\0"; + constexpr char mini_config[] = "mainnet\0" "salvium_mini\0" "\0" "10\0" "100000\0" "2160\0" "20\0"; + constexpr char nano_config[] = "mainnet\0" "salvium_nano\0" "\0" "30\0" "100000\0" "2160\0" "10\0"; // Hardcoded default consensus ID if ((s.m_pos == sizeof(default_config) - 1) && (memcmp(buf, default_config, sizeof(default_config) - 1) == 0)) {