From 75ae1dd60165141700c36ab699656e9e073e186d Mon Sep 17 00:00:00 2001 From: Tony Butler Date: Thu, 5 Apr 2018 23:19:48 -0600 Subject: Repair all 'namepsace' to 'namespace' (all within comments) --- xmrstak/backend/cpu/autoAdjust.hpp | 2 +- xmrstak/backend/cpu/autoAdjustHwloc.hpp | 2 +- xmrstak/backend/cpu/jconf.cpp | 2 +- xmrstak/backend/cpu/jconf.hpp | 2 +- xmrstak/backend/cpu/minethd.cpp | 2 +- xmrstak/backend/cpu/minethd.hpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'xmrstak/backend/cpu') diff --git a/xmrstak/backend/cpu/autoAdjust.hpp b/xmrstak/backend/cpu/autoAdjust.hpp index 969d478..abba8b6 100644 --- a/xmrstak/backend/cpu/autoAdjust.hpp +++ b/xmrstak/backend/cpu/autoAdjust.hpp @@ -172,4 +172,4 @@ private: }; } // namespace cpu -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/backend/cpu/autoAdjustHwloc.hpp b/xmrstak/backend/cpu/autoAdjustHwloc.hpp index 568abb5..68d2b3f 100644 --- a/xmrstak/backend/cpu/autoAdjustHwloc.hpp +++ b/xmrstak/backend/cpu/autoAdjustHwloc.hpp @@ -214,4 +214,4 @@ private: }; } // namespace cpu -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/backend/cpu/jconf.cpp b/xmrstak/backend/cpu/jconf.cpp index 399dd16..49da7ae 100644 --- a/xmrstak/backend/cpu/jconf.cpp +++ b/xmrstak/backend/cpu/jconf.cpp @@ -259,4 +259,4 @@ bool jconf::parse_config(const char* sFilename) } } // namespace cpu -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/backend/cpu/jconf.hpp b/xmrstak/backend/cpu/jconf.hpp index e98ed16..be85503 100644 --- a/xmrstak/backend/cpu/jconf.hpp +++ b/xmrstak/backend/cpu/jconf.hpp @@ -40,4 +40,4 @@ private: }; } // namespace cpu -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 5b56f85..ec3e145 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -769,4 +769,4 @@ void minethd::multiway_work_main() } } // namespace cpu -} // namepsace xmrstak +} // namespace xmrstak diff --git a/xmrstak/backend/cpu/minethd.hpp b/xmrstak/backend/cpu/minethd.hpp index cd78343..59583b6 100644 --- a/xmrstak/backend/cpu/minethd.hpp +++ b/xmrstak/backend/cpu/minethd.hpp @@ -65,4 +65,4 @@ private: }; } // namespace cpu -} // namepsace xmrstak +} // namespace xmrstak -- cgit v1.1 From 5fd4520afa4dd824676f9e24e3f3c771687a6a39 Mon Sep 17 00:00:00 2001 From: Tony Butler Date: Thu, 5 Apr 2018 23:30:19 -0600 Subject: Repair more typos in comments only --- xmrstak/backend/cpu/crypto/skein_port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmrstak/backend/cpu') diff --git a/xmrstak/backend/cpu/crypto/skein_port.h b/xmrstak/backend/cpu/crypto/skein_port.h index 9cbefcb..99641bc 100644 --- a/xmrstak/backend/cpu/crypto/skein_port.h +++ b/xmrstak/backend/cpu/crypto/skein_port.h @@ -49,7 +49,7 @@ multiple of size / 8) ptr_cast(x,size) casts a pointer to a pointer to a - varaiable of length 'size' bits + variable of length 'size' bits */ #define ui_type(size) uint##size##_t -- cgit v1.1 From 1b18f598aa1190a0e6126ed2c70e052e9403d180 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Sun, 8 Apr 2018 20:40:54 +0200 Subject: refactor scratchpad creation Use the maximum scratchpad size from before and after the fork. --- xmrstak/backend/cpu/autoAdjust.hpp | 5 ++++- xmrstak/backend/cpu/autoAdjustHwloc.hpp | 5 ++++- xmrstak/backend/cpu/crypto/cryptonight_common.cpp | 11 +++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'xmrstak/backend/cpu') diff --git a/xmrstak/backend/cpu/autoAdjust.hpp b/xmrstak/backend/cpu/autoAdjust.hpp index abba8b6..ed96d8b 100644 --- a/xmrstak/backend/cpu/autoAdjust.hpp +++ b/xmrstak/backend/cpu/autoAdjust.hpp @@ -36,7 +36,10 @@ public: bool printConfig() { - const size_t hashMemSizeKB = cn_select_memory(::jconf::inst()->GetMiningAlgo()) / 1024u; + const size_t hashMemSizeKB = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ) / 1024u; const size_t halfHashMemSizeKB = hashMemSizeKB / 2u; configEditor configTpl{}; diff --git a/xmrstak/backend/cpu/autoAdjustHwloc.hpp b/xmrstak/backend/cpu/autoAdjustHwloc.hpp index 68d2b3f..f110ee3 100644 --- a/xmrstak/backend/cpu/autoAdjustHwloc.hpp +++ b/xmrstak/backend/cpu/autoAdjustHwloc.hpp @@ -28,7 +28,10 @@ public: autoAdjust() { - hashMemSize = cn_select_memory(::jconf::inst()->GetMiningAlgo()); + hashMemSize = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ); halfHashMemSize = hashMemSize / 2u; } diff --git a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp index 17fa24b..ac696dd 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp +++ b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp @@ -35,6 +35,7 @@ extern "C" #include "xmrstak/jconf.hpp" #include #include +#include #ifdef __GNUC__ #include @@ -202,7 +203,10 @@ size_t cryptonight_init(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg) cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg) { - size_t hashMemSize = cn_select_memory(::jconf::inst()->GetMiningAlgo()); + size_t hashMemSize = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ); cryptonight_ctx* ptr = (cryptonight_ctx*)_mm_malloc(sizeof(cryptonight_ctx), 4096); @@ -278,7 +282,10 @@ cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, al void cryptonight_free_ctx(cryptonight_ctx* ctx) { - size_t hashMemSize = cn_select_memory(::jconf::inst()->GetMiningAlgo()); + size_t hashMemSize = std::max( + cn_select_memory(::jconf::inst()->GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + ); if(ctx->ctx_info[0] != 0) { -- cgit v1.1 From 8a2e5049f6dee227eb8b4fa8d747863ac18b9e58 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Sat, 14 Apr 2018 21:29:57 +0200 Subject: change 64Bit size value to 32Bit avoid conversion warning by reducing the size value type --- xmrstak/backend/cpu/crypto/c_blake256.c | 16 ++++++++-------- xmrstak/backend/cpu/crypto/c_blake256.h | 16 ++++++++-------- xmrstak/backend/cpu/crypto/c_skein.h | 2 +- xmrstak/backend/cpu/crypto/cryptonight_aesni.h | 2 +- xmrstak/backend/cpu/crypto/cryptonight_common.cpp | 10 +++++----- xmrstak/backend/cpu/crypto/hash.h | 4 +++- 6 files changed, 26 insertions(+), 24 deletions(-) (limited to 'xmrstak/backend/cpu') diff --git a/xmrstak/backend/cpu/crypto/c_blake256.c b/xmrstak/backend/cpu/crypto/c_blake256.c index ff623dd..e5fadfe 100644 --- a/xmrstak/backend/cpu/crypto/c_blake256.c +++ b/xmrstak/backend/cpu/crypto/c_blake256.c @@ -124,7 +124,7 @@ void blake224_init(state *S) { } // datalen = number of bits -void blake256_update(state *S, const uint8_t *data, uint64_t datalen) { +void blake256_update(state *S, const uint8_t *data, uint32_t datalen) { int left = S->buflen >> 3; int fill = 64 - left; @@ -155,7 +155,7 @@ void blake256_update(state *S, const uint8_t *data, uint64_t datalen) { } // datalen = number of bits -void blake224_update(state *S, const uint8_t *data, uint64_t datalen) { +void blake224_update(state *S, const uint8_t *data, uint32_t datalen) { blake256_update(S, data, datalen); } @@ -206,7 +206,7 @@ void blake224_final(state *S, uint8_t *digest) { } // inlen = number of bytes -void blake256_hash(uint8_t *out, const uint8_t *in, uint64_t inlen) { +void blake256_hash(uint8_t *out, const uint8_t *in, uint32_t inlen) { state S; blake256_init(&S); blake256_update(&S, in, inlen * 8); @@ -214,7 +214,7 @@ void blake256_hash(uint8_t *out, const uint8_t *in, uint64_t inlen) { } // inlen = number of bytes -void blake224_hash(uint8_t *out, const uint8_t *in, uint64_t inlen) { +void blake224_hash(uint8_t *out, const uint8_t *in, uint32_t inlen) { state S; blake224_init(&S); blake224_update(&S, in, inlen * 8); @@ -282,13 +282,13 @@ void hmac_blake224_init(hmac_state *S, const uint8_t *_key, uint64_t keylen) { } // datalen = number of bits -void hmac_blake256_update(hmac_state *S, const uint8_t *data, uint64_t datalen) { +void hmac_blake256_update(hmac_state *S, const uint8_t *data, uint32_t datalen) { // update the inner state blake256_update(&S->inner, data, datalen); } // datalen = number of bits -void hmac_blake224_update(hmac_state *S, const uint8_t *data, uint64_t datalen) { +void hmac_blake224_update(hmac_state *S, const uint8_t *data, uint32_t datalen) { // update the inner state blake224_update(&S->inner, data, datalen); } @@ -310,7 +310,7 @@ void hmac_blake224_final(hmac_state *S, uint8_t *digest) { } // keylen = number of bytes; inlen = number of bytes -void hmac_blake256_hash(uint8_t *out, const uint8_t *key, uint64_t keylen, const uint8_t *in, uint64_t inlen) { +void hmac_blake256_hash(uint8_t *out, const uint8_t *key, uint64_t keylen, const uint8_t *in, uint32_t inlen) { hmac_state S; hmac_blake256_init(&S, key, keylen); hmac_blake256_update(&S, in, inlen * 8); @@ -318,7 +318,7 @@ void hmac_blake256_hash(uint8_t *out, const uint8_t *key, uint64_t keylen, const } // keylen = number of bytes; inlen = number of bytes -void hmac_blake224_hash(uint8_t *out, const uint8_t *key, uint64_t keylen, const uint8_t *in, uint64_t inlen) { +void hmac_blake224_hash(uint8_t *out, const uint8_t *key, uint64_t keylen, const uint8_t *in, uint32_t inlen) { hmac_state S; hmac_blake224_init(&S, key, keylen); hmac_blake224_update(&S, in, inlen * 8); diff --git a/xmrstak/backend/cpu/crypto/c_blake256.h b/xmrstak/backend/cpu/crypto/c_blake256.h index b9c2aad..06c7917 100644 --- a/xmrstak/backend/cpu/crypto/c_blake256.h +++ b/xmrstak/backend/cpu/crypto/c_blake256.h @@ -17,27 +17,27 @@ typedef struct { void blake256_init(state *); void blake224_init(state *); -void blake256_update(state *, const uint8_t *, uint64_t); -void blake224_update(state *, const uint8_t *, uint64_t); +void blake256_update(state *, const uint8_t *, uint32_t); +void blake224_update(state *, const uint8_t *, uint32_t); void blake256_final(state *, uint8_t *); void blake224_final(state *, uint8_t *); -void blake256_hash(uint8_t *, const uint8_t *, uint64_t); -void blake224_hash(uint8_t *, const uint8_t *, uint64_t); +void blake256_hash(uint8_t *, const uint8_t *, uint32_t); +void blake224_hash(uint8_t *, const uint8_t *, uint32_t); /* HMAC functions: */ void hmac_blake256_init(hmac_state *, const uint8_t *, uint64_t); void hmac_blake224_init(hmac_state *, const uint8_t *, uint64_t); -void hmac_blake256_update(hmac_state *, const uint8_t *, uint64_t); -void hmac_blake224_update(hmac_state *, const uint8_t *, uint64_t); +void hmac_blake256_update(hmac_state *, const uint8_t *, uint32_t); +void hmac_blake224_update(hmac_state *, const uint8_t *, uint32_t); void hmac_blake256_final(hmac_state *, uint8_t *); void hmac_blake224_final(hmac_state *, uint8_t *); -void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); -void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); +void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint32_t); +void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint32_t); #endif /* _BLAKE256_H_ */ diff --git a/xmrstak/backend/cpu/crypto/c_skein.h b/xmrstak/backend/cpu/crypto/c_skein.h index 6165a2a..86dbc08 100644 --- a/xmrstak/backend/cpu/crypto/c_skein.h +++ b/xmrstak/backend/cpu/crypto/c_skein.h @@ -37,7 +37,7 @@ typedef enum } SkeinHashReturn; -typedef size_t SkeinDataLength; /* bit count type */ +typedef uint32_t SkeinDataLength; /* bit count type */ typedef u08b_t SkeinBitSequence; /* bit stream type */ /* "all-in-one" call */ diff --git a/xmrstak/backend/cpu/crypto/cryptonight_aesni.h b/xmrstak/backend/cpu/crypto/cryptonight_aesni.h index 5203de8..c7d28e9 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_aesni.h +++ b/xmrstak/backend/cpu/crypto/cryptonight_aesni.h @@ -43,7 +43,7 @@ extern "C" { void keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); void keccakf(uint64_t st[25], int rounds); - extern void(*const extra_hashes[4])(const void *, size_t, char *); + extern void(*const extra_hashes[4])(const void *, uint32_t, char *); } // This will shift and xor tmp1 into itself as 4 32-bit vals such as diff --git a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp index ac696dd..3ff3cb9 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp +++ b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp @@ -56,23 +56,23 @@ extern "C" #include #endif // _WIN32 -void do_blake_hash(const void* input, size_t len, char* output) { +void do_blake_hash(const void* input, uint32_t len, char* output) { blake256_hash((uint8_t*)output, (const uint8_t*)input, len); } -void do_groestl_hash(const void* input, size_t len, char* output) { +void do_groestl_hash(const void* input, uint32_t len, char* output) { groestl((const uint8_t*)input, len * 8, (uint8_t*)output); } -void do_jh_hash(const void* input, size_t len, char* output) { +void do_jh_hash(const void* input, uint32_t len, char* output) { jh_hash(32 * 8, (const uint8_t*)input, 8 * len, (uint8_t*)output); } -void do_skein_hash(const void* input, size_t len, char* output) { +void do_skein_hash(const void* input, uint32_t len, char* output) { skein_hash(8 * 32, (const uint8_t*)input, 8 * len, (uint8_t*)output); } -void (* const extra_hashes[4])(const void *, size_t, char *) = {do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash}; +void (* const extra_hashes[4])(const void *, uint32_t, char *) = {do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash}; #ifdef _WIN32 #include "xmrstak/misc/uac.hpp" diff --git a/xmrstak/backend/cpu/crypto/hash.h b/xmrstak/backend/cpu/crypto/hash.h index c12d355..2af3309 100644 --- a/xmrstak/backend/cpu/crypto/hash.h +++ b/xmrstak/backend/cpu/crypto/hash.h @@ -1,5 +1,7 @@ #pragma once +#include + typedef unsigned char BitSequence; -typedef unsigned long long DataLength; +typedef uint32_t DataLength; typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2} HashReturn; -- cgit v1.1 From 01ebc092d274d5244d2375d049f3baf91750f2a6 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Sat, 14 Apr 2018 22:09:39 +0200 Subject: fix a few conversion warnings - fix conversion from large type tp small --- xmrstak/backend/cpu/crypto/cryptonight_aesni.h | 2 +- xmrstak/backend/cpu/hwlocMemory.cpp | 2 +- xmrstak/backend/cpu/minethd.cpp | 10 +++++----- xmrstak/backend/cpu/minethd.hpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'xmrstak/backend/cpu') diff --git a/xmrstak/backend/cpu/crypto/cryptonight_aesni.h b/xmrstak/backend/cpu/crypto/cryptonight_aesni.h index c7d28e9..7562de1 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_aesni.h +++ b/xmrstak/backend/cpu/crypto/cryptonight_aesni.h @@ -429,7 +429,7 @@ inline void cryptonight_monero_tweak(uint64_t* mem_out, __m128i tmp) tmp = _mm_castps_si128(_mm_movehl_ps(_mm_castsi128_ps(tmp), _mm_castsi128_ps(tmp))); uint64_t vh = _mm_cvtsi128_si64(tmp); - uint8_t x = vh >> 24; + uint8_t x = static_cast(vh >> 24); static const uint16_t table = 0x7531; const uint8_t index = (((x >> 3) & 6) | (x & 1)) << 1; vh ^= ((table >> index) & 0x3) << 28; diff --git a/xmrstak/backend/cpu/hwlocMemory.cpp b/xmrstak/backend/cpu/hwlocMemory.cpp index 94d2b53..089570f 100644 --- a/xmrstak/backend/cpu/hwlocMemory.cpp +++ b/xmrstak/backend/cpu/hwlocMemory.cpp @@ -30,7 +30,7 @@ void bindMemoryToNUMANode( size_t puId ) depth = hwloc_get_type_depth(topology, HWLOC_OBJ_PU); - for( size_t i = 0; + for( uint32_t i = 0; i < hwloc_get_nbobjs_by_depth(topology, depth); i++ ) { diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index ec3e145..263c83a 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -627,22 +627,22 @@ minethd::cn_hash_fun_multi minethd::func_multi_selector(size_t N, bool bHaveAes, void minethd::double_work_main() { - multiway_work_main<2>(); + multiway_work_main<2u>(); } void minethd::triple_work_main() { - multiway_work_main<3>(); + multiway_work_main<3u>(); } void minethd::quad_work_main() { - multiway_work_main<4>(); + multiway_work_main<4u>(); } void minethd::penta_work_main() { - multiway_work_main<5>(); + multiway_work_main<5u>(); } template @@ -656,7 +656,7 @@ void minethd::prep_multiway_work(uint8_t *bWorkBlob, uint32_t **piNonce) } } -template +template void minethd::multiway_work_main() { if(affinity >= 0) //-1 means no affinity diff --git a/xmrstak/backend/cpu/minethd.hpp b/xmrstak/backend/cpu/minethd.hpp index 59583b6..85a95d1 100644 --- a/xmrstak/backend/cpu/minethd.hpp +++ b/xmrstak/backend/cpu/minethd.hpp @@ -35,7 +35,7 @@ private: minethd(miner_work& pWork, size_t iNo, int iMultiway, bool no_prefetch, int64_t affinity); - template + template void multiway_work_main(); template -- cgit v1.1 From a5ddd040a6eeb0609e1d1b0f16c1d271d31c7377 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Mon, 16 Apr 2018 17:52:42 +0200 Subject: fix wrong algo selection In the case where the dev pool mines on a higher version than a monero fork coin the miner is not resetting the algorithm. This PR select the correct algorithm each time the block version hash changed. --- xmrstak/backend/cpu/minethd.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'xmrstak/backend/cpu') diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 263c83a..9494a79 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -434,6 +434,7 @@ void minethd::work_main() result.iThreadId = iThreadNo; uint8_t version = 0; + size_t lastPoolId = 0; while (bQuit == 0) { @@ -461,13 +462,19 @@ void minethd::work_main() result.iNonce = *piNonce; uint8_t new_version = oWork.getVersion(); - if(new_version != version) + if(new_version != version || oWork.iPoolId != lastPoolId) { - if(new_version >= ::jconf::inst()->GetMiningForkVersion()) + if(new_version >= ::jconf::inst()->GetMiningForkVersion() || oWork.iPoolId == 0) { miner_algo = ::jconf::inst()->GetMiningAlgo(); hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); } + else + { + miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); + } + lastPoolId = oWork.iPoolId; version = new_version; } @@ -692,6 +699,7 @@ void minethd::multiway_work_main() auto miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); cn_hash_fun_multi hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); uint8_t version = 0; + size_t lastPoolId = 0; while (bQuit == 0) { @@ -718,13 +726,19 @@ void minethd::multiway_work_main() iNonce = *piNonce[0]; uint8_t new_version = oWork.getVersion(); - if(new_version != version) + if(new_version != version || oWork.iPoolId != lastPoolId) { - if(new_version >= ::jconf::inst()->GetMiningForkVersion()) + if(new_version >= ::jconf::inst()->GetMiningForkVersion() || oWork.iPoolId == 0) { miner_algo = ::jconf::inst()->GetMiningAlgo(); hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); } + else + { + miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); + } + lastPoolId = oWork.iPoolId; version = new_version; } -- cgit v1.1 From 0877e2f654b203c5145bb8154fcfb1ad46ba8265 Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Mon, 16 Apr 2018 21:46:33 +0200 Subject: add independent dev pool coin description - allow the dev pool to fork on a different block version than the user descriped coin All algorithm are centered around the user coin description. It is allowed to have two two different coin algorithms in the user coin description. It is only allowed to use algorithms for the dev pool coin description those are used in the user coin description. There are two ways to define a non forking coin. - set both user coin algorithm descriptions to the same algorithm and set version to zero - set the first algorithm in the user coin description to something you like to use in the dev pool and set the second algorithm to the correct representation of the coin. Set the version to 255. This will allow that the dev pool can mine on a different coin algorithm than the not forking user coin. Do not use an algorithm with different scratchpad size for the dev pool. --- xmrstak/backend/cpu/autoAdjust.hpp | 4 ++-- xmrstak/backend/cpu/autoAdjustHwloc.hpp | 4 ++-- xmrstak/backend/cpu/crypto/cryptonight_common.cpp | 8 +++---- xmrstak/backend/cpu/minethd.cpp | 26 ++++++++++++----------- 4 files changed, 22 insertions(+), 20 deletions(-) (limited to 'xmrstak/backend/cpu') diff --git a/xmrstak/backend/cpu/autoAdjust.hpp b/xmrstak/backend/cpu/autoAdjust.hpp index ed96d8b..518721a 100644 --- a/xmrstak/backend/cpu/autoAdjust.hpp +++ b/xmrstak/backend/cpu/autoAdjust.hpp @@ -37,8 +37,8 @@ public: { const size_t hashMemSizeKB = std::max( - cn_select_memory(::jconf::inst()->GetMiningAlgo()), - cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot()) ) / 1024u; const size_t halfHashMemSizeKB = hashMemSizeKB / 2u; diff --git a/xmrstak/backend/cpu/autoAdjustHwloc.hpp b/xmrstak/backend/cpu/autoAdjustHwloc.hpp index f110ee3..b1f3914 100644 --- a/xmrstak/backend/cpu/autoAdjustHwloc.hpp +++ b/xmrstak/backend/cpu/autoAdjustHwloc.hpp @@ -29,8 +29,8 @@ public: autoAdjust() { hashMemSize = std::max( - cn_select_memory(::jconf::inst()->GetMiningAlgo()), - cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot()) ); halfHashMemSize = hashMemSize / 2u; } diff --git a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp index 3ff3cb9..ee3b663 100644 --- a/xmrstak/backend/cpu/crypto/cryptonight_common.cpp +++ b/xmrstak/backend/cpu/crypto/cryptonight_common.cpp @@ -204,8 +204,8 @@ size_t cryptonight_init(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg) cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg) { size_t hashMemSize = std::max( - cn_select_memory(::jconf::inst()->GetMiningAlgo()), - cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot()) ); cryptonight_ctx* ptr = (cryptonight_ctx*)_mm_malloc(sizeof(cryptonight_ctx), 4096); @@ -283,8 +283,8 @@ cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, al void cryptonight_free_ctx(cryptonight_ctx* ctx) { size_t hashMemSize = std::max( - cn_select_memory(::jconf::inst()->GetMiningAlgo()), - cn_select_memory(::jconf::inst()->GetMiningAlgoRoot()) + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo()), + cn_select_memory(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot()) ); if(ctx->ctx_info[0] != 0) diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 9494a79..f8f70f9 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -231,7 +231,7 @@ bool minethd::self_test() bool bResult = true; - if(::jconf::inst()->GetMiningAlgo() == cryptonight) + if(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight) { unsigned char out[32 * MAX_N]; cn_hash_fun hashf; @@ -276,13 +276,13 @@ bool minethd::self_test() "\xa0\x84\xf0\x1d\x14\x37\xa0\x9c\x69\x85\x40\x1b\x60\xd4\x35\x54\xae\x10\x58\x02\xc5\xf5\xd8\xa9\xb3\x25\x36\x49\xc0\xbe\x66\x05" "\xa0\x84\xf0\x1d\x14\x37\xa0\x9c\x69\x85\x40\x1b\x60\xd4\x35\x54\xae\x10\x58\x02\xc5\xf5\xd8\xa9\xb3\x25\x36\x49\xc0\xbe\x66\x05", 160) == 0; } - else if(::jconf::inst()->GetMiningAlgo() == cryptonight_lite) + else if(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight_lite) { } - else if(::jconf::inst()->GetMiningAlgo() == cryptonight_monero) + else if(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight_monero) { } - else if(::jconf::inst()->GetMiningAlgo() == cryptonight_aeon) + else if(::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() == cryptonight_aeon) { } @@ -424,7 +424,7 @@ void minethd::work_main() job_result result; // start with root algorithm and switch later if fork version is reached - auto miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + auto miner_algo = ::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot(); cn_hash_fun hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); ctx = minethd_alloc_ctx(); @@ -464,14 +464,15 @@ void minethd::work_main() uint8_t new_version = oWork.getVersion(); if(new_version != version || oWork.iPoolId != lastPoolId) { - if(new_version >= ::jconf::inst()->GetMiningForkVersion() || oWork.iPoolId == 0) + coinDescription coinDesc = ::jconf::inst()->GetCurrentCoinSelection().GetDescription(oWork.iPoolId); + if(new_version >= coinDesc.GetMiningForkVersion()) { - miner_algo = ::jconf::inst()->GetMiningAlgo(); + miner_algo = coinDesc.GetMiningAlgo(); hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); } else { - miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + miner_algo = coinDesc.GetMiningAlgoRoot(); hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); } lastPoolId = oWork.iPoolId; @@ -696,7 +697,7 @@ void minethd::multiway_work_main() globalStates::inst().iConsumeCnt++; // start with root algorithm and switch later if fork version is reached - auto miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + auto miner_algo = ::jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgoRoot(); cn_hash_fun_multi hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); uint8_t version = 0; size_t lastPoolId = 0; @@ -728,14 +729,15 @@ void minethd::multiway_work_main() uint8_t new_version = oWork.getVersion(); if(new_version != version || oWork.iPoolId != lastPoolId) { - if(new_version >= ::jconf::inst()->GetMiningForkVersion() || oWork.iPoolId == 0) + coinDescription coinDesc = ::jconf::inst()->GetCurrentCoinSelection().GetDescription(oWork.iPoolId); + if(new_version >= coinDesc.GetMiningForkVersion()) { - miner_algo = ::jconf::inst()->GetMiningAlgo(); + miner_algo = coinDesc.GetMiningAlgo(); hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); } else { - miner_algo = ::jconf::inst()->GetMiningAlgoRoot(); + miner_algo = coinDesc.GetMiningAlgoRoot(); hash_fun_multi = func_multi_selector(N, ::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); } lastPoolId = oWork.iPoolId; -- cgit v1.1