diff --git a/CHANGELOG.md b/CHANGELOG.md index 25fd77aff..708d712ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v6.7.2 +- [#2039](https://github.com/xmrig/xmrig/pull/2039) Fixed solo mining. + # v6.7.1 - [#1995](https://github.com/xmrig/xmrig/issues/1995) Fixed log initialization. - [#1998](https://github.com/xmrig/xmrig/pull/1998) Added hashrate in the benchmark finished message. diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 8b4d0fb69..554ee8a89 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -104,7 +104,7 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result) # ifdef XMRIG_PROXY_PROJECT memcpy(data + 78, result.nonce, 8); # else - Cvt::toHex(data + 78, 9, reinterpret_cast<const uint8_t *>(&result.nonce), 4); + Cvt::toHex(data + 78, 8, reinterpret_cast<const uint8_t *>(&result.nonce), 4); # endif using namespace rapidjson; @@ -227,7 +227,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value ¶ms, int *code) m_blockhashingblob = Json::getString(params, "blockhashing_blob"); if (m_apiVersion == API_DERO) { const uint64_t offset = Json::getUint64(params, "reserved_offset"); - Cvt::toHex(m_blockhashingblob.data() + offset * 2, kBlobReserveSize * 2 + 1, Cvt::randomBytes(kBlobReserveSize).data(), kBlobReserveSize); + Cvt::toHex(m_blockhashingblob.data() + offset * 2, kBlobReserveSize * 2, Cvt::randomBytes(kBlobReserveSize).data(), kBlobReserveSize); } if (blocktemplate.isNull() || !job.setBlob(m_blockhashingblob)) { diff --git a/src/base/tools/Cvt.cpp b/src/base/tools/Cvt.cpp index c80c022c0..18d5e627a 100644 --- a/src/base/tools/Cvt.cpp +++ b/src/base/tools/Cvt.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2013-2020 Frank Denis <j at pureftpd dot org> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,11 +34,6 @@ namespace xmrig { -#ifndef XMRIG_SODIUM -static std::random_device randomDevice; -static std::mt19937 randomEngine(randomDevice()); - - static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigned char *const bin, const size_t bin_len) { size_t i = 0U; @@ -46,7 +41,7 @@ static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigne int b; int c; - if (bin_len >= SIZE_MAX / 2 || hex_maxlen <= bin_len * 2U) { + if (bin_len >= SIZE_MAX / 2 || hex_maxlen < bin_len * 2U) { return nullptr; /* LCOV_EXCL_LINE */ } @@ -60,12 +55,20 @@ static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigne hex[i * 2U + 1U] = (char) x; i++; } - hex[i * 2U] = 0U; + + if (i * 2U < hex_maxlen) { + hex[i * 2U] = 0U; + } return hex; } +#ifndef XMRIG_SODIUM +static std::random_device randomDevice; +static std::mt19937 randomEngine(randomDevice()); + + static int cvt_hex2bin(unsigned char *const bin, const size_t bin_maxlen, const char *const hex, const size_t hex_len, const char *const ignore, size_t *const bin_len, const char **const hex_end) { size_t bin_pos = 0U; @@ -137,7 +140,6 @@ static int cvt_hex2bin(unsigned char *const bin, const size_t bin_maxlen, const return ret; } -#define sodium_bin2hex cvt_bin2hex #define sodium_hex2bin cvt_hex2bin #endif @@ -215,7 +217,7 @@ xmrig::Buffer xmrig::Cvt::fromHex(const char *in, size_t size) bool xmrig::Cvt::toHex(char *hex, size_t hex_maxlen, const uint8_t *bin, size_t bin_len) { - return sodium_bin2hex(hex, hex_maxlen, bin, bin_len) != nullptr; + return cvt_bin2hex(hex, hex_maxlen, bin, bin_len) != nullptr; } @@ -273,3 +275,17 @@ xmrig::String xmrig::Cvt::toHex(const uint8_t *in, size_t size) return buf; } + + +void xmrig::Cvt::randomBytes(void *buf, size_t size) +{ +# ifndef XMRIG_SODIUM + std::uniform_int_distribution<> dis(0, 255); + + for (size_t i = 0; i < size; ++i) { + static_cast<uint8_t *>(buf)[i] = static_cast<char>(dis(randomEngine)); + } +# else + randombytes_buf(buf, size); +# endif +} diff --git a/src/base/tools/Cvt.h b/src/base/tools/Cvt.h index 8b67b1466..e7507aafd 100644 --- a/src/base/tools/Cvt.h +++ b/src/base/tools/Cvt.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,6 +52,7 @@ public: static rapidjson::Value toHex(const std::string &data, rapidjson::Document &doc); static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc); static String toHex(const uint8_t *in, size_t size); + static void randomBytes(void *buf, size_t size); }; diff --git a/src/version.h b/src/version.h index 1f69d3ffd..159b29d6a 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.7.1" +#define APP_VERSION "6.7.2-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2021 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 7 -#define APP_VER_PATCH 0 +#define APP_VER_PATCH 2 #ifdef _MSC_VER # if (_MSC_VER >= 1920)