From e149fef131fb6b00b4f255752c4b0da8b321fa5e Mon Sep 17 00:00:00 2001 From: psychocrypt <psychocryptHPC@gmail.com> Date: Wed, 11 Jul 2018 21:32:35 +0200 Subject: [PATCH] fix wrong miner algorithm in result data fix #1708 The extension of the job result contains the wrong algorithm used to create the nonce. The fix provide now the correct used algorithm even if the coin is forking to a new algorithm. - forward the used algorithm from the miner --- xmrstak/backend/amd/minethd.cpp | 2 +- xmrstak/backend/cpu/minethd.cpp | 6 +++++- xmrstak/backend/nvidia/minethd.cpp | 2 +- xmrstak/misc/executor.cpp | 4 ++-- xmrstak/net/msgstruct.hpp | 6 +++++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/xmrstak/backend/amd/minethd.cpp b/xmrstak/backend/amd/minethd.cpp index 88431cc..f7b4724 100644 --- a/xmrstak/backend/amd/minethd.cpp +++ b/xmrstak/backend/amd/minethd.cpp @@ -254,7 +254,7 @@ void minethd::work_main() hash_fun(bWorkBlob, oWork.iWorkSize, bResult, cpu_ctx); if ( (*((uint64_t*)(bResult + 24))) < oWork.iTarget) - executor::inst()->push_event(ex_event(job_result(oWork.sJobID, results[i], bResult, iThreadNo), oWork.iPoolId)); + executor::inst()->push_event(ex_event(job_result(oWork.sJobID, results[i], bResult, iThreadNo, miner_algo), oWork.iPoolId)); else executor::inst()->push_event(ex_event("AMD Invalid Result", pGpuCtx->deviceIdx, oWork.iPoolId)); } diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp index 7e2a28b..0222469 100644 --- a/xmrstak/backend/cpu/minethd.cpp +++ b/xmrstak/backend/cpu/minethd.cpp @@ -504,6 +504,7 @@ void minethd::work_main() miner_algo = coinDesc.GetMiningAlgoRoot(); hash_fun = func_selector(::jconf::inst()->HaveHardwareAes(), bNoPrefetch, miner_algo); } + result.algorithm = miner_algo; lastPoolId = oWork.iPoolId; version = new_version; } @@ -885,7 +886,10 @@ void minethd::multiway_work_main() { if (*piHashVal[i] < oWork.iTarget) { - executor::inst()->push_event(ex_event(job_result(oWork.sJobID, iNonce - N + i, bHashOut + 32 * i, iThreadNo), oWork.iPoolId)); + executor::inst()->push_event( + ex_event(job_result(oWork.sJobID, iNonce - N + i, bHashOut + 32 * i, iThreadNo, miner_algo), + oWork.iPoolId) + ); } } diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp index 16171e1..88a1acc 100644 --- a/xmrstak/backend/nvidia/minethd.cpp +++ b/xmrstak/backend/nvidia/minethd.cpp @@ -302,7 +302,7 @@ void minethd::work_main() hash_fun(bWorkBlob, oWork.iWorkSize, bResult, cpu_ctx); if ( (*((uint64_t*)(bResult + 24))) < oWork.iTarget) - executor::inst()->push_event(ex_event(job_result(oWork.sJobID, foundNonce[i], bResult, iThreadNo), oWork.iPoolId)); + executor::inst()->push_event(ex_event(job_result(oWork.sJobID, foundNonce[i], bResult, iThreadNo, miner_algo), oWork.iPoolId)); else executor::inst()->push_event(ex_event("NVIDIA Invalid Result", ctx.device_id, oWork.iPoolId)); } diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index e4b8504..11d0f6d 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -422,7 +422,7 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult) //Ignore errors silently if(pool->is_running() && pool->is_logged_in()) pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, backend_name, - backend_hashcount, total_hashcount, jconf::inst()->GetCurrentCoinSelection().GetDescription(0).GetMiningAlgo() + backend_hashcount, total_hashcount, oResult.algorithm ); return; } @@ -435,7 +435,7 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult) size_t t_start = get_timestamp_ms(); bool bResult = pool->cmd_submit(oResult.sJobID, oResult.iNonce, oResult.bResult, - backend_name, backend_hashcount, total_hashcount, jconf::inst()->GetCurrentCoinSelection().GetDescription(1).GetMiningAlgo() + backend_name, backend_hashcount, total_hashcount, oResult.algorithm ); size_t t_len = get_timestamp_ms() - t_start; diff --git a/xmrstak/net/msgstruct.hpp b/xmrstak/net/msgstruct.hpp index 20092fe..6a05eb9 100644 --- a/xmrstak/net/msgstruct.hpp +++ b/xmrstak/net/msgstruct.hpp @@ -1,5 +1,7 @@ #pragma once +#include "xmrstak/backend/cryptonight.hpp" + #include <string> #include <string.h> #include <assert.h> @@ -31,9 +33,11 @@ struct job_result char sJobID[64]; uint32_t iNonce; uint32_t iThreadId; + xmrstak_algo algorithm = invalid_algo; job_result() {} - job_result(const char* sJobID, uint32_t iNonce, const uint8_t* bResult, uint32_t iThreadId) : iNonce(iNonce), iThreadId(iThreadId) + job_result(const char* sJobID, uint32_t iNonce, const uint8_t* bResult, uint32_t iThreadId, xmrstak_algo algo) : + iNonce(iNonce), iThreadId(iThreadId), algorithm(algo) { memcpy(this->sJobID, sJobID, sizeof(job_result::sJobID)); memcpy(this->bResult, bResult, sizeof(job_result::bResult)); -- GitLab