Merge xmrig v6.22.0 into master

This commit is contained in:
MoneroOcean 2024-08-12 00:05:37 +03:00
commit 90ba7c93de
41 changed files with 4531 additions and 4174 deletions

View file

@ -86,7 +86,7 @@ const char *Algorithm::kRX_ARQ = "rx/arq";
const char *Algorithm::kRX_XEQ = "rx/xeq";
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
@ -163,7 +163,7 @@ static const std::map<uint32_t, const char *> kAlgorithmNames = {
ALGO_NAME(RX_XEQ),
ALGO_NAME(RX_GRAFT),
ALGO_NAME(RX_SFX),
ALGO_NAME(RX_KEVA),
ALGO_NAME(RX_YADA),
# endif
# ifdef XMRIG_ALGO_ARGON2
@ -289,8 +289,8 @@ static const std::map<const char *, Algorithm::Id, aliasCompare> 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
@ -386,7 +386,7 @@ std::vector<xmrig::Algorithm> xmrig::Algorithm::all(const std::function<bool(con
CN_UPX2,
CN_GPU,
RX_0, RX_WOW, RX_ARQ, RX_XEQ, RX_GRAFT, RX_SFX, RX_KEVA,
RX_XLA,
RX_XLA, RX_YADA,
AR2_CHUKWA, AR2_CHUKWA_V2, AR2_WRKZ,
KAWPOW_RVN,
GHOSTRIDER_RTM,

View file

@ -80,7 +80,7 @@ public:
RX_XEQ = 0x72121000,
RX_GRAFT = 0x72151267, // "rx/graft" RandomGRAFT (Graft).
RX_SFX = 0x72151273, // "rx/sfx" RandomSFX (Safex Cash).
RX_KEVA = 0x7214116b, // "rx/keva" RandomKEVA (Keva).
RX_YADA = 0x72151279, // "rx/yada" RandomYada (YadaCoin).
AR2_CHUKWA = 0x61130000, // "argon2/chukwa" Argon2id (Chukwa).
AR2_CHUKWA_V2 = 0x61140000, // "argon2/chukwav2" Argon2id (Chukwa v2).
AR2_WRKZ = 0x61120000, // "argon2/wrkz" Argon2id (WRKZ)
@ -153,7 +153,7 @@ public:
static const char *kRX_XEQ;
static const char *kRX_GRAFT;
static const char *kRX_SFX;
static const char *kRX_KEVA;
static const char *kRX_YADA;
# endif
# ifdef XMRIG_ALGO_ARGON2

View file

@ -51,11 +51,11 @@ static const CoinInfo coinInfo[] = {
{ Algorithm::RX_ARQ, "ARQ", "ArQmA", 120, 1000000000, BLUE_BG_BOLD( WHITE_BOLD_S " arqma ") },
{ Algorithm::RX_XEQ, "XEQ", "Equilibria", 120, 10000, BLUE_BG_BOLD( WHITE_BOLD_S " equilibria ") },
{ Algorithm::RX_GRAFT, "GRFT", "Graft", 120, 10000000000, BLUE_BG_BOLD( WHITE_BOLD_S " graft ") },
{ Algorithm::RX_KEVA, "KVA", "Kevacoin", 0, 0, MAGENTA_BG_BOLD(WHITE_BOLD_S " keva ") },
{ Algorithm::KAWPOW_RVN, "RVN", "Ravencoin", 0, 0, BLUE_BG_BOLD( WHITE_BOLD_S " raven ") },
{ Algorithm::RX_WOW, "WOW", "Wownero", 300, 100000000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " wownero ") },
{ Algorithm::RX_0, "ZEPH", "Zephyr", 120, 1000000000000, BLUE_BG_BOLD( WHITE_BOLD_S " zephyr ") },
{ Algorithm::RX_0, "Townforge","Townforge", 30, 100000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " townforge ") },
{ Algorithm::RX_YADA, "YDA", "YadaCoin", 120, 100000000, BLUE_BG_BOLD( WHITE_BOLD_S " yada ") },
};

View file

@ -37,11 +37,11 @@ public:
ARQ,
XEQ,
GRAFT,
KEVA,
RAVEN,
WOWNERO,
ZEPHYR,
TOWNFORGE,
YADA,
MAX
};

View file

@ -211,11 +211,13 @@ rapidjson::Value xmrig::Json::normalize(double value, bool zero)
{
using namespace rapidjson;
if (!std::isnormal(value)) {
const double value_rounded = floor(value * 100.0) / 100.0;
if (!std::isnormal(value) || !std::isnormal(value_rounded)) {
return zero ? Value(0.0) : Value(kNullType);
}
return Value(floor(value * 100.0) / 100.0);
return Value(value_rounded);
}

View file

@ -365,7 +365,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
Job job(has<EXT_NICEHASH>(), m_pool.algorithm(), m_rpcId);
if (!job.setId(params["job_id"].GetString())) {
if (!job.setId(Json::getString(params, "job_id"))) {
*code = 3;
return false;
}
@ -402,7 +402,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
}
}
if (!job.setTarget(params["target"].GetString())) {
if (!job.setTarget(Json::getString(params, "target"))) {
*code = 5;
return false;
}

View file

@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2019 Howard Chu <https://github.com/hyc>
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 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
@ -24,11 +24,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cassert>
#include <cstring>
#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) {
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, size);
switch (raw.size()) {
case 4:
return 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data())));
case 8:
return *reinterpret_cast<const uint64_t *>(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;
}
const auto raw = Cvt::fromHex(target, strlen(target));
const size_t size = raw.size();
if (size == 4) {
m_target = 0xFFFFFFFFFFFFFFFFULL / (0xFFFFFFFFULL / uint64_t(*reinterpret_cast<const uint32_t *>(raw.data())));
}
else if (size == 8) {
m_target = *reinterpret_cast<const uint64_t *>(raw.data());
}
else {
return false;
}
# ifdef XMRIG_PROXY_PROJECT
assert(sizeof(m_rawTarget) > (size * 2));
memset(m_rawTarget, 0, sizeof(m_rawTarget));
memcpy(m_rawTarget, target, std::min(size * 2, sizeof(m_rawTarget)));
# endif
m_diff = toDiff(m_target);
# ifdef XMRIG_PROXY_PROJECT
if (size >= sizeof(m_rawTarget)) {
return false;
}
memset(m_rawTarget, 0, sizeof(m_rawTarget));
memcpy(m_rawTarget, target, size);
# endif
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)) {

View file

@ -7,8 +7,8 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2019 Howard Chu <https://github.com/hyc>
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 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
@ -27,11 +27,9 @@
#ifndef XMRIG_JOB_H
#define XMRIG_JOB_H
#include <cstddef>
#include <cstdint>
#include "base/crypto/Algorithm.h"
#include "base/tools/Buffer.h"
#include "base/tools/String.h"
@ -63,6 +61,7 @@ public:
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 @@ public:
inline const String &poolWallet() const { return m_poolWallet; }
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(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<uint32_t*>(m_blob + nonceOffset()); }
@ -111,7 +109,7 @@ public:
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