From 3232d9987d48c1c4351d3a320a87efbd49624241 Mon Sep 17 00:00:00 2001 From: joetom Date: Tue, 17 Mar 2026 16:28:54 +0000 Subject: [PATCH] add broadcast_custom_mining task/sol placeholders --- src/network_messages/network_message_type.h | 2 + src/qubic.cpp | 65 ++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/network_messages/network_message_type.h b/src/network_messages/network_message_type.h index 7ec9a6af7..bf7d424db 100644 --- a/src/network_messages/network_message_type.h +++ b/src/network_messages/network_message_type.h @@ -51,6 +51,8 @@ enum NetworkMessageType : unsigned char RESPOND_ACTIVE_IPO = 65, REQUEST_ORACLE_DATA = 66, RESPOND_ORACLE_DATA = 67, + BROADCAST_CUSTOM_MINING_TASK = 68, + BROADCAST_CUSTOM_MINING_SOLUTION = 69, ORACLE_MACHINE_QUERY = 190, // only on communication channel Core node <-> OM node ORACLE_MACHINE_REPLY = 191, // only on communication channel Core node <-> OM node REQUEST_TX_STATUS = 201, // tx addon only diff --git a/src/qubic.cpp b/src/qubic.cpp index 1ae1cace8..3121d484e 100644 --- a/src/qubic.cpp +++ b/src/qubic.cpp @@ -1477,10 +1477,61 @@ static void processRequestedCustomMiningSolutionVerificationRequest(Peer* peer, } } +// Hardcoded doge dispatcher public key (identity: XPILPIJYHRBTACMMIRSJLIZWCXDBHWVEOTZBQFBXWEUXDZGGDEKDQPIEQKQK) +static const unsigned char dogeDispatcherPubkey[32] = { + 0x25, 0x98, 0x6d, 0x38, 0xa6, 0x3d, 0xd6, 0x45, + 0x0c, 0x07, 0x34, 0xd8, 0xaa, 0x47, 0x95, 0x27, + 0xd7, 0x2c, 0x0f, 0x9b, 0x3a, 0x86, 0x0a, 0xa8, + 0x9e, 0x9f, 0xb1, 0xf3, 0xfd, 0x3d, 0x1f, 0x95 +}; + +// Process a doge custom mining task broadcast (type 68). +// Verifies the signature against the hardcoded doge dispatcher public key and relays if valid. +static void processBroadcastCustomMiningTask(RequestResponseHeader* header) +{ + if (!header->isDejavuZero()) + return; + const unsigned int messageSize = header->size() - sizeof(RequestResponseHeader); + if (messageSize <= SIGNATURE_SIZE) + return; + const unsigned char* payload = (const unsigned char*)header->getPayload(); + m256i digest; + KangarooTwelve(payload, messageSize - SIGNATURE_SIZE, &digest, sizeof(digest)); + if (verify(dogeDispatcherPubkey, digest.m256i_u8, payload + (messageSize - SIGNATURE_SIZE))) + { + enqueueResponse(NULL, header); + } +} + +// Process a doge custom mining solution broadcast (type 69). +// Verifies the signature against the sender's public key (first 32 bytes of payload) +// and relays if the sender is a computor or has enough balance. +static void processBroadcastCustomMiningSolution(RequestResponseHeader* header) +{ + if (!header->isDejavuZero()) + return; + const unsigned int messageSize = header->size() - sizeof(RequestResponseHeader); + if (messageSize <= SIGNATURE_SIZE) + return; + const unsigned char* payload = (const unsigned char*)header->getPayload(); + const m256i* sourcePublicKey = (const m256i*)payload; + + m256i digest; + KangarooTwelve(payload, messageSize - SIGNATURE_SIZE, &digest, sizeof(digest)); + if (verify(sourcePublicKey->m256i_u8, digest.m256i_u8, payload + (messageSize - SIGNATURE_SIZE))) + { + if (computorIndex(*sourcePublicKey) >= 0 + || (::spectrumIndex(*sourcePublicKey) >= 0 && energy(::spectrumIndex(*sourcePublicKey)) >= MESSAGE_DISSEMINATION_THRESHOLD)) + { + enqueueResponse(NULL, header); + } + } +} + // Process custom mining data requests. // Currently supports: // - Requesting a range of tasks (using Unix timestamps as unique indexes; each task has only one unique index). -// - Requesting all solutions corresponding to a specific task index. +// - Requesting all solutions corresponding to a specific task index. // The total size of the response will not exceed CUSTOM_MINING_RESPOND_MESSAGE_MAX_SIZE. // For the solution respond, only respond solution that has not been verified yet static void processCustomMiningDataRequest(Peer* peer, const unsigned long long processorNumber, RequestResponseHeader* header) @@ -2286,6 +2337,18 @@ static void requestProcessor(void* ProcedureArgument) } break; + case BROADCAST_CUSTOM_MINING_TASK: + { + processBroadcastCustomMiningTask(header); + } + break; + + case BROADCAST_CUSTOM_MINING_SOLUTION: + { + processBroadcastCustomMiningSolution(header); + } + break; + case RequestCustomMiningSolutionVerification::type(): { processRequestedCustomMiningSolutionVerificationRequest(peer, header);