From 9b63955b0989eb256a45cc55ca21ed51e3ce89cf Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 8 Jun 2021 21:56:02 -0400 Subject: [PATCH 1/9] Fix shellcheck warnings in randomx_boost.sh Checked using www.shellcheck.net Specific issues addessed: * https://github.com/koalaman/shellcheck/wiki/SC2002 * Use POSIX instead of bash for wider compatibility * Fail on error --- scripts/randomx_boost.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/randomx_boost.sh b/scripts/randomx_boost.sh index f74b34b23..3b60959d9 100755 --- a/scripts/randomx_boost.sh +++ b/scripts/randomx_boost.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh -e MSR_FILE=/sys/module/msr/parameters/allow_writes @@ -8,9 +8,9 @@ else modprobe msr allow_writes=on fi -if cat /proc/cpuinfo | grep -E 'AMD Ryzen|AMD EPYC' > /dev/null; +if grep -E 'AMD Ryzen|AMD EPYC' /proc/cpuinfo > /dev/null; then - if cat /proc/cpuinfo | grep "cpu family[[:space:]]:[[:space:]]25" > /dev/null; + if grep "cpu family[[:space:]]:[[:space:]]25" /proc/cpuinfo > /dev/null; then echo "Detected Zen3 CPU" wrmsr -a 0xc0011020 0x4480000000000 @@ -26,7 +26,7 @@ if cat /proc/cpuinfo | grep -E 'AMD Ryzen|AMD EPYC' > /dev/null; wrmsr -a 0xc001102b 0x2000cc16 echo "MSR register values for Zen1/Zen2 applied" fi -elif cat /proc/cpuinfo | grep "Intel" > /dev/null; +elif grep "Intel" /proc/cpuinfo > /dev/null; then echo "Detected Intel CPU" wrmsr -a 0x1a4 0xf From 9e6311a7e0ebd6a66240bca5a26550c1e7b1fa7d Mon Sep 17 00:00:00 2001 From: xmrig Date: Thu, 1 Jul 2021 13:54:09 +0700 Subject: [PATCH 2/9] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4a899cd3..745151b3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v6.13.0 +- [#2445](https://github.com/xmrig/xmrig/pull/2445) Added support for solo mining with miner signatures for the upcoming Wownero fork. + # v6.12.2 - [#2280](https://github.com/xmrig/xmrig/issues/2280) GPU backends are now disabled in benchmark mode. - [#2322](https://github.com/xmrig/xmrig/pull/2322) Improved MSR compatibility with recent Linux kernels and updated `randomx_boost.sh`. From 9f778742a6f44881aa687f0bfd037ed139c92c0b Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 1 Jul 2021 20:03:52 +0700 Subject: [PATCH 3/9] v6.13.0 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 744b538e0..7641dc5c9 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.13.0-dev" +#define APP_VERSION "6.13.0" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" From 1b4abe1e981799b70dc5c5d0924e3b2ab118990f Mon Sep 17 00:00:00 2001 From: SChernykh Date: Thu, 1 Jul 2021 19:31:55 +0200 Subject: [PATCH 4/9] Fix: don't send miner signature during regular mining --- src/backend/cpu/CpuWorker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index fc7d8bf3b..085bccb6c 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -329,7 +329,7 @@ void xmrig::CpuWorker::start() else # endif if (value < job.target()) { - JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), miner_signature_saved); + JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), job.hasMinerSignature() ? miner_signature_saved : nullptr); } } m_count += N; From 0243789c04855adfaabe74c4580e57bc7044a8bb Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 2 Jul 2021 00:36:32 +0700 Subject: [PATCH 5/9] v6.13.1-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 7641dc5c9..a54fab1a2 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.13.0" +#define APP_VERSION "6.13.1-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 13 -#define APP_VER_PATCH 0 +#define APP_VER_PATCH 1 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From 9a77d39a3f62c9a14a176a210d0e7bdc9e612ce7 Mon Sep 17 00:00:00 2001 From: xmrig Date: Sat, 3 Jul 2021 15:16:47 +0700 Subject: [PATCH 6/9] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 745151b3e..d1f4b4612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v6.13.1 +- [#2468](https://github.com/xmrig/xmrig/pull/2468) Fixed regression in previous version: don't send miner signature during regular mining. + # v6.13.0 - [#2445](https://github.com/xmrig/xmrig/pull/2445) Added support for solo mining with miner signatures for the upcoming Wownero fork. From 02b2b87bb685ab83b132267aa3c2de0766f16b8b Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 3 Jul 2021 15:29:49 +0700 Subject: [PATCH 7/9] v6.13.1 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index a54fab1a2..4d7714fdd 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.13.1-dev" +#define APP_VERSION "6.13.1" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" From 7177b42903af6856ff06bee9be2850d6a92dcb96 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 3 Jul 2021 16:00:30 +0700 Subject: [PATCH 8/9] v6.13.2-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 4d7714fdd..5dfc7b2b7 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.13.1" +#define APP_VERSION "6.13.2-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 13 -#define APP_VER_PATCH 1 +#define APP_VER_PATCH 2 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From 3f2dfa42794fc7a097fa55d426bdfa4f0dc22fdd Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 5 Jul 2021 02:31:29 +0700 Subject: [PATCH 9/9] Sync with proxy. --- src/base/net/stratum/Client.cpp | 15 ++++----- src/base/net/stratum/Client.h | 4 +-- src/base/net/stratum/Job.cpp | 60 ++++++++++++++++++++++----------- src/base/net/stratum/Job.h | 23 +++++++------ 4 files changed, 63 insertions(+), 39 deletions(-) diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 1871b6df0..95e1d8d05 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -6,8 +6,8 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2019 jtgrassie - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -225,6 +225,10 @@ int64_t xmrig::Client::submit(const JobResult &result) if (result.minerSignature()) { params.AddMember("sig", StringRef(signature), allocator); } +# else + if (result.sig) { + params.AddMember("sig", StringRef(result.sig), allocator); + } # endif if (has() && result.algorithm.isValid()) { @@ -440,12 +444,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code) return false; } -# ifndef XMRIG_PROXY_PROJECT - uint8_t signatureKeyBuf[32 * 2]; - if (Cvt::fromHex(signatureKeyBuf, sizeof(signatureKeyBuf), Json::getValue(params, "sig_key"))) { - job.setEphemeralKeys(signatureKeyBuf, signatureKeyBuf + 32); - } -# endif + job.setSigKey(Json::getString(params, "sig_key")); m_job.setClientId(m_rpcId); diff --git a/src/base/net/stratum/Client.h b/src/base/net/stratum/Client.h index fdaac9f15..d9164b8a3 100644 --- a/src/base/net/stratum/Client.h +++ b/src/base/net/stratum/Client.h @@ -6,8 +6,8 @@ * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2019 jtgrassie - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index c92f6f015..5e0c0f489 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -7,8 +7,8 @@ * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2019 Howard Chu - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -144,6 +144,25 @@ void xmrig::Job::setDiff(uint64_t diff) } +void xmrig::Job::setSigKey(const char *sig_key) +{ + constexpr const size_t size = 64; + + if (!sig_key || strlen(sig_key) != size * 2) { + return; + } + +# ifndef XMRIG_PROXY_PROJECT + const auto buf = Cvt::fromHex(sig_key, size * 2); + if (buf.size() == size) { + setEphemeralKeys(buf.data(), buf.data() + 32); + } +# else + m_rawSigKey = sig_key; +# endif +} + + void xmrig::Job::copy(const Job &other) { m_algorithm = other.m_algorithm; @@ -164,6 +183,7 @@ void xmrig::Job::copy(const Job &other) # ifdef XMRIG_PROXY_PROJECT m_rawSeedHash = other.m_rawSeedHash; + m_rawSigKey = other.m_rawSigKey; memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob)); memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget)); @@ -215,6 +235,7 @@ void xmrig::Job::move(Job &&other) # ifdef XMRIG_PROXY_PROJECT m_rawSeedHash = std::move(other.m_rawSeedHash); + m_rawSigKey = std::move(other.m_rawSigKey); memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob)); memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget)); @@ -229,10 +250,11 @@ void xmrig::Job::move(Job &&other) memcpy(m_viewSecretKey, other.m_viewSecretKey, sizeof(m_viewSecretKey)); memcpy(m_spendPublicKey, other.m_spendPublicKey, sizeof(m_spendPublicKey)); memcpy(m_viewPublicKey, other.m_viewPublicKey, sizeof(m_viewPublicKey)); - m_minerTxPrefix = std::move(other.m_minerTxPrefix); - m_minerTxEphPubKeyOffset = other.m_minerTxEphPubKeyOffset; - m_minerTxPubKeyOffset = other.m_minerTxPubKeyOffset; - m_minerTxMerkleTreeBranch = std::move(other.m_minerTxMerkleTreeBranch); + + m_minerTxPrefix = std::move(other.m_minerTxPrefix); + m_minerTxEphPubKeyOffset = other.m_minerTxEphPubKeyOffset; + m_minerTxPubKeyOffset = other.m_minerTxPubKeyOffset; + m_minerTxMerkleTreeBranch = std::move(other.m_minerTxMerkleTreeBranch); # else memcpy(m_ephPublicKey, other.m_ephPublicKey, sizeof(m_ephPublicKey)); memcpy(m_ephSecretKey, other.m_ephSecretKey, sizeof(m_ephSecretKey)); @@ -245,26 +267,27 @@ void xmrig::Job::move(Job &&other) #ifdef XMRIG_PROXY_PROJECT -void xmrig::Job::setSpendSecretKey(uint8_t* key) +void xmrig::Job::setSpendSecretKey(const uint8_t *key) { m_hasMinerSignature = true; memcpy(m_spendSecretKey, key, sizeof(m_spendSecretKey)); - xmrig::derive_view_secret_key(m_spendSecretKey, m_viewSecretKey); - xmrig::secret_key_to_public_key(m_spendSecretKey, m_spendPublicKey); - xmrig::secret_key_to_public_key(m_viewSecretKey, m_viewPublicKey); + + derive_view_secret_key(m_spendSecretKey, m_viewSecretKey); + secret_key_to_public_key(m_spendSecretKey, m_spendPublicKey); + secret_key_to_public_key(m_viewSecretKey, m_viewPublicKey); } -void xmrig::Job::setMinerTx(const uint8_t* begin, const uint8_t* end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, const Buffer& minerTxMerkleTreeBranch) +void xmrig::Job::setMinerTx(const uint8_t *begin, const uint8_t *end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, const Buffer &minerTxMerkleTreeBranch) { m_minerTxPrefix.assign(begin, end); - m_minerTxEphPubKeyOffset = minerTxEphPubKeyOffset; - m_minerTxPubKeyOffset = minerTxPubKeyOffset; - m_minerTxMerkleTreeBranch = minerTxMerkleTreeBranch; + m_minerTxEphPubKeyOffset = minerTxEphPubKeyOffset; + m_minerTxPubKeyOffset = minerTxPubKeyOffset; + m_minerTxMerkleTreeBranch = minerTxMerkleTreeBranch; } -void xmrig::Job::generateHashingBlob(String& blob, String& signatureData) const +void xmrig::Job::generateHashingBlob(String &signatureData) { uint8_t* eph_public_key = m_minerTxPrefix.data() + m_minerTxEphPubKeyOffset; uint8_t* txkey_pub = m_minerTxPrefix.data() + m_minerTxPubKeyOffset; @@ -285,15 +308,14 @@ void xmrig::Job::generateHashingBlob(String& blob, String& signatureData) const generate_key_derivation(txkey_pub, m_viewSecretKey, derivation); derive_secret_key(derivation, 0, m_spendSecretKey, buf + 64); - signatureData = xmrig::Cvt::toHex(buf, sizeof(buf)); + signatureData = Cvt::toHex(buf, sizeof(buf)); uint8_t root_hash[32]; const uint8_t* p = m_minerTxPrefix.data(); - xmrig::BlockTemplate::CalculateRootHash(p, p + m_minerTxPrefix.size(), m_minerTxMerkleTreeBranch, root_hash); + BlockTemplate::CalculateRootHash(p, p + m_minerTxPrefix.size(), m_minerTxMerkleTreeBranch, root_hash); - blob = rawBlob(); const uint64_t offset = nonceOffset() + nonceSize() + BlockTemplate::SIGNATURE_SIZE + 2 /* vote */; - xmrig::Cvt::toHex(blob.data() + offset * 2, 64, root_hash, 32); + Cvt::toHex(m_rawBlob + offset * 2, 64, root_hash, 32); } diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 85b01e789..42e6947f3 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -7,8 +7,8 @@ * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2019 Howard Chu - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,6 +63,7 @@ public: bool setSeedHash(const char *hash); bool setTarget(const char *target); void setDiff(uint64_t diff); + void setSigKey(const char *sig_key); inline bool isNicehash() const { return m_nicehash; } inline bool isValid() const { return (m_size > 0 && m_diff > 0) || !m_poolWallet.isEmpty(); } @@ -102,6 +103,7 @@ public: inline const char *rawBlob() const { return m_rawBlob; } inline const char *rawTarget() const { return m_rawTarget; } inline const String &rawSeedHash() const { return m_rawSeedHash; } + inline const String &rawSigKey() const { return m_rawSigKey; } # endif static inline uint64_t toDiff(uint64_t target) { return target ? (0xFFFFFFFFFFFFFFFFULL / target) : 0; } @@ -117,13 +119,13 @@ public: # endif # ifdef XMRIG_PROXY_PROJECT - void setSpendSecretKey(uint8_t* key); - void setMinerTx(const uint8_t* begin, const uint8_t* end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, const Buffer& minerTxMerkleTreeBranch); - void generateHashingBlob(String& blob, String& signatureData) const; + void setSpendSecretKey(const uint8_t *key); + void setMinerTx(const uint8_t *begin, const uint8_t *end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, const Buffer &minerTxMerkleTreeBranch); + void generateHashingBlob(String &signatureData); # else inline const uint8_t* ephSecretKey() const { return m_hasMinerSignature ? m_ephSecretKey : nullptr; } - inline void setEphemeralKeys(uint8_t* pub_key, uint8_t* sec_key) + inline void setEphemeralKeys(const uint8_t *pub_key, const uint8_t *sec_key) { m_hasMinerSignature = true; memcpy(m_ephPublicKey, pub_key, sizeof(m_ephSecretKey)); @@ -158,12 +160,13 @@ private: char m_rawBlob[kMaxBlobSize * 2 + 8]{}; char m_rawTarget[24]{}; String m_rawSeedHash; + String m_rawSigKey; // Miner signatures - uint8_t m_spendSecretKey[32]; - uint8_t m_viewSecretKey[32]; - uint8_t m_spendPublicKey[32]; - uint8_t m_viewPublicKey[32]; + uint8_t m_spendSecretKey[32]{}; + uint8_t m_viewSecretKey[32]{}; + uint8_t m_spendPublicKey[32]{}; + uint8_t m_viewPublicKey[32]{}; mutable Buffer m_minerTxPrefix; size_t m_minerTxEphPubKeyOffset = 0; size_t m_minerTxPubKeyOffset = 0;