From 98e33747a4b0878ff452e1b3768c2dc1ab0cf107 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 16 Aug 2022 17:00:02 +0700 Subject: [PATCH 1/9] v6.18.1-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 200d4068..54fb60a4 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define APP_ID "xmrig-proxy" #define APP_NAME "xmrig-proxy" #define APP_DESC "XMRig Stratum proxy" -#define APP_VERSION "6.18.0" +#define APP_VERSION "6.18.1-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2022 xmrig.com" @@ -30,7 +30,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 18 -#define APP_VER_PATCH 0 +#define APP_VER_PATCH 1 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From 0a32cc81e4be58544a6ad1a8f8866e3699b69bcd Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 29 Jan 2023 10:11:20 +0100 Subject: [PATCH 2/9] Sync with latest XMRig --- cmake/os.cmake | 2 +- src/base/kernel/Platform_unix.cpp | 28 +++++++++++++++++------- src/base/kernel/config/BaseTransform.cpp | 4 ++++ src/base/kernel/interfaces/IConfig.h | 1 + src/base/net/stratum/Client.cpp | 2 +- src/base/net/stratum/DaemonClient.cpp | 25 +++++++++++++++++++-- src/base/net/stratum/DaemonClient.h | 1 + src/base/net/stratum/Job.cpp | 21 ++++++++++++------ src/base/net/stratum/Job.h | 1 + src/base/net/stratum/Pool.cpp | 7 ++++++ src/base/net/stratum/Pool.h | 4 ++++ src/core/config/Config_platform.h | 6 +++++ src/core/config/usage.h | 2 ++ 13 files changed, 85 insertions(+), 19 deletions(-) diff --git a/cmake/os.cmake b/cmake/os.cmake index 0270cc93..c9e46165 100644 --- a/cmake/os.cmake +++ b/cmake/os.cmake @@ -15,7 +15,7 @@ else() set(XMRIG_OS_ANDROID ON) elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") set(XMRIG_OS_LINUX ON) - elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL DragonFly) set(XMRIG_OS_FREEBSD ON) endif() endif() diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index f5bbc193..4ffee214 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -16,10 +16,12 @@ * along with this program. If not, see . */ -#ifdef __FreeBSD__ +#ifdef XMRIG_OS_FREEBSD # include # include -# include +# ifndef __DragonFly__ +# include +# endif # include #endif @@ -41,11 +43,6 @@ #include "version.h" -#ifdef __FreeBSD__ -typedef cpuset_t cpu_set_t; -#endif - - char *xmrig::Platform::createUserAgent() { constexpr const size_t max = 256; @@ -74,6 +71,19 @@ char *xmrig::Platform::createUserAgent() #ifndef XMRIG_FEATURE_HWLOC +#ifdef __DragonFly__ + +bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) +{ + return true; +} + +#else + +#ifdef XMRIG_OS_FREEBSD +typedef cpuset_t cpu_set_t; +#endif + bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) { cpu_set_t mn; @@ -89,7 +99,9 @@ bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id) std::this_thread::sleep_for(std::chrono::milliseconds(1)); return result; } -#endif + +#endif // __DragonFly__ +#endif // XMRIG_FEATURE_HWLOC void xmrig::Platform::setProcessPriority(int) diff --git a/src/base/kernel/config/BaseTransform.cpp b/src/base/kernel/config/BaseTransform.cpp index c924dd59..a1b430da 100644 --- a/src/base/kernel/config/BaseTransform.cpp +++ b/src/base/kernel/config/BaseTransform.cpp @@ -247,6 +247,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch case IConfig::HttpPort: /* --http-port */ case IConfig::DonateLevelKey: /* --donate-level */ case IConfig::DaemonPollKey: /* --daemon-poll-interval */ + case IConfig::DaemonJobTimeoutKey: /* --daemon-job-timeout */ case IConfig::DnsTtlKey: /* --dns-ttl */ case IConfig::DaemonZMQPortKey: /* --daemon-zmq-port */ return transformUint64(doc, key, static_cast(strtol(arg, nullptr, 10))); @@ -360,6 +361,9 @@ void xmrig::BaseTransform::transformUint64(rapidjson::Document &doc, int key, ui case IConfig::DaemonPollKey: /* --daemon-poll-interval */ return add(doc, Pools::kPools, Pool::kDaemonPollInterval, arg); + case IConfig::DaemonJobTimeoutKey: /* --daemon-job-timeout */ + return add(doc, Pools::kPools, Pool::kDaemonJobTimeout, arg); + case IConfig::DaemonZMQPortKey: /* --daemon-zmq-port */ return add(doc, Pools::kPools, Pool::kDaemonZMQPort, arg); # endif diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index ed76f4cd..98957fc4 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -88,6 +88,7 @@ class IConfig DaemonZMQPortKey = 1056, HugePagesJitKey = 1057, RotationKey = 1058, + DaemonJobTimeoutKey = 1059, // xmrig common CPUPriorityKey = 1021, diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 7abb7253..dfe2d664 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -1018,7 +1018,7 @@ void xmrig::Client::onConnect(uv_connect_t *req, int status) if (status < 0) { if (!client->isQuiet()) { - LOG_ERR("%s " RED("connect error: ") RED_BOLD("\"%s\""), client->tag(), uv_strerror(status)); + LOG_ERR("%s %s " RED("connect error: ") RED_BOLD("\"%s\""), client->tag(), client->ip().data(), uv_strerror(status)); } if (client->state() == ReconnectingState || client->state() == ClosingState) { diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 821045e9..10c04116 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -66,7 +66,6 @@ Storage DaemonClient::m_storage; static const char* kBlocktemplateBlob = "blocktemplate_blob"; static const char* kBlockhashingBlob = "blockhashing_blob"; -static const char* kLastError = "lasterror"; static const char *kGetHeight = "/getheight"; static const char *kGetInfo = "/getinfo"; static const char *kHash = "hash"; @@ -304,6 +303,18 @@ void xmrig::DaemonClient::onHttpData(const HttpData &data) void xmrig::DaemonClient::onTimer(const Timer *) { + if (m_pool.zmq_port() >= 0) { + m_prevHash = nullptr; + m_blocktemplateRequestHash = nullptr; + send(kGetHeight); + return; + } + + if (Chrono::steadyMSecs() >= m_jobSteadyMs + m_pool.jobTimeout()) { + m_prevHash = nullptr; + m_blocktemplateRequestHash = nullptr; + } + if (m_state == ConnectingState) { connect(); } @@ -353,7 +364,7 @@ void xmrig::DaemonClient::onResolved(const DnsRecords &records, int status, cons bool xmrig::DaemonClient::isOutdated(uint64_t height, const char *hash) const { - return m_job.height() != height || m_prevHash != hash; + return m_job.height() != height || m_prevHash != hash || Chrono::steadyMSecs() >= m_jobSteadyMs + m_pool.jobTimeout(); } @@ -469,6 +480,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code) m_job = std::move(job); m_blocktemplateStr = std::move(blocktemplate); m_prevHash = Json::getString(params, "prev_hash"); + m_jobSteadyMs = Chrono::steadyMSecs(); if (m_state == ConnectingState) { setState(ConnectedState); @@ -597,6 +609,10 @@ void xmrig::DaemonClient::setState(SocketState state) const uint64_t interval = std::max(20, m_pool.pollInterval()); m_timer->start(interval, interval); } + else { + const uint64_t t = m_pool.jobTimeout(); + m_timer->start(t, t); + } } break; @@ -866,7 +882,12 @@ void xmrig::DaemonClient::ZMQParse() // Clear previous hash and check daemon height to guarantee that xmrig will call get_block_template RPC later // We can't call get_block_template directly because daemon is not ready yet m_prevHash = nullptr; + m_blocktemplateRequestHash = nullptr; send(kGetHeight); + + const uint64_t t = m_pool.jobTimeout(); + m_timer->stop(); + m_timer->start(t, t); } diff --git a/src/base/net/stratum/DaemonClient.h b/src/base/net/stratum/DaemonClient.h index 7880de40..94d2b973 100644 --- a/src/base/net/stratum/DaemonClient.h +++ b/src/base/net/stratum/DaemonClient.h @@ -104,6 +104,7 @@ class DaemonClient : public BaseClient, public IDnsListener, public ITimerListen String m_blocktemplateStr; String m_currentJobId; String m_prevHash; + uint64_t m_jobSteadyMs = 0; String m_tlsFingerprint; String m_tlsVersion; Timer *m_timer; diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index 7f5d8d3f..56f5de80 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -48,7 +48,13 @@ xmrig::Job::Job(bool nicehash, const Algorithm &algorithm, const String &clientI bool xmrig::Job::isEqual(const Job &other) const { - return m_id == other.m_id && m_clientId == other.m_clientId && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0 && m_target == other.m_target; + return m_id == other.m_id && m_clientId == other.m_clientId && isEqualBlob(other) && m_target == other.m_target; +} + + +bool xmrig::Job::isEqualBlob(const Job &other) const +{ + return (m_size == other.m_size) && (memcmp(m_blob, other.m_blob, m_size) == 0); } @@ -58,19 +64,19 @@ bool xmrig::Job::setBlob(const char *blob) return false; } - m_size = strlen(blob); - if (m_size % 2 != 0) { + size_t size = strlen(blob); + if (size % 2 != 0) { return false; } - m_size /= 2; + size /= 2; const size_t minSize = nonceOffset() + nonceSize(); - if (m_size < minSize || m_size >= sizeof(m_blob)) { + if (size < minSize || size >= sizeof(m_blob)) { return false; } - if (!Cvt::fromHex(m_blob, sizeof(m_blob), blob, m_size * 2)) { + if (!Cvt::fromHex(m_blob, sizeof(m_blob), blob, size * 2)) { return false; } @@ -80,9 +86,10 @@ bool xmrig::Job::setBlob(const char *blob) # ifdef XMRIG_PROXY_PROJECT memset(m_rawBlob, 0, sizeof(m_rawBlob)); - memcpy(m_rawBlob, blob, m_size * 2); + memcpy(m_rawBlob, blob, size * 2); # endif + m_size = size; return true; } diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 3fb31baa..e314a266 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -59,6 +59,7 @@ class Job ~Job() = default; bool isEqual(const Job &other) const; + bool isEqualBlob(const Job &other) const; bool setBlob(const char *blob); bool setSeedHash(const char *hash); bool setTarget(const char *target); diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index 7a58f4cb..b1773c46 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -65,6 +65,7 @@ const char *Pool::kAlgo = "algo"; const char *Pool::kCoin = "coin"; const char *Pool::kDaemon = "daemon"; const char *Pool::kDaemonPollInterval = "daemon-poll-interval"; +const char *Pool::kDaemonJobTimeout = "daemon-job-timeout"; const char *Pool::kDaemonZMQPort = "daemon-zmq-port"; const char *Pool::kEnabled = "enabled"; const char *Pool::kFingerprint = "tls-fingerprint"; @@ -88,6 +89,7 @@ const char *Pool::kNicehashHost = "nicehash.com"; xmrig::Pool::Pool(const char *url) : m_flags(1 << FLAG_ENABLED), m_pollInterval(kDefaultPollInterval), + m_jobTimeout(kDefaultJobTimeout), m_url(url) { } @@ -101,6 +103,7 @@ xmrig::Pool::Pool(const char *host, uint16_t port, const char *user, const char m_user(user), m_spendSecretKey(spendSecretKey), m_pollInterval(kDefaultPollInterval), + m_jobTimeout(kDefaultJobTimeout), m_url(host, port, tls) { m_flags.set(FLAG_NICEHASH, nicehash || strstr(host, kNicehashHost)); @@ -111,6 +114,7 @@ xmrig::Pool::Pool(const char *host, uint16_t port, const char *user, const char xmrig::Pool::Pool(const rapidjson::Value &object) : m_flags(1 << FLAG_ENABLED), m_pollInterval(kDefaultPollInterval), + m_jobTimeout(kDefaultJobTimeout), m_url(Json::getString(object, kUrl)) { if (!m_url.isValid()) { @@ -123,6 +127,7 @@ xmrig::Pool::Pool(const rapidjson::Value &object) : m_rigId = Json::getString(object, kRigId); m_fingerprint = Json::getString(object, kFingerprint); m_pollInterval = Json::getUint64(object, kDaemonPollInterval, kDefaultPollInterval); + m_jobTimeout = Json::getUint64(object, kDaemonJobTimeout, kDefaultJobTimeout); m_algorithm = Json::getString(object, kAlgo); m_coin = Json::getString(object, kCoin); m_daemon = Json::getString(object, kSelfSelect); @@ -207,6 +212,7 @@ bool xmrig::Pool::isEqual(const Pool &other) const && m_url == other.m_url && m_user == other.m_user && m_pollInterval == other.m_pollInterval + && m_jobTimeout == other.m_jobTimeout && m_daemon == other.m_daemon && m_proxy == other.m_proxy ); @@ -299,6 +305,7 @@ rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const if (m_mode == MODE_DAEMON) { obj.AddMember(StringRef(kDaemonPollInterval), m_pollInterval, allocator); + obj.AddMember(StringRef(kDaemonJobTimeout), m_jobTimeout, allocator); obj.AddMember(StringRef(kDaemonZMQPort), m_zmqPort, allocator); } else { diff --git a/src/base/net/stratum/Pool.h b/src/base/net/stratum/Pool.h index 78684510..8374f20f 100644 --- a/src/base/net/stratum/Pool.h +++ b/src/base/net/stratum/Pool.h @@ -59,6 +59,7 @@ class Pool static const char *kCoin; static const char *kDaemon; static const char *kDaemonPollInterval; + static const char* kDaemonJobTimeout; static const char *kEnabled; static const char *kFingerprint; static const char *kKeepalive; @@ -78,6 +79,7 @@ class Pool constexpr static int kKeepAliveTimeout = 60; constexpr static uint16_t kDefaultPort = 3333; constexpr static uint64_t kDefaultPollInterval = 1000; + constexpr static uint64_t kDefaultJobTimeout = 15000; Pool() = default; Pool(const char *host, uint16_t port, const char *user, const char *password, const char* spendSecretKey, int keepAlive, bool nicehash, bool tls, Mode mode); @@ -110,6 +112,7 @@ class Pool inline uint16_t port() const { return m_url.port(); } inline int zmq_port() const { return m_zmqPort; } inline uint64_t pollInterval() const { return m_pollInterval; } + inline uint64_t jobTimeout() const { return m_jobTimeout; } inline void setAlgo(const Algorithm &algorithm) { m_algorithm = algorithm; } inline void setUrl(const char *url) { m_url = Url(url); } inline void setPassword(const String &password) { m_password = password; } @@ -156,6 +159,7 @@ class Pool String m_user; String m_spendSecretKey; uint64_t m_pollInterval = kDefaultPollInterval; + uint64_t m_jobTimeout = kDefaultJobTimeout; Url m_daemon; Url m_url; int m_zmqPort = -1; diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index 2c090e3b..e229220d 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -54,6 +54,12 @@ static struct option const options[] = { { "http-access-token", 1, nullptr, IConfig::HttpAccessTokenKey}, { "http-port", 1, nullptr, IConfig::HttpPort }, { "http-no-restricted",0, nullptr, IConfig::HttpRestrictedKey }, + { "daemon", 0, nullptr, IConfig::DaemonKey }, + { "daemon-poll-interval", 1, nullptr, IConfig::DaemonPollKey }, + { "daemon-job-timeout", 1, nullptr, IConfig::DaemonJobTimeoutKey }, + { "self-select", 1, nullptr, IConfig::SelfSelectKey }, + { "submit-to-origin", 0, nullptr, IConfig::SubmitToOriginKey }, + { "daemon-zmq-port", 1, nullptr, IConfig::DaemonZMQPortKey }, { "background", 0, nullptr, IConfig::BackgroundKey }, { "bind", 1, nullptr, IConfig::BindKey }, { "config", 1, nullptr, IConfig::ConfigKey }, diff --git a/src/core/config/usage.h b/src/core/config/usage.h index d55b61a5..8bc4fe34 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -64,7 +64,9 @@ static inline const std::string &usage() # ifdef XMRIG_FEATURE_HTTP u += " --daemon use daemon RPC instead of pool for solo mining\n"; + u += " --daemon-zmq-port daemon's zmq-pub port number (only use it if daemon has it enabled)\n"; u += " --daemon-poll-interval=N daemon poll interval in milliseconds (default: 1000)\n"; + u += " --daemon-job-timeout=N daemon job timeout in milliseconds (default: 15000)\n"; u += " --self-select=URL self-select block templates from URL\n"; u += " --submit-to-origin also submit solution back to self-select URL\n"; # endif From 8b937daa7f995698fc132cdf714ab2f881caf33a Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 2 Feb 2023 11:14:29 +0700 Subject: [PATCH 3/9] v6.19.0-dev --- CHANGELOG.md | 3 +++ src/version.h | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48472f02..655682cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v6.19.0 +- [#530](https://github.com/xmrig/xmrig-proxy/pull/530) Sync with latest XMRig. + # v6.18.0 - Sync changes with XMRig v6.18.0 - [#499](https://github.com/xmrig/xmrig-proxy/pull/499) Fixed socket and memory leak. diff --git a/src/version.h b/src/version.h index 54fb60a4..1e1a20d3 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2022 SChernykh - * Copyright (c) 2016-2022 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -22,18 +22,20 @@ #define APP_ID "xmrig-proxy" #define APP_NAME "xmrig-proxy" #define APP_DESC "XMRig Stratum proxy" -#define APP_VERSION "6.18.1-dev" +#define APP_VERSION "6.19.0-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" -#define APP_COPYRIGHT "Copyright (C) 2016-2022 xmrig.com" +#define APP_COPYRIGHT "Copyright (C) 2016-2023 xmrig.com" #define APP_KIND "proxy" #define APP_VER_MAJOR 6 -#define APP_VER_MINOR 18 -#define APP_VER_PATCH 1 +#define APP_VER_MINOR 19 +#define APP_VER_PATCH 0 #ifdef _MSC_VER -# if (_MSC_VER >= 1920) +# if (_MSC_VER >= 1930) +# define MSVC_VERSION 2022 +# elif (_MSC_VER >= 1920 && _MSC_VER < 1930) # define MSVC_VERSION 2019 # elif (_MSC_VER >= 1910 && _MSC_VER < 1920) # define MSVC_VERSION 2017 @@ -50,4 +52,4 @@ # endif #endif -#endif /* XMRIG_VERSION_H */ +#endif // XMRIG_VERSION_H From 58b1c890c7be29c79eec0f4449ac5c66c232d7ec Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 2 Feb 2023 11:52:12 +0700 Subject: [PATCH 4/9] v6.19.0 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 1e1a20d3..f3b98a28 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define APP_ID "xmrig-proxy" #define APP_NAME "xmrig-proxy" #define APP_DESC "XMRig Stratum proxy" -#define APP_VERSION "6.19.0-dev" +#define APP_VERSION "6.19.0" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2023 xmrig.com" From 52aec4d9572ca98033613a18e5b4a6a63149d9bf Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 2 Feb 2023 12:26:46 +0700 Subject: [PATCH 5/9] v6.19.1-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index f3b98a28..07c4c493 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define APP_ID "xmrig-proxy" #define APP_NAME "xmrig-proxy" #define APP_DESC "XMRig Stratum proxy" -#define APP_VERSION "6.19.0" +#define APP_VERSION "6.19.1-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2023 xmrig.com" @@ -30,7 +30,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 19 -#define APP_VER_PATCH 0 +#define APP_VER_PATCH 1 #ifdef _MSC_VER # if (_MSC_VER >= 1930) From 207072653f36a3134c353e89f54e1a081f57af84 Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 16 Mar 2023 23:45:49 +0700 Subject: [PATCH 6/9] Sync changes with XMRig. --- src/base/kernel/Platform.cpp | 10 +++++---- src/base/net/dns/DnsRecord.cpp | 8 +++---- src/base/net/dns/DnsUvBackend.cpp | 29 +++++++++++++++---------- src/base/net/tls/TlsContext.cpp | 36 +++++++++++++++++++++++++++++-- src/base/net/tls/TlsContext.h | 12 +++++------ src/base/net/tls/TlsGen.cpp | 8 +++++-- src/base/net/tls/TlsGen.h | 8 +++---- src/base/net/tools/Storage.h | 9 +++++--- src/base/tools/Object.h | 13 ++++++----- 9 files changed, 91 insertions(+), 42 deletions(-) diff --git a/src/base/kernel/Platform.cpp b/src/base/kernel/Platform.cpp index ef2b67eb..9baf77c2 100644 --- a/src/base/kernel/Platform.cpp +++ b/src/base/kernel/Platform.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -16,7 +16,6 @@ * along with this program. If not, see . */ - #include "base/kernel/Platform.h" @@ -42,9 +41,12 @@ void xmrig::Platform::init(const char *userAgent) # ifdef XMRIG_FEATURE_TLS SSL_library_init(); SSL_load_error_strings(); + +# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) ERR_load_BIO_strings(); ERR_load_crypto_strings(); - SSL_load_error_strings(); +# endif + OpenSSL_add_all_digests(); # endif diff --git a/src/base/net/dns/DnsRecord.cpp b/src/base/net/dns/DnsRecord.cpp index bfa84613..3bf8f097 100644 --- a/src/base/net/dns/DnsRecord.cpp +++ b/src/base/net/dns/DnsRecord.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -46,11 +46,11 @@ xmrig::String xmrig::DnsRecord::ip() const if (m_type == AAAA) { buf = new char[45](); - uv_ip6_name(reinterpret_cast(m_data), buf, 45); + uv_ip6_name(reinterpret_cast(m_data), buf, 45); } else { buf = new char[16](); - uv_ip4_name(reinterpret_cast(m_data), buf, 16); + uv_ip4_name(reinterpret_cast(m_data), buf, 16); } return buf; diff --git a/src/base/net/dns/DnsUvBackend.cpp b/src/base/net/dns/DnsUvBackend.cpp index 8de95df5..33f27f95 100644 --- a/src/base/net/dns/DnsUvBackend.cpp +++ b/src/base/net/dns/DnsUvBackend.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -28,18 +28,19 @@ namespace xmrig { -static Storage* storage = nullptr; -Storage& DnsUvBackend::getStorage() +static Storage *storage = nullptr; + + +Storage &DnsUvBackend::getStorage() { - if (storage == nullptr) storage = new Storage(); + if (storage == nullptr) { + storage = new Storage(); + } + return *storage; } -void DnsUvBackend::releaseStorage() -{ - delete storage; -} static addrinfo hints{}; @@ -61,8 +62,14 @@ xmrig::DnsUvBackend::DnsUvBackend() xmrig::DnsUvBackend::~DnsUvBackend() { - getStorage().release(m_key); - releaseStorage(); + assert(storage); + + storage->release(m_key); + + if (storage->isEmpty()) { + delete storage; + storage = nullptr; + } } diff --git a/src/base/net/tls/TlsContext.cpp b/src/base/net/tls/TlsContext.cpp index e3621797..54b904ea 100644 --- a/src/base/net/tls/TlsContext.cpp +++ b/src/base/net/tls/TlsContext.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018 Lee Clagett - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -45,6 +45,7 @@ namespace xmrig { // https://wiki.openssl.org/index.php/Diffie-Hellman_parameters +#if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) static DH *get_dh2048() { static unsigned char dhp_2048[] = { @@ -96,6 +97,8 @@ static DH *get_dh2048() return dh; } +#endif + } // namespace xmrig @@ -191,6 +194,7 @@ bool xmrig::TlsContext::setCipherSuites(const char *ciphersuites) bool xmrig::TlsContext::setDH(const char *dhparam) { +# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) DH *dh = nullptr; if (dhparam != nullptr) { @@ -225,6 +229,34 @@ bool xmrig::TlsContext::setDH(const char *dhparam) return false; } +# else + if (dhparam != nullptr) { + EVP_PKEY *dh = nullptr; + BIO *bio = BIO_new_file(Env::expand(dhparam), "r"); + + if (bio) { + dh = PEM_read_bio_Parameters(bio, nullptr); + BIO_free(bio); + } + + if (!dh) { + LOG_ERR("PEM_read_bio_Parameters(\"%s\") failed.", dhparam); + + return false; + } + + if (SSL_CTX_set0_tmp_dh_pkey(m_ctx, dh) != 1) { + EVP_PKEY_free(dh); + + LOG_ERR("SSL_CTX_set0_tmp_dh_pkey(\"%s\") failed.", dhparam); + + return false; + } + } + else { + SSL_CTX_set_dh_auto(m_ctx, 1); + } +# endif return true; } diff --git a/src/base/net/tls/TlsContext.h b/src/base/net/tls/TlsContext.h index 9a9b3cb1..0bb7eec3 100644 --- a/src/base/net/tls/TlsContext.h +++ b/src/base/net/tls/TlsContext.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018 Lee Clagett - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -24,9 +24,6 @@ #include "base/tools/Object.h" -#include - - using SSL_CTX = struct ssl_ctx_st; @@ -60,6 +57,7 @@ class TlsContext }; -} /* namespace xmrig */ +} // namespace xmrig + -#endif /* XMRIG_TLSCONTEXT_H */ +#endif // XMRIG_TLSCONTEXT_H diff --git a/src/base/net/tls/TlsGen.cpp b/src/base/net/tls/TlsGen.cpp index 42892053..ad2e648b 100644 --- a/src/base/net/tls/TlsGen.cpp +++ b/src/base/net/tls/TlsGen.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -33,6 +33,7 @@ static const char *kLocalhost = "localhost"; static EVP_PKEY *generate_pkey() { +# if OPENSSL_VERSION_NUMBER < 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) auto pkey = EVP_PKEY_new(); if (!pkey) { return nullptr; @@ -53,6 +54,9 @@ static EVP_PKEY *generate_pkey() BN_free(exponent); return pkey; +# else + return EVP_RSA_gen(2048); +# endif } diff --git a/src/base/net/tls/TlsGen.h b/src/base/net/tls/TlsGen.h index c471c8ca..193dd2d5 100644 --- a/src/base/net/tls/TlsGen.h +++ b/src/base/net/tls/TlsGen.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -55,7 +55,7 @@ class TlsGen }; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_TLSGEN_H */ +#endif // XMRIG_TLSGEN_H diff --git a/src/base/net/tools/Storage.h b/src/base/net/tools/Storage.h index e23e8666..390101c3 100644 --- a/src/base/net/tools/Storage.h +++ b/src/base/net/tools/Storage.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2023 SChernykh + * Copyright 2016-2023 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 @@ -42,7 +42,7 @@ class Storage } - inline void *ptr(uintptr_t id) { return reinterpret_cast(id); } + inline TYPE *ptr(uintptr_t id) { return reinterpret_cast(id); } inline TYPE *get(const void *id) const { return get(reinterpret_cast(id)); } @@ -56,6 +56,9 @@ class Storage return m_data.at(id); } + inline bool isEmpty() const { return m_data.empty(); } + inline size_t size() const { return m_data.size(); } + inline void remove(const void *id) { delete release(reinterpret_cast(id)); } inline void remove(uintptr_t id) { delete release(id); } diff --git a/src/base/tools/Object.h b/src/base/tools/Object.h index 00bd9315..f67464ab 100644 --- a/src/base/tools/Object.h +++ b/src/base/tools/Object.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2023 SChernykh + * Copyright (c) 2016-2023 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 @@ -20,7 +20,9 @@ #define XMRIG_OBJECT_H -#include +#include +#include +#include namespace xmrig { @@ -41,6 +43,7 @@ namespace xmrig { X &operator=(X &&other) = delete; -} /* namespace xmrig */ +} // namespace xmrig -#endif /* XMRIG_OBJECT_H */ + +#endif // XMRIG_OBJECT_H From c5e94e1ea472c023371bc436e2d6c93465f23590 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Mon, 3 Apr 2023 14:44:49 +0200 Subject: [PATCH 7/9] Added view tag calculation --- src/base/net/stratum/DaemonClient.cpp | 21 +++++++++++++++++---- src/base/net/stratum/DaemonClient.h | 2 +- src/base/net/stratum/Job.cpp | 17 +++++++++++++---- src/base/net/stratum/Job.h | 8 ++++++-- src/base/tools/cryptonote/Signatures.cpp | 18 +++++++++++++++++- src/base/tools/cryptonote/Signatures.h | 2 +- src/net/JobResult.cpp | 3 ++- src/net/JobResult.h | 3 ++- src/proxy/Miner.cpp | 8 ++++++-- src/proxy/Miner.h | 1 + src/proxy/events/SubmitEvent.h | 8 ++++---- 11 files changed, 70 insertions(+), 21 deletions(-) diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 10c04116..9b1cdc42 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -148,6 +148,11 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result) memcpy(data + sig_offset * 2, result.sig, 64 * 2); memcpy(data + m_blocktemplate.offset(BlockTemplate::TX_PUBKEY_OFFSET) * 2, result.sig_data, 32 * 2); memcpy(data + m_blocktemplate.offset(BlockTemplate::EPH_PUBLIC_KEY_OFFSET) * 2, result.sig_data + 32 * 2, 32 * 2); + + // Handle view tag for txout_to_tagged_key outputs + if (m_blocktemplate.outputType() == 3) { + Cvt::toHex(data + m_blocktemplate.offset(BlockTemplate::EPH_PUBLIC_KEY_OFFSET) * 2 + 32 * 2, 2, &result.view_tag, 1); + } } if (result.extra_nonce >= 0) { @@ -178,7 +183,10 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result) m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff(), 0, result.backend); # endif - return rpcSend(doc); + std::map headers; + headers.insert({"X-Hash-Difficulty", std::to_string(result.actualDiff())}); + + return rpcSend(doc, headers); } @@ -401,7 +409,8 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code) m_blocktemplate.offset(BlockTemplate::TX_PUBKEY_OFFSET) - k, m_blocktemplate.offset(BlockTemplate::TX_EXTRA_NONCE_OFFSET) - k, m_blocktemplate.txExtraNonce().size(), - m_blocktemplate.minerTxMerkleTreeBranch() + m_blocktemplate.minerTxMerkleTreeBranch(), + m_blocktemplate.outputType() == 3 ); # endif @@ -438,7 +447,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code) } uint8_t derivation[32]; - if (!generate_key_derivation(m_blocktemplate.blob(BlockTemplate::TX_PUBKEY_OFFSET), secret_viewkey, derivation)) { + if (!generate_key_derivation(m_blocktemplate.blob(BlockTemplate::TX_PUBKEY_OFFSET), secret_viewkey, derivation, nullptr)) { return jobError("Failed to generate key derivation for miner signature."); } @@ -553,9 +562,13 @@ int64_t xmrig::DaemonClient::getBlockTemplate() } -int64_t xmrig::DaemonClient::rpcSend(const rapidjson::Document &doc) +int64_t xmrig::DaemonClient::rpcSend(const rapidjson::Document &doc, const std::map &headers) { FetchRequest req(HTTP_POST, m_pool.host(), m_pool.port(), kJsonRPC, doc, m_pool.isTLS(), isQuiet()); + for (const auto &header : headers) { + req.headers.insert(header); + } + fetch(tag(), std::move(req), m_httpListener); return m_sequence++; diff --git a/src/base/net/stratum/DaemonClient.h b/src/base/net/stratum/DaemonClient.h index 94d2b973..e852f428 100644 --- a/src/base/net/stratum/DaemonClient.h +++ b/src/base/net/stratum/DaemonClient.h @@ -86,7 +86,7 @@ class DaemonClient : public BaseClient, public IDnsListener, public ITimerListen bool parseJob(const rapidjson::Value ¶ms, int *code); bool parseResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error); int64_t getBlockTemplate(); - int64_t rpcSend(const rapidjson::Document &doc); + int64_t rpcSend(const rapidjson::Document &doc, const std::map &headers = {}); void retry(); void send(const char *path); void setState(SocketState state); diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index 56f5de80..d62e00b1 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -245,6 +245,7 @@ void xmrig::Job::copy(const Job &other) m_minerTxExtraNonceOffset = other.m_minerTxExtraNonceOffset; m_minerTxExtraNonceSize = other.m_minerTxExtraNonceSize; m_minerTxMerkleTreeBranch = other.m_minerTxMerkleTreeBranch; + m_hasViewTag = other.m_hasViewTag; # else memcpy(m_ephPublicKey, other.m_ephPublicKey, sizeof(m_ephPublicKey)); memcpy(m_ephSecretKey, other.m_ephSecretKey, sizeof(m_ephSecretKey)); @@ -300,6 +301,7 @@ void xmrig::Job::move(Job &&other) m_minerTxExtraNonceOffset = other.m_minerTxExtraNonceOffset; m_minerTxExtraNonceSize = other.m_minerTxExtraNonceSize; m_minerTxMerkleTreeBranch = std::move(other.m_minerTxMerkleTreeBranch); + m_hasViewTag = other.m_hasViewTag; # else memcpy(m_ephPublicKey, other.m_ephPublicKey, sizeof(m_ephPublicKey)); memcpy(m_ephSecretKey, other.m_ephSecretKey, sizeof(m_ephSecretKey)); @@ -323,7 +325,7 @@ void xmrig::Job::setSpendSecretKey(const uint8_t *key) } -void xmrig::Job::setMinerTx(const uint8_t *begin, const uint8_t *end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, size_t minerTxExtraNonceOffset, size_t minerTxExtraNonceSize, const Buffer &minerTxMerkleTreeBranch) +void xmrig::Job::setMinerTx(const uint8_t *begin, const uint8_t *end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, size_t minerTxExtraNonceOffset, size_t minerTxExtraNonceSize, const Buffer &minerTxMerkleTreeBranch, bool hasViewTag) { m_minerTxPrefix.assign(begin, end); m_minerTxEphPubKeyOffset = minerTxEphPubKeyOffset; @@ -331,6 +333,13 @@ void xmrig::Job::setMinerTx(const uint8_t *begin, const uint8_t *end, size_t min m_minerTxExtraNonceOffset = minerTxExtraNonceOffset; m_minerTxExtraNonceSize = minerTxExtraNonceSize; m_minerTxMerkleTreeBranch = minerTxMerkleTreeBranch; + m_hasViewTag = hasViewTag; +} + + +void xmrig::Job::setViewTagInMinerTx(uint8_t view_tag) +{ + memcpy(m_minerTxPrefix.data() + m_minerTxEphPubKeyOffset + 32, &view_tag, 1); } @@ -340,7 +349,7 @@ void xmrig::Job::setExtraNonceInMinerTx(uint32_t extra_nonce) } -void xmrig::Job::generateSignatureData(String &signatureData) const +void xmrig::Job::generateSignatureData(String &signatureData, uint8_t& view_tag) const { uint8_t* eph_public_key = m_minerTxPrefix.data() + m_minerTxEphPubKeyOffset; uint8_t* txkey_pub = m_minerTxPrefix.data() + m_minerTxPubKeyOffset; @@ -351,14 +360,14 @@ void xmrig::Job::generateSignatureData(String &signatureData) const uint8_t derivation[32]; - generate_key_derivation(m_viewPublicKey, txkey_sec, derivation); + generate_key_derivation(m_viewPublicKey, txkey_sec, derivation, &view_tag); derive_public_key(derivation, 0, m_spendPublicKey, eph_public_key); uint8_t buf[32 * 3] = {}; memcpy(buf, txkey_pub, 32); memcpy(buf + 32, eph_public_key, 32); - generate_key_derivation(txkey_pub, m_viewSecretKey, derivation); + generate_key_derivation(txkey_pub, m_viewSecretKey, derivation, nullptr); derive_secret_key(derivation, 0, m_spendSecretKey, buf + 64); signatureData = Cvt::toHex(buf, sizeof(buf)); diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index e314a266..1ecff369 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -120,10 +120,13 @@ class Job # endif # ifdef XMRIG_PROXY_PROJECT + inline bool hasViewTag() const { return m_hasViewTag; } + void setSpendSecretKey(const uint8_t* key); - void setMinerTx(const uint8_t* begin, const uint8_t* end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, size_t minerTxExtraNonceOffset, size_t minerTxExtraNonceSize, const Buffer& minerTxMerkleTreeBranch); + void setMinerTx(const uint8_t* begin, const uint8_t* end, size_t minerTxEphPubKeyOffset, size_t minerTxPubKeyOffset, size_t minerTxExtraNonceOffset, size_t minerTxExtraNonceSize, const Buffer& minerTxMerkleTreeBranch, bool hasViewTag); + void setViewTagInMinerTx(uint8_t view_tag); void setExtraNonceInMinerTx(uint32_t extra_nonce); - void generateSignatureData(String& signatureData) const; + void generateSignatureData(String& signatureData, uint8_t& view_tag) const; void generateHashingBlob(String& blob) const; # else inline const uint8_t* ephSecretKey() const { return m_hasMinerSignature ? m_ephSecretKey : nullptr; } @@ -178,6 +181,7 @@ class Job size_t m_minerTxExtraNonceOffset = 0; size_t m_minerTxExtraNonceSize = 0; Buffer m_minerTxMerkleTreeBranch; + bool m_hasViewTag = false; # else // Miner signatures uint8_t m_ephPublicKey[32]{}; diff --git a/src/base/tools/cryptonote/Signatures.cpp b/src/base/tools/cryptonote/Signatures.cpp index 93571258..13f0c948 100644 --- a/src/base/tools/cryptonote/Signatures.cpp +++ b/src/base/tools/cryptonote/Signatures.cpp @@ -147,7 +147,7 @@ bool check_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8 } -bool generate_key_derivation(const uint8_t* key1, const uint8_t* key2, uint8_t* derivation) +bool generate_key_derivation(const uint8_t* key1, const uint8_t* key2, uint8_t* derivation, uint8_t* view_tag) { ge_p3 point; ge_p2 point2; @@ -162,6 +162,22 @@ bool generate_key_derivation(const uint8_t* key1, const uint8_t* key2, uint8_t* ge_p1p1_to_p2(&point2, &point3); ge_tobytes(derivation, &point2); + if (view_tag) { + constexpr uint8_t salt[] = "view_tag"; + constexpr size_t SALT_SIZE = sizeof(salt) - 1; + + uint8_t buf[SALT_SIZE + 32 + 1]; + memcpy(buf, salt, SALT_SIZE); + memcpy(buf + SALT_SIZE, derivation, 32); + + // Assuming output_index == 0 + buf[SALT_SIZE + 32] = 0; + + uint8_t view_tag_full[32]; + xmrig::keccak(buf, sizeof(buf), view_tag_full, sizeof(view_tag_full)); + *view_tag = view_tag_full[0]; + } + return true; } diff --git a/src/base/tools/cryptonote/Signatures.h b/src/base/tools/cryptonote/Signatures.h index 04813313..24ea9ac6 100644 --- a/src/base/tools/cryptonote/Signatures.h +++ b/src/base/tools/cryptonote/Signatures.h @@ -31,7 +31,7 @@ namespace xmrig { void generate_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8_t* sec, uint8_t* sig); bool check_signature(const uint8_t* prefix_hash, const uint8_t* pub, const uint8_t* sig); -bool generate_key_derivation(const uint8_t* key1, const uint8_t* key2, uint8_t* derivation); +bool generate_key_derivation(const uint8_t* key1, const uint8_t* key2, uint8_t* derivation, uint8_t* view_tag); void derive_secret_key(const uint8_t* derivation, size_t output_index, const uint8_t* base, uint8_t* derived_key); bool derive_public_key(const uint8_t* derivation, size_t output_index, const uint8_t* base, uint8_t* derived_key); diff --git a/src/net/JobResult.cpp b/src/net/JobResult.cpp index 91501025..37db9c2f 100644 --- a/src/net/JobResult.cpp +++ b/src/net/JobResult.cpp @@ -25,12 +25,13 @@ #include -xmrig::JobResult::JobResult(int64_t id, const char *jobId, const char *nonce, const char *result, const xmrig::Algorithm &algorithm, const char* sig, const char* sig_data, int64_t extra_nonce) : +xmrig::JobResult::JobResult(int64_t id, const char *jobId, const char *nonce, const char *result, const xmrig::Algorithm &algorithm, const char* sig, const char* sig_data, uint8_t view_tag, int64_t extra_nonce) : algorithm(algorithm), nonce(nonce), result(result), sig(sig), sig_data(sig_data), + view_tag(view_tag), id(id), extra_nonce(extra_nonce), jobId(jobId) diff --git a/src/net/JobResult.h b/src/net/JobResult.h index 9996caac..a7feb762 100644 --- a/src/net/JobResult.h +++ b/src/net/JobResult.h @@ -37,7 +37,7 @@ class JobResult static constexpr uint32_t backend = 0; JobResult() = default; - JobResult(int64_t id, const char *jobId, const char *nonce, const char *result, const xmrig::Algorithm &algorithm, const char* sig, const char* sig_data, int64_t extra_nonce); + JobResult(int64_t id, const char *jobId, const char *nonce, const char *result, const xmrig::Algorithm &algorithm, const char* sig, const char* sig_data, uint8_t view_tag, int64_t extra_nonce); bool isCompatible(uint8_t fixedByte) const; bool isValid() const; @@ -49,6 +49,7 @@ class JobResult const char *result = nullptr; const char *sig = nullptr; const char *sig_data = nullptr; + const uint8_t view_tag = 0; const int64_t id = 0; const int64_t extra_nonce = -1; String jobId; diff --git a/src/proxy/Miner.cpp b/src/proxy/Miner.cpp index 6b78ff65..c7be63d3 100644 --- a/src/proxy/Miner.cpp +++ b/src/proxy/Miner.cpp @@ -162,12 +162,16 @@ void xmrig::Miner::setJob(Job &job, int64_t extra_nonce) String tmp_blob; if (job.hasMinerSignature()) { - job.generateSignatureData(m_signatureData); + job.generateSignatureData(m_signatureData, m_viewTag); } else if (!job.rawSigKey().isNull()) { m_signatureData = job.rawSigKey(); } + if (job.hasViewTag()) { + job.setViewTagInMinerTx(m_viewTag); + } + if (extra_nonce >= 0) { m_extraNonce = extra_nonce; job.setExtraNonceInMinerTx(static_cast(m_extraNonce)); @@ -250,7 +254,7 @@ bool xmrig::Miner::parseRequest(int64_t id, const char *method, const rapidjson: Algorithm algorithm(Json::getString(params, "algo")); - SubmitEvent *event = SubmitEvent::create(this, id, Json::getString(params, "job_id"), Json::getString(params, "nonce"), Json::getString(params, "result"), algorithm, Json::getString(params, "sig"), m_signatureData, m_extraNonce); + SubmitEvent *event = SubmitEvent::create(this, id, Json::getString(params, "job_id"), Json::getString(params, "nonce"), Json::getString(params, "result"), algorithm, Json::getString(params, "sig"), m_signatureData, m_viewTag, m_extraNonce); if (!event->request.isValid() || event->request.actualDiff() < diff()) { event->reject(Error::LowDifficulty); diff --git a/src/proxy/Miner.h b/src/proxy/Miner.h index 932038b5..7ce4f451 100644 --- a/src/proxy/Miner.h +++ b/src/proxy/Miner.h @@ -147,6 +147,7 @@ class Miner : public ILineListener String m_rigId; String m_user; String m_signatureData; + uint8_t m_viewTag; Tls *m_tls = nullptr; uint16_t m_localPort; uint64_t m_customDiff = 0; diff --git a/src/proxy/events/SubmitEvent.h b/src/proxy/events/SubmitEvent.h index 55460a81..cf5fd052 100644 --- a/src/proxy/events/SubmitEvent.h +++ b/src/proxy/events/SubmitEvent.h @@ -37,9 +37,9 @@ namespace xmrig { class SubmitEvent : public MinerEvent { public: - static inline SubmitEvent *create(Miner *miner, int64_t id, const char *jobId, const char *nonce, const char *result, const Algorithm &algorithm, const char* sig, const char* sig_data, int64_t extra_nonce) + static inline SubmitEvent *create(Miner *miner, int64_t id, const char *jobId, const char *nonce, const char *result, const Algorithm &algorithm, const char* sig, const char* sig_data, uint8_t view_tag, int64_t extra_nonce) { - return new (m_buf) SubmitEvent(miner, id, jobId, nonce, result, algorithm, sig, sig_data, extra_nonce); + return new (m_buf) SubmitEvent(miner, id, jobId, nonce, result, algorithm, sig, sig_data, view_tag, extra_nonce); } @@ -54,9 +54,9 @@ class SubmitEvent : public MinerEvent protected: - inline SubmitEvent(Miner *miner, int64_t id, const char *jobId, const char *nonce, const char *result, const Algorithm &algorithm, const char* sig, const char* sig_data, int64_t extra_nonce) + inline SubmitEvent(Miner *miner, int64_t id, const char *jobId, const char *nonce, const char *result, const Algorithm &algorithm, const char* sig, const char* sig_data, uint8_t view_tag, int64_t extra_nonce) : MinerEvent(SubmitType, miner), - request(id, jobId, nonce, result, algorithm, sig, sig_data, extra_nonce), + request(id, jobId, nonce, result, algorithm, sig, sig_data, view_tag, extra_nonce), m_error(Error::NoError) {} From 67a99bc50ccd9ec98be3c4641582bc3730fe8dac Mon Sep 17 00:00:00 2001 From: xmrig Date: Mon, 3 Apr 2023 20:45:10 +0700 Subject: [PATCH 8/9] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 655682cb..dd93770a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v6.19.2 +- [#532](https://github.com/xmrig/xmrig-proxy/pull/532) Added view tag calculation (fixes Wownero solo mining issue). +- Sync with latest XMRig. + # v6.19.0 - [#530](https://github.com/xmrig/xmrig-proxy/pull/530) Sync with latest XMRig. From d6ce28a18225fa7ae2aabeb60061b8c9d419bb56 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 3 Apr 2023 22:17:52 +0700 Subject: [PATCH 9/9] v6.19.2 --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 07c4c493..2f0b0310 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define APP_ID "xmrig-proxy" #define APP_NAME "xmrig-proxy" #define APP_DESC "XMRig Stratum proxy" -#define APP_VERSION "6.19.1-dev" +#define APP_VERSION "6.19.2" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2023 xmrig.com" @@ -30,7 +30,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 19 -#define APP_VER_PATCH 1 +#define APP_VER_PATCH 2 #ifdef _MSC_VER # if (_MSC_VER >= 1930)