Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 76 additions & 2 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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 ()
Expand All @@ -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(
Expand All @@ -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
)
3 changes: 3 additions & 0 deletions core/network/impl/peer_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ namespace kagome::network {
// Do first alignment of peers count
align();

// Start timer for periodic collecting garbage
collectGarbage();

return true;
}

Expand Down
3 changes: 0 additions & 3 deletions core/network/impl/peer_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions core/network/impl/protocols/parachain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion core/network/impl/protocols/parachain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace kagome::network {
class PeerView;
struct Seconded;
class ValidationObserver;
struct View;
} // namespace kagome::network

namespace kagome::network {
Expand Down Expand Up @@ -76,6 +75,7 @@ namespace kagome::network {
primitives::events::SyncStateSubscriptionEnginePtr sync_engine_;
std::shared_ptr<void> sync_sub_;
std::shared_ptr<void> my_view_sub_;
View last_sent_view_;
// NOLINTEND(cppcoreguidelines-non-private-member-variables-in-classes)
};

Expand Down
28 changes: 18 additions & 10 deletions core/parachain/pvf/workers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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<Free::iterator> {
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<Used>(*this));
}

Expand Down Expand Up @@ -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<Buffer> r) mutable {
Expand All @@ -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
9 changes: 5 additions & 4 deletions core/parachain/pvf/workers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <deque>
#include <filesystem>
#include <list>
#include <mutex>

#include "metrics/metrics.hpp"
#include "parachain/pvf/pvf_worker_types.hpp"
Expand Down Expand Up @@ -71,7 +70,10 @@ namespace kagome::parachain {
std::weak_ptr<PvfWorkers> weak_self;
};

void findFree(Job &&job);
using Free = std::list<Worker>;

std::optional<Free::iterator> findFree(const Job &job);
void runJob(Free::iterator free_it, Job &&job);
void writeCode(Job &&job, Worker &&worker, std::shared_ptr<Used> &&used);
void call(Job &&job, Worker &&worker, std::shared_ptr<Used> &&used);
void dequeue();
Expand All @@ -82,8 +84,7 @@ namespace kagome::parachain {
std::filesystem::path exe_;
size_t max_;
PvfWorkerInputConfig worker_config_;
std::list<Worker> free_;
mutable std::mutex free_mutex_; // Mutex for protecting free_ list
Free free_;
size_t used_ = 0;
std::unordered_map<PvfExecTimeoutKind, std::deque<Job>> queues_;

Expand Down
Loading