diff --git a/CMakeModules/cppcheck.cmake b/CMakeModules/cppcheck.cmake index 4f7a0b22bb..2cd752ccc1 100644 --- a/CMakeModules/cppcheck.cmake +++ b/CMakeModules/cppcheck.cmake @@ -11,6 +11,7 @@ else () --error-exitcode=1 --enable=all --suppress=missingInclude + --suppress=missingIncludeSystem # find_if - useless here --suppress=useStlAlgorithm:${PROJECT_SOURCE_DIR}/*/pbft_sync_packet_handler.cpp --suppress=noExplicitConstructor @@ -36,8 +37,10 @@ else () --suppress=unmatchedSuppression:${PROJECT_SOURCE_DIR}/*/Common.h --suppress=cstyleCast:${PROJECT_SOURCE_DIR}/*/vector_ref.h --suppress=cstyleCast:${PROJECT_SOURCE_DIR}/*/Common.h - #not an issue here + # not an issue here --suppress=virtualCallInConstructor:${PROJECT_SOURCE_DIR}/*/final_chain.cpp + # just a warning + --suppress=duplInheritedMember:${PROJECT_SOURCE_DIR}/*/FixedHash.h # Only show found errors "--quiet" diff --git a/conanfile.py b/conanfile.py index 364e1d5d2a..49e27f5ef8 100644 --- a/conanfile.py +++ b/conanfile.py @@ -13,11 +13,11 @@ class TaraxaConan(ConanFile): generators = "cmake" def requirements(self): - self.requires("boost/1.81.0") - self.requires("cppcheck/2.10") - self.requires("openssl/1.1.1t") + self.requires("boost/1.83.0") + self.requires("cppcheck/2.12") + self.requires("openssl/3.0.10") self.requires("cryptopp/8.7.0") - self.requires("gtest/1.13.0") + self.requires("gtest/1.14.0") self.requires("lz4/1.9.4") self.requires("rocksdb/6.29.5") self.requires("prometheus-cpp/1.1.0") diff --git a/libraries/aleth/libdevcore/Address.cpp b/libraries/aleth/libdevcore/Address.cpp deleted file mode 100644 index 6bb3463e46..0000000000 --- a/libraries/aleth/libdevcore/Address.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Aleth: Ethereum C++ client, tools and libraries. -// Copyright 2014-2019 Aleth Authors. -// Licensed under the GNU General Public License, Version 3. -#include "Address.h" - -namespace dev { -Address const ZeroAddress; -Address const MaxAddress{"0xffffffffffffffffffffffffffffffffffffffff"}; -Address const SystemAddress{"0xfffffffffffffffffffffffffffffffffffffffe"}; -} // namespace dev diff --git a/libraries/aleth/libdevcore/Address.h b/libraries/aleth/libdevcore/Address.h index b9fdcf8fae..66be630322 100644 --- a/libraries/aleth/libdevcore/Address.h +++ b/libraries/aleth/libdevcore/Address.h @@ -23,12 +23,5 @@ using Addresses = h160s; using AddressSet = std::unordered_set; /// The zero address. -extern Address const ZeroAddress; - -/// The last address. -extern Address const MaxAddress; - -/// The SYSTEM address. -extern Address const SystemAddress; - +Address const ZeroAddress; } // namespace dev diff --git a/libraries/aleth/libdevcore/Common.h b/libraries/aleth/libdevcore/Common.h index 10dc3e8403..e7dfe89035 100644 --- a/libraries/aleth/libdevcore/Common.h +++ b/libraries/aleth/libdevcore/Common.h @@ -127,7 +127,6 @@ using strings = std::vector; // Null/Invalid values for convenience. extern bytes const NullBytes; -u256 constexpr Invalid256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_cppui256; /// Interprets @a _u as a two's complement signed number and returns the /// resulting s256. diff --git a/libraries/cli/include/cli/tools.hpp b/libraries/cli/include/cli/tools.hpp index d372684ca9..cf33ed2928 100644 --- a/libraries/cli/include/cli/tools.hpp +++ b/libraries/cli/include/cli/tools.hpp @@ -35,8 +35,9 @@ Json::Value getGenesis(Config::ChainIdType chain_id); void generateWallet(const std::string& wallet); // Override existing config and wallet files -Json::Value overrideConfig(Json::Value& config, std::string& data_dir, std::vector boot_nodes, - std::vector log_channels, std::vector log_configurations, +Json::Value overrideConfig(Json::Value& config, std::string& data_dir, const std::vector& boot_nodes, + const std::vector& log_channels, + const std::vector& log_configurations, const std::vector& boot_nodes_append, const std::vector& log_channels_append); Json::Value overrideWallet(Json::Value& wallet, const std::string& node_key, const std::string& vrf_key); diff --git a/libraries/cli/src/tools.cpp b/libraries/cli/src/tools.cpp index 92b2720760..cdfea7be4f 100644 --- a/libraries/cli/src/tools.cpp +++ b/libraries/cli/src/tools.cpp @@ -64,8 +64,8 @@ Json::Value getGenesis(Config::ChainIdType chain_id) { return genesis; } -Json::Value overrideConfig(Json::Value& conf, std::string& data_dir, vector boot_nodes, - vector log_channels, vector log_configurations, +Json::Value overrideConfig(Json::Value& conf, std::string& data_dir, const vector& boot_nodes, + const vector& log_channels, const vector& log_configurations, const vector& boot_nodes_append, const vector& log_channels_append) { if (data_dir.empty()) { if (conf["data_path"].asString().empty()) { @@ -88,10 +88,7 @@ Json::Value overrideConfig(Json::Value& conf, std::string& data_dir, vector 0) { - boot_nodes = boot_nodes_append; - } - if (boot_nodes.size() > 0) { - for (auto const& b : boot_nodes) { + for (auto const& b : boot_nodes_append) { vector result; boost::split(result, b, boost::is_any_of(":/")); if (result.size() != 3) throw invalid_argument("Boot node in boot_nodes not specified correctly"); @@ -130,10 +127,7 @@ Json::Value overrideConfig(Json::Value& conf, std::string& data_dir, vector 0) { - log_channels = log_channels_append; - } - if (log_channels.size() > 0) { - for (auto const& l : log_channels) { + for (auto const& l : log_channels_append) { vector result; boost::split(result, l, boost::is_any_of(":")); if (result.size() != 2) throw invalid_argument("Log channel in log_channels not specified correctly"); diff --git a/libraries/config/include/config/config_utils.hpp b/libraries/config/include/config/config_utils.hpp index 36d7f5367f..e5b168d85f 100644 --- a/libraries/config/include/config/config_utils.hpp +++ b/libraries/config/include/config/config_utils.hpp @@ -7,7 +7,7 @@ #include "common/util.hpp" namespace taraxa { -std::string getConfigErr(std::vector path); +std::string getConfigErr(const std::vector &path); Json::Value getConfigData(Json::Value root, const std::vector &path, bool optional = false); diff --git a/libraries/config/src/config_utils.cpp b/libraries/config/src/config_utils.cpp index 599125ae8b..bdef058854 100644 --- a/libraries/config/src/config_utils.cpp +++ b/libraries/config/src/config_utils.cpp @@ -2,7 +2,7 @@ namespace taraxa { -std::string getConfigErr(std::vector path) { +std::string getConfigErr(const std::vector &path) { std::string res = "Error in processing configuration file on param: "; for (size_t i = 0; i < path.size(); i++) res += path[i] + "."; res += " "; diff --git a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp index c4b848cd4e..0f064497dc 100644 --- a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp +++ b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp @@ -18,7 +18,6 @@ class FinalChainImpl final : public FinalChain { const bool kLightNode = false; const uint64_t kLightNodeHistory = 0; const uint32_t kMaxLevelsPerPeriod; - const uint32_t kRewardsDistributionInterval = 100; rewards::Stats rewards_; // It is not prepared to use more then 1 thread. Examine it if you want to change threads count diff --git a/libraries/core_libs/network/rpc/eth/LogFilter.cpp b/libraries/core_libs/network/rpc/eth/LogFilter.cpp index 2130f49fa6..efd332930f 100644 --- a/libraries/core_libs/network/rpc/eth/LogFilter.cpp +++ b/libraries/core_libs/network/rpc/eth/LogFilter.cpp @@ -48,14 +48,12 @@ std::vector LogFilter::bloomPossibilities() const { bool LogFilter::matches(LogBloom b) const { if (!addresses_.empty()) { - auto ok = false; - for (const auto& i : addresses_) { - if (b.containsBloom<3>(sha3(i))) { - ok = true; - break; - } - } - if (!ok) { + if (std::none_of(addresses_.cbegin(), addresses_.cend(), [&b](const auto& i) { + if (b.containsBloom<3>(sha3(i))) { + return true; + } + return false; + })) { return false; } } @@ -63,14 +61,13 @@ bool LogFilter::matches(LogBloom b) const { if (t.empty()) { continue; } - auto ok = false; - for (const auto& i : t) { - if (b.containsBloom<3>(sha3(i))) { - ok = true; - break; - } - } - if (!ok) { + + if (std::none_of(t.cbegin(), t.cend(), [&b](const auto& i) { + if (b.containsBloom<3>(sha3(i))) { + return true; + } + return false; + })) { return false; } } diff --git a/libraries/core_libs/network/src/tarcap/packets_handlers/latest/dag_block_packet_handler.cpp b/libraries/core_libs/network/src/tarcap/packets_handlers/latest/dag_block_packet_handler.cpp index 5903c3d3b0..1d6fb93bf2 100644 --- a/libraries/core_libs/network/src/tarcap/packets_handlers/latest/dag_block_packet_handler.cpp +++ b/libraries/core_libs/network/src/tarcap/packets_handlers/latest/dag_block_packet_handler.cpp @@ -67,7 +67,7 @@ void DagBlockPacketHandler::sendBlock(dev::p2p::NodeID const &peer_id, taraxa::D taraxa::bytes trx_bytes; for (uint32_t i = index; i < index + trx_count_to_send; i++) { - auto &trx_data = trxs[i]->rlp(); + auto trx_data = trxs[i]->rlp(); s << trxs[i]->getHash(); trx_bytes.insert(trx_bytes.end(), std::begin(trx_data), std::end(trx_data)); } diff --git a/libraries/core_libs/storage/src/storage.cpp b/libraries/core_libs/storage/src/storage.cpp index f9a419ddbc..64144592c2 100644 --- a/libraries/core_libs/storage/src/storage.cpp +++ b/libraries/core_libs/storage/src/storage.cpp @@ -923,7 +923,9 @@ void DbStorage::addPbftMgrFieldToBatch(PbftMgrField field, uint32_t value, Batch bool DbStorage::getPbftMgrStatus(PbftMgrStatus field) { auto status = lookup(toSlice(field), Columns::pbft_mgr_status); if (!status.empty()) { - return *(bool*)&status[0]; + bool value; + memcpy(&value, status.data(), sizeof(bool)); + return value; } return false; }