Implemented CN-Heavy algo, Algo tests and fixed n-loop variants (#86)

* Debouncing of connection retry when connecting donation server fails
* When PoW variant is set on proxy, it will overrule local set PoW
* Implementation of cn_heavy algo
* Added self test for cn-heavy
* Fixed n-loop variant of powV2 and cn-heavy
* Fixed n-loop variant of powV2 and added cn-heavy for ARM
* Fixing n-loop for arm
* Limited cn-heavy to max hashfactor 3 on higher seltest fails.
* Removed a lot of casts
* Fixed algo selftest
This commit is contained in:
Ben Gräf 2018-04-07 21:20:24 +02:00 committed by GitHub
parent 06bb082041
commit 1ce9d2bf3c
17 changed files with 2682 additions and 450 deletions

View file

@ -6,7 +6,6 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
option(WITH_LIBCPUID "Use Libcpuid" ON) option(WITH_LIBCPUID "Use Libcpuid" ON)
option(WITH_AEON "CryptoNight-Lite support" ON)
option(WITH_HTTPD "HTTP REST API" OFF) option(WITH_HTTPD "HTTP REST API" OFF)
option(WITH_CC_CLIENT "CC Client" ON) option(WITH_CC_CLIENT "CC Client" ON)
option(WITH_CC_SERVER "CC Server" ON) option(WITH_CC_SERVER "CC Server" ON)
@ -154,10 +153,6 @@ if (HAVE_SYSLOG_H)
set(SOURCES_SYSLOG src/log/SysLog.h src/log/SysLog.cpp) set(SOURCES_SYSLOG src/log/SysLog.h src/log/SysLog.cpp)
endif() endif()
if (NOT WITH_AEON)
add_definitions(/DXMRIG_NO_AEON)
endif()
if (WITH_HTTPD) if (WITH_HTTPD)
find_package(MHD) find_package(MHD)

View file

@ -186,9 +186,9 @@ net_resolve_cb(uv_getaddrinfo_t *rv, int err, net_ai * ai) {
ret = uv_tcp_connect(net->conn, net->handle, (const struct sockaddr*) &dest, net_connect_cb); ret = uv_tcp_connect(net->conn, net->handle, (const struct sockaddr*) &dest, net_connect_cb);
if (ret != NET_OK) { if (ret != NET_OK) {
if (net->error_cb) { if (net->error_cb) {
net->error_cb(net, ret, (char *) uv_strerror(err)); net->error_cb(net, ret, (char *) uv_strerror(ret));
} else { } else {
printf("error(%s:%d) %s", net->hostname, net->port, (char *) uv_strerror(err)); printf("error(%s:%d) %s", net->hostname, net->port, (char *) uv_strerror(ret));
net_free(net); net_free(net);
} }
return; return;
@ -206,12 +206,7 @@ net_connect_cb(uv_connect_t *conn, int err) {
int read; int read;
if (err < 0) { if (err < 0) {
if (net->error_cb) {
net->error_cb(net, err, (char *) uv_strerror(err));
} else {
printf("error(%s:%d) %s", net->hostname, net->port, (char *) uv_strerror(err));
net_free(net); net_free(net);
}
return; return;
} }

View file

@ -55,7 +55,7 @@ void CpuImpl::optimizeParameters(size_t& threadsCount, size_t& hashFactor,
Options::Algo algo, size_t maxCpuUsage, bool safeMode) Options::Algo algo, size_t maxCpuUsage, bool safeMode)
{ {
// limits hashfactor to maximum possible value defined by compiler flag // limits hashfactor to maximum possible value defined by compiler flag
hashFactor = std::min(hashFactor, static_cast<size_t>(MAX_NUM_HASH_BLOCKS)); hashFactor = std::min(hashFactor, algo == Options::ALGO_CRYPTONIGHT_HEAVY ? 3 : static_cast<size_t>(MAX_NUM_HASH_BLOCKS));
if (!safeMode && threadsCount > 0 && hashFactor > 0) if (!safeMode && threadsCount > 0 && hashFactor > 0)
{ {
@ -69,6 +69,9 @@ void CpuImpl::optimizeParameters(size_t& threadsCount, size_t& hashFactor,
case Options::ALGO_CRYPTONIGHT_LITE: case Options::ALGO_CRYPTONIGHT_LITE:
algoBlockSize = 1024; algoBlockSize = 1024;
break; break;
case Options::ALGO_CRYPTONIGHT_HEAVY:
algoBlockSize = 4096;
break;
case Options::ALGO_CRYPTONIGHT: case Options::ALGO_CRYPTONIGHT:
default: default:
algoBlockSize = 2048; algoBlockSize = 2048;
@ -77,7 +80,7 @@ void CpuImpl::optimizeParameters(size_t& threadsCount, size_t& hashFactor,
size_t maximumReasonableFactor = std::max(cache / algoBlockSize, static_cast<size_t>(1ul)); size_t maximumReasonableFactor = std::max(cache / algoBlockSize, static_cast<size_t>(1ul));
size_t maximumReasonableThreadCount = std::min(maximumReasonableFactor, m_totalThreads); size_t maximumReasonableThreadCount = std::min(maximumReasonableFactor, m_totalThreads);
size_t maximumReasonableHashFactor = std::min(maximumReasonableFactor, static_cast<size_t>(MAX_NUM_HASH_BLOCKS)); size_t maximumReasonableHashFactor = std::min(maximumReasonableFactor, algo == Options::ALGO_CRYPTONIGHT_HEAVY ? 3 : static_cast<size_t>(MAX_NUM_HASH_BLOCKS));
if (safeMode) { if (safeMode) {
if (threadsCount > maximumReasonableThreadCount) { if (threadsCount > maximumReasonableThreadCount) {

View file

@ -39,7 +39,21 @@ Mem::ThreadBitSet Mem::m_multiHashThreadMask = Mem::ThreadBitSet(-1L);
cryptonight_ctx *Mem::create(int threadId) cryptonight_ctx *Mem::create(int threadId)
{ {
size_t scratchPadSize = m_algo == Options::ALGO_CRYPTONIGHT ? MEMORY : MEMORY_LITE; size_t scratchPadSize;
switch (m_algo)
{
case Options::ALGO_CRYPTONIGHT_LITE:
scratchPadSize = MEMORY_LITE;
break;
case Options::ALGO_CRYPTONIGHT_HEAVY:
scratchPadSize = MEMORY_HEAVY;
break;
case Options::ALGO_CRYPTONIGHT:
default:
scratchPadSize = MEMORY;
break;
}
size_t offset = 0; size_t offset = 0;
for (int i=0; i < threadId; i++) { for (int i=0; i < threadId; i++) {

View file

@ -46,7 +46,21 @@ bool Mem::allocate(const Options* options)
m_multiHashThreadMask = Mem::ThreadBitSet(options->multiHashThreadMask()); m_multiHashThreadMask = Mem::ThreadBitSet(options->multiHashThreadMask());
m_memorySize = 0; m_memorySize = 0;
size_t scratchPadSize = m_algo == Options::ALGO_CRYPTONIGHT ? MEMORY : MEMORY_LITE; size_t scratchPadSize;
switch (m_algo)
{
case Options::ALGO_CRYPTONIGHT_LITE:
scratchPadSize = MEMORY_LITE;
break;
case Options::ALGO_CRYPTONIGHT_HEAVY:
scratchPadSize = MEMORY_HEAVY;
break;
case Options::ALGO_CRYPTONIGHT:
default:
scratchPadSize = MEMORY;
break;
}
for (size_t i=0; i < m_threads; i++) { for (size_t i=0; i < m_threads; i++) {
m_memorySize += sizeof(cryptonight_ctx); m_memorySize += sizeof(cryptonight_ctx);
m_memorySize += scratchPadSize * getThreadHashFactor(i); m_memorySize += scratchPadSize * getThreadHashFactor(i);

View file

@ -152,7 +152,21 @@ bool Mem::allocate(const Options* options)
m_multiHashThreadMask = Mem::ThreadBitSet(options->multiHashThreadMask()); m_multiHashThreadMask = Mem::ThreadBitSet(options->multiHashThreadMask());
m_memorySize = 0; m_memorySize = 0;
size_t scratchPadSize = m_algo == Options::ALGO_CRYPTONIGHT ? MEMORY : MEMORY_LITE; size_t scratchPadSize;
switch (m_algo)
{
case Options::ALGO_CRYPTONIGHT_LITE:
scratchPadSize = MEMORY_LITE;
break;
case Options::ALGO_CRYPTONIGHT_HEAVY:
scratchPadSize = MEMORY_HEAVY;
break;
case Options::ALGO_CRYPTONIGHT:
default:
scratchPadSize = MEMORY;
break;
}
for (size_t i=0; i < m_threads; i++) { for (size_t i=0; i < m_threads; i++) {
m_memorySize += sizeof(cryptonight_ctx); m_memorySize += sizeof(cryptonight_ctx);
m_memorySize += scratchPadSize * getThreadHashFactor(i); m_memorySize += scratchPadSize * getThreadHashFactor(i);

View file

@ -64,7 +64,7 @@ Usage: " APP_ID " [OPTIONS]\n\
Options:\n" Options:\n"
# ifndef XMRIG_CC_SERVER # ifndef XMRIG_CC_SERVER
"\ "\
-a, --algo=ALGO cryptonight (default) or cryptonight-lite\n\ -a, --algo=ALGO cryptonight (default) / cryptonight-lite or cryptonight-heavy\n\
-o, --url=URL URL of mining server\n\ -o, --url=URL URL of mining server\n\
-O, --userpass=U:P username:password pair for mining server\n\ -O, --userpass=U:P username:password pair for mining server\n\
-u, --user=USERNAME username for mining server\n\ -u, --user=USERNAME username for mining server\n\
@ -76,6 +76,7 @@ Options:\n"
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\ -r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
-R, --retry-pause=N time to pause between retries (default: 5)\n\ -R, --retry-pause=N time to pause between retries (default: 5)\n\
--force-pow-version=N force to use specific PoW variation (default: 0 POW_AUTODETECT, 1 POW_V1, 2 POW_V2)\n\ --force-pow-version=N force to use specific PoW variation (default: 0 POW_AUTODETECT, 1 POW_V1, 2 POW_V2)\n\
--multihash-factor=N number of hash blocks to process at a time (not set or 0 enables automatic selection of optimal number of hash blocks)\n\
--multihash-thread-mask for av=2/4 only, limits multihash to given threads (mask), (default: all threads)\n\ --multihash-thread-mask for av=2/4 only, limits multihash to given threads (mask), (default: all threads)\n\
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\ --cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\ --cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
@ -257,9 +258,8 @@ static struct option const cc_server_options[] = {
static const char *algo_names[] = { static const char *algo_names[] = {
"cryptonight", "cryptonight",
# ifndef XMRIG_NO_AEON "cryptonight-lite",
"cryptonight-lite" "cryptonight-heavy"
# endif
}; };
@ -616,7 +616,7 @@ bool Options::parseArg(int key, uint64_t arg)
break; break;
case 't': /* --threads */ case 't': /* --threads */
if (arg < 1 || arg > 1024) { if (arg < 0 || arg > 1024) {
showUsage(1); showUsage(1);
return false; return false;
} }
@ -919,12 +919,15 @@ bool Options::setAlgo(const char *algo)
break; break;
} }
# ifndef XMRIG_NO_AEON
if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-light")) { if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-light")) {
m_algo = ALGO_CRYPTONIGHT_LITE; m_algo = ALGO_CRYPTONIGHT_LITE;
break; break;
} }
# endif
if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-heavy")) {
m_algo = ALGO_CRYPTONIGHT_HEAVY;
break;
}
if (i == ARRAY_SIZE(algo_names) - 1) { if (i == ARRAY_SIZE(algo_names) - 1) {
showUsage(1); showUsage(1);
@ -977,6 +980,11 @@ void Options::optimizeAlgorithmConfiguration()
m_aesni = aesniFromCpu; m_aesni = aesniFromCpu;
} }
if (m_algo == Options::ALGO_CRYPTONIGHT_HEAVY && m_hashFactor > 3) {
fprintf(stderr, "Maximum supported hashfactor for cryptonight-heavy is: 3\n");
m_hashFactor = 3;
}
Cpu::optimizeParameters(m_threads, m_hashFactor, m_algo, m_maxCpuUsage, m_safe); Cpu::optimizeParameters(m_threads, m_hashFactor, m_algo, m_maxCpuUsage, m_safe);
} }

View file

@ -44,6 +44,7 @@ public:
enum Algo { enum Algo {
ALGO_CRYPTONIGHT, /* CryptoNight (Monero) */ ALGO_CRYPTONIGHT, /* CryptoNight (Monero) */
ALGO_CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ ALGO_CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
ALGO_CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (SUMO) */
}; };
enum AlgoVariant { enum AlgoVariant {

View file

@ -34,7 +34,7 @@
#include "crypto/CryptoNight_test.h" #include "crypto/CryptoNight_test.h"
template <size_t NUM_HASH_BLOCKS> template <size_t NUM_HASH_BLOCKS>
static void cryptonight_aesni(const void *input, size_t size, void *output, cryptonight_ctx *ctx) { static void cryptonight_aesni(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
# if !defined(XMRIG_ARMv7) # if !defined(XMRIG_ARMv7)
if ((reinterpret_cast<const uint8_t*>(input)[0] > 6 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) || if ((reinterpret_cast<const uint8_t*>(input)[0] > 6 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) ||
Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) { Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) {
@ -46,7 +46,7 @@ static void cryptonight_aesni(const void *input, size_t size, void *output, cryp
} }
template <size_t NUM_HASH_BLOCKS> template <size_t NUM_HASH_BLOCKS>
static void cryptonight_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx) { static void cryptonight_softaes(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
if ((reinterpret_cast<const uint8_t*>(input)[0] > 6 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) || if ((reinterpret_cast<const uint8_t*>(input)[0] > 6 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) ||
Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) { Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) {
CryptoNightMultiHash<0x80000, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); CryptoNightMultiHash<0x80000, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
@ -56,7 +56,7 @@ static void cryptonight_softaes(const void *input, size_t size, void *output, cr
} }
template <size_t NUM_HASH_BLOCKS> template <size_t NUM_HASH_BLOCKS>
static void cryptonight_lite_aesni(const void *input, size_t size, void *output, cryptonight_ctx *ctx) { static void cryptonight_lite_aesni(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
# if !defined(XMRIG_ARMv7) # if !defined(XMRIG_ARMv7)
if ((reinterpret_cast<const uint8_t*>(input)[0] > 1 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) || if ((reinterpret_cast<const uint8_t*>(input)[0] > 1 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) ||
Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) { Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) {
@ -68,7 +68,7 @@ static void cryptonight_lite_aesni(const void *input, size_t size, void *output,
} }
template <size_t NUM_HASH_BLOCKS> template <size_t NUM_HASH_BLOCKS>
static void cryptonight_lite_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx) { static void cryptonight_lite_softaes(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
if ((reinterpret_cast<const uint8_t*>(input)[0] > 1 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) || if ((reinterpret_cast<const uint8_t*>(input)[0] > 1 && Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT) ||
Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) { Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) {
CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
@ -77,7 +77,20 @@ static void cryptonight_lite_softaes(const void *input, size_t size, void *outpu
} }
} }
void (*cryptonight_hash_ctx[MAX_NUM_HASH_BLOCKS])(const void *input, size_t size, void *output, cryptonight_ctx *ctx);
template <size_t NUM_HASH_BLOCKS>
static void cryptonight_heavy_aesni(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
# if !defined(XMRIG_ARMv7)
CryptoNightMultiHash<0x40000, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
# endif
}
template <size_t NUM_HASH_BLOCKS>
static void cryptonight_heavy_softaes(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
CryptoNightMultiHash<0x40000, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
}
void (*cryptonight_hash_ctx[MAX_NUM_HASH_BLOCKS])(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx);
template <size_t HASH_FACTOR> template <size_t HASH_FACTOR>
void setCryptoNightHashMethods(Options::Algo algo, bool aesni) void setCryptoNightHashMethods(Options::Algo algo, bool aesni)
@ -98,6 +111,14 @@ void setCryptoNightHashMethods(Options::Algo algo, bool aesni)
cryptonight_hash_ctx[HASH_FACTOR - 1] = cryptonight_lite_softaes<HASH_FACTOR>; cryptonight_hash_ctx[HASH_FACTOR - 1] = cryptonight_lite_softaes<HASH_FACTOR>;
} }
break; break;
case Options::ALGO_CRYPTONIGHT_HEAVY:
if (aesni) {
cryptonight_hash_ctx[HASH_FACTOR - 1] = cryptonight_heavy_aesni<HASH_FACTOR>;
} else {
cryptonight_hash_ctx[HASH_FACTOR - 1] = cryptonight_heavy_softaes<HASH_FACTOR>;
}
break;
} }
// next iteration // next iteration
setCryptoNightHashMethods<HASH_FACTOR-1>(algo, aesni); setCryptoNightHashMethods<HASH_FACTOR-1>(algo, aesni);
@ -139,56 +160,92 @@ bool CryptoNight::selfTest(int algo)
return false; return false;
} }
char output[160]; uint8_t output[160];
auto ctx = (struct cryptonight_ctx*) _mm_malloc(sizeof(struct cryptonight_ctx), 16); auto ctx = (struct cryptonight_ctx*) _mm_malloc(sizeof(struct cryptonight_ctx), 16);
ctx->memory = (uint8_t *) _mm_malloc(MEMORY * 6, 16); ctx->memory = (uint8_t *) _mm_malloc(MEMORY * 6, 16);
bool resultV1Pow = true; bool resultV1Pow = true;
if (Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT || Options::i()->forcePowVersion() == Options::PowVersion::POW_V1) { bool resultV2Pow = true;
bool resultHeavy = true;
if (algo == Options::ALGO_CRYPTONIGHT_HEAVY)
{
cryptonight_hash_ctx[0](test_input, 76, output, ctx); cryptonight_hash_ctx[0](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, 32) == 0; resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 32) == 0;
#if MAX_NUM_HASH_BLOCKS > 1 #if MAX_NUM_HASH_BLOCKS > 1
cryptonight_hash_ctx[1](test_input, 76, output, ctx); cryptonight_hash_ctx[1](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, 64) == 0; resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 64) == 0;
#endif #endif
#if MAX_NUM_HASH_BLOCKS > 2 #if MAX_NUM_HASH_BLOCKS > 2
cryptonight_hash_ctx[2](test_input, 76, output, ctx); cryptonight_hash_ctx[2](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, 96) == 0; resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 96) == 0;
#endif #endif
}
else {
if (Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT ||
Options::i()->forcePowVersion() == Options::PowVersion::POW_V1) {
cryptonight_hash_ctx[0](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow &&
memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output,
32) == 0;
#if MAX_NUM_HASH_BLOCKS > 3 #if MAX_NUM_HASH_BLOCKS > 1
cryptonight_hash_ctx[1](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow &&
memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output,
64) == 0;
#endif
#if MAX_NUM_HASH_BLOCKS > 2
cryptonight_hash_ctx[2](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow &&
memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output,
96) == 0;
#endif
#if MAX_NUM_HASH_BLOCKS > 3
cryptonight_hash_ctx[3](test_input, 76, output, ctx); cryptonight_hash_ctx[3](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, 128) == 0; resultV1Pow = resultV1Pow &&
#endif memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output,
128) == 0;
#endif
#if MAX_NUM_HASH_BLOCKS > 4 #if MAX_NUM_HASH_BLOCKS > 4
cryptonight_hash_ctx[4](test_input, 76, output, ctx); cryptonight_hash_ctx[4](test_input, 76, output, ctx);
resultV1Pow = resultV1Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, 160) == 0; resultV1Pow = resultV1Pow &&
#endif memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output,
160) == 0;
#endif
} }
// monero/aeon v2 pow (monero/aeon blockchain version 7) // monero/aeon v2 pow (monero/aeon blockchain version 7)
bool resultV2Pow = true; if (Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT ||
if (Options::i()->forcePowVersion() == Options::PowVersion::POW_AUTODETECT || Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) { Options::i()->forcePowVersion() == Options::PowVersion::POW_V2) {
cryptonight_hash_ctx[0](test_input_monero_v2_pow_0, sizeof(test_input_monero_v2_pow_0), output, ctx); cryptonight_hash_ctx[0](test_input_monero_v2_pow_0, sizeof(test_input_monero_v2_pow_0), output, ctx);
resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_monero_v2_pow_light[0] : test_output_monero_v2_pow[0], 32) == 0; resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE
? test_output_monero_v2_pow_light[0]
: test_output_monero_v2_pow[0], 32) == 0;
#if MAX_NUM_HASH_BLOCKS > 1 #if MAX_NUM_HASH_BLOCKS > 1
cryptonight_hash_ctx[1](test_input_monero_v2_pow_1, sizeof(test_input_monero_v2_pow_1), output, ctx); cryptonight_hash_ctx[1](test_input_monero_v2_pow_1, sizeof(test_input_monero_v2_pow_1), output, ctx);
resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_monero_v2_pow_light[1] : test_output_monero_v2_pow[1], 32) == 0; resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE
#endif ? test_output_monero_v2_pow_light[1]
: test_output_monero_v2_pow[1], 32) == 0;
#endif
#if MAX_NUM_HASH_BLOCKS > 2 #if MAX_NUM_HASH_BLOCKS > 2
cryptonight_hash_ctx[2](test_input_monero_v2_pow_2, sizeof(test_input_monero_v2_pow_2), output, ctx); cryptonight_hash_ctx[2](test_input_monero_v2_pow_2, sizeof(test_input_monero_v2_pow_2), output, ctx);
resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_monero_v2_pow_light[2] : test_output_monero_v2_pow[2], 32) == 0; resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE
#endif ? test_output_monero_v2_pow_light[2]
: test_output_monero_v2_pow[2], 32) == 0;
#endif
}
} }
_mm_free(ctx->memory); _mm_free(ctx->memory);
_mm_free(ctx); _mm_free(ctx);
return resultV1Pow && resultV2Pow; return resultV1Pow && resultV2Pow & resultHeavy;
} }

View file

@ -32,6 +32,7 @@
#define MEMORY 2097152 /* 2 MiB */ #define MEMORY 2097152 /* 2 MiB */
#define MEMORY_LITE 1048576 /* 1 MiB */ #define MEMORY_LITE 1048576 /* 1 MiB */
#define MEMORY_HEAVY 4194304 /* 4 MiB */
struct cryptonight_ctx { struct cryptonight_ctx {
alignas(16) uint8_t state[MAX_NUM_HASH_BLOCKS][208]; // 208 instead of 200 to maintain aligned to 16 byte boundaries alignas(16) uint8_t state[MAX_NUM_HASH_BLOCKS][208]; // 208 instead of 200 to maintain aligned to 16 byte boundaries

File diff suppressed because it is too large Load diff

View file

@ -64,10 +64,12 @@ const static uint8_t test_output[] = {
0x96, 0xB6, 0x1C, 0x8A, 0xE9, 0x82, 0xF6, 0x1A, 0x90, 0x16, 0x0F, 0x4E, 0x52, 0x82, 0x8A, 0x7F, 0x96, 0xB6, 0x1C, 0x8A, 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C, 0xBE, 0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE,
0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD, 0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD,
0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E, 0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E,
@ -131,10 +135,22 @@ const static uint8_t test_output_monero_v2_pow_light[3][32] = {
0x03, 0xf5, 0x39, 0x53, 0x15, 0xde, 0x91, 0x9a, 0xcf, 0x1b, 0x97, 0xf0, 0xa8, 0x4f, 0xbd, 0x2d} 0x03, 0xf5, 0x39, 0x53, 0x15, 0xde, 0x91, 0x9a, 0xcf, 0x1b, 0x97, 0xf0, 0xa8, 0x4f, 0xbd, 0x2d}
}; };
const static uint8_t test_output_heavy[] = {
0x4D, 0x94, 0x7D, 0xD6, 0xDB, 0x6E, 0x07, 0x48, 0x26, 0x4A, 0x51, 0x2E, 0xAC, 0xF3, 0x25, 0x4A,
0x1F, 0x1A, 0xA2, 0x5B, 0xFC, 0x0A, 0xAD, 0x82, 0xDE, 0xA8, 0x99, 0x96, 0x88, 0x52, 0xD2, 0x7D,
0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64,
0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2,
0x4D, 0x94, 0x7D, 0xD6, 0xDB, 0x6E, 0x07, 0x48, 0x26, 0x4A, 0x51, 0x2E, 0xAC, 0xF3, 0x25, 0x4A,
0x1F, 0x1A, 0xA2, 0x5B, 0xFC, 0x0A, 0xAD, 0x82, 0xDE, 0xA8, 0x99, 0x96, 0x88, 0x52, 0xD2, 0x7D,
0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64,
0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2,
0x4D, 0x94, 0x7D, 0xD6, 0xDB, 0x6E, 0x07, 0x48, 0x26, 0x4A, 0x51, 0x2E, 0xAC, 0xF3, 0x25, 0x4A,
0x1F, 0x1A, 0xA2, 0x5B, 0xFC, 0x0A, 0xAD, 0x82, 0xDE, 0xA8, 0x99, 0x96, 0x88, 0x52, 0xD2, 0x7D,
0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64,
0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2
};
#endif /* __CRYPTONIGHT_TEST_H__ */ #endif /* __CRYPTONIGHT_TEST_H__ */

File diff suppressed because it is too large Load diff

View file

@ -209,7 +209,6 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
if (params.HasMember("variant")) { if (params.HasMember("variant")) {
int variantFromProxy = params["variant"].GetInt(); int variantFromProxy = params["variant"].GetInt();
if (Options::i()->forcePowVersion() == Options::POW_AUTODETECT) {
switch (variantFromProxy) { switch (variantFromProxy) {
case -1: case -1:
Options::i()->setForcePowVersion(Options::POW_AUTODETECT); Options::i()->setForcePowVersion(Options::POW_AUTODETECT);
@ -224,7 +223,6 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
break; break;
} }
} }
}
if (m_job != job) { if (m_job != job) {
m_jobs++; m_jobs++;
@ -584,7 +582,10 @@ void Client::reconnect() {
# endif # endif
if (m_failures == -1) { if (m_failures == -1) {
LOG_DEBUG("Client::onConnect -> m_failures == -1"); LOG_DEBUG("Client::reconnect -> m_failures == -1");
m_failures = 0;
m_expire = 0;
return m_listener->onClose(this, -1); return m_listener->onClose(this, -1);
} }

View file

@ -23,6 +23,7 @@
*/ */
#include <log/Log.h>
#include "interfaces/IStrategyListener.h" #include "interfaces/IStrategyListener.h"
#include "net/Client.h" #include "net/Client.h"
#include "net/Job.h" #include "net/Job.h"
@ -55,6 +56,9 @@ DonateStrategy::DonateStrategy(const char *agent, IStrategyListener *listener) :
Url *url; Url *url;
#ifndef XMRIG_NO_TLS #ifndef XMRIG_NO_TLS
if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_HEAVY) {
url = new Url("donate2.graef.in", 8443, userId, nullptr, true, false, true);
} else {
if (Options::i()->forcePowVersion() == Options::POW_V1) { if (Options::i()->forcePowVersion() == Options::POW_V1) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 8081, userId, nullptr, true, false, true); url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 8081, userId, nullptr, true, false, true);
} else if (Options::i()->forcePowVersion() == Options::POW_V2) { } else if (Options::i()->forcePowVersion() == Options::POW_V2) {
@ -62,7 +66,11 @@ DonateStrategy::DonateStrategy(const char *agent, IStrategyListener *listener) :
} else { } else {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8081 : 443, userId, nullptr, true, false, true); url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8081 : 443, userId, nullptr, true, false, true);
} }
}
#else #else
if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_HEAVY) {
url = new Url("donate.graef.in", 8443, userId, nullptr, false, false, true);
} else {
if (Options::i()->forcePowVersion() == Options::POW_V1) { if (Options::i()->forcePowVersion() == Options::POW_V1) {
url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 80 : 443, userId, nullptr, false, false, true); url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 80 : 443, userId, nullptr, false, false, true);
} else if (Options::i()->forcePowVersion() == Options::POW_V2) { } else if (Options::i()->forcePowVersion() == Options::POW_V2) {
@ -70,6 +78,7 @@ DonateStrategy::DonateStrategy(const char *agent, IStrategyListener *listener) :
} else { } else {
url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 80, userId, nullptr, false, false, true); url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 80, userId, nullptr, false, false, true);
} }
}
#endif #endif
m_client = new Client(-1, agent, this); m_client = new Client(-1, agent, this);
@ -113,6 +122,11 @@ void DonateStrategy::tick(uint64_t now)
void DonateStrategy::onClose(Client *client, int failures) void DonateStrategy::onClose(Client *client, int failures)
{ {
if (failures == 5) {
LOG_ERR("Failed to connect to donate address. Reschedule.");
uv_timer_stop(&m_timer);
uv_timer_start(&m_timer, DonateStrategy::onSuspendTimer, 1000, 0);
}
} }
@ -166,3 +180,9 @@ void DonateStrategy::onTimer(uv_timer_t *handle)
strategy->suspend(); strategy->suspend();
} }
void DonateStrategy::onSuspendTimer(uv_timer_t *handle)
{
auto strategy = static_cast<DonateStrategy*>(handle->data);
strategy->suspend();
}

View file

@ -62,6 +62,7 @@ private:
void suspend(); void suspend();
static void onTimer(uv_timer_t *handle); static void onTimer(uv_timer_t *handle);
static void onSuspendTimer(uv_timer_t *handle);
bool m_active; bool m_active;
Client *m_client; Client *m_client;

View file

@ -36,14 +36,14 @@
#define APP_DESC "XMRigCC CPU miner" #define APP_DESC "XMRigCC CPU miner"
#define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id" #define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id"
#endif #endif
#define APP_VERSION "1.5.5 (based on XMRig 2.5.2)" #define APP_VERSION "1.6.0_cn_heavy_support_v1 (based on XMRig 2.5.2)"
#define APP_DOMAIN "" #define APP_DOMAIN ""
#define APP_SITE "https://github.com/Bendr0id/xmrigCC" #define APP_SITE "https://github.com/Bendr0id/xmrigCC"
#define APP_KIND "cpu" #define APP_KIND "cpu"
#define APP_VER_MAJOR 1 #define APP_VER_MAJOR 1
#define APP_VER_MINOR 5 #define APP_VER_MINOR 6
#define APP_VER_BUILD 5 #define APP_VER_BUILD 0
#define APP_VER_REV 0 #define APP_VER_REV 0
#ifndef NDEBUG #ifndef NDEBUG