diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ed4cdc..087b818 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,11 +23,20 @@ jobs: cd external/src/curl cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF make -j$(nproc) + cd ../libuv + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DLIBUV_BUILD_TESTS=OFF + make -j$(nproc) + cd ../../libzmq + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DWITH_LIBSODIUM=OFF -DBUILD_TESTS=OFF + make -j$(nproc) cd ../../.. mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DSTATIC_BINARY=ON -DWITH_LTO=OFF - make -j$(nproc) + make -j$(nproc) p2pool-salvium strip p2pool-salvium + ./p2pool-salvium --test - name: Package run: | @@ -62,11 +71,20 @@ jobs: cd external/src/curl cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Os -flto=auto" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF make -j$(nproc) + cd ../libuv + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Os -flto=auto" -DBUILD_SHARED_LIBS=OFF -DLIBUV_BUILD_TESTS=OFF + make -j$(nproc) + cd ../../libzmq + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Os -flto=auto" -DBUILD_SHARED_LIBS=OFF -DWITH_LIBSODIUM=OFF -DBUILD_TESTS=OFF + make -j$(nproc) cd ../../.. mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DSTATIC_BINARY=ON -DWITH_LTO=OFF - make -j$(nproc) + make -j$(nproc) p2pool-salvium strip p2pool-salvium + ./p2pool-salvium --test tar -czf p2pool-salvium-v${{ inputs.version }}-linux-aarch64.tar.gz p2pool-salvium - uses: actions/upload-artifact@v4 @@ -96,11 +114,20 @@ jobs: cd external/src/curl cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Os" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF make -j$(nproc) + cd ../libuv + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Os" -DBUILD_SHARED_LIBS=OFF -DLIBUV_BUILD_TESTS=OFF + make -j$(nproc) + cd ../../libzmq + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Os" -DBUILD_SHARED_LIBS=OFF -DWITH_LIBSODIUM=OFF -DBUILD_TESTS=OFF + make -j$(nproc) cd ../../.. mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DSTATIC_BINARY=ON -DWITH_LTO=OFF - make -j$(nproc) + make -j$(nproc) p2pool-salvium strip p2pool-salvium + ./p2pool-salvium --test tar -czf p2pool-salvium-v${{ inputs.version }}-linux-riscv64.tar.gz p2pool-salvium - uses: actions/upload-artifact@v4 @@ -123,9 +150,10 @@ jobs: make -j$(sysctl -n hw.ncpu) cd ../../.. mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - make -j$(sysctl -n hw.ncpu) + cmake .. -DCMAKE_BUILD_TYPE=Release -DSTATIC_LIBS=ON -DWITH_LTO=OFF + make -j$(sysctl -n hw.ncpu) p2pool-salvium strip p2pool-salvium + ./p2pool-salvium --test tar -czf p2pool-salvium-v${{ inputs.version }}-macos-x64.tar.gz p2pool-salvium - uses: actions/upload-artifact@v4 @@ -148,9 +176,10 @@ jobs: make -j$(sysctl -n hw.ncpu) cd ../../.. mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release - make -j$(sysctl -n hw.ncpu) + cmake .. -DCMAKE_BUILD_TYPE=Release -DSTATIC_LIBS=ON -DWITH_LTO=OFF + make -j$(sysctl -n hw.ncpu) p2pool-salvium strip p2pool-salvium + ./p2pool-salvium --test tar -czf p2pool-salvium-v${{ inputs.version }}-macos-aarch64.tar.gz p2pool-salvium - uses: actions/upload-artifact@v4 @@ -181,9 +210,10 @@ jobs: make -j$(nproc) cd ../../.. mkdir build && cd build - cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release - make -j$(nproc) + cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DSTATIC_LIBS=ON -DOPENSSL_NO_ASM=ON -DWITH_LTO=OFF + make -j$(nproc) p2pool-salvium strip p2pool-salvium.exe + ./p2pool-salvium.exe --test zip p2pool-salvium-v${{ inputs.version }}-windows-x64.zip p2pool-salvium.exe - uses: actions/upload-artifact@v4 diff --git a/src/block_template.cpp b/src/block_template.cpp index b5f177c..eed880f 100644 --- a/src/block_template.cpp +++ b/src/block_template.cpp @@ -1431,10 +1431,10 @@ hash BlockTemplate::calc_miner_tx_hash(uint32_t extra_nonce) const char prunable_hash_hex[65] = {0}; char final_hash_hex[65] = {0}; for (int i = 0; i < 32; ++i) { - snprintf(prefix_hash_hex + i*2, 3, "%02x", hashes[i]); - snprintf(base_rct_hash_hex + i*2, 3, "%02x", hashes[32 + i]); - snprintf(prunable_hash_hex + i*2, 3, "%02x", hashes[64 + i]); - snprintf(final_hash_hex + i*2, 3, "%02x", result.h[i]); + snprintf(prefix_hash_hex + static_cast(i) * 2, 3, "%02x", hashes[i]); + snprintf(base_rct_hash_hex + static_cast(i) * 2, 3, "%02x", hashes[32 + i]); + snprintf(prunable_hash_hex + static_cast(i) * 2, 3, "%02x", hashes[64 + i]); + snprintf(final_hash_hex + static_cast(i) * 2, 3, "%02x", result.h[i]); } LOGINFO(3, "Miner TX hash components:"); LOGINFO(3, " Prefix hash: " << static_cast(prefix_hash_hex)); diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index b16cb8b..cb22f8b 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -3158,7 +3158,7 @@ bool P2PServer::P2PClient::on_genesis_info(const uint8_t* buf) if (!server->find_block(peer_genesis_id)) { LOGINFO(5, "Requesting genesis block " << peer_genesis_id << " from peer"); const bool result = server->send(this, - [&peer_genesis_id, this](uint8_t* buf, size_t buf_size) -> size_t + [&peer_genesis_id](uint8_t* buf, size_t buf_size) -> size_t { if (buf_size < 1 + HASH_SIZE) { return 0; diff --git a/src/p2pool.cpp b/src/p2pool.cpp index ee7932d..d1d77b5 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -1976,7 +1976,7 @@ void p2pool::prefetch_mainchain_blocks(uint64_t current_height) s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_headers_range\",\"params\":{\"start_height\":" << start_height << ",\"end_height\":" << (current_height - 1) << "}}" << '\0'; JSONRPCRequest::call(host.m_address, host.m_rpcPort, buf, host.m_rpcLogin, m_params->m_socks5Proxy, host.m_rpcSSL, host.m_rpcSSL_Fingerprint, - [this, start_height, current_height](const char* data, size_t size, double) { + [this](const char* data, size_t size, double) { const uint32_t parsed = parse_block_headers_range(data, size); if (parsed > 0) { LOGINFO(1, "Pre-fetched " << parsed << " mainchain blocks into cache"); @@ -1984,7 +1984,7 @@ void p2pool::prefetch_mainchain_blocks(uint64_t current_height) LOGWARN(1, "Failed to pre-fetch mainchain blocks, will rely on ZMQ"); } }, - [this](const char* data, size_t size, double) { + [](const char* data, size_t size, double) { if (size > 0) { LOGWARN(1, "Failed to pre-fetch mainchain blocks: " << log::const_buf(data, size)); } @@ -2021,7 +2021,7 @@ void p2pool::fetch_mainchain_block(uint64_t height) LOGWARN(3, "Failed to parse block header for height " << height); } }, - [this, height](const char* data, size_t size, double) { + [height](const char* data, size_t size, double) { if (size > 0) { LOGWARN(3, "Failed to fetch mainchain block at height " << height << ": " << log::const_buf(data, size)); } diff --git a/src/pool_block.h b/src/pool_block.h index 76b0a1a..2803ad6 100644 --- a/src/pool_block.h +++ b/src/pool_block.h @@ -174,8 +174,8 @@ struct PoolBlock // Just temporary stuff, not a part of the block uint64_t m_depth; - bool m_verified; - bool m_invalid; + mutable bool m_verified; + mutable bool m_invalid; mutable bool m_broadcasted; mutable bool m_wantBroadcast; diff --git a/src/protocol_tx_hash.cpp b/src/protocol_tx_hash.cpp index d10ff5b..6a82749 100644 --- a/src/protocol_tx_hash.cpp +++ b/src/protocol_tx_hash.cpp @@ -34,7 +34,7 @@ void calculate_protocol_tx_hash(uint64_t height, hash& result) { hash prefix_hash, base_rct_hash; uint8_t rct_type = 0; - keccak(prefix_serialized.data(), prefix_serialized.size(), prefix_hash.h); + keccak(prefix_serialized.data(), static_cast(prefix_serialized.size()), prefix_hash.h); keccak(&rct_type, 1, base_rct_hash.h); // Combine: prefix_hash + base_rct_hash + null_hash (32 zeros) diff --git a/src/side_chain.cpp b/src/side_chain.cpp index cfa124e..93558cc 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -73,10 +73,10 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name, cons , m_chainWindowSize(2160) , m_unclePenalty(20) , m_precalcFinished(false) - , m_externalBlockFailures(0) #ifdef DEV_TEST_SYNC , m_firstPruneTime(0) #endif + , m_externalBlockFailures(0) { if (s_networkType == NetworkType::Invalid) { s_networkType = type; @@ -3417,8 +3417,7 @@ bool SideChain::validate_loaded_checkpoints() // No checkpoints - need to bootstrap from chain tip const PoolBlock* tip = m_chainTip; if (tip && !tip->m_verified) { - PoolBlock* mutable_tip = const_cast(tip); - mutable_tip->m_verified = true; + tip->m_verified = true; LOGINFO(1, "No checkpoints - bootstrapping verification from chain tip height " << tip->m_sidechainHeight); } return true; // Safe to mine @@ -3443,7 +3442,7 @@ bool SideChain::validate_loaded_checkpoints() LOGINFO(3, "Checkpoint at height " << cp.height << " is reachable, looking up block id " << cp.id); // Direct lookup - sidechain lock held above - const PoolBlock* found = nullptr; + PoolBlock* found = nullptr; auto it = m_blocksById.find(cp.id); if (it != m_blocksById.end()) { found = it->second; @@ -3457,7 +3456,7 @@ bool SideChain::validate_loaded_checkpoints() return false; // NOT safe to mine yet } - PoolBlock* block = const_cast(found); + PoolBlock* block = found; if (block->m_sidechainId != cp.id) { LOGWARN(0, "CHECKPOINT MISMATCH at height " << cp.height << @@ -3489,8 +3488,7 @@ bool SideChain::validate_loaded_checkpoints() if (m_checkpoints.empty()) { const PoolBlock* tip = m_chainTip; if (tip) { - PoolBlock* mutable_tip = const_cast(tip); - mutable_tip->m_verified = true; + tip->m_verified = true; LOGINFO(1, "All checkpoints stale - bootstrapping verification from chain tip height " << tip->m_sidechainHeight); need_bootstrap = true; bootstrap_height = tip->m_sidechainHeight; @@ -3544,25 +3542,25 @@ bool SideChain::validate_loaded_checkpoints() save_checkpoints(); // Persist the cleaned list } return true; // Safe to mine - } else { - LOGERR(0, "Cached checkpoints are INVALID - chain has diverged since last run"); - LOGERR(0, "First mismatch at height " << first_mismatch_height); - - { - WriteLock wlock(m_checkpointsLock); - m_checkpoints.clear(); - } - - LOGINFO(0, "Cleared stale checkpoints - will rebuild from current chain"); - save_checkpoints(); // Persist the cleared state - - // Rebuild checkpoints from current chain - const PoolBlock* tip = m_chainTip; - if (tip) { - update_checkpoints(tip->m_sidechainHeight); - } - return true; // Checkpoints cleared and rebuilt, safe to mine } + + LOGERR(0, "Cached checkpoints are INVALID - chain has diverged since last run"); + LOGERR(0, "First mismatch at height " << first_mismatch_height); + + { + WriteLock wlock(m_checkpointsLock); + m_checkpoints.clear(); + } + + LOGINFO(0, "Cleared stale checkpoints - will rebuild from current chain"); + save_checkpoints(); // Persist the cleared state + + // Rebuild checkpoints from current chain + const PoolBlock* tip = m_chainTip; + if (tip) { + update_checkpoints(tip->m_sidechainHeight); + } + return true; // Checkpoints cleared and rebuilt, safe to mine } } // namespace p2pool diff --git a/src/wallet.cpp b/src/wallet.cpp index c7e73fd..2e77e9c 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -42,8 +42,6 @@ constexpr uint64_t valid_prefixes[] = { 0x180c96, 0x254c96, 0x24cc96 }; // SC1, constexpr uint64_t valid_prefixes_subaddress[] = { 0x314c96, 0x3c54c96, 0x384cc96 }; // SC1s, SC1Ts, SC1Ss constexpr std::array block_sizes{ 0, 2, 3, 5, 6, 7, 9, 10, 11 }; -constexpr int num_full_blocks = p2pool::Wallet::ADDRESS_LENGTH / block_sizes.back(); -constexpr int last_block_size = p2pool::Wallet::ADDRESS_LENGTH % block_sizes.back(); constexpr int block_sizes_lookup[11] = { 0, -1, 1, 2, -1, 3, 4, 5, -1, 6, 7 }; @@ -127,8 +125,8 @@ bool Wallet::decode(const char* address) } // Calculate based on actual address length - const int actual_num_full_blocks = addr_len / block_sizes.back(); - const int actual_last_block_size = addr_len % block_sizes.back(); + const int actual_num_full_blocks = static_cast(addr_len / block_sizes.back()); + const int actual_last_block_size = static_cast(addr_len % block_sizes.back()); const int actual_last_block_size_index = block_sizes_lookup[actual_last_block_size]; if (actual_last_block_size_index < 0) {