More tests, code cleanup
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
Sync test / sync-test-ubuntu-tsan (push) Waiting to run
Sync test / sync-test-ubuntu-ubsan (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-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
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-msan (push) Waiting to run

This commit is contained in:
SChernykh 2024-06-26 11:25:21 +02:00
parent 75a894bbd1
commit b5558baa4c
6 changed files with 24 additions and 9 deletions

View file

@ -23,6 +23,8 @@
#include "merge_mining_client_tari.h"
#endif
LOG_CATEGORY(MergeMiningClient)
namespace p2pool {
IMergeMiningClient* IMergeMiningClient::create(p2pool* pool, const std::string& host, const std::string& wallet) noexcept
@ -39,6 +41,7 @@ IMergeMiningClient* IMergeMiningClient::create(p2pool* pool, const std::string&
}
}
catch (...) {
LOGERR(1, "Failed to create merge mining client for " << host);
}
return nullptr;
}

View file

@ -384,7 +384,7 @@ 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) {
if (status[0] == '\0') {
status = "accepted";
}

View file

@ -259,7 +259,7 @@ root_hash get_root_from_proof(hash h, const std::vector<hash>& proof, size_t ind
return root_hash(h);
}
bool verify_merkle_proof(hash h, const std::vector<hash>& proof, size_t index, size_t count, const root_hash& root)
bool verify_merkle_proof(const hash& h, const std::vector<hash>& proof, size_t index, size_t count, const root_hash& root)
{
return get_root_from_proof(h, proof, index, count) == root;
}

View file

@ -26,7 +26,7 @@ bool get_merkle_proof(const std::vector<std::vector<hash>>& tree, const hash& h,
root_hash get_root_from_proof(hash h, const std::vector<hash>& proof, size_t index, size_t count);
bool verify_merkle_proof(hash h, const std::vector<hash>& proof, size_t index, size_t count, const root_hash& root);
bool verify_merkle_proof(const hash& h, const std::vector<hash>& proof, size_t index, size_t count, const root_hash& root);
bool verify_merkle_proof(hash h, const std::vector<hash>& proof, uint32_t path, const root_hash& root);
uint32_t get_aux_slot(const hash &id, uint32_t nonce, uint32_t n_aux_chains);

View file

@ -564,7 +564,7 @@ void p2pool::update_aux_data(const hash& chain_id)
data.aux_nonce = m_auxNonce;
}
else if (find_aux_nonce(aux_id, data.aux_nonce)) {
m_auxId = aux_id;
m_auxId = std::move(aux_id);
m_auxNonce = data.aux_nonce;
}
else {

View file

@ -334,6 +334,8 @@ TEST(merkle, params)
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(1, 0xFFFFFFFFU), 0xFFFFFFFF0ULL);
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0), 0x3F6U);
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0xFFFFFFFFU), 0x3FFFFFFFFF6ULL);
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(256, 0), 0x7FFU);
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(256, 0xFFFFFFFFU), 0x7FFFFFFFFFFULL);
PoolBlock b;
uint32_t n1, nonce1;
@ -354,12 +356,22 @@ TEST(merkle, params)
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_TRUE(n1 == 127 && nonce1 == 0xFFFFFFFFU);
for (uint32_t n_aux_chains = 1; n_aux_chains < 128; ++n_aux_chains) {
b.m_merkleTreeData = 0x7FFU;
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_TRUE(n1 == 256 && nonce1 == 0);
b.m_merkleTreeData = 0x7FFFFFFFFFFULL;
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_TRUE(n1 == 256 && nonce1 == 0xFFFFFFFFU);
for (uint32_t n_aux_chains = 1; n_aux_chains <= 256; ++n_aux_chains) {
for (uint32_t nonce = 1; nonce; nonce <<= 1) {
b.m_merkleTreeData = PoolBlock::encode_merkle_tree_data(n_aux_chains, nonce);
for (uint32_t i = 0; i <= 1; ++i) {
b.m_merkleTreeData = PoolBlock::encode_merkle_tree_data(n_aux_chains, nonce - i);
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_EQ(n1, n_aux_chains);
ASSERT_EQ(nonce1, nonce);
ASSERT_EQ(nonce1, nonce - i);
}
}
}
}