mirror of
https://github.com/xmrig/xmrig.git
synced 2026-02-01 09:43:03 -05:00
RandomX v2: added commitment field to stratum submit message
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,6 +199,7 @@ 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);
|
||||
@@ -206,6 +207,10 @@ int64_t xmrig::Client::submit(const JobResult &result)
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ private:
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user