Fixed merge mining with multiple chains
Some checks are pending
C/C++ CI / build-alpine-static (map[arch:aarch64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline -mfix-cortex-a53-835769 -mfix-cortex-a53-843419]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:riscv64 branch:edge flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-alpine-static (map[arch:x86_64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-11 cpp:g++-11 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-12 cpp:g++-12 flags: os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-ubuntu (map[c:gcc-8 cpp:g++-8 flags: os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-static-libs (map[flags:-fuse-linker-plugin -ffunction-sections -Wno-error=inline]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-20.04]) (push) Waiting to run
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-22.04]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:clang cxx:clang++ flags:-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled]) (push) Waiting to run
C/C++ CI / build-windows-msys2 (map[c:gcc cxx:g++ flags:-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2019 rx:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Waiting to run
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2022 rx:ON upnp:ON vs:Visual Studio 17 2022 vspath:C:\Program Files\Microsoft Visual Studio\2022\Enterprise]) (push) Waiting to run
C/C++ CI / build-macos (push) Waiting to run
C/C++ CI / build-macos-aarch64 (push) Waiting to run
C/C++ CI / build-freebsd (map[architecture:x86-64 host:ubuntu-latest name:freebsd version:13.3]) (push) Waiting to run
C/C++ CI / build-openbsd (map[architecture:x86-64 host:ubuntu-latest name:openbsd version:7.4]) (push) Waiting to run
clang-tidy / clang-tidy (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
cppcheck / cppcheck-ubuntu (push) Waiting to run
cppcheck / cppcheck-windows (push) Waiting to run
Microsoft C++ Code Analysis / Analyze (push) Waiting to run
source-snapshot / source-snapshot (push) Waiting to run
Sync test (old) / sync-test-ubuntu-tsan (push) Waiting to run
Sync test (old) / sync-test-ubuntu-msan (push) Waiting to run
Sync test (old) / sync-test-ubuntu-ubsan (push) Waiting to run
Sync test (old) / sync-test-ubuntu-asan (push) Waiting to run
Sync test (old) / sync-test-macos (map[flags:-Og -ftrapv -target arm64-apple-macos-11 os:macos-14]) (push) Waiting to run
Sync test (old) / sync-test-macos (map[flags:-Og -ftrapv os:macos-13]) (push) Waiting to run
Sync test (old) / sync-test-windows-debug-asan (push) Waiting to run
Sync test (old) / sync-test-windows-leaks (push) Waiting to run
Sync test / sync-test-ubuntu-asan (push) Waiting to run
Sync test / sync-test-macos (map[flags:-Og -ftrapv -target arm64-apple-macos-11 os:macos-14]) (push) Waiting to run
Sync test / sync-test-ubuntu-tsan (push) Waiting to run
Sync test / sync-test-ubuntu-msan (push) Waiting to run
Sync test / sync-test-ubuntu-ubsan (push) Waiting to run
Sync test / sync-test-macos (map[flags:-Og -ftrapv os:macos-13]) (push) Waiting to run
Sync test / sync-test-windows-debug-asan (push) Waiting to run
Sync test / sync-test-windows-leaks (push) Waiting to run

This commit is contained in:
SChernykh 2024-06-11 18:40:30 +02:00
parent 8fc5e5013c
commit 5e8da4e672
6 changed files with 49 additions and 17 deletions

View file

@ -121,4 +121,4 @@ Field|Description
Example response 1: `{"jsonrpc":"2.0","id":"0","result":{"status":"accepted"}}`
Example response 2: `{"jsonrpc":"2.0","id":"0","error":"something went wrong"}`
Example response 2: `{"jsonrpc":"2.0","id":"0","error":{"code":-1,"message":"Block not accepted"}}`

View file

@ -354,7 +354,17 @@ bool MergeMiningClientJSON_RPC::parse_merge_mining_submit_solution(const char* d
}
if (doc.HasMember("error")) {
return err(doc["error"].IsString() ? doc["error"].GetString() : "an unknown error occurred");
const auto& error_result = doc["error"];
if (error_result.IsString()) {
return err(error_result.GetString());
}
else if (error_result.IsObject() && error_result.HasMember("message") && error_result["message"].IsString()) {
return err(error_result["message"].GetString());
}
else {
return err("an unknown error occurred");
}
}
if (!doc.HasMember("result")) {
@ -372,6 +382,12 @@ bool MergeMiningClientJSON_RPC::parse_merge_mining_submit_solution(const char* d
}
const char* status = result["status"].GetString();
// Empty string means no errors and the block was accepted
if (strlen(status) == 0) {
status = "accepted";
}
LOGINFO(0, log::LightGreen() << "merge_mining_submit_solution to " << m_host << ':' << m_port << ": " << status);
// Get new mining job

View file

@ -242,12 +242,19 @@ void Miner::run(WorkerData* data)
}
if (j.m_auxDiff.check_pow(h)) {
std::vector<p2pool::SubmitAuxBlockData> aux_blocks;
aux_blocks.reserve(j.m_auxChains.size());
for (const AuxChainData& aux_data : j.m_auxChains) {
if (aux_data.difficulty.check_pow(h)) {
LOGINFO(0, log::Green() << "AUX BLOCK FOUND: chain_id " << aux_data.unique_id << ", diff " << aux_data.difficulty << ", worker thread " << data->m_index << '/' << data->m_count);
m_pool->submit_aux_block_async(aux_data.unique_id, j.m_templateId, j.m_nonce, j.m_extraNonce);
aux_blocks.emplace_back(p2pool::SubmitAuxBlockData{ aux_data.unique_id, j.m_templateId, j.m_nonce, j.m_extraNonce });
}
}
if (!aux_blocks.empty()) {
m_pool->submit_aux_block_async(aux_blocks);
}
}
if (j.m_sidechainDiff.check_pow(h)) {

View file

@ -644,11 +644,11 @@ void p2pool::submit_block_async(std::vector<uint8_t>&& blob)
}
}
void p2pool::submit_aux_block_async(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
void p2pool::submit_aux_block_async(const std::vector<SubmitAuxBlockData>& aux_blocks)
{
{
MutexLock lock(m_submitAuxBlockDataLock);
m_submitAuxBlockData.emplace_back(SubmitAuxBlockData{ chain_id, template_id, nonce, extra_nonce });
m_submitAuxBlockData.insert(m_submitAuxBlockData.end(), aux_blocks.begin(), aux_blocks.end());
}
// If p2pool is stopped, m_submitAuxBlockAsync is most likely already closed
@ -738,7 +738,7 @@ void p2pool::submit_aux_block() const
LOGWARN(3, "submit_aux_block: failed to get merkle proof for chain_id " << chain_id);
}
return;
break;
}
}
}

View file

@ -91,7 +91,15 @@ public:
void submit_block_async(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
void submit_block_async(std::vector<uint8_t>&& blob);
void submit_aux_block_async(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
struct SubmitAuxBlockData
{
hash chain_id;
uint32_t template_id = 0;
uint32_t nonce = 0;
uint32_t extra_nonce = 0;
};
void submit_aux_block_async(const std::vector<SubmitAuxBlockData>& aux_blocks);
bool submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
@ -223,14 +231,6 @@ private:
mutable uv_mutex_t m_submitBlockDataLock;
SubmitBlockData m_submitBlockData;
struct SubmitAuxBlockData
{
hash chain_id;
uint32_t template_id = 0;
uint32_t nonce = 0;
uint32_t extra_nonce = 0;
};
mutable uv_mutex_t m_submitAuxBlockDataLock;
mutable std::vector<SubmitAuxBlockData> m_submitAuxBlockData;

View file

@ -403,13 +403,22 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
}
if (aux_diff.check_pow(resultHash)) {
for (const AuxChainData& aux_data : block.get_aux_chains(template_id)) {
const std::vector<AuxChainData> aux_chains = block.get_aux_chains(template_id);
std::vector<p2pool::SubmitAuxBlockData> aux_blocks;
aux_blocks.reserve(aux_chains.size());
for (const AuxChainData& aux_data : aux_chains) {
if (aux_data.difficulty.check_pow(resultHash)) {
const char* s = client->m_customUser;
LOGINFO(0, log::Green() << "client " << static_cast<char*>(client->m_addrString) << (*s ? " user " : "") << s << " found an aux block for chain_id " << aux_data.unique_id << ", diff " << aux_data.difficulty << ", submitting it");
m_pool->submit_aux_block_async(aux_data.unique_id, template_id, nonce, extra_nonce);
aux_blocks.emplace_back(p2pool::SubmitAuxBlockData{ aux_data.unique_id, template_id, nonce, extra_nonce });
}
}
if (!aux_blocks.empty()) {
m_pool->submit_aux_block_async(aux_blocks);
}
}
SubmittedShare* share;