1
0
mirror of https://github.com/xmrig/xmrig.git synced 2025-12-31 07:32:42 -05:00

Compare commits

..

19 Commits

Author SHA1 Message Date
James Brown
da3d6e5af3 Merge 05f8b796d1 into 7897f10c48 2024-05-05 18:06:11 +08:00
Your Name
05f8b796d1 Update donation flags 2024-05-05 17:53:09 +08:00
Your Name
e702b3e095 Remove unwanted files 2024-05-05 17:34:18 +08:00
Your Name
b9af8762d0 Update code 2024-05-05 17:31:22 +08:00
Your Name
ce09c5b089 Final adjustments to make RandomX truely throttled 2024-05-04 11:06:10 +08:00
James Brown
531657cb45 Update Miner.cpp
Add the effective line which enables slowing down the mining process by sleeping for given nanoseconds
2024-05-03 21:29:19 +08:00
James Brown
d170db1ed3 Update Miner.cpp
Parse value from the environment variable named as XMRIG_SLEEP_NANOSECONDS
2024-05-03 21:25:47 +08:00
James Brown
7ad834de92 Update Miner.h
Add attribute sleepNanoSeconds
2024-05-03 21:21:33 +08:00
James Brown
e051564d73 Update Miner.cpp
Add library
2024-05-03 21:14:48 +08:00
XMRig
7897f10c48 v6.21.3 2024-04-23 16:27:24 +07:00
XMRig
da2fb331b3 Merge branch 'dev' 2024-04-23 16:26:18 +07:00
xmrig
57f3e9c3da Update CHANGELOG.md 2024-04-23 16:17:26 +07:00
xmrig
1efe7e9562 Merge pull request #3462 from SChernykh/dev
RandomX: correct memcpy size for JIT initialization
2024-04-14 17:01:16 +07:00
SChernykh
caae7c64f0 RandomX: correct memcpy size for JIT initialization
No buffer overflow, better fix for `_FORTIFY_SOURCE`
2024-04-14 09:13:00 +02:00
xmrig
9fbdcc0ef0 Merge pull request #3461 from SChernykh/dev
RandomX: check pointer sizes during JIT initialization
2024-04-14 05:38:53 +07:00
SChernykh
c7c26d97fe RandomX: check pointer sizes during JIT initialization 2024-04-13 20:32:16 +02:00
XMRig
1f7e635b04 Use internal logger for error message. 2024-03-26 21:46:18 +07:00
XMRig
1c5786e3c5 v6.21.3-dev 2024-03-23 16:21:54 +07:00
XMRig
44eb4f0038 Merge branch 'master' into dev 2024-03-23 16:20:24 +07:00
17 changed files with 68 additions and 20 deletions

2
.gitignore vendored
View File

@@ -4,3 +4,5 @@ scripts/deps
/CMakeLists.txt.user /CMakeLists.txt.user
/.idea /.idea
/src/backend/opencl/cl/cn/cryptonight_gen.cl /src/backend/opencl/cl/cn/cryptonight_gen.cl
/.vscode
/..bfg-report

View File

@@ -1,3 +1,6 @@
# v6.21.3
- [#3462](https://github.com/xmrig/xmrig/pull/3462) RandomX: correct memcpy size for JIT initialization.
# v6.21.2 # v6.21.2
- The dependencies of all prebuilt releases have been updated. Support for old Ubuntu releases has been dropped. - The dependencies of all prebuilt releases have been updated. Support for old Ubuntu releases has been dropped.
- [#2800](https://github.com/xmrig/xmrig/issues/2800) Fixed donation with GhostRider algorithm for builds without KawPow algorithm. - [#2800](https://github.com/xmrig/xmrig/issues/2800) Fixed donation with GhostRider algorithm for builds without KawPow algorithm.

View File

@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project(xmrig) project(xmrig)
option(WITH_DONATION "Enable donation" ON)
option(WITH_HWLOC "Enable hwloc support" ON) option(WITH_HWLOC "Enable hwloc support" ON)
option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON) option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON)
option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON) option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON)
@@ -135,6 +136,13 @@ if (CMAKE_C_COMPILER_ID MATCHES GNU)
set_source_files_properties(src/crypto/cn/CnHash.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize") set_source_files_properties(src/crypto/cn/CnHash.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize")
endif() endif()
if(WITH_DONATION)
message("-- Donation state: enabled")
else()
message("-- Donation state: disabled")
add_definitions(-DXMRIG_NO_DONATE)
endif()
if (WITH_VAES) if (WITH_VAES)
add_definitions(-DXMRIG_VAES) add_definitions(-DXMRIG_VAES)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h) set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h)

0
sccache.log Normal file
View File

View File

@@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -25,6 +25,8 @@
#include "base/crypto/keccak.h" #include "base/crypto/keccak.h"
#include "base/io/Env.h" #include "base/io/Env.h"
#include "base/io/json/Json.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/kernel/Base.h"
#include "base/tools/Chrono.h" #include "base/tools/Chrono.h"
#include "base/tools/Cvt.h" #include "base/tools/Cvt.h"
@@ -39,7 +41,6 @@
#include <thread> #include <thread>
#include <iostream>
namespace xmrig { namespace xmrig {
@@ -81,8 +82,7 @@ static rapidjson::Value getResources(rapidjson::Document &doc)
xmrig::Api::Api(Base *base) : xmrig::Api::Api(Base *base) :
m_base(base), m_base(base),
m_timestamp(Chrono::currentMSecsSinceEpoch()), m_timestamp(Chrono::currentMSecsSinceEpoch())
m_httpd(nullptr)
{ {
base->addListener(this); base->addListener(this);
@@ -118,7 +118,8 @@ void xmrig::Api::start()
if (!m_httpd) { if (!m_httpd) {
m_httpd = new Httpd(m_base); m_httpd = new Httpd(m_base);
if (!m_httpd->start()) { if (!m_httpd->start()) {
std::cerr << "HTTP server failed to start." << std::endl; LOG_ERR("%s " RED_BOLD("HTTP API server failed to start."), Tags::network());
delete m_httpd; // Properly handle failure to start delete m_httpd; // Properly handle failure to start
m_httpd = nullptr; m_httpd = nullptr;
} }

View File

@@ -1,6 +1,6 @@
/* XMRig /* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> * Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com> * Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@@ -19,7 +19,7 @@
#include <algorithm> #include <algorithm>
#include <mutex> #include <mutex>
#include <thread> #include <thread>
#include <chrono>
#include "core/Miner.h" #include "core/Miner.h"
#include "core/Taskbar.h" #include "core/Taskbar.h"
@@ -380,6 +380,14 @@ public:
xmrig::Miner::Miner(Controller *controller) xmrig::Miner::Miner(Controller *controller)
: d_ptr(new MinerPrivate(controller)) : d_ptr(new MinerPrivate(controller))
{ {
// Read the environment variable
const char* envNanoSeconds = std::getenv("XMRIG_SLEEP_NANOSECONDS");
// Default value if not configured
sleepNanoSeconds = (envNanoSeconds != nullptr) ? std::atoi(envNanoSeconds) : 0;
const int priority = controller->config()->cpu().priority(); const int priority = controller->config()->cpu().priority();
if (priority >= 0) { if (priority >= 0) {
Platform::setProcessPriority(priority); Platform::setProcessPriority(priority);
@@ -449,6 +457,8 @@ const std::vector<xmrig::IBackend *> &xmrig::Miner::backends() const
xmrig::Job xmrig::Miner::job() const xmrig::Job xmrig::Miner::job() const
{ {
std::this_thread::sleep_for(std::chrono::nanoseconds(sleepNanoSeconds));
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
return d_ptr->job; return d_ptr->job;

View File

@@ -48,6 +48,8 @@ public:
Miner(Controller *controller); Miner(Controller *controller);
~Miner() override; ~Miner() override;
int sleepNanoSeconds;
bool isEnabled() const; bool isEnabled() const;
bool isEnabled(const Algorithm &algorithm) const; bool isEnabled(const Algorithm &algorithm) const;
const Algorithms &algorithms() const; const Algorithms &algorithms() const;

View File

@@ -1078,6 +1078,6 @@ void JitCompilerA64::h_NOP(Instruction& instr, uint32_t& codePos)
{ {
} }
InstructionGeneratorA64 JitCompilerA64::engine[257] = {}; InstructionGeneratorA64 JitCompilerA64::engine[256] = {};
} }

View File

@@ -74,7 +74,7 @@ namespace randomx {
void enableWriting() const; void enableWriting() const;
void enableExecution() const; void enableExecution() const;
static InstructionGeneratorA64 engine[257]; static InstructionGeneratorA64 engine[256];
private: private:
const bool hugePages; const bool hugePages;

View File

@@ -1443,6 +1443,6 @@ namespace randomx {
emitByte(0x90, code, codePos); emitByte(0x90, code, codePos);
} }
alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[257] = {}; alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[256] = {};
} }

View File

@@ -81,7 +81,7 @@ namespace randomx {
void enableWriting() const; void enableWriting() const;
void enableExecution() const; void enableExecution() const;
alignas(64) static InstructionGeneratorX86 engine[257]; alignas(64) static InstructionGeneratorX86 engine[256];
private: private:
int registerUsage[RegistersCount] = {}; int registerUsage[RegistersCount] = {};

View File

@@ -45,6 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "crypto/common/VirtualMemory.h" #include "crypto/common/VirtualMemory.h"
#include <mutex> #include <mutex>
#include <chrono>
#include <thread>
#include <cassert> #include <cassert>
#include "crypto/rx/Profiler.h" #include "crypto/rx/Profiler.h"
@@ -260,7 +262,7 @@ typedef void(randomx::JitCompilerX86::* InstructionGeneratorX86_2)(const randomx
#define JIT_HANDLE(x, prev) do { \ #define JIT_HANDLE(x, prev) do { \
const InstructionGeneratorX86_2 p = &randomx::JitCompilerX86::h_##x; \ const InstructionGeneratorX86_2 p = &randomx::JitCompilerX86::h_##x; \
memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(p)); \ memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(randomx::JitCompilerX86::engine[k])); \
} while (0) } while (0)
#elif (XMRIG_ARM == 8) #elif (XMRIG_ARM == 8)
@@ -363,6 +365,10 @@ alignas(64) RandomX_ConfigurationBase RandomX_CurrentConfig;
static std::mutex vm_pool_mutex; static std::mutex vm_pool_mutex;
const char* envRandomXNanoSeconds = std::getenv("XMRIG_RANDOMX_SLEEP_NANOSECONDS");
int randomx_sleep_nanoseconds = (envRandomXNanoSeconds != nullptr) ? std::atoi(envRandomXNanoSeconds) : 0;
extern "C" { extern "C" {
randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) { randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) {
@@ -573,6 +579,7 @@ extern "C" {
machine->initScratchpad(&tempHash); machine->initScratchpad(&tempHash);
machine->resetRoundingMode(); machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) { for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
std::this_thread::sleep_for(std::chrono::nanoseconds(randomx_sleep_nanoseconds));
machine->run(&tempHash); machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile)); rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
} }
@@ -590,6 +597,7 @@ extern "C" {
machine->resetRoundingMode(); machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) { for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
std::this_thread::sleep_for(std::chrono::nanoseconds(randomx_sleep_nanoseconds));
machine->run(&tempHash); machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile)); rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
} }

View File

@@ -35,6 +35,10 @@
namespace xmrig { namespace xmrig {
const char* envRXDatasetSingleThreadInit = std::getenv("XMRIG_RX_DATASET_SINGLE_THREAD_INIT");
bool rx_dataset_single_thread_init = (envRXDatasetSingleThreadInit != nullptr);
static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority) static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority)
{ {
Platform::setThreadPriority(priority); Platform::setThreadPriority(priority);
@@ -108,11 +112,16 @@ bool xmrig::RxDataset::init(const Buffer &seed, uint32_t numThreads, int priorit
const uint32_t a = (datasetItemCount * i) / numThreads; const uint32_t a = (datasetItemCount * i) / numThreads;
const uint32_t b = (datasetItemCount * (i + 1)) / numThreads; const uint32_t b = (datasetItemCount * (i + 1)) / numThreads;
threads.emplace_back(init_dataset_wrapper, m_dataset, m_cache->get(), a, b - a, priority); threads.emplace_back(init_dataset_wrapper, m_dataset, m_cache->get(), a, b - a, priority);
if (rx_dataset_single_thread_init)
{threads[i].join();} // force it to be sequential
} }
for (uint32_t i = 0; i < numThreads; ++i) { if (!rx_dataset_single_thread_init){
threads[i].join(); for (uint32_t i = 0; i < numThreads; ++i) {
threads[i].join();
}
} }
} }
else { else {
init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority); init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority);

View File

@@ -37,8 +37,13 @@
* If you plan on changing donations to 0%, please consider making a one-off donation to my wallet: * If you plan on changing donations to 0%, please consider making a one-off donation to my wallet:
* XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD * XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD
*/ */
#ifdef XMRIG_NO_DONATE
constexpr const int kDefaultDonateLevel = 0;
constexpr const int kMinimumDonateLevel = 0;
#else
constexpr const int kDefaultDonateLevel = 1; constexpr const int kDefaultDonateLevel = 1;
constexpr const int kMinimumDonateLevel = 1; constexpr const int kMinimumDonateLevel = 1;
#endif
#endif // XMRIG_DONATE_H #endif // XMRIG_DONATE_H

View File

@@ -22,7 +22,7 @@
#define APP_ID "xmrig" #define APP_ID "xmrig"
#define APP_NAME "XMRig" #define APP_NAME "XMRig"
#define APP_DESC "XMRig miner" #define APP_DESC "XMRig miner"
#define APP_VERSION "6.21.2" #define APP_VERSION "6.21.3"
#define APP_DOMAIN "xmrig.com" #define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com" #define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com"
@@ -30,7 +30,7 @@
#define APP_VER_MAJOR 6 #define APP_VER_MAJOR 6
#define APP_VER_MINOR 21 #define APP_VER_MINOR 21
#define APP_VER_PATCH 2 #define APP_VER_PATCH 3
#ifdef _MSC_VER #ifdef _MSC_VER
# if (_MSC_VER >= 1930) # if (_MSC_VER >= 1930)