From fbd100ef10565a148dc1e5928b8b2d6343bb0325 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 16 Dec 2017 19:27:11 +0700 Subject: [PATCH 01/14] #262 Reduce cmake version requirement to 2.8. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a1f238acc..377bdb944c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 2.8) project(xmrig) option(WITH_LIBCPUID "Use Libcpuid" ON) From 114a9b041dc1fe9195d7923d2a5396b97c45e8f3 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 2 Jan 2018 12:24:57 +0700 Subject: [PATCH 02/14] #279 Add missing stdio header --- src/Platform_mac.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Platform_mac.cpp b/src/Platform_mac.cpp index 5e53aacb92..ba541f1d0a 100644 --- a/src/Platform_mac.cpp +++ b/src/Platform_mac.cpp @@ -22,6 +22,7 @@ */ +#include #include #include #include @@ -41,11 +42,11 @@ static inline char *createUserAgent() char *buf = new char[max]; -# ifdef XMRIG_NVIDIA_PROJECT - const int cudaVersion = cuda_get_runtime_version(); - snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__); -# else - snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__); +# ifdef XMRIG_NVIDIA_PROJECT + const int cudaVersion = cuda_get_runtime_version(); + snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__); +# else + snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__); # endif return buf; From 1b025f681cdb7dcc7c98fd8cf82ee353e80d2262 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 2 Jan 2018 13:41:00 +0700 Subject: [PATCH 03/14] Remove extra semicolon. --- src/net/Client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/net/Client.cpp b/src/net/Client.cpp index 88134ae74a..8e8ebcfdb1 100644 --- a/src/net/Client.cpp +++ b/src/net/Client.cpp @@ -582,11 +582,11 @@ void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) LOG_ERR("[%s:%u] read error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror((int) nread)); } - return client->close();; + return client->close(); } if ((size_t) nread > (sizeof(m_buf) - 8 - client->m_recvBufPos)) { - return client->close();; + return client->close(); } client->m_recvBufPos += nread; @@ -623,7 +623,7 @@ void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res) auto client = getClient(req->data); if (status < 0) { LOG_ERR("[%s:%u] DNS error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror(status)); - return client->reconnect();; + return client->reconnect(); } addrinfo *ptr = res; From 785df621833319b380f1af2ee936a6bb05be2a9e Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 2 Jan 2018 13:49:31 +0700 Subject: [PATCH 04/14] Update README.md. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 50ab830bdd..b4880b3804 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # XMRig -XMRig is high performance Monero (XMR) CPU miner, with the official full Windows support. -Originally based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of legacy code, since version 1.0.0 complete rewritten from scratch on C++. +XMRig is a high performance Monero (XMR) CPU miner, with official support for Windows. +Originally based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of legacy code, since version 1.0.0 completely rewritten from scratch on C++. * This is the **CPU-mining** version, there is also a [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia) and [AMD GPU version]( https://github.com/xmrig/xmrig-amd). * [Roadmap](https://github.com/xmrig/xmrig/issues/106) for next releases. @@ -89,7 +89,7 @@ Since version 0.8.0. ## Common Issues ### HUGE PAGES unavailable * Run XMRig as Administrator. -* Since version 0.8.0 XMRig automatically enable SeLockMemoryPrivilege for current user, but reboot or sign out still required. [Manual instruction](https://msdn.microsoft.com/en-gb/library/ms190730.aspx). +* Since version 0.8.0 XMRig automatically enables SeLockMemoryPrivilege for current user, but reboot or sign out still required. [Manual instruction](https://msdn.microsoft.com/en-gb/library/ms190730.aspx). ## Other information * No HTTP support, only stratum protocol support. @@ -106,7 +106,7 @@ Please note performance is highly dependent on system load. The numbers above ar ### Maximum performance checklist * Idle operating system. * Do not exceed optimal thread count. -* Use modern CPUs with AES-NI instructuon set. +* Use modern CPUs with AES-NI instruction set. * Try setup optimal cpu affinity. * Enable fast memory (Large/Huge pages). From 5b88213f61ac41e62b906595b60ffb62527ff650 Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 4 Jan 2018 11:38:32 +0700 Subject: [PATCH 05/14] Fix wrong signal handle. --- src/App.cpp | 10 ++++++---- src/App.h | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index 1aae7ae099..c08a8be297 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -92,7 +92,9 @@ App::App(int argc, char **argv) : m_network = new Network(m_options); - uv_signal_init(uv_default_loop(), &m_signal); + uv_signal_init(uv_default_loop(), &m_sigHUP); + uv_signal_init(uv_default_loop(), &m_sigINT); + uv_signal_init(uv_default_loop(), &m_sigTERM); } @@ -114,9 +116,9 @@ int App::exec() return 0; } - uv_signal_start(&m_signal, App::onSignal, SIGHUP); - uv_signal_start(&m_signal, App::onSignal, SIGTERM); - uv_signal_start(&m_signal, App::onSignal, SIGINT); + uv_signal_start(&m_sigHUP, App::onSignal, SIGHUP); + uv_signal_start(&m_sigINT, App::onSignal, SIGINT); + uv_signal_start(&m_sigTERM, App::onSignal, SIGTERM); background(); diff --git a/src/App.h b/src/App.h index 781f78f25b..fcb3b71b7d 100644 --- a/src/App.h +++ b/src/App.h @@ -60,7 +60,9 @@ class App : public IConsoleListener Httpd *m_httpd; Network *m_network; Options *m_options; - uv_signal_t m_signal; + uv_signal_t m_sigHUP; + uv_signal_t m_sigINT; + uv_signal_t m_sigTERM; }; From 8b7a737ceb14871fd09ad4b190cd126e079852d9 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 5 Jan 2018 17:23:39 +0700 Subject: [PATCH 06/14] Fix recent MSVC 2017 version detection. --- src/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/version.h b/src/version.h index c362e7be69..f869db8a4f 100644 --- a/src/version.h +++ b/src/version.h @@ -4,7 +4,7 @@ * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee - * Copyright 2016-2017 XMRig + * Copyright 2016-2018 XMRig * * * This program is free software: you can redistribute it and/or modify @@ -27,10 +27,10 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig CPU miner" -#define APP_VERSION "2.4.3" +#define APP_VERSION "2.4.4" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" -#define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com" +#define APP_COPYRIGHT "Copyright (C) 2016-2018 xmrig.com" #define APP_KIND "cpu" #define APP_VER_MAJOR 2 @@ -39,7 +39,7 @@ #define APP_VER_REV 0 #ifdef _MSC_VER -# if (_MSC_VER == 1910 || _MSC_VER == 1911) +# if (_MSC_VER >= 1910) # define MSVC_VERSION 2017 # elif _MSC_VER == 1900 # define MSVC_VERSION 2015 From 49b45ddd18461558e80b3e7c0eb741409072fd78 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 5 Jan 2018 19:41:19 +0700 Subject: [PATCH 07/14] Add libmicrohttpd version to --version output. --- src/Options.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Options.cpp b/src/Options.cpp index b1197223e7..3eaf07ce15 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -33,6 +33,11 @@ #endif +#ifndef XMRIG_NO_HTTPD +# include +#endif + + #include "Cpu.h" #include "donate.h" #include "net/Url.h" @@ -665,6 +670,10 @@ void Options::showVersion() "\n"); printf("\nlibuv/%s\n", uv_version_string()); + +# ifndef XMRIG_NO_HTTPD + printf("libmicrohttpd/%s\n", MHD_get_version()); +# endif } From f93187b024610ed83f41e18a5b6145ff7b91f61d Mon Sep 17 00:00:00 2001 From: stanz2g Date: Sat, 6 Jan 2018 17:07:07 +0800 Subject: [PATCH 08/14] can build without microhttpd when WITH_HTTPD=OFF --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 377bdb944c..1e1673eac8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,6 +195,7 @@ if (WITH_HTTPD) message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_HTTPD=OFF` to build without http deamon support") endif() else() + set(MHD_LIBRARY "") add_definitions(/DXMRIG_NO_HTTPD) add_definitions(/DXMRIG_NO_API) endif() From d73bee81abe74c962a423053c19c834300de5268 Mon Sep 17 00:00:00 2001 From: xmrig Date: Sun, 7 Jan 2018 21:36:49 +0700 Subject: [PATCH 09/14] Update README.md --- README.md | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index b4880b3804..6ab4b6a240 100644 --- a/README.md +++ b/README.md @@ -50,31 +50,34 @@ For failover you can add multiple pools, maximum count not limited. ### Options ``` - -a, --algo=ALGO cryptonight (default) or cryptonight-lite - -o, --url=URL URL of mining server - -O, --userpass=U:P username:password pair for mining server - -u, --user=USERNAME username for mining server - -p, --pass=PASSWORD password for mining server - -t, --threads=N number of miner threads - -v, --av=N algorithm variation, 0 auto select - -k, --keepalive send keepalived for prevent timeout (need pool support) - -r, --retries=N number of times to retry before switch to backup server (default: 5) - -R, --retry-pause=N time to pause between retries (default: 5) - --cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1 - --cpu-priority set process priority (0 idle, 2 normal to 5 highest) - --no-huge-pages disable huge pages support - --no-color disable colored output - --donate-level=N donate level, default 5% (5 minutes in 100 minutes) - --user-agent set custom user-agent string for pool - -B, --background run the miner in the background - -c, --config=FILE load a JSON-format configuration file - -l, --log-file=FILE log all output to a file - --max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75) - --safe safe adjust threads and av settings for current CPU - --nicehash enable nicehash support - --print-time=N print hashrate report every N seconds - -h, --help display this help and exit - -V, --version output version information and exit + -a, --algo=ALGO cryptonight (default) or cryptonight-lite + -o, --url=URL URL of mining server + -O, --userpass=U:P username:password pair for mining server + -u, --user=USERNAME username for mining server + -p, --pass=PASSWORD password for mining server + -t, --threads=N number of miner threads + -v, --av=N algorithm variation, 0 auto select + -k, --keepalive send keepalived for prevent timeout (need pool support) + -r, --retries=N number of times to retry before switch to backup server (default: 5) + -R, --retry-pause=N time to pause between retries (default: 5) + --cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1 + --cpu-priority set process priority (0 idle, 2 normal to 5 highest) + --no-huge-pages disable huge pages support + --no-color disable colored output + --donate-level=N donate level, default 5% (5 minutes in 100 minutes) + --user-agent set custom user-agent string for pool + -B, --background run the miner in the background + -c, --config=FILE load a JSON-format configuration file + -l, --log-file=FILE log all output to a file + --max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75) + --safe safe adjust threads and av settings for current CPU + --nicehash enable nicehash/xmrig-proxy support + --print-time=N print hashrate report every N seconds + --api-port=N port for the miner API + --api-access-token=T access token for API + --api-worker-id=ID custom worker-id for API + -h, --help display this help and exit + -V, --version output version information and exit ``` Also you can use configuration via config file, default **config.json**. You can load multiple config files and combine it with command line options. From 038bb1f6bc2c422a7c7c5a4c23bc2129de4cdbf0 Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 10 Jan 2018 16:56:08 +0700 Subject: [PATCH 10/14] Fix version. --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index f869db8a4f..52058eec1a 100644 --- a/src/version.h +++ b/src/version.h @@ -35,7 +35,7 @@ #define APP_VER_MAJOR 2 #define APP_VER_MINOR 4 -#define APP_VER_BUILD 3 +#define APP_VER_BUILD 4 #define APP_VER_REV 0 #ifdef _MSC_VER From e6540229cba5bdb52c3a80615bb0f5266f63d4db Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 10 Jan 2018 22:55:45 +0700 Subject: [PATCH 11/14] #328 Added guard to prevent paused message spam and crash. --- src/App.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index c08a8be297..1c00e4fbbb 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -166,8 +166,10 @@ void App::onConsoleCommand(char command) case 'p': case 'P': - LOG_INFO(m_options->colors() ? "\x1B[01;33mpaused\x1B[0m, press \x1B[01;35mr\x1B[0m to resume" : "paused, press 'r' to resume"); - Workers::setEnabled(false); + if (Workers::isEnabled()) { + LOG_INFO(m_options->colors() ? "\x1B[01;33mpaused\x1B[0m, press \x1B[01;35mr\x1B[0m to resume" : "paused, press 'r' to resume"); + Workers::setEnabled(false); + } break; case 'r': From 916cf0ae0da6ac9a59bebb86a6106d0e34d3eb96 Mon Sep 17 00:00:00 2001 From: xmrig Date: Thu, 11 Jan 2018 15:08:24 +0700 Subject: [PATCH 12/14] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54314ecaf8..878ff98492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v2.4.4 + - Added libmicrohttpd version to --version output. + - Fixed bug in singal handler, in some cases miner wasn't shutdown properly. + - Fixed recent MSVC 2017 version detection. + - [#279](https://github.com/xmrig/xmrig/pull/279) Fixed build on some macOS versions. + # v2.4.3 - [#94](https://github.com/xmrig/xmrig/issues/94#issuecomment-342019257) [#216](https://github.com/xmrig/xmrig/issues/216) Added **ARMv8** and **ARMv7** support. Hardware AES supported, thanks [Imran Yusuff](https://github.com/imranyusuff). - [#157](https://github.com/xmrig/xmrig/issues/157) [#196](https://github.com/xmrig/xmrig/issues/196) Fixed Linux compile issues. From 56ffa7af794c0eebaad557d1218b6ee8f766d4e5 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 20 Jan 2018 12:58:43 +0700 Subject: [PATCH 13/14] #341 Fix wrong exit code. --- src/App.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.cpp b/src/App.cpp index 1c00e4fbbb..2eb81f5624 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -113,7 +113,7 @@ App::~App() int App::exec() { if (!m_options) { - return 0; + return 2; } uv_signal_start(&m_sigHUP, App::onSignal, SIGHUP); From 631fd755c814b772dc2bf95fe3c54a3273c4607b Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 20 Jan 2018 20:43:31 +0700 Subject: [PATCH 14/14] #341 Added option --dry-run. --- src/App.cpp | 26 ++++++++++++++++++++------ src/App.h | 1 + src/Options.cpp | 14 +++++++++++--- src/Options.h | 2 ++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index 2eb81f5624..d656acc8c9 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -130,6 +130,13 @@ int App::exec() Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash(), m_options->hugePages()); Summary::print(); + if (m_options->dryRun()) { + LOG_NOTICE("OK"); + release(); + + return 0; + } + # ifndef XMRIG_NO_API Api::start(); # endif @@ -146,12 +153,7 @@ int App::exec() const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); uv_loop_close(uv_default_loop()); - delete m_network; - - Options::release(); - Mem::release(); - Platform::release(); - + release(); return r; } @@ -200,6 +202,18 @@ void App::close() } +void App::release() +{ + if (m_network) { + delete m_network; + } + + Options::release(); + Mem::release(); + Platform::release(); +} + + void App::onSignal(uv_signal_t *handle, int signum) { switch (signum) diff --git a/src/App.h b/src/App.h index fcb3b71b7d..1b96040dc3 100644 --- a/src/App.h +++ b/src/App.h @@ -51,6 +51,7 @@ class App : public IConsoleListener private: void background(); void close(); + void release(); static void onSignal(uv_signal_t *handle, int signum); diff --git a/src/Options.cpp b/src/Options.cpp index 3eaf07ce15..4e7c75cac5 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -101,12 +101,16 @@ static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vl:S"; static struct option const options[] = { { "algo", 1, nullptr, 'a' }, + { "api-access-token", 1, nullptr, 4001 }, + { "api-port", 1, nullptr, 4000 }, + { "api-worker-id", 1, nullptr, 4002 }, { "av", 1, nullptr, 'v' }, { "background", 0, nullptr, 'B' }, { "config", 1, nullptr, 'c' }, { "cpu-affinity", 1, nullptr, 1020 }, { "cpu-priority", 1, nullptr, 1021 }, { "donate-level", 1, nullptr, 1003 }, + { "dry-run", 0, nullptr, 5000 }, { "help", 0, nullptr, 'h' }, { "keepalive", 0, nullptr ,'k' }, { "log-file", 1, nullptr, 'l' }, @@ -126,9 +130,6 @@ static struct option const options[] = { { "user-agent", 1, nullptr, 1008 }, { "userpass", 1, nullptr, 'O' }, { "version", 0, nullptr, 'V' }, - { "api-port", 1, nullptr, 4000 }, - { "api-access-token", 1, nullptr, 4001 }, - { "api-worker-id", 1, nullptr, 4002 }, { 0, 0, 0, 0 } }; @@ -141,6 +142,7 @@ static struct option const config_options[] = { { "cpu-affinity", 1, nullptr, 1020 }, { "cpu-priority", 1, nullptr, 1021 }, { "donate-level", 1, nullptr, 1003 }, + { "dry-run", 0, nullptr, 5000 }, { "huge-pages", 0, nullptr, 1009 }, { "log-file", 1, nullptr, 'l' }, { "max-cpu-usage", 1, nullptr, 1004 }, @@ -205,6 +207,7 @@ Options::Options(int argc, char **argv) : m_background(false), m_colors(true), m_doubleHash(false), + m_dryRun(false), m_hugePages(true), m_ready(false), m_safe(false), @@ -384,6 +387,7 @@ bool Options::parseArg(int key, const char *arg) case 'S': /* --syslog */ case 1005: /* --safe */ case 1006: /* --nicehash */ + case 5000: /* --dry-run */ return parseBoolean(key, true); case 1002: /* --no-color */ @@ -557,6 +561,10 @@ bool Options::parseBoolean(int key, bool enable) m_colors = enable; break; + case 5000: /* --dry-run */ + m_dryRun = enable; + break; + default: break; } diff --git a/src/Options.h b/src/Options.h index 9070888f72..6f0749179d 100644 --- a/src/Options.h +++ b/src/Options.h @@ -59,6 +59,7 @@ class Options inline bool background() const { return m_background; } inline bool colors() const { return m_colors; } inline bool doubleHash() const { return m_doubleHash; } + inline bool dryRun() const { return m_dryRun; } inline bool hugePages() const { return m_hugePages; } inline bool syslog() const { return m_syslog; } inline const char *apiToken() const { return m_apiToken; } @@ -110,6 +111,7 @@ class Options bool m_background; bool m_colors; bool m_doubleHash; + bool m_dryRun; bool m_hugePages; bool m_ready; bool m_safe;