From ba2f6f4fc30f1bfb5cf7f873e4d8c9a7be32ca4c Mon Sep 17 00:00:00 2001 From: wowario Date: Thu, 31 Oct 2019 21:30:47 +0300 Subject: [PATCH] add RandomWOW submodule --- .gitmodules | 5 +++++ CMakeLists.txt | 2 +- external/CMakeLists.txt | 2 +- external/RandomWOW | 1 + src/crypto/rx-slow-hash.c | 16 ++++++++-------- src/cryptonote_core/cryptonote_tx_utils.cpp | 9 +-------- 6 files changed, 17 insertions(+), 18 deletions(-) create mode 160000 external/RandomWOW diff --git a/.gitmodules b/.gitmodules index 6e2339fb9..001e16c63 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,3 +12,8 @@ [submodule "external/trezor-common"] path = external/trezor-common url = https://github.com/trezor/trezor-common.git +[submodule "external/RandomWOW"] + path = external/RandomWOW + url = https://github.com/wownero/RandomWOW + branch = 1.1.6-wow + diff --git a/CMakeLists.txt b/CMakeLists.txt index c0ec0c2b8..baccf1751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,7 +211,7 @@ if(NOT MANUAL_SUBMODULES) check_submodule(external/unbound) check_submodule(external/rapidjson) check_submodule(external/trezor-common) - check_submodule(external/randomx) + check_submodule(external/RandomWOW) endif() endif() diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index d51ed36c7..6549236af 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -100,4 +100,4 @@ endif() add_subdirectory(db_drivers) add_subdirectory(easylogging++) -add_subdirectory(randomx EXCLUDE_FROM_ALL) +add_subdirectory(RandomWOW EXCLUDE_FROM_ALL) diff --git a/external/RandomWOW b/external/RandomWOW new file mode 160000 index 000000000..ae1377c0d --- /dev/null +++ b/external/RandomWOW @@ -0,0 +1 @@ +Subproject commit ae1377c0d744929ecd7ff5772574b3f758ce967c diff --git a/src/crypto/rx-slow-hash.c b/src/crypto/rx-slow-hash.c index a7a459ad3..67727c0b1 100644 --- a/src/crypto/rx-slow-hash.c +++ b/src/crypto/rx-slow-hash.c @@ -160,11 +160,11 @@ static void rx_initdata(randomx_cache *rs_cache, const int miners, const uint64_ CTHR_THREAD_TYPE *st; si = malloc(miners * sizeof(seedinfo)); if (si == NULL) - local_abort("Couldn't allocate RandomX mining threadinfo"); + local_abort("Couldn't allocate RandomWOW mining threadinfo"); st = malloc(miners * sizeof(CTHR_THREAD_TYPE)); if (st == NULL) { free(si); - local_abort("Couldn't allocate RandomX mining threadlist"); + local_abort("Couldn't allocate RandomWOW mining threadlist"); } for (i=0; irs_height != seedheight || rx_sp->rs_cache == NULL || memcmp(seedhash, rx_sp->rs_hash, HASH_SIZE)) { @@ -249,7 +249,7 @@ void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const ch if (rx_dataset == NULL) { rx_dataset = randomx_alloc_dataset(RANDOMX_FLAG_LARGE_PAGES); if (rx_dataset == NULL) { - mdebug(RX_LOGCAT, "Couldn't use largePages for RandomX dataset"); + mdebug(RX_LOGCAT, "Couldn't use largePages for RandomWOW dataset"); rx_dataset = randomx_alloc_dataset(RANDOMX_FLAG_DEFAULT); } if (rx_dataset != NULL) @@ -259,13 +259,13 @@ void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const ch flags |= RANDOMX_FLAG_FULL_MEM; else { miners = 0; - mwarning(RX_LOGCAT, "Couldn't allocate RandomX dataset for miner"); + mwarning(RX_LOGCAT, "Couldn't allocate RandomWOW dataset for miner"); } CTHR_MUTEX_UNLOCK(rx_dataset_mutex); } rx_vm = randomx_create_vm(flags | RANDOMX_FLAG_LARGE_PAGES, rx_sp->rs_cache, rx_dataset); if(rx_vm == NULL) { //large pages failed - mdebug(RX_LOGCAT, "Couldn't use largePages for RandomX VM"); + mdebug(RX_LOGCAT, "Couldn't use largePages for RandomWOW VM"); rx_vm = randomx_create_vm(flags, rx_sp->rs_cache, rx_dataset); } if(rx_vm == NULL) {//fallback if everything fails @@ -273,7 +273,7 @@ void rx_slow_hash(const uint64_t mainheight, const uint64_t seedheight, const ch rx_vm = randomx_create_vm(flags, rx_sp->rs_cache, rx_dataset); } if (rx_vm == NULL) - local_abort("Couldn't allocate RandomX VM"); + local_abort("Couldn't allocate RandomWOW VM"); } else if (miners) { CTHR_MUTEX_LOCK(rx_dataset_mutex); if (rx_dataset != NULL && rx_dataset_height != seedheight) diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 124a713a3..249691cb5 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -680,13 +680,6 @@ namespace cryptonote bool get_block_longhash(const Blockchain *pbc, const block& b, crypto::hash& res, const uint64_t height, const int miners) { - // block 202612 bug workaround - if (height == 202612) - { - static const std::string longhash_202612 = "84f64766475d51837ac9efbef1926486e58563c95a19fef4aec3254f03000000"; - epee::string_tools::hex_to_pod(longhash_202612, res); - return true; - } blobdata bd = get_block_hashing_blob(b); if (b.major_version >= RX_BLOCK_VERSION) { @@ -705,7 +698,7 @@ namespace cryptonote } rx_slow_hash(main_height, seed_height, hash.data, bd.data(), bd.size(), res.data, miners, 0); } else { - const int pow_variant = b.major_version >= 7 ? b.major_version - 6 : 0; + const int pow_variant = b.major_version >= 13 ? 6 : b.major_version >= 11 && b.major_version <= 12 ? 4 : 2; crypto::cn_slow_hash(bd.data(), bd.size(), res, pow_variant, height); } return true;