From 43c93db00f038acc5788e8f562f8ebf19d2c31be Mon Sep 17 00:00:00 2001 From: cyber-pc Date: Wed, 7 Jan 2026 15:31:23 +0700 Subject: [PATCH 1/2] Support setting addtion score's threshold. --- README.md | 2 +- argparser.h | 3 ++- global.h | 1 + main.cpp | 3 ++- node_utils.cpp | 6 ++++-- node_utils.h | 2 +- sanity_check.h | 10 ++++++++++ structs.h | 6 ++++-- 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 17a30901..934d1b0c 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ Commands: -togglemainaux Remotely toggle Main/Aux mode on node, valid seed and node ip/port are required. and value are: MAIN or AUX - -setsolutionthreshold + -setsolutionthreshold Remotely set solution threshold for future epoch, valid seed and node ip/port are required. -refreshpeerlist (equivalent to F4) Remotely refresh the peer list of node, all current connections will be closed after this command is sent, valid seed and node ip/port are required. diff --git a/argparser.h b/argparser.h index 58b6c801..3a475bfe 100644 --- a/argparser.h +++ b/argparser.h @@ -1055,7 +1055,8 @@ void parseArgument(int argc, char** argv) g_cmd = SET_SOLUTION_THRESHOLD; g_setSolutionThresholdEpoch = int(charToNumber(argv[i+1])); g_setSolutionThresholdValue = int(charToNumber(argv[i+2])); - i+=3; + g_setSolutionThresholdAlgo = int(charToNumber(argv[i+3])); + i+=4; CHECK_OVER_PARAMETERS break; } diff --git a/global.h b/global.h index 7a87a9dd..59ad68d7 100644 --- a/global.h +++ b/global.h @@ -36,6 +36,7 @@ char* g_toggleMainAux0 = nullptr; char* g_toggleMainAux1 = nullptr; int g_setSolutionThresholdEpoch = -1; int g_setSolutionThresholdValue = -1; +int g_setSolutionThresholdAlgo = -1; char* g_filePath = nullptr; char* g_compressTool = nullptr; uint32_t g_contractIndex = 0; diff --git a/main.cpp b/main.cpp index 67cdc8f7..b757d239 100644 --- a/main.cpp +++ b/main.cpp @@ -338,7 +338,8 @@ int run(int argc, char* argv[]) sanityCheckSeed(g_seed); checkValidEpoch(g_setSolutionThresholdEpoch); checkValidSolutionThreshold(g_setSolutionThresholdValue); - setSolutionThreshold(g_nodeIp, g_nodePort, g_seed, g_setSolutionThresholdEpoch, g_setSolutionThresholdValue); + checkValidSolutionThresholdAlgo(g_setSolutionThresholdAlgo); + setSolutionThreshold(g_nodeIp, g_nodePort, g_seed, g_setSolutionThresholdEpoch, g_setSolutionThresholdValue, g_setSolutionThresholdAlgo); break; case SEND_SPECIAL_COMMAND: case REFRESH_PEER_LIST: diff --git a/node_utils.cpp b/node_utils.cpp index 021adbb8..c5f2c939 100644 --- a/node_utils.cpp +++ b/node_utils.cpp @@ -112,6 +112,7 @@ void printSystemInfoFromNode(const char* nodeIp, int nodePort) byteToHex(curSystemInfo.randomMiningSeed, hex, 32); LOG("RandomMiningSeed: %s\n", hex); LOG("SolutionThreshold: %u\n", curSystemInfo.solutionThreshold); + LOG("AdditionSolutionThreshold: %llu\n", curSystemInfo.solutionAdditionalThreshold); // todo: add initial time @@ -1296,7 +1297,7 @@ void toggleMainAux(const char* nodeIp, const int nodePort, const char* seed, std } } -void setSolutionThreshold(const char* nodeIp, const int nodePort, const char* seed, int epoch, int threshold) +void setSolutionThreshold(const char* nodeIp, const int nodePort, const char* seed, int epoch, int threshold, int algo) { uint8_t privateKey[32] = {0}; uint8_t sourcePublicKey[32] = {0}; @@ -1317,6 +1318,7 @@ void setSolutionThreshold(const char* nodeIp, const int nodePort, const char* se packet.cmd.everIncreasingNonceAndCommandType = commandByte | curTime; packet.cmd.epoch = epoch; packet.cmd.threshold = threshold; + packet.cmd.algoType = algo; getSubseedFromSeed((uint8_t*)seed, subseed); getPrivateKeyFromSubSeed(subseed, privateKey); @@ -1342,7 +1344,7 @@ void setSolutionThreshold(const char* nodeIp, const int nodePort, const char* se if (response.everIncreasingNonceAndCommandType == packet.cmd.everIncreasingNonceAndCommandType) { - if (response.epoch == packet.cmd.epoch && response.threshold == packet.cmd.threshold) + if (response.epoch == packet.cmd.epoch && response.threshold == packet.cmd.threshold && response.algoType == packet.cmd.algoType) { LOG("Successfully set solution threshold\n"); } diff --git a/node_utils.h b/node_utils.h index 2b54dc90..87e059d7 100644 --- a/node_utils.h +++ b/node_utils.h @@ -30,7 +30,7 @@ void getVoteCounterTransaction(const char* nodeIp, const int nodePort, unsigned void uploadFile(const char* nodeIp, const int nodePort, const char* filePath, const char* seed, unsigned int tickOffset, const char* compressTool = nullptr); // remote tools: void toggleMainAux(const char* nodeIp, const int nodePort, const char* seed, std::string mode0, std::string mode1); -void setSolutionThreshold(const char* nodeIp, const int nodePort, const char* seed, int epoch, int threshold); +void setSolutionThreshold(const char* nodeIp, const int nodePort, const char* seed, int epoch, int threshold, int algoType); void syncTime(const char* nodeIp, const int nodePort, const char* seed); void setLoggingMode(const char* nodeIp, const int nodePort, const char* seed, char mode); void broadcastCompChat(const char* nodeIp, const int nodePort, const char* seed, char* compChatMsg); diff --git a/sanity_check.h b/sanity_check.h index e916b8dc..004c5266 100644 --- a/sanity_check.h +++ b/sanity_check.h @@ -258,6 +258,16 @@ static void checkValidSolutionThreshold(int thres) exit(1); } +static void checkValidSolutionThresholdAlgo(int algo) +{ + if (algo >= 0 && algo < 2) + { + return; + } + LOG("Invalid solution algo. Now only support value 0:hyperidentity, 1:addition\n"); + exit(1); +} + static void sanityCheckValidAssetName(const char * name) { bool okay = false; diff --git a/structs.h b/structs.h index 1529b279..6acbea78 100644 --- a/structs.h +++ b/structs.h @@ -373,8 +373,8 @@ struct CurrentSystemInfo unsigned long long currentEntityBalanceDustThreshold; unsigned int targetTickVoteSignature; - unsigned long long _reserve0; - unsigned long long _reserve1; + unsigned long long computorPacketSignature; + unsigned long long solutionAdditionalThreshold; unsigned long long _reserve2; unsigned long long _reserve3; unsigned long long _reserve4; @@ -793,6 +793,8 @@ struct SpecialCommandSetSolutionThresholdResquestAndResponse unsigned long long everIncreasingNonceAndCommandType; unsigned int epoch; int threshold; + int algoType; + int padding; static constexpr unsigned char type() { return 255; From 09bfeae079397283ba87ba319ee93348bcd938a2 Mon Sep 17 00:00:00 2001 From: cyber-pc Date: Wed, 21 Jan 2026 21:02:38 +0700 Subject: [PATCH 2/2] Update usage instructions for setsolutionthreshold. --- README.md | 2 +- sanity_check.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 934d1b0c..103a3a1d 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Commands: Remotely toggle Main/Aux mode on node, valid seed and node ip/port are required. and value are: MAIN or AUX -setsolutionthreshold - Remotely set solution threshold for future epoch, valid seed and node ip/port are required. + Remotely set solution threshold for future epoch, valid seed and node ip/port are required. : 0 - HYPERIDENTITY, 1 - ADDITION -refreshpeerlist (equivalent to F4) Remotely refresh the peer list of node, all current connections will be closed after this command is sent, valid seed and node ip/port are required. -forcenexttick diff --git a/sanity_check.h b/sanity_check.h index 004c5266..d92e99fe 100644 --- a/sanity_check.h +++ b/sanity_check.h @@ -264,7 +264,7 @@ static void checkValidSolutionThresholdAlgo(int algo) { return; } - LOG("Invalid solution algo. Now only support value 0:hyperidentity, 1:addition\n"); + LOG("As of now, the only supported values are 0:hyperidentity, 1:addition\n"); exit(1); }