Merge branch 'evo' into beta

This commit is contained in:
XMRig
2019-06-25 14:13:50 +07:00
24 changed files with 88 additions and 57 deletions

View File

@@ -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.

View File

@@ -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()

View File

@@ -26,7 +26,7 @@
#define XMRIG_ICONFIG_H
#include "common/crypto/Algorithm.h"
#include "crypto/common/Algorithm.h"
#include "rapidjson/fwd.h"

View File

@@ -26,7 +26,7 @@
#define XMRIG_ICONFIGTRANSFORM_H
#include "common/crypto/Algorithm.h"
#include "crypto/common/Algorithm.h"
#include "rapidjson/fwd.h"

View File

@@ -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 &params, 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;

View File

@@ -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;

View File

@@ -220,6 +220,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value &params, 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);

View File

@@ -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) {

View File

@@ -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<const uint32_t*>(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<uint32_t*>(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
};

View File

@@ -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
}

View File

@@ -32,7 +32,7 @@
#include "base/tools/String.h"
#include "common/crypto/Algorithm.h"
#include "crypto/common/Algorithm.h"
#include "rapidjson/fwd.h"

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -25,7 +25,8 @@
#include <string.h>
#include <thread>
#if __ARM_FEATURE_CRYPTO
#if __ARM_FEATURE_CRYPTO && !defined(__APPLE__)
# include <sys/auxv.h>
# include <asm/hwcap.h>
#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
}

View File

@@ -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
};

View File

@@ -30,7 +30,7 @@
#include <stdio.h>
#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",
};

View File

@@ -31,7 +31,7 @@
#include "base/tools/String.h"
#include "common/crypto/Algorithm.h"
#include "crypto/common/Algorithm.h"
namespace xmrig {

View File

@@ -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) {

View File

@@ -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);

View File

@@ -29,7 +29,7 @@
#include <stdint.h>
#include "common/crypto/Algorithm.h"
#include "crypto/common/Algorithm.h"
#include "proxy/events/MinerEvent.h"
#include "rapidjson/fwd.h"

View File

@@ -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"

View File

@@ -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