Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MoneroOcean committed May 29, 2024
2 parents 67209ed + 704060b commit 5825823
Show file tree
Hide file tree
Showing 18 changed files with 235 additions and 85 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 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).
- [#3420](https://github.com/xmrig/xmrig/pull/3420) Fixed segfault in HTTP API rebind.
- [#3436](https://github.com/xmrig/xmrig/pull/3436) Fixed, the file log writer was not thread-safe.

# v6.21.0
- [#548](https://github.com/xmrig/xmrig-proxy/pull/548) Sync changes with XMRig.
- [#553](https://github.com/xmrig/xmrig-proxy/pull/553) Fixes for **Zephyr** solo mining.
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.5)
project(xmrig-proxy)


Expand Down Expand Up @@ -120,7 +120,7 @@ if (WIN32)
)

add_definitions(/DWIN32)
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv)
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv dbghelp)
elseif (APPLE)
set(SOURCES_OS
"${SOURCES_OS}"
Expand Down
7 changes: 7 additions & 0 deletions cmake/os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ elseif(XMRIG_OS_UNIX)
add_definitions(/DXMRIG_OS_FREEBSD)
endif()
endif()

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(XMRIG_64_BIT ON)
add_definitions(-DXMRIG_64_BIT)
else()
set(XMRIG_64_BIT OFF)
endif()
33 changes: 25 additions & 8 deletions src/base/api/Api.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 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
Expand All @@ -25,6 +25,8 @@
#include "base/crypto/keccak.h"
#include "base/io/Env.h"
#include "base/io/json/Json.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/kernel/Base.h"
#include "base/tools/Chrono.h"
#include "base/tools/Cvt.h"
Expand Down Expand Up @@ -91,7 +93,11 @@ xmrig::Api::Api(Base *base) :
xmrig::Api::~Api()
{
# ifdef XMRIG_FEATURE_HTTP
delete m_httpd;
if (m_httpd) {
m_httpd->stop();
delete m_httpd;
m_httpd = nullptr; // Ensure the pointer is set to nullptr after deletion
}
# endif
}

Expand All @@ -109,30 +115,41 @@ void xmrig::Api::start()
genWorkerId(m_base->config()->apiWorkerId());

# ifdef XMRIG_FEATURE_HTTP
m_httpd = new Httpd(m_base);
m_httpd->start();
if (!m_httpd) {
m_httpd = new Httpd(m_base);
if (!m_httpd->start()) {
LOG_ERR("%s " RED_BOLD("HTTP API server failed to start."), Tags::network());

delete m_httpd; // Properly handle failure to start
m_httpd = nullptr;
}
}
# endif
}


void xmrig::Api::stop()
{
# ifdef XMRIG_FEATURE_HTTP
m_httpd->stop();
if (m_httpd) {
m_httpd->stop();
}
# endif
}


void xmrig::Api::tick()
{
# ifdef XMRIG_FEATURE_HTTP
if (m_httpd->isBound() || !m_base->config()->http().isEnabled()) {
if (!m_httpd || !m_base->config()->http().isEnabled() || m_httpd->isBound()) {
return;
}

if (++m_ticks % 10 == 0) {
m_ticks = 0;
m_httpd->start();
if (m_httpd) {
m_httpd->start();
}
}
# endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/base/api/Api.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 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
Expand Down
48 changes: 28 additions & 20 deletions src/base/crypto/Algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ const char *Algorithm::kCN_PICO_TLO = "cn-pico/tlo";
const char *Algorithm::kCN_UPX2 = "cn/upx2";
#endif

#ifdef XMRIG_ALGO_CN_GPU
const char *Algorithm::kCN_GPU = "cn/gpu";
#endif

#ifdef XMRIG_ALGO_RANDOMX
const char *Algorithm::kRX = "rx";
const char *Algorithm::kRX_0 = "rx/0";
const char *Algorithm::kRX_WOW = "rx/wow";
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";
Expand All @@ -99,25 +104,20 @@ const char *Algorithm::kKAWPOW_RVN = "kawpow";
#ifdef XMRIG_ALGO_GHOSTRIDER
const char* Algorithm::kGHOSTRIDER = "ghostrider";
const char* Algorithm::kGHOSTRIDER_RTM = "ghostrider";
#endif

#ifdef XMRIG_ALGO_CN_GPU
const char *Algorithm::kCN_GPU = "cn/gpu";
const char* Algorithm::kFLEX = "flex";
const char* Algorithm::kFLEX_KCN = "flex";
#endif

#ifdef XMRIG_ALGO_RANDOMX
const char *Algorithm::kRX_XLA = "panthera";
#endif


#define ALGO_NAME(ALGO) { Algorithm::ALGO, Algorithm::k##ALGO }
#define ALGO_ALIAS(ALGO, NAME) { NAME, Algorithm::ALGO }
#define ALGO_ALIAS_AUTO(ALGO) { Algorithm::k##ALGO, Algorithm::ALGO }


#ifdef _MSC_VER
# define strcasecmp _stricmp
#endif

static const std::map<uint32_t, const char *> kAlgorithmNames = {
ALGO_NAME(CN_0),
ALGO_NAME(CN_1),
Expand Down Expand Up @@ -152,10 +152,15 @@ static const std::map<uint32_t, const char *> kAlgorithmNames = {
ALGO_NAME(CN_UPX2),
# endif

# ifdef XMRIG_ALGO_CN_GPU
ALGO_NAME(CN_GPU),
# endif

# ifdef XMRIG_ALGO_RANDOMX
ALGO_NAME(RX_0),
ALGO_NAME(RX_WOW),
ALGO_NAME(RX_ARQ),
ALGO_NAME(RX_XEQ),
ALGO_NAME(RX_GRAFT),
ALGO_NAME(RX_SFX),
ALGO_NAME(RX_KEVA),
Expand All @@ -171,16 +176,13 @@ static const std::map<uint32_t, const char *> kAlgorithmNames = {
ALGO_NAME(KAWPOW_RVN),
# endif

# ifdef XMRIG_ALGO_CN_GPU
ALGO_NAME(CN_GPU),
# endif

# ifdef XMRIG_ALGO_RANDOMX
ALGO_NAME(RX_XLA),
# endif

# ifdef XMRIG_ALGO_GHOSTRIDER
ALGO_NAME(GHOSTRIDER_RTM),
ALGO_NAME(FLEX_KCN),
# endif
};

Expand Down Expand Up @@ -266,6 +268,11 @@ static const std::map<const char *, Algorithm::Id, aliasCompare> kAlgorithmAlias
ALGO_ALIAS(CN_UPX2, "cryptonight-upx/2"),
# endif

# ifdef XMRIG_ALGO_CN_GPU
ALGO_ALIAS_AUTO(CN_GPU), ALGO_ALIAS(CN_GPU, "cryptonight/gpu"),
ALGO_ALIAS(CN_GPU, "cryptonight_gpu"),
# endif

# ifdef XMRIG_ALGO_RANDOMX
ALGO_ALIAS_AUTO(RX_0), ALGO_ALIAS(RX_0, "randomx/0"),
ALGO_ALIAS(RX_0, "randomx/test"),
Expand All @@ -276,6 +283,8 @@ static const std::map<const char *, Algorithm::Id, aliasCompare> kAlgorithmAlias
ALGO_ALIAS(RX_WOW, "randomwow"),
ALGO_ALIAS_AUTO(RX_ARQ), ALGO_ALIAS(RX_ARQ, "randomx/arq"),
ALGO_ALIAS(RX_ARQ, "randomarq"),
ALGO_ALIAS_AUTO(RX_XEQ), ALGO_ALIAS(RX_XEQ, "randomx/xeq"),
ALGO_ALIAS(RX_XEQ, "randomxeq"),
ALGO_ALIAS_AUTO(RX_GRAFT), ALGO_ALIAS(RX_GRAFT, "randomx/graft"),
ALGO_ALIAS(RX_GRAFT, "randomgraft"),
ALGO_ALIAS_AUTO(RX_SFX), ALGO_ALIAS(RX_SFX, "randomx/sfx"),
Expand All @@ -294,18 +303,15 @@ static const std::map<const char *, Algorithm::Id, aliasCompare> kAlgorithmAlias
ALGO_ALIAS_AUTO(KAWPOW_RVN), ALGO_ALIAS(KAWPOW_RVN, "kawpow/rvn"),
# endif

# ifdef XMRIG_ALGO_CN_GPU
ALGO_ALIAS_AUTO(CN_GPU), ALGO_ALIAS(CN_GPU, "cryptonight/gpu"),
ALGO_ALIAS(CN_GPU, "cryptonight_gpu"),
# endif

# ifdef XMRIG_ALGO_RANDOMX
ALGO_ALIAS_AUTO(RX_XLA), ALGO_ALIAS(RX_XLA, "Panthera"),
# endif

# ifdef XMRIG_ALGO_GHOSTRIDER
ALGO_ALIAS_AUTO(GHOSTRIDER_RTM), ALGO_ALIAS(GHOSTRIDER_RTM, "ghostrider/rtm"),
ALGO_ALIAS(GHOSTRIDER_RTM, "gr"),
ALGO_ALIAS_AUTO(FLEX_KCN), ALGO_ALIAS(FLEX_KCN, "flex/kcn"),
ALGO_ALIAS(FLEX_KCN, "flex"),
# endif
};

Expand Down Expand Up @@ -378,11 +384,13 @@ 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,
CN_GPU, RX_XLA,
RX_0, RX_WOW, RX_ARQ, RX_GRAFT, RX_SFX, RX_KEVA,
CN_GPU,
RX_0, RX_WOW, RX_ARQ, RX_XEQ, RX_GRAFT, RX_SFX, RX_KEVA,
RX_XLA,
AR2_CHUKWA, AR2_CHUKWA_V2, AR2_WRKZ,
KAWPOW_RVN,
GHOSTRIDER_RTM
GHOSTRIDER_RTM,
FLEX_KCN
};

Algorithms out;
Expand Down
20 changes: 12 additions & 8 deletions src/base/crypto/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <functional>
#include <vector>
#include <map>


#include "3rdparty/rapidjson/fwd.h"
Expand Down Expand Up @@ -66,16 +65,19 @@ class Algorithm
CN_PICO_0 = 0x63120200, // "cn-pico" CryptoNight-Pico
CN_PICO_TLO = 0x63120274, // "cn-pico/tlo" CryptoNight-Pico (TLO)
CN_UPX2 = 0x63110200, // "cn/upx2" Uplexa (UPX2)
CN_GPU = 0x63150300, // "cn/gpu" CryptoNight-GPU (Ryo).
CN_GR_0 = 0x63130100, // "cn/dark" GhostRider
CN_GR_1 = 0x63130101, // "cn/dark-lite" GhostRider
CN_GR_2 = 0x63150102, // "cn/fast" GhostRider
CN_GR_3 = 0x63140103, // "cn/lite" GhostRider
CN_GR_4 = 0x63120104, // "cn/turtle" GhostRider
CN_GR_5 = 0x63120105, // "cn/turtle-lite" GhostRider
GHOSTRIDER_RTM = 0x6c150000, // "ghostrider" GhostRider
FLEX_KCN = 0x6c150001, // "flex" Flex
RX_0 = 0x72151200, // "rx/0" RandomX (reference configuration).
RX_WOW = 0x72141177, // "rx/wow" RandomWOW (Wownero).
RX_ARQ = 0x72121061, // "rx/arq" RandomARQ (Arqma).
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).
Expand All @@ -84,7 +86,6 @@ class Algorithm
AR2_WRKZ = 0x61120000, // "argon2/wrkz" Argon2id (WRKZ)
KAWPOW_RVN = 0x6b0f0000, // "kawpow/rvn" KawPow (RVN)

CN_GPU = 0x631500ff, // "cn/gpu" CryptoNight-GPU (Ryo).
RX_XLA = 0x721211ff, // "panthera" Panthera (Scala2).
};

Expand Down Expand Up @@ -140,11 +141,16 @@ class Algorithm
static const char *kCN_UPX2;
# endif

# ifdef XMRIG_ALGO_CN_GPU
static const char *kCN_GPU;
# endif

# ifdef XMRIG_ALGO_RANDOMX
static const char *kRX;
static const char *kRX_0;
static const char *kRX_WOW;
static const char *kRX_ARQ;
static const char *kRX_XEQ;
static const char *kRX_GRAFT;
static const char *kRX_SFX;
static const char *kRX_KEVA;
Expand All @@ -162,17 +168,15 @@ class Algorithm
static const char *kKAWPOW_RVN;
# endif

# ifdef XMRIG_ALGO_CN_GPU
static const char *kCN_GPU;
# endif

# ifdef XMRIG_ALGO_RANDOMX
static const char *kRX_XLA;
# endif

# ifdef XMRIG_ALGO_GHOSTRIDER
static const char* kGHOSTRIDER;
static const char* kGHOSTRIDER_RTM;
static const char* kFLEX;
static const char* kFLEX_KCN;
# endif

inline Algorithm() = default;
Expand All @@ -194,8 +198,8 @@ class Algorithm
inline Id id() const { return m_id; }
inline size_t l2() const { return l2(m_id); }
inline uint32_t family() const { return family(m_id); }
inline uint32_t minIntensity() const { return ((m_id == GHOSTRIDER_RTM) ? 8 : 1); };
inline uint32_t maxIntensity() const { return isCN() ? 5 : ((m_id == GHOSTRIDER_RTM) ? 8 : 1); };
inline uint32_t minIntensity() const { return ((family(m_id) == GHOSTRIDER) ? 8 : 1); };
inline uint32_t maxIntensity() const { return isCN() ? 5 : ((family(m_id) == GHOSTRIDER) ? 8 : 1); };

inline size_t l3() const { return l3(m_id); }

Expand Down
2 changes: 2 additions & 0 deletions src/base/crypto/Coin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ static const CoinInfo coinInfo[] = {
{ Algorithm::RX_0, "XMR", "Monero", 120, 1000000000000, YELLOW_BG_BOLD( WHITE_BOLD_S " monero ") },
{ 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_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 ") },
};


Expand Down
1 change: 1 addition & 0 deletions src/base/crypto/Coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Coin
RAVEN,
WOWNERO,
ZEPHYR,
TOWNFORGE,
MAX
};

Expand Down
Loading

0 comments on commit 5825823

Please sign in to comment.