Merge branch 'dev'

This commit is contained in:
XMRig 2021-09-22 13:05:36 +07:00
commit 298c5cccfa
No known key found for this signature in database
GPG key ID: 446A53638BE94409
12 changed files with 250 additions and 39 deletions

View file

@ -1,3 +1,7 @@
# v6.15.1
- [#2586](https://github.com/xmrig/xmrig/pull/2586) Fixed Windows 7 compatibility.
- [#2594](https://github.com/xmrig/xmrig/pull/2594) Added Windows taskbar icon colors.
# v6.15.0
- [#2548](https://github.com/xmrig/xmrig/pull/2548) Added automatic coin detection for daemon mining.
- [#2563](https://github.com/xmrig/xmrig/pull/2563) Added new algorithm RandomX Graft (`rx/graft`).

View file

@ -56,6 +56,7 @@ set(HEADERS
src/core/config/usage.h
src/core/Controller.h
src/core/Miner.h
src/core/Taskbar.h
src/net/interfaces/IJobResultListener.h
src/net/JobResult.h
src/net/JobResults.h
@ -104,6 +105,7 @@ set(SOURCES
src/core/config/ConfigTransform.cpp
src/core/Controller.cpp
src/core/Miner.cpp
src/core/Taskbar.cpp
src/net/JobResults.cpp
src/net/Network.cpp
src/net/strategies/DonateStrategy.cpp

View file

@ -274,9 +274,9 @@ void xmrig::CpuWorker<N>::start()
bool valid = true;
uint8_t miner_signature_saved[64];
uint8_t* miner_signature_ptr = m_job.blob() + m_job.nonceOffset() + m_job.nonceSize();
# ifdef XMRIG_ALGO_RANDOMX
uint8_t* miner_signature_ptr = m_job.blob() + m_job.nonceOffset() + m_job.nonceSize();
if (job.algorithm().family() == Algorithm::RANDOM_X) {
if (first) {
first = false;

View file

@ -142,10 +142,30 @@ xmrig::String xmrig::Env::get(const String &name, const std::map<String, String>
xmrig::String xmrig::Env::hostname()
{
# ifdef _WIN32
const HMODULE hLib = LoadLibraryA("Ws2_32.dll");
if (hLib) {
typedef int (WSAAPI* GetHostNameW_proc)(PWSTR, int);
GetHostNameW_proc GetHostNameW_ptr = reinterpret_cast<GetHostNameW_proc>(GetProcAddress(hLib, "GetHostNameW"));
if (GetHostNameW_ptr) {
WCHAR buf[UV_MAXHOSTNAMESIZE];
if (GetHostNameW_ptr(buf, UV_MAXHOSTNAMESIZE) != 0) {
return {};
}
char utf8_str[UV_MAXHOSTNAMESIZE * 4 + 1];
const int len = WideCharToMultiByte(CP_UTF8, 0, buf, -1, utf8_str, sizeof(utf8_str), nullptr, nullptr);
if (len <= 0) {
return {};
}
return utf8_str;
}
}
# endif
char buf[UV_MAXHOSTNAMESIZE]{};
size_t size = sizeof(buf);
# if UV_VERSION_HEX >= 0x010c00
# if (UV_VERSION_HEX >= 0x010c00) && !defined(_WIN32)
if (uv_os_gethostname(buf, &size) == 0) {
return static_cast<const char *>(buf);
}

View file

@ -22,6 +22,7 @@
#include "core/Miner.h"
#include "core/Taskbar.h"
#include "3rdparty/rapidjson/document.h"
#include "backend/common/Hashrate.h"
#include "backend/cpu/Cpu.h"
@ -348,6 +349,8 @@ public:
String userJobId;
Timer *timer = nullptr;
uint64_t ticks = 0;
Taskbar m_taskbar;
};
@ -475,6 +478,7 @@ void xmrig::Miner::execCommand(char command)
void xmrig::Miner::pause()
{
d_ptr->active = false;
d_ptr->m_taskbar.setActive(false);
Nonce::pause(true);
Nonce::touch();
@ -494,6 +498,7 @@ void xmrig::Miner::setEnabled(bool enabled)
}
d_ptr->enabled = enabled;
d_ptr->m_taskbar.setEnabled(enabled);
if (enabled) {
LOG_INFO("%s " GREEN_BOLD("resumed"), Tags::miner());
@ -551,6 +556,7 @@ void xmrig::Miner::setJob(const Job &job, bool donate)
mutex.unlock();
d_ptr->active = true;
d_ptr->m_taskbar.setActive(true);
if (ready) {
d_ptr->handleJobChange();

126
src/core/Taskbar.cpp Normal file
View file

@ -0,0 +1,126 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/Taskbar.h"
#ifdef _WIN32
#include <Shobjidl.h>
#include <Objbase.h>
namespace xmrig {
struct TaskbarPrivate
{
TaskbarPrivate()
{
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
if (hr < 0) {
return;
}
hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_taskbar));
if (hr < 0) {
return;
}
hr = m_taskbar->HrInit();
if (hr < 0) {
m_taskbar->Release();
m_taskbar = nullptr;
return;
}
m_consoleWnd = GetConsoleWindow();
}
~TaskbarPrivate()
{
if (m_taskbar) {
m_taskbar->Release();
}
CoUninitialize();
}
ITaskbarList3* m_taskbar = nullptr;
HWND m_consoleWnd = nullptr;
};
Taskbar::Taskbar() : d_ptr(new TaskbarPrivate())
{
}
Taskbar::~Taskbar()
{
delete d_ptr;
}
void Taskbar::setActive(bool active)
{
m_active = active;
updateTaskbarColor();
}
void Taskbar::setEnabled(bool enabled)
{
m_enabled = enabled;
updateTaskbarColor();
}
void Taskbar::updateTaskbarColor()
{
if (d_ptr->m_taskbar) {
if (m_active) {
d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, m_enabled ? TBPF_NOPROGRESS : TBPF_PAUSED);
d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, m_enabled ? 0 : 1, 1);
}
else {
d_ptr->m_taskbar->SetProgressState(d_ptr->m_consoleWnd, TBPF_ERROR);
d_ptr->m_taskbar->SetProgressValue(d_ptr->m_consoleWnd, 1, 1);
}
}
}
} // namespace xmrig
#else // _WIN32
namespace xmrig {
Taskbar::Taskbar() {}
Taskbar::~Taskbar() {}
void Taskbar::setActive(bool) {}
void Taskbar::setEnabled(bool) {}
} // namespace xmrig
#endif // _WIN32

51
src/core/Taskbar.h Normal file
View file

@ -0,0 +1,51 @@
/* XMRig
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2021 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_TASKBAR_H
#define XMRIG_TASKBAR_H
namespace xmrig {
struct TaskbarPrivate;
class Taskbar
{
public:
Taskbar();
~Taskbar();
void setActive(bool active);
void setEnabled(bool enabled);
private:
bool m_active = false;
bool m_enabled = true;
TaskbarPrivate* d_ptr = nullptr;
void updateTaskbarColor();
};
} // namespace xmrig
#endif /* XMRIG_TASKBAR_H */

View file

@ -17,6 +17,7 @@
*/
#include "core/config/ConfigTransform.h"
#include "base/crypto/Algorithm.h"
#include "base/kernel/interfaces/IConfig.h"
#include "base/net/stratum/Pool.h"
#include "base/net/stratum/Pools.h"
@ -102,6 +103,7 @@ void xmrig::ConfigTransform::finalize(rapidjson::Document &doc)
profile.AddMember(StringRef(kThreads), m_threads, allocator);
profile.AddMember(StringRef(kAffinity), m_affinity, allocator);
doc[CpuConfig::kField].AddMember(StringRef(Algorithm::kKAWPOW), false, doc.GetAllocator());
doc[CpuConfig::kField].AddMember(StringRef(kAsterisk), profile, doc.GetAllocator());
}

View file

@ -114,42 +114,42 @@ namespace randomx {
#define codeLoopBegin ADDR(randomx_program_loop_begin)
#define codeLoopLoad ADDR(randomx_program_loop_load)
#define codeLoopLoadXOP ADDR(randomx_program_loop_load_xop)
#define codeProgamStart ADDR(randomx_program_start)
#define codeProgramStart ADDR(randomx_program_start)
#define codeReadDataset ADDR(randomx_program_read_dataset)
#define codeReadDatasetLightSshInit ADDR(randomx_program_read_dataset_sshash_init)
#define codeReadDatasetLightSshFin ADDR(randomx_program_read_dataset_sshash_fin)
#define codeDatasetInit ADDR(randomx_dataset_init)
#define codeDatasetInitAVX2_prologue ADDR(randomx_dataset_init_avx2_prologue)
#define codeDatasetInitAVX2_loop_end ADDR(randomx_dataset_init_avx2_loop_end)
#define codeDatasetInitAVX2_loop_epilogue ADDR(randomx_dataset_init_avx2_epilogue)
#define codeDatasetInitAVX2_ssh_load ADDR(randomx_dataset_init_avx2_ssh_load)
#define codeDatasetInitAVX2_ssh_prefetch ADDR(randomx_dataset_init_avx2_ssh_prefetch)
#define codeDatasetInitAVX2Prologue ADDR(randomx_dataset_init_avx2_prologue)
#define codeDatasetInitAVX2LoopEnd ADDR(randomx_dataset_init_avx2_loop_end)
#define codeDatasetInitAVX2Epilogue ADDR(randomx_dataset_init_avx2_epilogue)
#define codeDatasetInitAVX2SshLoad ADDR(randomx_dataset_init_avx2_ssh_load)
#define codeDatasetInitAVX2SshPrefetch ADDR(randomx_dataset_init_avx2_ssh_prefetch)
#define codeLoopStore ADDR(randomx_program_loop_store)
#define codeLoopEnd ADDR(randomx_program_loop_end)
#define codeEpilogue ADDR(randomx_program_epilogue)
#define codeProgramEnd ADDR(randomx_program_end)
#define codeShhLoad ADDR(randomx_sshash_load)
#define codeShhPrefetch ADDR(randomx_sshash_prefetch)
#define codeShhEnd ADDR(randomx_sshash_end)
#define codeShhInit ADDR(randomx_sshash_init)
#define codeSshLoad ADDR(randomx_sshash_load)
#define codeSshPrefetch ADDR(randomx_sshash_prefetch)
#define codeSshEnd ADDR(randomx_sshash_end)
#define codeSshInit ADDR(randomx_sshash_init)
#define prologueSize (codeLoopBegin - codePrologue)
#define loopLoadSize (codeLoopLoadXOP - codeLoopLoad)
#define loopLoadXOPSize (codeProgamStart - codeLoopLoadXOP)
#define loopLoadXOPSize (codeProgramStart - codeLoopLoadXOP)
#define readDatasetSize (codeReadDatasetLightSshInit - codeReadDataset)
#define readDatasetLightInitSize (codeReadDatasetLightSshFin - codeReadDatasetLightSshInit)
#define readDatasetLightFinSize (codeLoopStore - codeReadDatasetLightSshFin)
#define loopStoreSize (codeLoopEnd - codeLoopStore)
#define datasetInitSize (codeDatasetInitAVX2_prologue - codeDatasetInit)
#define datasetInitAVX2_prologue_size (codeDatasetInitAVX2_loop_end - codeDatasetInitAVX2_prologue)
#define datasetInitAVX2_loop_end_size (codeDatasetInitAVX2_loop_epilogue - codeDatasetInitAVX2_loop_end)
#define datasetInitAVX2_epilogue_size (codeDatasetInitAVX2_ssh_load - codeDatasetInitAVX2_loop_epilogue)
#define datasetInitAVX2_ssh_load_size (codeDatasetInitAVX2_ssh_prefetch - codeDatasetInitAVX2_ssh_load)
#define datasetInitAVX2_ssh_prefetch_size (codeEpilogue - codeDatasetInitAVX2_ssh_prefetch)
#define epilogueSize (codeShhLoad - codeEpilogue)
#define codeSshLoadSize (codeShhPrefetch - codeShhLoad)
#define codeSshPrefetchSize (codeShhEnd - codeShhPrefetch)
#define codeSshInitSize (codeProgramEnd - codeShhInit)
#define datasetInitSize (codeDatasetInitAVX2Prologue - codeDatasetInit)
#define datasetInitAVX2PrologueSize (codeDatasetInitAVX2LoopEnd - codeDatasetInitAVX2Prologue)
#define datasetInitAVX2LoopEndSize (codeDatasetInitAVX2Epilogue - codeDatasetInitAVX2LoopEnd)
#define datasetInitAVX2EpilogueSize (codeDatasetInitAVX2SshLoad - codeDatasetInitAVX2Epilogue)
#define datasetInitAVX2SshLoadSize (codeDatasetInitAVX2SshPrefetch - codeDatasetInitAVX2SshLoad)
#define datasetInitAVX2SshPrefetchSize (codeEpilogue - codeDatasetInitAVX2SshPrefetch)
#define epilogueSize (codeSshLoad - codeEpilogue)
#define codeSshLoadSize (codeSshPrefetch - codeSshLoad)
#define codeSshPrefetchSize (codeSshEnd - codeSshPrefetch)
#define codeSshInitSize (codeProgramEnd - codeSshInit)
#define epilogueOffset ((CodeSize - epilogueSize) & ~63)
@ -341,7 +341,7 @@ namespace randomx {
uint8_t* p = code;
if (initDatasetAVX2) {
codePos = 0;
emit(codeDatasetInitAVX2_prologue, datasetInitAVX2_prologue_size, code, codePos);
emit(codeDatasetInitAVX2Prologue, datasetInitAVX2PrologueSize, code, codePos);
for (unsigned j = 0; j < RandomX_CurrentConfig.CacheAccesses; ++j) {
SuperscalarProgram& prog = programs[j];
@ -350,29 +350,29 @@ namespace randomx {
generateSuperscalarCode<true>(prog(i), p, pos);
}
codePos = pos;
emit(codeShhLoad, codeSshLoadSize, code, codePos);
emit(codeDatasetInitAVX2_ssh_load, datasetInitAVX2_ssh_load_size, code, codePos);
emit(codeSshLoad, codeSshLoadSize, code, codePos);
emit(codeDatasetInitAVX2SshLoad, datasetInitAVX2SshLoadSize, code, codePos);
if (j < RandomX_CurrentConfig.CacheAccesses - 1) {
*(uint32_t*)(code + codePos) = 0xd88b49 + (static_cast<uint32_t>(prog.getAddressRegister()) << 16);
codePos += 3;
emit(RandomX_CurrentConfig.codeShhPrefetchTweaked, codeSshPrefetchSize, code, codePos);
emit(RandomX_CurrentConfig.codeSshPrefetchTweaked, codeSshPrefetchSize, code, codePos);
uint8_t* p = code + codePos;
emit(codeDatasetInitAVX2_ssh_prefetch, datasetInitAVX2_ssh_prefetch_size, code, codePos);
emit(codeDatasetInitAVX2SshPrefetch, datasetInitAVX2SshPrefetchSize, code, codePos);
p[3] += prog.getAddressRegister() << 3;
}
}
emit(codeDatasetInitAVX2_loop_end, datasetInitAVX2_loop_end_size, code, codePos);
emit(codeDatasetInitAVX2LoopEnd, datasetInitAVX2LoopEndSize, code, codePos);
// Number of bytes from the start of randomx_dataset_init_avx2_prologue to loop_begin label
constexpr int32_t prologue_size = 320;
*(int32_t*)(code + codePos - 4) = prologue_size - codePos;
emit(codeDatasetInitAVX2_loop_epilogue, datasetInitAVX2_epilogue_size, code, codePos);
emit(codeDatasetInitAVX2Epilogue, datasetInitAVX2EpilogueSize, code, codePos);
return;
}
memcpy(code + superScalarHashOffset, codeShhInit, codeSshInitSize);
memcpy(code + superScalarHashOffset, codeSshInit, codeSshInitSize);
codePos = superScalarHashOffset + codeSshInitSize;
for (unsigned j = 0; j < RandomX_CurrentConfig.CacheAccesses; ++j) {
SuperscalarProgram& prog = programs[j];
@ -381,11 +381,11 @@ namespace randomx {
generateSuperscalarCode<false>(prog(i), p, pos);
}
codePos = pos;
emit(codeShhLoad, codeSshLoadSize, code, codePos);
emit(codeSshLoad, codeSshLoadSize, code, codePos);
if (j < RandomX_CurrentConfig.CacheAccesses - 1) {
*(uint32_t*)(code + codePos) = 0xd88b49 + (static_cast<uint32_t>(prog.getAddressRegister()) << 16);
codePos += 3;
emit(RandomX_CurrentConfig.codeShhPrefetchTweaked, codeSshPrefetchSize, code, codePos);
emit(RandomX_CurrentConfig.codeSshPrefetchTweaked, codeSshPrefetchSize, code, codePos);
}
}
emitByte(0xc3, code, codePos);
@ -411,7 +411,7 @@ namespace randomx {
}
# ifdef XMRIG_FIX_RYZEN
xmrig::RxFix::setMainLoopBounds(mainLoopBounds);
xmrig::RxFix::setMainLoopBounds(mainLoopBounds);
# endif
imul_rcp_storage = code + (ADDR(randomx_program_imul_rcp_store) - codePrologue) + 2;

View file

@ -172,7 +172,7 @@ RandomX_ConfigurationBase::RandomX_ConfigurationBase()
{
const uint8_t* a = addr(randomx_sshash_prefetch);
const uint8_t* b = addr(randomx_sshash_end);
memcpy(codeShhPrefetchTweaked, a, b - a);
memcpy(codeSshPrefetchTweaked, a, b - a);
}
if (xmrig::Cpu::info()->hasBMI2()) {
const uint8_t* a = addr(randomx_prefetch_scratchpad_bmi2);
@ -214,7 +214,7 @@ void RandomX_ConfigurationBase::Apply()
ScratchpadL3Mask64_Calculated = ((ScratchpadL3_Size / sizeof(uint64_t)) / 8 - 1) * 64;
#if defined(XMRIG_FEATURE_ASM) && (defined(_M_X64) || defined(__x86_64__))
*(uint32_t*)(codeShhPrefetchTweaked + 3) = ArgonMemory * 16 - 1;
*(uint32_t*)(codeSshPrefetchTweaked + 3) = ArgonMemory * 16 - 1;
// Not needed right now because all variants use default dataset base size
//const uint32_t DatasetBaseMask = DatasetBaseSize - RANDOMX_DATASET_ITEM_SIZE;
//*(uint32_t*)(codeReadDatasetTweaked + 9) = DatasetBaseMask;

View file

@ -124,7 +124,7 @@ struct RandomX_ConfigurationBase
rx_vec_i128 fillAes4Rx4_Key[8];
uint8_t codeShhPrefetchTweaked[20];
uint8_t codeSshPrefetchTweaked[20];
uint8_t codePrefetchScratchpadTweaked[28];
uint32_t codePrefetchScratchpadTweakedSize;

View file

@ -22,7 +22,7 @@
#define APP_ID "xmrig"
#define APP_NAME "XMRig"
#define APP_DESC "XMRig miner"
#define APP_VERSION "6.15.0"
#define APP_VERSION "6.15.1-dev"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com"
@ -30,7 +30,7 @@
#define APP_VER_MAJOR 6
#define APP_VER_MINOR 15
#define APP_VER_PATCH 0
#define APP_VER_PATCH 1
#ifdef _MSC_VER
# if (_MSC_VER >= 1920)