What changed, and why it matters
This commit updates the XMRig mining software to support a new RandomX v2 protocol feature. When a mining pool asks for it, the miner now includes an extra 'commitment' value alongside its share submissions. The change is a feature addition for cryptocurrency mining protocol compatibility, not a fix for a security vulnerability in the traditional sense. There is also a small adjustment to how generated code is aligned for a CPU performance tweak.
No immediate security action is required. This is a protocol compatibility update. Operators using XMRig with RandomX v2 pools should ensure they run a version that includes this commit to avoid rejected shares. Reviewers may want to verify that the shared extra_data buffer handling correctly distinguishes RX_V2 (32-byte commitment) from RX_WOW (64-byte signature) to prevent mis-serialization.
Security signals we found
Protocol feature addition (RandomX v2 commitment field)
Buffer size increase in stratum client (256 -> 320 bytes)
Shared extra_data buffer used for two different-sized data types (32-byte commitment vs 64-byte signature)
JIT compiler alignment tweak for RandomX v2 CFROUND branches
Evidence from the diff
The patch adds a ‘commitment’ field to stratum share submissions for the RandomX v2 algorithm. It renames the generic ‘miner_signature’ parameter to ‘extra_data’ in JobResult/JobResults, stores either a 32-byte commitment (RX_V2) or a 64-byte miner signature (RX_WOW) in a shared buffer, and serializes the commitment as a hex string in the stratum JSON. The temp buffer in Client.cpp is enlarged from 256 to 320 bytes to accommodate the new field. Additionally, jit_compiler_x86.cpp adjusts the NOP alignment threshold for CFROUND branches from >=30 to >=28 and changes the branch_begin calculation from (pos+2)&31 to pos&31, which is part of the RandomX v2 code-generation tweaks.
Changed components
src/backend/cpu/CpuWorker.cppsrc/base/net/stratum/Client.cppsrc/crypto/randomx/jit_compiler_x86.cppsrc/net/JobResult.hsrc/net/JobResults.cppsrc/net/JobResults.hInspect captured patch +49 / −15
### src/backend/cpu/CpuWorker.cpp
@@ -363,8 +363,20 @@ void xmrig::CpuWorker<N>::start()
}
else
# endif
+
if (value < job.target()) {
- JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), job.hasMinerSignature() ? miner_signature_saved : nullptr);
+ uint8_t* extra_data = nullptr;
+
+ if (job.algorithm().family() == Algorithm::RANDOM_X) {
+ if (RandomX_CurrentConfig.Tweak_V2_COMMITMENT) {
+ extra_data = m_commitment;
+ }
+ else if (job.hasMinerSignature()) {
+ extra_data = miner_signature_saved;
+ }
+ }
+
+ JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), extra_data);
}
}
m_count += N;
### src/base/net/stratum/Client.cpp
@@ -81,7 +81,7 @@ xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
BaseClient(id, listener),
m_agent(agent),
m_sendBuf(1024),
- m_tempBuf(256)
+ m_tempBuf(320)
{
m_reader.setListener(this);
m_key = m_storage.add(this);
@@ -199,13 +199,18 @@ int64_t xmrig::Client::submit(const JobResult &result)
char *nonce = m_tempBuf.data();
char *data = m_tempBuf.data() + 16;
char *signature = m_tempBuf.data() + 88;
+ char *commitment = m_tempBuf.data() + 224;
Cvt::toHex(nonce, sizeof(uint32_t) * 2 + 1, reinterpret_cast<const uint8_t *>(&result.nonce), sizeof(uint32_t));
Cvt::toHex(data, 65, result.result(), 32);
if (result.minerSignature()) {
Cvt::toHex(signature, 129, result.minerSignature(), 64);
}
+
+ if (result.commitment()) {
+ Cvt::toHex(commitment, 65, result.commitment(), 32);
+ }
# endif
Document doc(kObjectType);
@@ -227,6 +232,12 @@ int64_t xmrig::Client::submit(const JobResult &result)
}
# endif
+# ifndef XMRIG_PROXY_PROJECT
+ if (result.commitment()) {
+ params.AddMember("commitment", StringRef(commitment), allocator);
+ }
+# endif
+
if (has<EXT_ALGO>() && result.algorithm.isValid()) {
params.AddMember("algo", StringRef(result.algorithm.name()), allocator);
}
### src/crypto/randomx/jit_compiler_x86.cpp
@@ -1379,10 +1379,10 @@ namespace randomx {
if (RandomX_CurrentConfig.Tweak_V2_CFROUND) {
if (BranchesWithin32B) {
- const uint32_t branch_begin = static_cast<uint32_t>(pos + 2) & 31;
+ const uint32_t branch_begin = pos & 31;
// If the jump crosses or touches 32-byte boundary, align it
- if (branch_begin >= 30) {
+ if (branch_begin >= 28) {
const uint32_t alignment_size = 32 - branch_begin;
emit(NOPX[alignment_size - 1], alignment_size, code, pos);
}
@@ -1438,10 +1438,10 @@ namespace randomx {
if (RandomX_CurrentConfig.Tweak_V2_CFROUND) {
if (BranchesWithin32B) {
- const uint32_t branch_begin = static_cast<uint32_t>(pos + 2) & 31;
+ const uint32_t branch_begin = pos & 31;
// If the jump crosses or touches 32-byte boundary, align it
- if (branch_begin >= 30) {
+ if (branch_begin >= 28) {
const uint32_t alignment_size = 32 - branch_begin;
emit(NOPX[alignment_size - 1], alignment_size, code, pos);
}
### src/net/JobResult.h
@@ -34,6 +34,8 @@
#include "base/tools/String.h"
#include "base/net/stratum/Job.h"
+#include "crypto/randomx/randomx.h"
+
namespace xmrig {
@@ -43,7 +45,7 @@ class JobResult
public:
JobResult() = delete;
- inline JobResult(const Job &job, uint64_t nonce, const uint8_t *result, const uint8_t* header_hash = nullptr, const uint8_t *mix_hash = nullptr, const uint8_t* miner_signature = nullptr) :
+ inline JobResult(const Job &job, uint64_t nonce, const uint8_t *result, const uint8_t* header_hash = nullptr, const uint8_t *mix_hash = nullptr, const uint8_t* extra_data = nullptr) :
algorithm(job.algorithm()),
index(job.index()),
clientId(job.clientId()),
@@ -62,9 +64,15 @@ class JobResult
memcpy(m_mixHash, mix_hash, sizeof(m_mixHash));
}
- if (miner_signature) {
- m_hasMinerSignature = true;
- memcpy(m_minerSignature, miner_signature, sizeof(m_minerSignature));
+ if (extra_data) {
+ if (algorithm == Algorithm::RX_V2) {
+ m_hasCommitment = true;
+ memcpy(m_extraData, extra_data, RANDOMX_HASH_SIZE);
+ }
+ else if (algorithm == Algorithm::RX_WOW) {
+ m_hasMinerSignature = true;
+ memcpy(m_extraData, extra_data, RANDOMX_HASH_SIZE * 2);
+ }
}
}
@@ -85,7 +93,8 @@ class JobResult
inline const uint8_t *headerHash() const { return m_headerHash; }
inline const uint8_t *mixHash() const { return m_mixHash; }
- inline const uint8_t *minerSignature() const { return m_hasMinerSignature ? m_minerSignature : nullptr; }
+ inline const uint8_t *minerSignature() const { return m_hasMinerSignature ? m_extraData : nullptr; }
+ inline const uint8_t *commitment() const { return m_hasCommitment ? m_extraData : nullptr; }
const Algorithm algorithm;
const uint8_t index;
@@ -100,8 +109,10 @@ class JobResult
uint8_t m_headerHash[32] = { 0 };
uint8_t m_mixHash[32] = { 0 };
- uint8_t m_minerSignature[64] = { 0 };
+ uint8_t m_extraData[RANDOMX_HASH_SIZE * 2] = { 0 };
+
bool m_hasMinerSignature = false;
+ bool m_hasCommitment = false;
};
### src/net/JobResults.cpp
@@ -339,9 +339,9 @@ void xmrig::JobResults::submit(const Job &job, uint32_t nonce, const uint8_t *re
}
-void xmrig::JobResults::submit(const Job& job, uint32_t nonce, const uint8_t* result, const uint8_t* miner_signature)
+void xmrig::JobResults::submit(const Job& job, uint32_t nonce, const uint8_t* result, const uint8_t* extra_data)
{
- submit(JobResult(job, nonce, result, nullptr, nullptr, miner_signature));
+ submit(JobResult(job, nonce, result, nullptr, nullptr, extra_data));
}
### src/net/JobResults.h
@@ -46,7 +46,7 @@ class JobResults
static void setListener(IJobResultListener *listener, bool hwAES);
static void stop();
static void submit(const Job &job, uint32_t nonce, const uint8_t *result);
- static void submit(const Job& job, uint32_t nonce, const uint8_t* result, const uint8_t* miner_signature);
+ static void submit(const Job& job, uint32_t nonce, const uint8_t* result, const uint8_t* extra_data);
static void submit(const JobResult &result);
# if defined(XMRIG_FEATURE_OPENCL) || defined(XMRIG_FEATURE_CUDA)Why this scored 19/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.