From d50de5d9732671a07cb4b813592f085c914332a3 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 26 Mar 2024 22:21:05 +0700 Subject: [PATCH 1/4] v6.21.2-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 53d35aae..d5fe7af3 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.21.1" +#define APP_VERSION "6.21.2-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com" @@ -30,7 +30,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 21 -#define APP_VER_PATCH 1 +#define APP_VER_PATCH 2 #ifdef _MSC_VER # if (_MSC_VER >= 1930) From 0e71c4bec2ebac99b483a76e219d785d9e2b3b9d Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 4 Apr 2024 01:52:19 +0700 Subject: [PATCH 2/4] Added missing CMake option: BUILD_STATIC --- cmake/flags.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 685f7d1b..d4f92671 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -26,6 +26,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") endif() + if (BUILD_STATIC) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") + endif() + add_definitions(/D_GNU_SOURCE) if (WITH_GOOGLE_BREAKPAD) From 5cd4d855e28542da8d3119e5a2c4478b295febdd Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 6 Aug 2024 23:33:39 +0700 Subject: [PATCH 3/4] Sync changes with the miner. --- src/base/crypto/Algorithm.cpp | 10 ++--- src/base/crypto/Algorithm.h | 4 +- src/base/crypto/Coin.cpp | 2 +- src/base/crypto/Coin.h | 2 +- src/base/io/json/Json.cpp | 6 ++- src/base/net/stratum/Client.cpp | 4 +- src/base/net/stratum/Job.cpp | 78 +++++++++++++++++++++------------ src/base/net/stratum/Job.h | 10 ++--- src/proxy/Miner.cpp | 6 +-- 9 files changed, 73 insertions(+), 49 deletions(-) diff --git a/src/base/crypto/Algorithm.cpp b/src/base/crypto/Algorithm.cpp index 6e76fd26..e7c4f551 100644 --- a/src/base/crypto/Algorithm.cpp +++ b/src/base/crypto/Algorithm.cpp @@ -81,7 +81,7 @@ const char *Algorithm::kRX_WOW = "rx/wow"; const char *Algorithm::kRX_ARQ = "rx/arq"; const char *Algorithm::kRX_GRAFT = "rx/graft"; const char *Algorithm::kRX_SFX = "rx/sfx"; -const char *Algorithm::kRX_KEVA = "rx/keva"; +const char *Algorithm::kRX_YADA = "rx/yada"; #endif #ifdef XMRIG_ALGO_ARGON2 @@ -147,7 +147,7 @@ static const std::map kAlgorithmNames = { ALGO_NAME(RX_ARQ), ALGO_NAME(RX_GRAFT), ALGO_NAME(RX_SFX), - ALGO_NAME(RX_KEVA), + ALGO_NAME(RX_YADA), # endif # ifdef XMRIG_ALGO_ARGON2 @@ -261,8 +261,8 @@ static const std::map kAlgorithmAlias ALGO_ALIAS(RX_GRAFT, "randomgraft"), ALGO_ALIAS_AUTO(RX_SFX), ALGO_ALIAS(RX_SFX, "randomx/sfx"), ALGO_ALIAS(RX_SFX, "randomsfx"), - ALGO_ALIAS_AUTO(RX_KEVA), ALGO_ALIAS(RX_KEVA, "randomx/keva"), - ALGO_ALIAS(RX_KEVA, "randomkeva"), + ALGO_ALIAS_AUTO(RX_YADA), ALGO_ALIAS(RX_YADA, "randomx/yada"), + ALGO_ALIAS(RX_YADA, "randomyada"), # endif # ifdef XMRIG_ALGO_ARGON2 @@ -350,7 +350,7 @@ std::vector xmrig::Algorithm::all(const std::function(), m_pool.algorithm(), m_rpcId); - if (!job.setId(params["job_id"].GetString())) { + if (!job.setId(Json::getString(params, "job_id"))) { *code = 3; return false; } @@ -400,7 +400,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code) } } - if (!job.setTarget(params["target"].GetString())) { + if (!job.setTarget(Json::getString(params, "target"))) { *code = 5; return false; } diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index d62e00b1..1a7cfbfe 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-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright 2018-2024 SChernykh + * Copyright 2016-2024 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,11 +24,9 @@ * along with this program. If not, see . */ - #include #include - #include "base/net/stratum/Job.h" #include "base/tools/Alignment.h" #include "base/tools/Buffer.h" @@ -112,35 +110,69 @@ bool xmrig::Job::setSeedHash(const char *hash) bool xmrig::Job::setTarget(const char *target) { - if (!target) { - return false; - } + static auto parse = [](const char *target, size_t size, const Algorithm &algorithm) -> uint64_t { + if (algorithm == Algorithm::RX_YADA) { + return strtoull(target, nullptr, 16); + } - const auto raw = Cvt::fromHex(target, strlen(target)); - const size_t size = raw.size(); + const auto raw = Cvt::fromHex(target, size); - if (size == 4) { - m_target = 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast(raw.data()))); - } - else if (size == 8) { - m_target = *reinterpret_cast(raw.data()); - } - else { + switch (raw.size()) { + case 4: + return 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast(raw.data()))); + + case 8: + return *reinterpret_cast(raw.data()); + + default: + break; + } + + return 0; + }; + + const size_t size = target ? strlen(target) : 0; + + if (size < 4 || (m_target = parse(target, size, algorithm())) == 0) { return false; } + m_diff = toDiff(m_target); + # ifdef XMRIG_PROXY_PROJECT - assert(sizeof(m_rawTarget) > (size * 2)); + if (size >= sizeof(m_rawTarget)) { + return false; + } memset(m_rawTarget, 0, sizeof(m_rawTarget)); - memcpy(m_rawTarget, target, std::min(size * 2, sizeof(m_rawTarget))); + memcpy(m_rawTarget, target, size); # endif - m_diff = toDiff(m_target); return true; } +size_t xmrig::Job::nonceOffset() const +{ + switch (algorithm().family()) { + case Algorithm::KAWPOW: + return 32; + + case Algorithm::GHOSTRIDER: + return 76; + + default: + break; + } + + if (algorithm() == Algorithm::RX_YADA) { + return 147; + } + + return 39; +} + + void xmrig::Job::setDiff(uint64_t diff) { m_diff = diff; @@ -171,14 +203,6 @@ void xmrig::Job::setSigKey(const char *sig_key) } -int32_t xmrig::Job::nonceOffset() const -{ - auto f = algorithm().family(); - if (f == Algorithm::KAWPOW) return 32; - if (f == Algorithm::GHOSTRIDER) return 76; - return 39; -} - uint32_t xmrig::Job::getNumTransactions() const { if (!(m_algorithm.isCN() || m_algorithm.family() == Algorithm::RANDOM_X)) { diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 1ecff369..5d29e68e 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-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright 2018-2024 SChernykh + * Copyright 2016-2024 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 @@ -27,11 +27,9 @@ #ifndef XMRIG_JOB_H #define XMRIG_JOB_H - #include #include - #include "base/crypto/Algorithm.h" #include "base/tools/Buffer.h" #include "base/tools/String.h" @@ -63,6 +61,7 @@ class Job bool setBlob(const char *blob); bool setSeedHash(const char *hash); bool setTarget(const char *target); + size_t nonceOffset() const; void setDiff(uint64_t diff); void setSigKey(const char *sig_key); @@ -77,7 +76,6 @@ class Job inline const String &poolWallet() const { return m_poolWallet; } inline const uint32_t *nonce() const { return reinterpret_cast(m_blob + nonceOffset()); } inline const uint8_t *blob() const { return m_blob; } - int32_t nonceOffset() const; inline size_t nonceSize() const { return (algorithm().family() == Algorithm::KAWPOW) ? 8 : 4; } inline size_t size() const { return m_size; } inline uint32_t *nonce() { return reinterpret_cast(m_blob + nonceOffset()); } @@ -111,7 +109,7 @@ class Job inline bool operator!=(const Job &other) const { return !isEqual(other); } inline bool operator==(const Job &other) const { return isEqual(other); } - inline Job &operator=(const Job &other) { copy(other); return *this; } + inline Job &operator=(const Job &other) { if (this != &other) { copy(other); } return *this; } inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; } # ifdef XMRIG_FEATURE_BENCHMARK diff --git a/src/proxy/Miner.cpp b/src/proxy/Miner.cpp index c7be63d3..6b7ecb1c 100644 --- a/src/proxy/Miner.cpp +++ b/src/proxy/Miner.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2021 SChernykh - * Copyright 2016-2021 XMRig , + * Copyright 2018-2024 SChernykh + * Copyright 2016-2024 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 @@ -146,7 +146,7 @@ void xmrig::Miner::setJob(Job &job, int64_t extra_nonce) if (hasExtension(EXT_NICEHASH)) { snprintf(m_sendBuf, 4, "%02hhx", m_fixedByte); - memcpy(job.rawBlob() + 84, m_sendBuf, 2); + memcpy(job.rawBlob() + (job.nonceOffset() + 3) * 2, m_sendBuf, 2); } m_diff = job.diff(); From 78727110638d22d9619e899778447382f6767634 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 10 Aug 2024 22:35:01 +0700 Subject: [PATCH 4/4] v6.22.0-dev --- CHANGELOG.md | 6 ++++++ src/App.cpp | 8 ++++---- src/App_unix.cpp | 14 +++----------- src/version.h | 6 +++--- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 580c3205..56226962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v6.22.0 +- [#2411](https://github.com/xmrig/xmrig/pull/2411) Added support for [Yada](https://yadacoin.io/) (`rx/yada` algorithm). +- [#3492](https://github.com/xmrig/xmrig/pull/3492) Fixed `--background` option on Unix systems. +- [#3518](https://github.com/xmrig/xmrig/pull/3518) Possible fix for corrupted API output in rare cases. +- [#3522](https://github.com/xmrig/xmrig/pull/3522) Removed `rx/keva` algorithm. + # v6.21.1 - The dependencies of all prebuilt releases have been updated. Support for old Ubuntu releases has been dropped. - [#3391](https://github.com/xmrig/xmrig/pull/3391) Added support for townforge (monero fork using randomx). diff --git a/src/App.cpp b/src/App.cpp index e3a6051b..7a9ac366 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2021 SChernykh - * Copyright (c) 2016-2021 XMRig , + * Copyright (c) 2018-2024 SChernykh + * Copyright (c) 2016-2024 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 @@ -49,13 +49,13 @@ int xmrig::App::exec() return 2; } - m_signals = std::make_shared(this); - int rc = 0; if (background(rc)) { return rc; } + m_signals = std::make_shared(this); + rc = m_controller->init(); if (rc != 0) { return rc; diff --git a/src/App_unix.cpp b/src/App_unix.cpp index ae2905db..f2a9841d 100644 --- a/src/App_unix.cpp +++ b/src/App_unix.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2024 SChernykh + * Copyright 2016-2024 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,7 +22,6 @@ * along with this program. If not, see . */ - #include #include #include @@ -55,16 +54,9 @@ bool xmrig::App::background(int &rc) return true; } - i = setsid(); - - if (i < 0) { + if (setsid() < 0) { LOG_ERR("setsid() failed (errno = %d)", errno); } - i = chdir("/"); - if (i < 0) { - LOG_ERR("chdir() failed (errno = %d)", errno); - } - return false; } diff --git a/src/version.h b/src/version.h index d5fe7af3..0e6ddfa5 100644 --- a/src/version.h +++ b/src/version.h @@ -22,15 +22,15 @@ #define APP_ID "xmrig-proxy" #define APP_NAME "xmrig-proxy" #define APP_DESC "XMRig Stratum proxy" -#define APP_VERSION "6.21.2-dev" +#define APP_VERSION "6.22.0-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com" #define APP_KIND "proxy" #define APP_VER_MAJOR 6 -#define APP_VER_MINOR 21 -#define APP_VER_PATCH 2 +#define APP_VER_MINOR 22 +#define APP_VER_PATCH 0 #ifdef _MSC_VER # if (_MSC_VER >= 1930)