From 4da37baf8c93bf8a78427f026e2b0a5a65528d70 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Mon, 16 Dec 2019 19:36:29 +0100 Subject: [PATCH] RandomSFX (Safex Cash variant) support --- src/backend/opencl/cl/cn/algorithm.cl | 5 +++-- src/backend/opencl/runners/OclRxBaseRunner.cpp | 5 ++++- src/crypto/common/Algorithm.cpp | 5 +++++ src/crypto/common/Algorithm.h | 1 + src/crypto/randomx/randomx.cpp | 6 ++++++ src/crypto/randomx/randomx.h | 2 ++ src/crypto/rx/RxAlgo.cpp | 3 +++ 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/backend/opencl/cl/cn/algorithm.cl b/src/backend/opencl/cl/cn/algorithm.cl index 1625edfd..a1bed3cc 100644 --- a/src/backend/opencl/cl/cn/algorithm.cl +++ b/src/backend/opencl/cl/cn/algorithm.cl @@ -20,8 +20,9 @@ #define ALGO_RX_WOW 19 #define ALGO_RX_LOKI 20 #define ALGO_RX_ARQMA 21 -#define ALGO_AR2_CHUKWA 22 -#define ALGO_AR2_WRKZ 23 +#define ALGO_RX_SFX 22 +#define ALGO_AR2_CHUKWA 23 +#define ALGO_AR2_WRKZ 24 #define FAMILY_UNKNOWN 0 #define FAMILY_CN 1 diff --git a/src/backend/opencl/runners/OclRxBaseRunner.cpp b/src/backend/opencl/runners/OclRxBaseRunner.cpp index 278c4f76..8eb390e6 100644 --- a/src/backend/opencl/runners/OclRxBaseRunner.cpp +++ b/src/backend/opencl/runners/OclRxBaseRunner.cpp @@ -56,7 +56,10 @@ xmrig::OclRxBaseRunner::OclRxBaseRunner(size_t index, const OclLaunchData &data) m_gcn_version = 14; } - m_options += " -DALGO=" + std::to_string(m_algorithm.id()); + // rx/sfx is the same as rx/0 except Argon salt for dataset generation + Algorithm::Id id = (m_algorithm.id() == Algorithm::RX_SFX) ? Algorithm::RX_0 : m_algorithm.id(); + + m_options += " -DALGO=" + std::to_string(id); m_options += " -DWORKERS_PER_HASH=" + std::to_string(m_worksize); m_options += " -DGCN_VERSION=" + std::to_string(m_gcn_version); } diff --git a/src/crypto/common/Algorithm.cpp b/src/crypto/common/Algorithm.cpp index d3c2838a..99883daa 100644 --- a/src/crypto/common/Algorithm.cpp +++ b/src/crypto/common/Algorithm.cpp @@ -112,6 +112,8 @@ static AlgoName const algorithm_names[] = { { "RandomXL", nullptr, Algorithm::RX_LOKI }, { "randomx/arq", "rx/arq", Algorithm::RX_ARQ }, { "RandomARQ", nullptr, Algorithm::RX_ARQ }, + { "randomx/sfx", "rx/sfx", Algorithm::RX_SFX }, + { "RandomSFX", nullptr, Algorithm::RX_SFX }, # endif # ifdef XMRIG_ALGO_ARGON2 { "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA }, @@ -138,6 +140,7 @@ size_t xmrig::Algorithm::l2() const switch (m_id) { case RX_0: case RX_LOKI: + case RX_SFX: return 0x40000; case RX_WOW: @@ -173,6 +176,7 @@ size_t xmrig::Algorithm::l3() const switch (m_id) { case RX_0: case RX_LOKI: + case RX_SFX: return oneMiB * 2; case RX_WOW: @@ -272,6 +276,7 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id) case RX_WOW: case RX_LOKI: case RX_ARQ: + case RX_SFX: return RANDOM_X; # endif diff --git a/src/crypto/common/Algorithm.h b/src/crypto/common/Algorithm.h index 0c6f2649..bfdcea5a 100644 --- a/src/crypto/common/Algorithm.h +++ b/src/crypto/common/Algorithm.h @@ -67,6 +67,7 @@ public: RX_WOW, // "rx/wow" RandomWOW (Wownero). RX_LOKI, // "rx/loki" RandomXL (Loki). RX_ARQ, // "rx/arq" RandomARQ (Arqma). + RX_SFX, // "rx/sfx" RandomSFX (Safex Cash). AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa). AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ) MAX diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index 8b1cfe2c..dfbda968 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -92,6 +92,11 @@ RandomX_ConfigurationArqma::RandomX_ConfigurationArqma() ScratchpadL3_Size = 262144; } +RandomX_ConfigurationSafex::RandomX_ConfigurationSafex() +{ + ArgonSalt = "RandomSFX\x01"; +} + RandomX_ConfigurationBase::RandomX_ConfigurationBase() : ArgonMemory(262144) , ArgonIterations(3) @@ -267,6 +272,7 @@ RandomX_ConfigurationMonero RandomX_MoneroConfig; RandomX_ConfigurationWownero RandomX_WowneroConfig; RandomX_ConfigurationLoki RandomX_LokiConfig; RandomX_ConfigurationArqma RandomX_ArqmaConfig; +RandomX_ConfigurationSafex RandomX_SafexConfig; RandomX_ConfigurationBase RandomX_CurrentConfig; diff --git a/src/crypto/randomx/randomx.h b/src/crypto/randomx/randomx.h index 1ed5aa53..793e6e1b 100644 --- a/src/crypto/randomx/randomx.h +++ b/src/crypto/randomx/randomx.h @@ -182,11 +182,13 @@ struct RandomX_ConfigurationMonero : public RandomX_ConfigurationBase {}; struct RandomX_ConfigurationWownero : public RandomX_ConfigurationBase { RandomX_ConfigurationWownero(); }; struct RandomX_ConfigurationLoki : public RandomX_ConfigurationBase { RandomX_ConfigurationLoki(); }; struct RandomX_ConfigurationArqma : public RandomX_ConfigurationBase { RandomX_ConfigurationArqma(); }; +struct RandomX_ConfigurationSafex : public RandomX_ConfigurationBase { RandomX_ConfigurationSafex(); }; extern RandomX_ConfigurationMonero RandomX_MoneroConfig; extern RandomX_ConfigurationWownero RandomX_WowneroConfig; extern RandomX_ConfigurationLoki RandomX_LokiConfig; extern RandomX_ConfigurationArqma RandomX_ArqmaConfig; +extern RandomX_ConfigurationSafex RandomX_SafexConfig; extern RandomX_ConfigurationBase RandomX_CurrentConfig; diff --git a/src/crypto/rx/RxAlgo.cpp b/src/crypto/rx/RxAlgo.cpp index 4de97876..4630303e 100644 --- a/src/crypto/rx/RxAlgo.cpp +++ b/src/crypto/rx/RxAlgo.cpp @@ -49,6 +49,9 @@ const RandomX_ConfigurationBase *xmrig::RxAlgo::base(Algorithm::Id algorithm) case Algorithm::RX_ARQ: return &RandomX_ArqmaConfig; + case Algorithm::RX_SFX: + return &RandomX_SafexConfig; + default: break; }