Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Aug 11, 2024
2 parents 704060b + 7872711 commit 5a455c9
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 67 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
4 changes: 4 additions & 0 deletions cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/App.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]>
*
* 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
Expand Down Expand Up @@ -49,13 +49,13 @@ int xmrig::App::exec()
return 2;
}

m_signals = std::make_shared<Signals>(this);

int rc = 0;
if (background(rc)) {
return rc;
}

m_signals = std::make_shared<Signals>(this);

rc = m_controller->init();
if (rc != 0) {
return rc;
Expand Down
14 changes: 3 additions & 11 deletions src/App_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[email protected]>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <[email protected]>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]>
*
* 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
Expand All @@ -22,7 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#include <cstdlib>
#include <csignal>
#include <cerrno>
Expand Down Expand Up @@ -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;
}
10 changes: 5 additions & 5 deletions src/base/crypto/Algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -147,7 +147,7 @@ static const std::map<uint32_t, const char *> 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
Expand Down Expand Up @@ -261,8 +261,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
Expand Down Expand Up @@ -350,7 +350,7 @@ std::vector<xmrig::Algorithm> xmrig::Algorithm::all(const std::function<bool(con
CN_HEAVY_0, CN_HEAVY_TUBE, CN_HEAVY_XHV,
CN_PICO_0, CN_PICO_TLO,
CN_UPX2,
RX_0, RX_WOW, RX_ARQ, RX_GRAFT, RX_SFX, RX_KEVA,
RX_0, RX_WOW, RX_ARQ, RX_GRAFT, RX_SFX, RX_YADA,
AR2_CHUKWA, AR2_CHUKWA_V2, AR2_WRKZ,
KAWPOW_RVN,
GHOSTRIDER_RTM
Expand Down
4 changes: 2 additions & 2 deletions src/base/crypto/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Algorithm
RX_ARQ = 0x72121061, // "rx/arq" RandomARQ (Arqma).
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)
Expand Down Expand Up @@ -143,7 +143,7 @@ class Algorithm
static const char *kRX_ARQ;
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
Expand Down
2 changes: 1 addition & 1 deletion src/base/crypto/Coin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ static const CoinInfo coinInfo[] = {
{ Algorithm::CN_R, "SUMO", "Sumokoin", 240, 1000000000, BLUE_BG_BOLD( WHITE_BOLD_S " sumo ") },
{ Algorithm::RX_ARQ, "ARQ", "ArQmA", 120, 1000000000, BLUE_BG_BOLD( WHITE_BOLD_S " arqma ") },
{ 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 ") },
};


Expand Down
2 changes: 1 addition & 1 deletion src/base/crypto/Coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class Coin
SUMO,
ARQMA,
GRAFT,
KEVA,
RAVEN,
WOWNERO,
ZEPHYR,
TOWNFORGE,
YADA,
MAX
};

Expand Down
6 changes: 4 additions & 2 deletions src/base/io/json/Json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
4 changes: 2 additions & 2 deletions src/base/net/stratum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,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;
}
Expand Down Expand Up @@ -400,7 +400,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;
}
Expand Down
78 changes: 51 additions & 27 deletions src/base/net/stratum/Job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>, <[email protected]>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]>
*
* 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
Expand All @@ -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"
Expand Down Expand Up @@ -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<const uint32_t *>(raw.data())));
}
else if (size == 8) {
m_target = *reinterpret_cast<const uint64_t *>(raw.data());
}
else {
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;
}

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;
Expand Down Expand Up @@ -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)) {
Expand Down
10 changes: 4 additions & 6 deletions src/base/net/stratum/Job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>, <[email protected]>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]>
*
* 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
Expand All @@ -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"
Expand Down Expand Up @@ -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);

Expand All @@ -77,7 +76,6 @@ class Job
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()); }
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/proxy/Miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[email protected]>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]>
* Copyright 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]>
*
* 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
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 5a455c9

Please sign in to comment.