diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake index bac8806512..53620cf6c6 100644 --- a/cmake/Hunter/config.cmake +++ b/cmake/Hunter/config.cmake @@ -22,6 +22,7 @@ hunter_config( URL https://github.com/bombela/backward-cpp/archive/refs/tags/v1.6.zip SHA1 93c4c843fc9308e62ac462459077d87dc6dd9885 CMAKE_ARGS BACKWARD_TESTS=OFF + CMAKE_POLICY_VERSION_MINIMUM=3.5 KEEP_PACKAGE_SOURCES ) @@ -82,6 +83,7 @@ if ("${WASM_COMPILER}" STREQUAL "WAVM") VERSION 1.0.14 CMAKE_ARGS WAVM_CXX_FLAGS=${WAVM_CXX_FLAGS} + CMAKE_POLICY_VERSION_MINIMUM=3.5 KEEP_PACKAGE_SOURCES ) endif () @@ -101,8 +103,8 @@ hunter_config( hunter_config( libp2p - URL https://github.com/libp2p/cpp-libp2p/archive/refs/tags/v0.1.34.zip - SHA1 ad725b991c6845d0e5d9f42c639ea62fa05593ff + URL https://github.com/libp2p/cpp-libp2p/archive/refs/tags/v0.1.37.zip + SHA1 0387feba109f0cd9c27e032a866831522a4f3f10 ) hunter_config( @@ -112,3 +114,75 @@ hunter_config( KEEP_PACKAGE_SOURCES ) + +hunter_config( + binaryen + VERSION 1.38.28-patch.3 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + ZLIB + VERSION 1.2.11-p1 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + Protobuf + VERSION 3.19.4-p0 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + c-ares + VERSION 1.14.0-p0 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + yaml-cpp + VERSION 0.6.2-p0 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + RapidJSON + VERSION 1.1.0-66eb606-p0 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + jsonrpc-lean + VERSION 0.0.0-6c093da8 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + Boost.DI + VERSION 1.1.0 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) + +hunter_config( + zstd + VERSION 1.4.5-d73e2fb-p0 + CMAKE_ARGS + CMAKE_POLICY_VERSION_MINIMUM=3.5 + KEEP_PACKAGE_SOURCES +) diff --git a/core/network/impl/peer_manager_impl.cpp b/core/network/impl/peer_manager_impl.cpp index c86cc0b16a..f38bbb01fa 100644 --- a/core/network/impl/peer_manager_impl.cpp +++ b/core/network/impl/peer_manager_impl.cpp @@ -224,6 +224,9 @@ namespace kagome::network { // Do first alignment of peers count align(); + // Start timer for periodic collecting garbage + collectGarbage(); + return true; } diff --git a/core/network/impl/peer_view.cpp b/core/network/impl/peer_view.cpp index 58ee637abf..de34815758 100644 --- a/core/network/impl/peer_view.cpp +++ b/core/network/impl/peer_view.cpp @@ -92,9 +92,6 @@ namespace kagome::network { .new_head = header, .lost = {}, }; - if (event.view == my_view_) { - return; - } my_view_stripped_ = std::move(stripped_view); for (const auto &head : my_view_.heads_) { if (not event.view.contains(head)) { diff --git a/core/network/impl/protocols/parachain.cpp b/core/network/impl/protocols/parachain.cpp index 0623a931fa..12f361aa35 100644 --- a/core/network/impl/protocols/parachain.cpp +++ b/core/network/impl/protocols/parachain.cpp @@ -116,6 +116,10 @@ namespace kagome::network { } void ParachainProtocol::write(const View &view) { + if (view == last_sent_view_) { + return; + } + last_sent_view_ = view; auto message = encodeView(view); notifications_->peersOut([&](const PeerId &peer_id, size_t protocol_group) { notifications_->write(peer_id, protocol_group, message); diff --git a/core/network/impl/protocols/parachain.hpp b/core/network/impl/protocols/parachain.hpp index 8b4a112134..5015a41888 100644 --- a/core/network/impl/protocols/parachain.hpp +++ b/core/network/impl/protocols/parachain.hpp @@ -23,7 +23,6 @@ namespace kagome::network { class PeerView; struct Seconded; class ValidationObserver; - struct View; } // namespace kagome::network namespace kagome::network { @@ -76,6 +75,7 @@ namespace kagome::network { primitives::events::SyncStateSubscriptionEnginePtr sync_engine_; std::shared_ptr sync_sub_; std::shared_ptr my_view_sub_; + View last_sent_view_; // NOLINTEND(cppcoreguidelines-non-private-member-variables-in-classes) }; diff --git a/core/parachain/pvf/workers.cpp b/core/parachain/pvf/workers.cpp index 23c4d7981e..ff8e9fd02f 100644 --- a/core/parachain/pvf/workers.cpp +++ b/core/parachain/pvf/workers.cpp @@ -139,7 +139,8 @@ namespace kagome::parachain { void PvfWorkers::execute(Job &&job) { REINVOKE(*main_pool_handler_, execute, std::move(job)); - if (free_.empty()) { + auto free = findFree(job); + if (not free.has_value()) { if (used_ >= max_) { auto &queue = queues_[job.kind]; queue.emplace_back(std::move(job)); @@ -193,20 +194,25 @@ namespace kagome::parachain { }); return; } - findFree(std::move(job)); + runJob(free.value(), std::move(job)); } - void PvfWorkers::findFree(Job &&job) { - std::unique_lock lock(free_mutex_); + auto PvfWorkers::findFree(const Job &job) -> std::optional { auto it = std::ranges::find_if(free_, [&](const Worker &worker) { return worker.code_params == job.code_params; }); if (it == free_.end()) { it = free_.begin(); } - auto worker = *it; - free_.erase(it); - lock.unlock(); + if (it == free_.end()) { + return std::nullopt; + } + return it; + } + + void PvfWorkers::runJob(Free::iterator free_it, Job &&job) { + auto worker = *free_it; + free_.erase(free_it); writeCode(std::move(job), std::move(worker), std::make_shared(*this)); } @@ -254,9 +260,7 @@ namespace kagome::parachain { if (not r) { return; } - std::unique_lock lock(self->free_mutex_); self->free_.emplace_back(std::move(worker)); - lock.unlock(); self->dequeue(); }); auto cb = [cb_shared, timeout](outcome::result r) mutable { @@ -283,10 +287,14 @@ namespace kagome::parachain { if (queue.empty()) { continue; } + auto free = findFree(queue.front()); + if (not free.has_value()) { + break; + } auto job = std::move(queue.front()); queue.pop_front(); metric_queue_size_.at(kind)->set(queue.size()); - findFree(std::move(job)); + runJob(free.value(), std::move(job)); } } } // namespace kagome::parachain diff --git a/core/parachain/pvf/workers.hpp b/core/parachain/pvf/workers.hpp index 9612ce61b3..f84d10d593 100644 --- a/core/parachain/pvf/workers.hpp +++ b/core/parachain/pvf/workers.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include "metrics/metrics.hpp" #include "parachain/pvf/pvf_worker_types.hpp" @@ -71,7 +70,10 @@ namespace kagome::parachain { std::weak_ptr weak_self; }; - void findFree(Job &&job); + using Free = std::list; + + std::optional findFree(const Job &job); + void runJob(Free::iterator free_it, Job &&job); void writeCode(Job &&job, Worker &&worker, std::shared_ptr &&used); void call(Job &&job, Worker &&worker, std::shared_ptr &&used); void dequeue(); @@ -82,8 +84,7 @@ namespace kagome::parachain { std::filesystem::path exe_; size_t max_; PvfWorkerInputConfig worker_config_; - std::list free_; - mutable std::mutex free_mutex_; // Mutex for protecting free_ list + Free free_; size_t used_ = 0; std::unordered_map> queues_;