diff --git a/CHANGELOG.md b/CHANGELOG.md index 9014f66..518afdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ - Added new options `algo-ext` and `access-password`. - Added real graceful exit. +# v2.14.4 +- Fixed MSVC 2019 version detection. +- Removed obsolete automatic variants. + # v2.14.1 - [#306](https://github.com/xmrig/xmrig-proxy/issues/306) [#310](https://github.com/xmrig/xmrig-proxy/issues/310) Fixed compile issues and random crashing if verbose mode or access log was enabled. diff --git a/CMakeLists.txt b/CMakeLists.txt index da7273e..c8dad98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ set(HEADERS "${HEADERS_BASE_HTTP}" src/3rdparty/align.h src/App.h - src/common/crypto/Algorithm.h src/common/crypto/keccak.h src/common/Platform.h src/common/xmrig.h @@ -26,6 +25,7 @@ set(HEADERS src/core/config/ConfigTransform.h src/core/config/usage.h src/core/Controller.h + src/crypto/common/Algorithm.h src/donate.h src/interfaces/IEvent.h src/interfaces/IEventListener.h @@ -74,12 +74,12 @@ set(SOURCES "${SOURCES_BASE}" "${SOURCES_BASE_HTTP}" src/App.cpp - src/common/crypto/Algorithm.cpp src/common/crypto/keccak.cpp src/common/Platform.cpp src/core/config/Config.cpp src/core/config/ConfigTransform.cpp src/core/Controller.cpp + src/crypto/common/Algorithm.cpp src/log/AccessLog.cpp src/log/ShareLog.cpp src/net/JobResult.cpp @@ -155,6 +155,12 @@ add_definitions(/D__STDC_FORMAT_MACROS) add_definitions(/DAPP_DEVEL) add_definitions(/DXMRIG_NO_ASM) +add_definitions(/DXMRIG_ALGO_RANDOMX) +add_definitions(/DXMRIG_ALGO_CN_LITE) +add_definitions(/DXMRIG_ALGO_CN_HEAVY) +add_definitions(/DXMRIG_ALGO_CN_PICO) +add_definitions(/DXMRIG_ALGO_CN_GPU) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$" AND CMAKE_SIZEOF_VOID_P EQUAL 8) add_definitions(/DRAPIDJSON_SSE2) endif() diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index 07849e3..3d0407e 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -26,7 +26,7 @@ #define XMRIG_ICONFIG_H -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" #include "rapidjson/fwd.h" diff --git a/src/base/kernel/interfaces/IConfigTransform.h b/src/base/kernel/interfaces/IConfigTransform.h index 37ceaba..f885438 100644 --- a/src/base/kernel/interfaces/IConfigTransform.h +++ b/src/base/kernel/interfaces/IConfigTransform.h @@ -26,7 +26,7 @@ #define XMRIG_ICONFIGTRANSFORM_H -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" #include "rapidjson/fwd.h" diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 1d448dd..7ee0228 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -37,6 +37,7 @@ #endif +#include "base/io/json/Json.h" #include "base/io/json/JsonRequest.h" #include "base/io/log/Log.h" #include "base/kernel/interfaces/IClientListener.h" @@ -344,13 +345,8 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code) } } - if (params.HasMember("height")) { - const rapidjson::Value &variant = params["height"]; - - if (variant.IsUint64()) { - job.setHeight(variant.GetUint64()); - } - } + job.setSeedHash(Json::getString(params, "seed_hash")); + job.setHeight(Json::getUint64(params, "height")); if (!verifyAlgorithm(job.algorithm())) { *code = 6; diff --git a/src/base/net/stratum/Client.h b/src/base/net/stratum/Client.h index c7aeabf..841e0e0 100644 --- a/src/base/net/stratum/Client.h +++ b/src/base/net/stratum/Client.h @@ -40,7 +40,7 @@ #include "base/net/stratum/SubmitResult.h" #include "base/net/tools/RecvBuf.h" #include "base/net/tools/Storage.h" -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" typedef struct bio_st BIO; diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 769e211..70cc915 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -220,6 +220,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code) return false; } + job.setSeedHash(Json::getString(params, "seed_hash")); job.setHeight(Json::getUint64(params, kHeight)); job.setDiff(Json::getUint64(params, "difficulty")); job.setId(blocktemplate.data() + blocktemplate.size() - 32); diff --git a/src/base/net/stratum/Job.cpp b/src/base/net/stratum/Job.cpp index 663818e..b4ebb2c 100644 --- a/src/base/net/stratum/Job.cpp +++ b/src/base/net/stratum/Job.cpp @@ -42,7 +42,8 @@ xmrig::Job::Job() : m_diff(0), m_height(0), m_target(0), - m_blob() + m_blob(), + m_seedHash() { } @@ -58,7 +59,8 @@ xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const Str m_diff(0), m_height(0), m_target(0), - m_blob() + m_blob(), + m_seedHash() { } @@ -102,24 +104,6 @@ bool xmrig::Job::setBlob(const char *blob) m_algorithm.setVariant(variant()); } - if (!m_algorithm.isForced()) { - if (m_algorithm.variant() == VARIANT_XTL && m_blob[0] >= 9) { - m_algorithm.setVariant(VARIANT_HALF); - } - else if (m_algorithm.variant() == VARIANT_MSR && m_blob[0] >= 8) { - m_algorithm.setVariant(VARIANT_HALF); - } - else if (m_algorithm.variant() == VARIANT_WOW && m_blob[0] < 11) { - m_algorithm.setVariant(VARIANT_2); - } - else if (m_algorithm.variant() == VARIANT_RWZ && m_blob[0] < 12) { - m_algorithm.setVariant(VARIANT_2); - } - else if (m_algorithm.variant() == VARIANT_ZLS && m_blob[0] < 8) { - m_algorithm.setVariant(VARIANT_2); - } - } - # ifdef XMRIG_PROXY_PROJECT memset(m_rawBlob, 0, sizeof(m_rawBlob)); memcpy(m_rawBlob, blob, m_size * 2); @@ -129,6 +113,20 @@ bool xmrig::Job::setBlob(const char *blob) } +bool xmrig::Job::setSeedHash(const char *hash) +{ + if (!hash || (strlen(hash) != sizeof(m_seedHash) * 2)) { + return false; + } + +# ifdef XMRIG_PROXY_PROJECT + m_rawSeedHash = hash; +# endif + + return Buffer::fromHex(hash, sizeof(m_seedHash) * 2, m_seedHash); +} + + bool xmrig::Job::setTarget(const char *target) { if (!target) { diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 16e9a86..bc0ec2e 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -33,7 +33,7 @@ #include "base/tools/String.h" -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" namespace xmrig { @@ -52,6 +52,7 @@ public: bool isEqual(const Job &other) const; bool setBlob(const char *blob); + bool setSeedHash(const char *hash); bool setTarget(const char *target); void setAlgorithm(const char *algo); void setDiff(uint64_t diff); @@ -64,6 +65,7 @@ public: inline const String &id() const { return m_id; } inline const uint32_t *nonce() const { return reinterpret_cast(m_blob + 39); } inline const uint8_t *blob() const { return m_blob; } + inline const uint8_t *seedHash() const { return m_seedHash; } inline int poolId() const { return m_poolId; } inline int threadId() const { return m_threadId; } inline size_t size() const { return m_size; } @@ -81,9 +83,10 @@ public: inline void setVariant(int variant) { m_algorithm.parseVariant(variant); } # ifdef XMRIG_PROXY_PROJECT - inline char *rawBlob() { return m_rawBlob; } - inline const char *rawBlob() const { return m_rawBlob; } - inline const char *rawTarget() const { return m_rawTarget; } + inline char *rawBlob() { return m_rawBlob; } + inline const char *rawBlob() const { return m_rawBlob; } + inline const char *rawTarget() const { return m_rawTarget; } + inline const String &rawSeedHash() const { return m_rawSeedHash; } # endif static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast(blob + 39); } @@ -107,10 +110,12 @@ private: uint64_t m_height; uint64_t m_target; uint8_t m_blob[kMaxBlobSize]; + uint8_t m_seedHash[32]; # ifdef XMRIG_PROXY_PROJECT char m_rawBlob[kMaxBlobSize * 2 + 8]; char m_rawTarget[24]; + String m_rawSeedHash; # endif }; diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index f441ba6..d3b4b4a 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -517,6 +517,7 @@ void xmrig::Pool::rebuild() addVariant(VARIANT_RWZ); addVariant(VARIANT_ZLS); addVariant(VARIANT_DOUBLE); + addVariant(VARIANT_RX_WOW); addVariant(VARIANT_AUTO); # endif } diff --git a/src/base/net/stratum/Pool.h b/src/base/net/stratum/Pool.h index f798770..5348271 100644 --- a/src/base/net/stratum/Pool.h +++ b/src/base/net/stratum/Pool.h @@ -32,7 +32,7 @@ #include "base/tools/String.h" -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" #include "rapidjson/fwd.h" diff --git a/src/base/net/stratum/strategies/FailoverStrategy.cpp b/src/base/net/stratum/strategies/FailoverStrategy.cpp index b89cd95..d524722 100644 --- a/src/base/net/stratum/strategies/FailoverStrategy.cpp +++ b/src/base/net/stratum/strategies/FailoverStrategy.cpp @@ -89,7 +89,7 @@ void xmrig::FailoverStrategy::add(const Pool &pool) int64_t xmrig::FailoverStrategy::submit(const JobResult &result) { - if (m_active == -1) { + if (!isActive()) { return -1; } diff --git a/src/base/net/stratum/strategies/FailoverStrategy.h b/src/base/net/stratum/strategies/FailoverStrategy.h index 344d815..b1fe8ba 100644 --- a/src/base/net/stratum/strategies/FailoverStrategy.h +++ b/src/base/net/stratum/strategies/FailoverStrategy.h @@ -52,7 +52,7 @@ public: protected: inline bool isActive() const override { return m_active >= 0; } - inline IClient *client() const override { return active(); } + inline IClient *client() const override { return isActive() ? active() : m_pools[m_index]; } inline void onLogin(IClient *, rapidjson::Document &, rapidjson::Value &) override {} int64_t submit(const JobResult &result) override; diff --git a/src/base/tools/String.h b/src/base/tools/String.h index eb0a182..2c47d85 100644 --- a/src/base/tools/String.h +++ b/src/base/tools/String.h @@ -80,6 +80,7 @@ public: inline String &operator=(char *str) { move(str); return *this; } inline String &operator=(const char *str) { copy(str); return *this; } inline String &operator=(const String &str) { copy(str); return *this; } + inline String &operator=(std::nullptr_t) { delete [] m_data; m_data = nullptr; m_size = 0; return *this; } inline String &operator=(String &&other) { move(std::move(other)); return *this; } rapidjson::Value toJSON() const; diff --git a/src/common/cpu/BasicCpuInfo_arm.cpp b/src/common/cpu/BasicCpuInfo_arm.cpp index 3396134..dea8de7 100644 --- a/src/common/cpu/BasicCpuInfo_arm.cpp +++ b/src/common/cpu/BasicCpuInfo_arm.cpp @@ -25,7 +25,8 @@ #include #include -#if __ARM_FEATURE_CRYPTO + +#if __ARM_FEATURE_CRYPTO && !defined(__APPLE__) # include # include #endif @@ -47,7 +48,11 @@ xmrig::BasicCpuInfo::BasicCpuInfo() : # endif # if __ARM_FEATURE_CRYPTO +# if !defined(__APPLE__) m_aes = getauxval(AT_HWCAP) & HWCAP_AES; +# else + m_aes = true; +# endif # endif } diff --git a/src/common/xmrig.h b/src/common/xmrig.h index e8ca885..e8aa505 100644 --- a/src/common/xmrig.h +++ b/src/common/xmrig.h @@ -36,6 +36,7 @@ enum Algo { CRYPTONIGHT_LITE, /* CryptoNight (1 MB) */ CRYPTONIGHT_HEAVY, /* CryptoNight (4 MB) */ CRYPTONIGHT_PICO, /* CryptoNight (256 KB) */ + RANDOM_X, /* RandomX */ ALGO_MAX }; @@ -79,6 +80,7 @@ enum Variant { VARIANT_RWZ = 14, // CryptoNight variant 2 with 3/4 iterations and reversed shuffle operation (Graft) VARIANT_ZLS = 15, // CryptoNight variant 2 with 3/4 iterations (Zelerius) VARIANT_DOUBLE = 16, // CryptoNight variant 2 with double iterations (X-CASH) + VARIANT_RX_WOW = 17, // RandomX (Wownero) VARIANT_MAX }; diff --git a/src/common/crypto/Algorithm.cpp b/src/crypto/common/Algorithm.cpp similarity index 95% rename from src/common/crypto/Algorithm.cpp rename to src/crypto/common/Algorithm.cpp index d9d3ead..c706ae0 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/crypto/common/Algorithm.cpp @@ -30,7 +30,7 @@ #include -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" #ifdef _MSC_VER @@ -70,21 +70,26 @@ static AlgoData const algorithms[] = { { "cryptonight/zls", "cn/zls", xmrig::CRYPTONIGHT, xmrig::VARIANT_ZLS }, { "cryptonight/double", "cn/double", xmrig::CRYPTONIGHT, xmrig::VARIANT_DOUBLE }, -# ifndef XMRIG_NO_AEON +# ifdef XMRIG_ALGO_RANDOMX + { "randomx/wow", "rx/wow", xmrig::RANDOM_X, xmrig::VARIANT_RX_WOW }, + { "randomx", "rx", xmrig::RANDOM_X, xmrig::VARIANT_RX_WOW }, +# endif + +# ifdef XMRIG_ALGO_CN_LITE { "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO }, { "cryptonight-light", "cn-light", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO }, { "cryptonight-lite/0", "cn-lite/0", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 }, { "cryptonight-lite/1", "cn-lite/1", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 }, # endif -# ifndef XMRIG_NO_SUMO +# ifdef XMRIG_ALGO_CN_HEAVY { "cryptonight-heavy", "cn-heavy", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_AUTO }, { "cryptonight-heavy/0", "cn-heavy/0", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 }, { "cryptonight-heavy/xhv", "cn-heavy/xhv", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_XHV }, { "cryptonight-heavy/tube", "cn-heavy/tube", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE }, # endif -# ifndef XMRIG_NO_CN_PICO +# ifdef XMRIG_ALGO_CN_PICO { "cryptonight-pico/trtl", "cn-pico/trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, { "cryptonight-pico", "cn-pico", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, { "cryptonight-turtle", "cn-trtl", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, @@ -92,7 +97,7 @@ static AlgoData const algorithms[] = { { "cryptonight_turtle", "cn_turtle", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL }, # endif -# ifndef XMRIG_NO_CN_GPU +# ifdef XMRIG_ALGO_CN_GPU { "cryptonight/gpu", "cn/gpu", xmrig::CRYPTONIGHT, xmrig::VARIANT_GPU }, # endif }; @@ -138,7 +143,8 @@ static const char *variants[] = { "r", "rwz", "zls", - "double" + "double", + "rx/wow", }; diff --git a/src/common/crypto/Algorithm.h b/src/crypto/common/Algorithm.h similarity index 100% rename from src/common/crypto/Algorithm.h rename to src/crypto/common/Algorithm.h diff --git a/src/net/JobResult.h b/src/net/JobResult.h index 756e6b5..359c29b 100644 --- a/src/net/JobResult.h +++ b/src/net/JobResult.h @@ -31,7 +31,7 @@ #include "base/tools/String.h" -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" namespace xmrig { diff --git a/src/proxy/Miner.cpp b/src/proxy/Miner.cpp index aeaeb60..6cde421 100644 --- a/src/proxy/Miner.cpp +++ b/src/proxy/Miner.cpp @@ -149,7 +149,7 @@ void xmrig::Miner::forwardJob(const Job &job, const char *algo) m_diff = job.diff(); setFixedByte(job.fixedByte()); - sendJob(job.rawBlob(), job.id().data(), job.rawTarget(), algo ? algo : job.algorithm().shortName(), job.height()); + sendJob(job.rawBlob(), job.id().data(), job.rawTarget(), algo ? algo : job.algorithm().shortName(), job.height(), job.rawSeedHash()); } @@ -178,7 +178,7 @@ void xmrig::Miner::setJob(Job &job) customDiff = true; } - sendJob(job.rawBlob(), job.id().data(), customDiff ? m_sendBuf : job.rawTarget(), job.algorithm().shortName(), job.height()); + sendJob(job.rawBlob(), job.id().data(), customDiff ? m_sendBuf : job.rawTarget(), job.algorithm().shortName(), job.height(), job.rawSeedHash()); } @@ -457,7 +457,7 @@ void xmrig::Miner::send(int size) } -void xmrig::Miner::sendJob(const char *blob, const char *jobId, const char *target, const char *algo, uint64_t height) +void xmrig::Miner::sendJob(const char *blob, const char *jobId, const char *target, const char *algo, uint64_t height, const String &seedHash) { using namespace rapidjson; @@ -474,6 +474,10 @@ void xmrig::Miner::sendJob(const char *blob, const char *jobId, const char *targ params.AddMember("height", height, allocator); } + if (!seedHash.isNull()) { + params.AddMember("seed_hash", seedHash.toJSON(), allocator); + } + doc.AddMember("jsonrpc", "2.0", allocator); if (m_state == WaitReadyState) { diff --git a/src/proxy/Miner.h b/src/proxy/Miner.h index 568828e..e0d8867 100644 --- a/src/proxy/Miner.h +++ b/src/proxy/Miner.h @@ -111,7 +111,7 @@ private: void readTLS(int nread); void send(const rapidjson::Document &doc); void send(int size); - void sendJob(const char *blob, const char *jobId, const char *target, const char *algo, uint64_t height); + void sendJob(const char *blob, const char *jobId, const char *target, const char *algo, uint64_t height, const String &seedHash); void setState(State state); void shutdown(bool had_error); diff --git a/src/proxy/events/LoginEvent.h b/src/proxy/events/LoginEvent.h index edb4018..31c286d 100644 --- a/src/proxy/events/LoginEvent.h +++ b/src/proxy/events/LoginEvent.h @@ -29,7 +29,7 @@ #include -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" #include "proxy/events/MinerEvent.h" #include "rapidjson/fwd.h" diff --git a/src/proxy/events/SubmitEvent.h b/src/proxy/events/SubmitEvent.h index b63a78b..bdc0aff 100644 --- a/src/proxy/events/SubmitEvent.h +++ b/src/proxy/events/SubmitEvent.h @@ -26,7 +26,7 @@ #define XMRIG_SUBMITEVENT_H -#include "common/crypto/Algorithm.h" +#include "crypto/common/Algorithm.h" #include "net/JobResult.h" #include "proxy/Error.h" #include "proxy/events/MinerEvent.h" diff --git a/src/version.h b/src/version.h index 4c5577f..592690f 100644 --- a/src/version.h +++ b/src/version.h @@ -28,18 +28,20 @@ #define APP_ID "xmrig-proxy" #define APP_NAME "xmrig-proxy" #define APP_DESC "XMRig Stratum proxy" -#define APP_VERSION "2.15.3-beta" +#define APP_VERSION "2.16.0-evo" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" #define APP_KIND "proxy" #define APP_VER_MAJOR 2 -#define APP_VER_MINOR 15 -#define APP_VER_PATCH 3 +#define APP_VER_MINOR 16 +#define APP_VER_PATCH 0 #ifdef _MSC_VER -# if (_MSC_VER >= 1910) +# if (_MSC_VER >= 1920) +# define MSVC_VERSION 2019 +# elif (_MSC_VER >= 1910 && _MSC_VER < 1920) # define MSVC_VERSION 2017 # elif _MSC_VER == 1900 # define MSVC_VERSION 2015