1
0
mirror of https://github.com/xmrig/xmrig.git synced 2026-06-26 13:12:39 -04:00

Compare commits

..

13 Commits

Author SHA1 Message Date
Stan Bondi
631febb7bb Merge af18c4571e into 7897f10c48 2024-04-30 21:41:55 +02:00
XMRig
7897f10c48 v6.21.3 2024-04-23 16:27:24 +07:00
XMRig
da2fb331b3 Merge branch 'dev' 2024-04-23 16:26:18 +07:00
xmrig
57f3e9c3da Update CHANGELOG.md 2024-04-23 16:17:26 +07:00
xmrig
1efe7e9562 Merge pull request #3462 from SChernykh/dev
RandomX: correct memcpy size for JIT initialization
2024-04-14 17:01:16 +07:00
SChernykh
caae7c64f0 RandomX: correct memcpy size for JIT initialization
No buffer overflow, better fix for `_FORTIFY_SOURCE`
2024-04-14 09:13:00 +02:00
xmrig
9fbdcc0ef0 Merge pull request #3461 from SChernykh/dev
RandomX: check pointer sizes during JIT initialization
2024-04-14 05:38:53 +07:00
SChernykh
c7c26d97fe RandomX: check pointer sizes during JIT initialization 2024-04-13 20:32:16 +02:00
XMRig
1f7e635b04 Use internal logger for error message. 2024-03-26 21:46:18 +07:00
XMRig
1c5786e3c5 v6.21.3-dev 2024-03-23 16:21:54 +07:00
XMRig
44eb4f0038 Merge branch 'master' into dev 2024-03-23 16:20:24 +07:00
Stan Bondi
af18c4571e Merge branch 'master' into self-select-parse-fix 2021-11-01 18:16:55 +04:00
Stanimal
302290c4a1 Handle submit block response in self select client
This PR fixes self-select client with submit-to-origin=true by handling `submitblock` responses.

Previously, the submit block responses would result in an error message
and enter RETRY state because parseResponse expects all responses to be
for `getblocktemplate`.
2021-03-01 13:07:52 +04:00
12 changed files with 53 additions and 21 deletions

6
.gitignore vendored
View File

@@ -4,3 +4,9 @@ scripts/deps
/CMakeLists.txt.user
/.idea
/src/backend/opencl/cl/cn/cryptonight_gen.cl
*.a
CMakeCache.txt
CMakeFiles/
Makefile
cmake_install.cmake
/xmrig

View File

@@ -1,3 +1,6 @@
# v6.21.3
- [#3462](https://github.com/xmrig/xmrig/pull/3462) RandomX: correct memcpy size for JIT initialization.
# v6.21.2
- The dependencies of all prebuilt releases have been updated. Support for old Ubuntu releases has been dropped.
- [#2800](https://github.com/xmrig/xmrig/issues/2800) Fixed donation with GhostRider algorithm for builds without KawPow algorithm.

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 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
@@ -25,6 +25,8 @@
#include "base/crypto/keccak.h"
#include "base/io/Env.h"
#include "base/io/json/Json.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/kernel/Base.h"
#include "base/tools/Chrono.h"
#include "base/tools/Cvt.h"
@@ -39,7 +41,6 @@
#include <thread>
#include <iostream>
namespace xmrig {
@@ -81,8 +82,7 @@ static rapidjson::Value getResources(rapidjson::Document &doc)
xmrig::Api::Api(Base *base) :
m_base(base),
m_timestamp(Chrono::currentMSecsSinceEpoch()),
m_httpd(nullptr)
m_timestamp(Chrono::currentMSecsSinceEpoch())
{
base->addListener(this);
@@ -118,7 +118,8 @@ void xmrig::Api::start()
if (!m_httpd) {
m_httpd = new Httpd(m_base);
if (!m_httpd->start()) {
std::cerr << "HTTP server failed to start." << std::endl;
LOG_ERR("%s " RED_BOLD("HTTP API server failed to start."), Tags::network());
delete m_httpd; // Properly handle failure to start
m_httpd = nullptr;
}

View File

@@ -1,6 +1,6 @@
/* XMRig
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2016-2024 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

View File

@@ -45,6 +45,8 @@ static const char *kJobId = "job_id";
static const char *kNextSeedHash = "next_seed_hash";
static const char *kPrevHash = "prev_hash";
static const char *kSeedHash = "seed_hash";
static const char *kStatus = "status";
static const char *kStatusOk = "OK";
static const char * const required_fields[] = { kBlocktemplateBlob, kBlockhashingBlob, kHeight, kDifficulty, kPrevHash };
@@ -55,8 +57,9 @@ xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientList
m_submitToOrigin(submitToOrigin),
m_listener(listener)
{
m_httpListener = std::make_shared<HttpListener>(this);
m_client = new Client(id, agent, this);
m_httpListener = std::make_shared<HttpListener>(this);
m_client = new Client(id, agent, this);
m_last_submit_req_id = -1;
}
@@ -129,6 +132,20 @@ bool xmrig::SelfSelectClient::parseResponse(int64_t id, rapidjson::Value &result
return false;
}
if (isSubmitBlockResponse(id)) {
xmrig::String submit_status = Json::getString(result, kStatus);
submit_status.toUpper();
if (submit_status == kStatusOk) {
// Ensure that the latest block template is available after block submission
getBlockTemplate();
return true;
}
LOG_ERR("[%s] " RED_BOLD("block not submitted to origin. status = \"%s\""), pool().daemon().url().data(), submit_status.data());
return false;
}
for (auto field : required_fields) {
if (!result.HasMember(field)) {
LOG_ERR("[%s] required field " RED_BOLD("\"%s\"") RED_S " not found", pool().daemon().url().data(), field);
@@ -158,6 +175,10 @@ bool xmrig::SelfSelectClient::parseResponse(int64_t id, rapidjson::Value &result
return true;
}
bool xmrig::SelfSelectClient::isSubmitBlockResponse(int64_t id)
{
return m_last_submit_req_id > -1 && id == m_last_submit_req_id;
}
void xmrig::SelfSelectClient::getBlockTemplate()
{
@@ -282,8 +303,8 @@ void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result)
Value params(kArrayType);
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
JsonRequest::create(doc, m_sequence, "submitblock", params);
m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff(), 0, result.backend);
m_last_submit_req_id = m_sequence;
JsonRequest::create(doc, m_sequence++, "submitblock", params);
FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet());
fetch(tag(), std::move(req), m_httpListener);

View File

@@ -99,6 +99,7 @@ private:
void getBlockTemplate();
void retry();
void setState(State state);
bool isSubmitBlockResponse(int64_t id);
void submitBlockTemplate(rapidjson::Value &result);
void submitOriginDaemon(const JobResult &result);
@@ -112,8 +113,8 @@ private:
int64_t m_sequence = 1;
Job m_job;
State m_state = IdleState;
std::map<int64_t, SubmitResult> m_results;
std::shared_ptr<IHttpListener> m_httpListener;
int64_t m_last_submit_req_id;
std::shared_ptr<IHttpListener> m_httpListener;
String m_blocktemplate;
uint64_t m_blockDiff = 0;
uint64_t m_originNotSubmitted = 0;

View File

@@ -1078,6 +1078,6 @@ void JitCompilerA64::h_NOP(Instruction& instr, uint32_t& codePos)
{
}
InstructionGeneratorA64 JitCompilerA64::engine[257] = {};
InstructionGeneratorA64 JitCompilerA64::engine[256] = {};
}

View File

@@ -74,7 +74,7 @@ namespace randomx {
void enableWriting() const;
void enableExecution() const;
static InstructionGeneratorA64 engine[257];
static InstructionGeneratorA64 engine[256];
private:
const bool hugePages;

View File

@@ -1443,6 +1443,6 @@ namespace randomx {
emitByte(0x90, code, codePos);
}
alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[257] = {};
alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[256] = {};
}

View File

@@ -81,7 +81,7 @@ namespace randomx {
void enableWriting() const;
void enableExecution() const;
alignas(64) static InstructionGeneratorX86 engine[257];
alignas(64) static InstructionGeneratorX86 engine[256];
private:
int registerUsage[RegistersCount] = {};

View File

@@ -260,7 +260,7 @@ typedef void(randomx::JitCompilerX86::* InstructionGeneratorX86_2)(const randomx
#define JIT_HANDLE(x, prev) do { \
const InstructionGeneratorX86_2 p = &randomx::JitCompilerX86::h_##x; \
memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(p)); \
memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(randomx::JitCompilerX86::engine[k])); \
} while (0)
#elif (XMRIG_ARM == 8)

View File

@@ -22,7 +22,7 @@
#define APP_ID "xmrig"
#define APP_NAME "XMRig"
#define APP_DESC "XMRig miner"
#define APP_VERSION "6.21.2"
#define APP_VERSION "6.21.3"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com"
@@ -30,7 +30,7 @@
#define APP_VER_MAJOR 6
#define APP_VER_MINOR 21
#define APP_VER_PATCH 2
#define APP_VER_PATCH 3
#ifdef _MSC_VER
# if (_MSC_VER >= 1930)