Merge branch 'dev'

This commit is contained in:
XMRig
2020-03-03 12:11:13 +07:00
9 changed files with 117 additions and 24 deletions

View File

@@ -1,3 +1,6 @@
# v5.8.0
- [#1573](https://github.com/xmrig/xmrig/pull/1573) Added new AstroBWT algorithm for upcoming DERO fork, as `"algo": "astrobwt"` or `"coin": "dero"`.
# v5.7.0
- **Added SOCKS5 proxies support for Tor https://xmrig.com/docs/miner/tor.**
- [#377](https://github.com/xmrig/xmrig-proxy/issues/377) Fixed duplicate jobs in daemon (solo) mining client.

View File

@@ -155,6 +155,7 @@ add_definitions(/DXMRIG_ALGO_CN_HEAVY)
add_definitions(/DXMRIG_ALGO_CN_PICO)
add_definitions(/DXMRIG_ALGO_CN_GPU)
add_definitions(/DXMRIG_ALGO_ARGON2)
add_definitions(/DXMRIG_ALGO_ASTROBWT)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(/DRAPIDJSON_SSE2)

View File

@@ -59,12 +59,14 @@ static const char *kHash = "hash";
static const char *kHeight = "height";
static const char *kJsonRPC = "/json_rpc";
static const size_t BlobReserveSize = 8;
}
xmrig::DaemonClient::DaemonClient(int id, IClientListener *listener) :
BaseClient(id, listener),
m_monero(true)
m_apiVersion(API_MONERO)
{
m_httpListener = std::make_shared<HttpListener>(this);
m_timer = new Timer(this);
@@ -103,17 +105,25 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result)
return -1;
}
char *data = (m_apiVersion == API_DERO) ? m_blockhashingblob.data() : m_blocktemplate.data();
# ifdef XMRIG_PROXY_PROJECT
memcpy(m_blocktemplate.data() + 78, result.nonce, 8);
memcpy(data + 78, result.nonce, 8);
# else
Buffer::toHex(reinterpret_cast<const uint8_t *>(&result.nonce), 4, m_blocktemplate.data() + 78);
Buffer::toHex(reinterpret_cast<const uint8_t *>(&result.nonce), 4, data + 78);
# endif
using namespace rapidjson;
Document doc(kObjectType);
Value params(kArrayType);
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
if (m_apiVersion == API_DERO) {
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
params.PushBack(m_blockhashingblob.toJSON(), doc.GetAllocator());
}
else {
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
}
JsonRequest::create(doc, m_sequence, "submitblock", params);
@@ -131,6 +141,10 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result)
void xmrig::DaemonClient::connect()
{
if ((m_pool.algorithm() == Algorithm::ASTROBWT_DERO) || (m_pool.coin() == Coin::DERO)) {
m_apiVersion = API_DERO;
}
setState(ConnectingState);
getBlockTemplate();
}
@@ -172,7 +186,7 @@ void xmrig::DaemonClient::onHttpData(const HttpData &data)
if (data.method == HTTP_GET) {
if (data.url == kGetHeight) {
if (!doc.HasMember(kHash)) {
m_monero = false;
m_apiVersion = API_CRYPTONOTE_DEFAULT;
return send(HTTP_GET, kGetInfo);
}
@@ -200,7 +214,21 @@ void xmrig::DaemonClient::onTimer(const Timer *)
getBlockTemplate();
}
else if (m_state == ConnectedState) {
send(HTTP_GET, m_monero ? kGetHeight : kGetInfo);
if (m_apiVersion == API_DERO) {
using namespace rapidjson;
Document doc(kObjectType);
auto& allocator = doc.GetAllocator();
doc.AddMember("id", m_sequence, allocator);
doc.AddMember("jsonrpc", "2.0", allocator);
doc.AddMember("method", "get_info", allocator);
send(HTTP_POST, kJsonRPC, doc);
++m_sequence;
}
else {
send(HTTP_GET, (m_apiVersion == API_MONERO) ? kGetHeight : kGetInfo);
}
}
}
@@ -216,7 +244,14 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value &params, int *code)
Job job(false, m_pool.algorithm(), String());
String blocktemplate = Json::getString(params, kBlocktemplateBlob);
if (blocktemplate.isNull() || !job.setBlob(Json::getString(params, "blockhashing_blob"))) {
m_blockhashingblob = Json::getString(params, "blockhashing_blob");
if (m_apiVersion == API_DERO) {
const uint64_t offset = Json::getUint64(params, "reserved_offset");
Buffer::toHex(Buffer::randomBytes(BlobReserveSize).data(), BlobReserveSize, m_blockhashingblob.data() + offset * 2);
}
if (blocktemplate.isNull() || !job.setBlob(m_blockhashingblob)) {
*code = 4;
return false;
}
@@ -263,6 +298,13 @@ bool xmrig::DaemonClient::parseResponse(int64_t id, const rapidjson::Value &resu
return false;
}
if (result.HasMember("top_block_hash")) {
if (m_prevHash != Json::getString(result, "top_block_hash")) {
getBlockTemplate();
}
return true;
}
int code = -1;
if (result.HasMember(kBlocktemplateBlob) && parseJob(result, &code)) {
return true;
@@ -286,7 +328,12 @@ int64_t xmrig::DaemonClient::getBlockTemplate()
Value params(kObjectType);
params.AddMember("wallet_address", m_user.toJSON(), allocator);
params.AddMember("extra_nonce", Buffer::randomBytes(8).toHex().toJSON(doc), allocator);
if (m_apiVersion == API_DERO) {
params.AddMember("reserve_size", BlobReserveSize, allocator);
}
else {
params.AddMember("extra_nonce", Buffer::randomBytes(BlobReserveSize).toHex().toJSON(doc), allocator);
}
JsonRequest::create(doc, m_sequence, "getblocktemplate", params);
@@ -338,6 +385,10 @@ void xmrig::DaemonClient::send(int method, const char *url, const char *data, si
client->setQuiet(isQuiet());
client->connect(m_pool.host(), m_pool.port());
if (method != HTTP_GET) {
client->headers.insert({ "Content-Type", "application/json" });
}
}

View File

@@ -76,9 +76,15 @@ private:
void send(int method, const char *url, const rapidjson::Document &doc);
void setState(SocketState state);
bool m_monero;
enum {
API_CRYPTONOTE_DEFAULT,
API_MONERO,
API_DERO,
} m_apiVersion;
std::shared_ptr<IHttpListener> m_httpListener;
String m_blocktemplate;
String m_blockhashingblob;
String m_prevHash;
String m_tlsFingerprint;
String m_tlsVersion;

View File

@@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
@@ -25,8 +25,6 @@
#include "crypto/common/Algorithm.h"
#include "crypto/cn/CnAlgo.h"
#include "rapidjson/document.h"
@@ -124,6 +122,10 @@ static AlgoName const algorithm_names[] = {
{ "chukwa", nullptr, Algorithm::AR2_CHUKWA },
{ "argon2/wrkz", nullptr, Algorithm::AR2_WRKZ },
# endif
# ifdef XMRIG_ALGO_ASTROBWT
{ "astrobwt", nullptr, Algorithm::ASTROBWT_DERO },
{ "astrobwt/dero", nullptr, Algorithm::ASTROBWT_DERO },
# endif
};
@@ -210,6 +212,18 @@ size_t xmrig::Algorithm::l3() const
}
# endif
# ifdef XMRIG_ALGO_ASTROBWT
if (f == ASTROBWT) {
switch (m_id) {
case ASTROBWT_DERO:
return oneMiB * 20;
default:
break;
}
}
# endif
return 0;
}
@@ -228,6 +242,12 @@ uint32_t xmrig::Algorithm::maxIntensity() const
}
# endif
# ifdef XMRIG_ALGO_ASTROBWT
if (family() == ASTROBWT) {
return 1;
}
# endif
# ifdef XMRIG_ALGO_CN_GPU
if (m_id == CN_GPU) {
return 1;
@@ -291,6 +311,11 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
return ARGON2;
# endif
# ifdef XMRIG_ALGO_ASTROBWT
case ASTROBWT_DERO:
return ASTROBWT;
# endif
default:
break;
}

View File

@@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
@@ -71,6 +71,7 @@ public:
RX_SFX, // "rx/sfx" RandomSFX (Safex Cash).
AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa).
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ)
ASTROBWT_DERO, // "astrobwt" AstroBWT (Dero)
MAX
};
@@ -81,7 +82,8 @@ public:
CN_HEAVY,
CN_PICO,
RANDOM_X,
ARGON2
ARGON2,
ASTROBWT
};
inline Algorithm() = default;

View File

@@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
@@ -50,7 +50,8 @@ static CoinName const coin_names[] = {
{ "monero", Coin::MONERO },
{ "xmr", Coin::MONERO },
{ "arqma", Coin::ARQMA },
{ "arq", Coin::ARQMA }
{ "arq", Coin::ARQMA },
{ "dero", Coin::DERO },
};
@@ -67,6 +68,9 @@ xmrig::Algorithm::Id xmrig::Coin::algorithm(uint8_t blobVersion) const
case ARQMA:
return (blobVersion >= 15) ? Algorithm::RX_ARQ : Algorithm::CN_PICO_0;
case DERO:
return (blobVersion >= 4) ? Algorithm::ASTROBWT_DERO : Algorithm::CN_0;
case INVALID:
break;
}

View File

@@ -6,8 +6,8 @@
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* 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
@@ -40,7 +40,8 @@ public:
enum Id : int {
INVALID = -1,
MONERO,
ARQMA
ARQMA,
DERO
};

View File

@@ -28,14 +28,14 @@
#define APP_ID "xmrig-proxy"
#define APP_NAME "xmrig-proxy"
#define APP_DESC "XMRig Stratum proxy"
#define APP_VERSION "5.7.0"
#define APP_VERSION "5.8.0-dev"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2020 xmrig.com"
#define APP_KIND "proxy"
#define APP_VER_MAJOR 5
#define APP_VER_MINOR 7
#define APP_VER_MINOR 8
#define APP_VER_PATCH 0
#ifdef _MSC_VER