Fix sync stall, C++17 compat, cppcheck shadow, and gate sync tests behind some CI checks

This commit is contained in:
Matt Hess
2026-02-19 01:42:21 +00:00
parent fedf09caa2
commit 7eac7d4542
8 changed files with 49 additions and 19 deletions

View File

@@ -13,6 +13,8 @@ on:
workflow_dispatch:
workflow_call:
jobs:
build-alpine-static:

View File

@@ -13,6 +13,8 @@ on:
workflow_dispatch:
workflow_call:
jobs:
clang-tidy:
runs-on: ubuntu-latest

View File

@@ -13,6 +13,8 @@ on:
workflow_dispatch:
workflow_call:
jobs:
cppcheck-ubuntu:

View File

@@ -14,7 +14,17 @@ on:
workflow_dispatch:
jobs:
clang-tidy:
uses: ./.github/workflows/clang-tidy.yml
cppcheck:
uses: ./.github/workflows/cppcheck.yml
c-cpp-ci:
uses: ./.github/workflows/c-cpp.yml
sync-test-macos:
needs: [clang-tidy, cppcheck, c-cpp-ci]
timeout-minutes: 120
runs-on: ${{ matrix.config.os }}

View File

@@ -14,8 +14,17 @@ on:
workflow_dispatch:
jobs:
sync-test-ubuntu-tsan:
clang-tidy:
uses: ./.github/workflows/clang-tidy.yml
cppcheck:
uses: ./.github/workflows/cppcheck.yml
c-cpp-ci:
uses: ./.github/workflows/c-cpp.yml
sync-test-ubuntu-tsan:
needs: [clang-tidy, cppcheck, c-cpp-ci]
timeout-minutes: 60
runs-on: ubuntu-22.04

View File

@@ -14,7 +14,17 @@ on:
workflow_dispatch:
jobs:
clang-tidy:
uses: ./.github/workflows/clang-tidy.yml
cppcheck:
uses: ./.github/workflows/cppcheck.yml
c-cpp-ci:
uses: ./.github/workflows/c-cpp.yml
sync-test-windows-debug-asan:
needs: [clang-tidy, cppcheck, c-cpp-ci]
timeout-minutes: 60
runs-on: windows-2022

View File

@@ -1657,7 +1657,10 @@ void P2PServer::download_missing_blocks()
}
// Send remaining batch requests
for (auto& [client, batch] : batch_requests) {
for (auto& entry : batch_requests) {
P2PClient* client = entry.first;
std::vector<hash>& batch = entry.second;
if (batch.empty()) {
continue;
}
@@ -3178,10 +3181,10 @@ bool P2PServer::P2PClient::on_block_batch_response(const uint8_t* buf, uint32_t
const uint64_t received_timestamp = microseconds_since_epoch();
const uint8_t* p = buf + 1;
const uint8_t* end = buf + size;
const uint8_t* buf_end = buf + size;
for (uint8_t i = 0; i < count; ++i) {
if (p + sizeof(uint32_t) > end) {
if (p + sizeof(uint32_t) > buf_end) {
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent truncated BLOCK_BATCH_RESPONSE");
return false;
}
@@ -3200,7 +3203,7 @@ bool P2PServer::P2PClient::on_block_batch_response(const uint8_t* buf, uint32_t
continue;
}
if (p + block_size > end) {
if (p + block_size > buf_end) {
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent truncated block in BLOCK_BATCH_RESPONSE");
return false;
}

View File

@@ -630,6 +630,12 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
LOGWARN(3, "add_external_block mined by " << block.m_minerWallet << ": wrong mainchain height " << block.m_txinGenHeight << ", expected " << data.height + 1);
return false;
}
// Hash is known but difficulty for this height may still be missing from cache.
// get_shares() needs it; fetch proactively so verification doesn't stall.
difficulty_type tmp_diff;
if (!m_pool->get_difficulty_at_height(block.m_txinGenHeight, tmp_diff) && is_main_thread()) {
m_pool->fetch_mainchain_block(block.m_txinGenHeight);
}
}
else {
LOGWARN(3, "add_external_block: block is built on top of an unknown mainchain block " << block.m_prevId << ", mainchain reorg might've happened, fetching mainchain height " << block.m_txinGenHeight);
@@ -651,8 +657,6 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
return false;
}
LOGINFO(6, "DEBUG get_pow_hash: seed=" << block.m_seed << " txinGenHeight=" << block.m_txinGenHeight);
if (!block.get_pow_hash(m_pool->hasher(), block.m_txinGenHeight, block.m_seed, block.m_powHash)) {
LOGWARN(3, "add_external_block: couldn't get PoW hash for height = " << block.m_sidechainHeight << ", mainchain height " << block.m_txinGenHeight << ". Ignoring it.");
forget_incoming_block(block);
@@ -676,8 +680,6 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
}
}
LOGINFO(6, "DEBUG PoW check: sidechainHeight=" << block.m_sidechainHeight << " m_difficulty.lo=" << block.m_difficulty.lo << " m_difficulty.hi=" << block.m_difficulty.hi << " m_powHash=" << block.m_powHash);
if (!block.m_difficulty.check_pow(block.m_powHash)) {
LOGWARN(3,
"add_external_block mined by " << block.m_minerWallet <<
@@ -903,16 +905,6 @@ const PoolBlock* SideChain::get_block_blob(const hash& id, std::vector<uint8_t>&
}
blob = block->serialize_mainchain_data();
{
std::string hex;
size_t start = 43; // approximate outputs offset
for (size_t i = start; i < std::min<size_t>(start + 64, blob.size()); ++i) {
char buf[4];
snprintf(buf, sizeof(buf), "%02x", blob[i]);
hex += buf;
}
LOGINFO(6, "DEBUG get_block_blob outputs area (64 bytes from offset 43): " << hex);
}
const std::vector<uint8_t> sidechain_data = block->serialize_sidechain_data();
blob.insert(blob.end(), sidechain_data.begin(), sidechain_data.end());