RandomX v2: added `commitment` field to stratum submit message
What changed, and why it matters
This commit updates the XMRig mining software to support a new 'commitment' field required by an upcoming RandomX version 2 protocol. It changes how miners package and submit proof-of-work results to mining pools. There is no direct evidence this is a security fix for an exploitable vulnerability; it appears to be a protocol compatibility update. A small adjustment to CPU jump alignment in the RandomX JIT compiler is also included, likely to preserve correct behavior on newer CPU features, but the diff alone does not show a security bug.
Treat as a normal protocol-compatibility commit. If RandomX v2 is supported, verify pool interoperability and that the commitment field is correctly serialized. Review the JIT alignment change in the context of the RandomX v2 specification, but no immediate security response is indicated by this diff alone.
Security signals we found
Protocol field addition for RandomX v2 stratum submit message
Buffer size increase in stratum client temporary buffer (256 -> 320 bytes)
JIT compiler alignment threshold change for CFROUND branches
Evidence from the diff
The patch adds a 32-byte ‘commitment’ value to stratum job-result submission for RandomX v2. CpuWorker.cpp now selects either the commitment (when Tweak_V2_COMMITMENT is active) or the existing miner signature as extra_data. JobResult.h generalizes the previous miner-signature buffer into m_extraData and exposes a commitment() accessor. Client.cpp increases its temporary hex buffer from 256 to 320 bytes and adds the ‘commitment’ JSON member to the submit RPC when present. Separately, jit_compiler_x86.cpp changes the CFROUND branch-alignment threshold from >=30 to >=28 and uses pos instead of pos+2 for the boundary check, which looks like a correctness/performance tweak for the RandomX v2 JIT rather than a security patch.
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.