mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-20 14:19:10 +00:00
commit
bc09aa5ad0
11 changed files with 63 additions and 10 deletions
|
@ -416,6 +416,10 @@ rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
|
||||||
out.AddMember("argon2-impl", argon2::Impl::name().toJSON(), allocator);
|
out.AddMember("argon2-impl", argon2::Impl::name().toJSON(), allocator);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_ASTROBWT
|
||||||
|
out.AddMember("astrobwt-max-size", cpu.astrobwtMaxSize(), allocator);
|
||||||
|
# endif
|
||||||
|
|
||||||
out.AddMember("hugepages", d_ptr->hugePages(2, doc), allocator);
|
out.AddMember("hugepages", d_ptr->hugePages(2, doc), allocator);
|
||||||
out.AddMember("memory", static_cast<uint64_t>(d_ptr->algo.isValid() ? (d_ptr->ways() * d_ptr->algo.l3()) : 0), allocator);
|
out.AddMember("memory", static_cast<uint64_t>(d_ptr->algo.isValid() ? (d_ptr->ways() * d_ptr->algo.l3()) : 0), allocator);
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "backend/cpu/Cpu.h"
|
#include "backend/cpu/Cpu.h"
|
||||||
#include "base/io/json/Json.h"
|
#include "base/io/json/Json.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -48,6 +49,11 @@ static const char *kAsm = "asm";
|
||||||
static const char *kArgon2Impl = "argon2-impl";
|
static const char *kArgon2Impl = "argon2-impl";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XMRIG_ALGO_ASTROBWT
|
||||||
|
static const char* kAstroBWTMaxSize = "astrobwt-max-size";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern template class Threads<CpuThreads>;
|
extern template class Threads<CpuThreads>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,6 +91,10 @@ rapidjson::Value xmrig::CpuConfig::toJSON(rapidjson::Document &doc) const
|
||||||
obj.AddMember(StringRef(kArgon2Impl), m_argon2Impl.toJSON(), allocator);
|
obj.AddMember(StringRef(kArgon2Impl), m_argon2Impl.toJSON(), allocator);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_ASTROBWT
|
||||||
|
obj.AddMember(StringRef(kAstroBWTMaxSize), m_astrobwtMaxSize, allocator);
|
||||||
|
# endif
|
||||||
|
|
||||||
m_threads.toJSON(obj, doc);
|
m_threads.toJSON(obj, doc);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -136,6 +146,16 @@ void xmrig::CpuConfig::read(const rapidjson::Value &value)
|
||||||
m_argon2Impl = Json::getString(value, kArgon2Impl);
|
m_argon2Impl = Json::getString(value, kArgon2Impl);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_ASTROBWT
|
||||||
|
const auto& obj = Json::getValue(value, kAstroBWTMaxSize);
|
||||||
|
if (obj.IsNull() || !obj.IsInt()) {
|
||||||
|
m_shouldSave = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_astrobwtMaxSize = std::min(std::max(obj.GetInt(), 400), 1200);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
m_threads.read(value);
|
m_threads.read(value);
|
||||||
|
|
||||||
generate();
|
generate();
|
||||||
|
@ -167,7 +187,7 @@ void xmrig::CpuConfig::generate()
|
||||||
count += xmrig::generate<Algorithm::ARGON2>(m_threads, m_limit);
|
count += xmrig::generate<Algorithm::ARGON2>(m_threads, m_limit);
|
||||||
count += xmrig::generate<Algorithm::ASTROBWT>(m_threads, m_limit);
|
count += xmrig::generate<Algorithm::ASTROBWT>(m_threads, m_limit);
|
||||||
|
|
||||||
m_shouldSave = count > 0;
|
m_shouldSave |= count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
inline bool isYield() const { return m_yield; }
|
inline bool isYield() const { return m_yield; }
|
||||||
inline const Assembly &assembly() const { return m_assembly; }
|
inline const Assembly &assembly() const { return m_assembly; }
|
||||||
inline const String &argon2Impl() const { return m_argon2Impl; }
|
inline const String &argon2Impl() const { return m_argon2Impl; }
|
||||||
|
inline int astrobwtMaxSize() const { return m_astrobwtMaxSize; }
|
||||||
inline const Threads<CpuThreads> &threads() const { return m_threads; }
|
inline const Threads<CpuThreads> &threads() const { return m_threads; }
|
||||||
inline int priority() const { return m_priority; }
|
inline int priority() const { return m_priority; }
|
||||||
inline uint32_t limit() const { return m_limit; }
|
inline uint32_t limit() const { return m_limit; }
|
||||||
|
@ -78,6 +79,7 @@ private:
|
||||||
int m_memoryPool = 0;
|
int m_memoryPool = 0;
|
||||||
int m_priority = -1;
|
int m_priority = -1;
|
||||||
String m_argon2Impl;
|
String m_argon2Impl;
|
||||||
|
int m_astrobwtMaxSize = 550;
|
||||||
Threads<CpuThreads> m_threads;
|
Threads<CpuThreads> m_threads;
|
||||||
uint32_t m_limit = 100;
|
uint32_t m_limit = 100;
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,7 +42,8 @@ xmrig::CpuLaunchData::CpuLaunchData(const Miner *miner, const Algorithm &algorit
|
||||||
priority(config.priority()),
|
priority(config.priority()),
|
||||||
affinity(thread.affinity()),
|
affinity(thread.affinity()),
|
||||||
miner(miner),
|
miner(miner),
|
||||||
intensity(std::min<uint32_t>(thread.intensity(), algorithm.maxIntensity()))
|
intensity(std::min<uint32_t>(thread.intensity(), algorithm.maxIntensity())),
|
||||||
|
astrobwtMaxSize(config.astrobwtMaxSize())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ public:
|
||||||
const int64_t affinity;
|
const int64_t affinity;
|
||||||
const Miner *miner;
|
const Miner *miner;
|
||||||
const uint32_t intensity;
|
const uint32_t intensity;
|
||||||
|
const int astrobwtMaxSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "core/Miner.h"
|
#include "core/Miner.h"
|
||||||
#include "crypto/cn/CnCtx.h"
|
#include "crypto/cn/CnCtx.h"
|
||||||
#include "crypto/cn/CryptoNight_test.h"
|
#include "crypto/cn/CryptoNight_test.h"
|
||||||
|
#include "crypto/cn/CryptoNight.h"
|
||||||
#include "crypto/common/Nonce.h"
|
#include "crypto/common/Nonce.h"
|
||||||
#include "crypto/common/VirtualMemory.h"
|
#include "crypto/common/VirtualMemory.h"
|
||||||
#include "crypto/rx/Rx.h"
|
#include "crypto/rx/Rx.h"
|
||||||
|
@ -76,6 +77,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
||||||
Worker(id, data.affinity, data.priority),
|
Worker(id, data.affinity, data.priority),
|
||||||
m_algorithm(data.algorithm),
|
m_algorithm(data.algorithm),
|
||||||
m_assembly(data.assembly),
|
m_assembly(data.assembly),
|
||||||
|
m_astrobwtMaxSize(data.astrobwtMaxSize * 1000),
|
||||||
m_hwAES(data.hwAES),
|
m_hwAES(data.hwAES),
|
||||||
m_yield(data.yield),
|
m_yield(data.yield),
|
||||||
m_av(data.av()),
|
m_av(data.av()),
|
||||||
|
@ -240,6 +242,8 @@ void xmrig::CpuWorker<N>::start()
|
||||||
current_job_nonces[i] = *m_job.nonce(i);
|
current_job_nonces[i] = *m_job.nonce(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool valid = true;
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
if (job.algorithm().family() == Algorithm::RANDOM_X) {
|
if (job.algorithm().family() == Algorithm::RANDOM_X) {
|
||||||
if (first) {
|
if (first) {
|
||||||
|
@ -256,20 +260,31 @@ void xmrig::CpuWorker<N>::start()
|
||||||
else
|
else
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
fn(job.algorithm())(m_job.blob(), job.size(), m_hash, m_ctx, job.height());
|
# ifdef XMRIG_ALGO_ASTROBWT
|
||||||
|
if (job.algorithm().family() == Algorithm::ASTROBWT) {
|
||||||
|
if (!astrobwt::astrobwt_dero(m_job.blob(), job.size(), m_ctx[0]->memory, m_hash, m_astrobwtMaxSize))
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
{
|
||||||
|
fn(job.algorithm())(m_job.blob(), job.size(), m_hash, m_ctx, job.height());
|
||||||
|
}
|
||||||
|
|
||||||
if (!nextRound(m_job)) {
|
if (!nextRound(m_job)) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < N; ++i) {
|
if (valid) {
|
||||||
if (*reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24) < job.target()) {
|
for (size_t i = 0; i < N; ++i) {
|
||||||
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32));
|
if (*reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24) < job.target()) {
|
||||||
|
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
m_count += N;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_count += N;
|
|
||||||
|
|
||||||
if (m_yield) {
|
if (m_yield) {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
|
|
||||||
const Algorithm m_algorithm;
|
const Algorithm m_algorithm;
|
||||||
const Assembly m_assembly;
|
const Assembly m_assembly;
|
||||||
|
const int m_astrobwtMaxSize;
|
||||||
const bool m_hwAES;
|
const bool m_hwAES;
|
||||||
const bool m_yield;
|
const bool m_yield;
|
||||||
const CnHash::AlgoVariant m_av;
|
const CnHash::AlgoVariant m_av;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
"max-threads-hint": 100,
|
"max-threads-hint": 100,
|
||||||
"asm": true,
|
"asm": true,
|
||||||
"argon2-impl": null,
|
"argon2-impl": null,
|
||||||
|
"astrobwt-max-size": 550,
|
||||||
"cn/0": false,
|
"cn/0": false,
|
||||||
"cn-lite/0": false
|
"cn-lite/0": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -63,6 +63,7 @@ R"===(
|
||||||
"max-threads-hint": 100,
|
"max-threads-hint": 100,
|
||||||
"asm": true,
|
"asm": true,
|
||||||
"argon2-impl": null,
|
"argon2-impl": null,
|
||||||
|
"astrobwt-max-size": 550,
|
||||||
"cn/0": false,
|
"cn/0": false,
|
||||||
"cn-lite/0": false
|
"cn-lite/0": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "AstroBWT.h"
|
#include "AstroBWT.h"
|
||||||
#include "sha3.h"
|
#include "sha3.h"
|
||||||
#include "crypto/cn/CryptoNight.h"
|
#include "crypto/cn/CryptoNight.h"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
constexpr int STAGE1_SIZE = 147253;
|
constexpr int STAGE1_SIZE = 147253;
|
||||||
constexpr int ALLOCATION_SIZE = (STAGE1_SIZE + 1048576) + (128 - (STAGE1_SIZE & 63));
|
constexpr int ALLOCATION_SIZE = (STAGE1_SIZE + 1048576) + (128 - (STAGE1_SIZE & 63));
|
||||||
|
@ -152,7 +153,7 @@ void sort_indices(int N, const uint8_t* v, uint64_t* indices, uint64_t* tmp_indi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void astrobwt_dero(const void* input_data, uint32_t input_size, void* scratchpad, uint8_t* output_hash)
|
bool xmrig::astrobwt::astrobwt_dero(const void* input_data, uint32_t input_size, void* scratchpad, uint8_t* output_hash, int stage2_max_size)
|
||||||
{
|
{
|
||||||
uint8_t key[32];
|
uint8_t key[32];
|
||||||
uint8_t* scratchpad_ptr = (uint8_t*)(scratchpad) + 64;
|
uint8_t* scratchpad_ptr = (uint8_t*)(scratchpad) + 64;
|
||||||
|
@ -178,6 +179,9 @@ void astrobwt_dero(const void* input_data, uint32_t input_size, void* scratchpad
|
||||||
sha3_HashBuffer(256, SHA3_FLAGS_NONE, stage1_result, STAGE1_SIZE + 1, key, sizeof(key));
|
sha3_HashBuffer(256, SHA3_FLAGS_NONE, stage1_result, STAGE1_SIZE + 1, key, sizeof(key));
|
||||||
|
|
||||||
const int stage2_size = STAGE1_SIZE + (*(uint32_t*)(key) & 0xfffff);
|
const int stage2_size = STAGE1_SIZE + (*(uint32_t*)(key) & 0xfffff);
|
||||||
|
if (stage2_size > stage2_max_size)
|
||||||
|
return false;
|
||||||
|
|
||||||
Salsa20_XORKeyStream(key, stage2_output, stage2_size);
|
Salsa20_XORKeyStream(key, stage2_output, stage2_size);
|
||||||
|
|
||||||
sort_indices(stage2_size + 1, stage2_output, indices, tmp_indices);
|
sort_indices(stage2_size + 1, stage2_output, indices, tmp_indices);
|
||||||
|
@ -198,10 +202,12 @@ void astrobwt_dero(const void* input_data, uint32_t input_size, void* scratchpad
|
||||||
}
|
}
|
||||||
|
|
||||||
sha3_HashBuffer(256, SHA3_FLAGS_NONE, stage2_result, stage2_size + 1, output_hash, 32);
|
sha3_HashBuffer(256, SHA3_FLAGS_NONE, stage2_result, stage2_size + 1, output_hash, 32);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void xmrig::astrobwt::single_hash<xmrig::Algorithm::ASTROBWT_DERO>(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx** ctx, uint64_t)
|
void xmrig::astrobwt::single_hash<xmrig::Algorithm::ASTROBWT_DERO>(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx** ctx, uint64_t)
|
||||||
{
|
{
|
||||||
astrobwt_dero(input, static_cast<uint32_t>(size), ctx[0]->memory, output);
|
astrobwt_dero(input, static_cast<uint32_t>(size), ctx[0]->memory, output, std::numeric_limits<int>::max());
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ struct cryptonight_ctx;
|
||||||
|
|
||||||
namespace xmrig { namespace astrobwt {
|
namespace xmrig { namespace astrobwt {
|
||||||
|
|
||||||
|
bool astrobwt_dero(const void* input_data, uint32_t input_size, void* scratchpad, uint8_t* output_hash, int stage2_max_size);
|
||||||
|
|
||||||
template<Algorithm::Id ALGO>
|
template<Algorithm::Id ALGO>
|
||||||
void single_hash(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx** ctx, uint64_t);
|
void single_hash(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx** ctx, uint64_t);
|
||||||
|
|
Loading…
Reference in a new issue