Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 2295-enhancement-up…
Browse files Browse the repository at this point in the history
…date-wasmedge-to-0141
  • Loading branch information
ErakhtinB committed Jan 10, 2025
2 parents e20ab29 + 5ca6b6b commit 22a9213
Show file tree
Hide file tree
Showing 191 changed files with 3,154 additions and 2,554 deletions.
1 change: 1 addition & 0 deletions .thread-sanitizer-ignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
race:soralog::Logger::push
deadlock:boost::di::v1_1_0::wrappers::shared
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"configurePresets": [
{
"name": "base",
"toolchainFile": "${sourceDir}/cmake/toolchain/clang-16_cxx20.cmake",
"toolchainFile": "${sourceDir}/cmake/toolchain/clang-19_cxx20.cmake",
"generator": "Ninja",
"hidden": true
},
Expand Down
6 changes: 4 additions & 2 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if ("${WASM_COMPILER}" STREQUAL "WasmEdge")
CMAKE_ARGS
WASMEDGE_BUILD_STATIC_LIB=ON
WASMEDGE_BUILD_SHARED_LIB=OFF
CMAKE_CXX_FLAGS=-Wno-error=maybe-uninitialized
KEEP_PACKAGE_SOURCES
)
endif ()
Expand Down Expand Up @@ -105,7 +106,8 @@ hunter_config(

hunter_config(
libp2p
VERSION 0.1.28
URL https://github.com/libp2p/cpp-libp2p/archive/c3e6cce18335c989c9bbf3485885630a6ba463e4.zip
SHA1 32698ef4c3d373a39f87e7acb60eb7dc39399653
)

hunter_config(
Expand All @@ -115,7 +117,7 @@ hunter_config(

hunter_config(
erasure_coding_crust
VERSION 0.0.8
VERSION 0.0.9
KEEP_PACKAGE_SOURCES
)

Expand Down
4 changes: 2 additions & 2 deletions cmake/Hunter/hunter-gate-url.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HunterGate(
URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm25.zip
SHA1 59c66ff04ebd2cbdf86c3b996d38d4be6eaaa78b
URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm26.zip
SHA1 21e8e29f562962e97fc8bcd35a4ad5244794c7fc
LOCAL
)
3 changes: 3 additions & 0 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ function(addtest test_name)
LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/test_lib
)
disable_clang_tidy(${test_name})
if(KAGOME_CTEST_ENV)
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "${KAGOME_CTEST_ENV}")
endif()
endfunction()

function(addtest_part test_name)
Expand Down
2 changes: 1 addition & 1 deletion cmake/toolchain/flags/sanitize_thread.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../add_cache_flag.cmake)

set(TSAN_IGNORELIST "${CMAKE_CURRENT_LIST_DIR}/../../../.thread-sanitizer-ignore")

set(ENV{TSAN_OPTIONS} "suppressions=${TSAN_IGNORELIST}")
list(APPEND KAGOME_CTEST_ENV "TSAN_OPTIONS=suppressions=${TSAN_IGNORELIST}")

set(FLAGS
-fsanitize=thread
Expand Down
8 changes: 2 additions & 6 deletions core/api/service/chain/impl/chain_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ namespace kagome::api {
using primitives::BlockNumber;

ChainApiImpl::ChainApiImpl(
std::shared_ptr<blockchain::BlockHeaderRepository> block_repo,
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<blockchain::BlockStorage> block_storage,
LazySPtr<api::ApiService> api_service)
: header_repo_{std::move(block_repo)},
block_tree_{std::move(block_tree)},
: block_tree_{std::move(block_tree)},
api_service_{api_service},
block_storage_{std::move(block_storage)} {
BOOST_ASSERT_MSG(header_repo_ != nullptr,
"block repo parameter is nullptr");
BOOST_ASSERT_MSG(block_tree_ != nullptr, "block tree parameter is nullptr");
BOOST_ASSERT(block_storage_);
}
Expand All @@ -48,7 +44,7 @@ namespace kagome::api {
}
outcome::result<common::Hash256> ChainApiImpl::getBlockHash(
BlockNumber value) const {
return header_repo_->getHashByNumber(value);
return block_tree_->getHashByNumber(value);
}

outcome::result<BlockHash> ChainApiImpl::getBlockHash(
Expand Down
8 changes: 3 additions & 5 deletions core/api/service/chain/impl/chain_api_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ namespace kagome::api {

~ChainApiImpl() override = default;

ChainApiImpl(std::shared_ptr<blockchain::BlockHeaderRepository> block_repo,
std::shared_ptr<blockchain::BlockTree> block_tree,
ChainApiImpl(std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<blockchain::BlockStorage> block_storage,
LazySPtr<api::ApiService> api_service);

Expand All @@ -44,12 +43,12 @@ namespace kagome::api {
outcome::result<primitives::BlockHeader> getHeader(
std::string_view hash) override {
OUTCOME_TRY(h, primitives::BlockHash::fromHexWithPrefix(hash));
return header_repo_->getBlockHeader(h);
return block_tree_->getBlockHeader(h);
}

outcome::result<primitives::BlockHeader> getHeader() override {
auto last = block_tree_->getLastFinalized();
return header_repo_->getBlockHeader(last.hash);
return block_tree_->getBlockHeader(last.hash);
}

outcome::result<primitives::BlockData> getBlock(
Expand All @@ -67,7 +66,6 @@ namespace kagome::api {
uint32_t subscription_id) override;

private:
std::shared_ptr<blockchain::BlockHeaderRepository> header_repo_;
std::shared_ptr<blockchain::BlockTree> block_tree_;
LazySPtr<api::ApiService> api_service_;
std::shared_ptr<blockchain::BlockStorage> block_storage_;
Expand Down
13 changes: 5 additions & 8 deletions core/api/service/child_state/impl/child_state_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
namespace kagome::api {

ChildStateApiImpl::ChildStateApiImpl(
std::shared_ptr<blockchain::BlockHeaderRepository> block_repo,
std::shared_ptr<const storage::trie::TrieStorage> trie_storage,
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<runtime::Core> runtime_core,
std::shared_ptr<runtime::Metadata> metadata)
: header_repo_{std::move(block_repo)},
storage_{std::move(trie_storage)},
: storage_{std::move(trie_storage)},
block_tree_{std::move(block_tree)},
runtime_core_{std::move(runtime_core)},
metadata_{std::move(metadata)} {
BOOST_ASSERT(nullptr != header_repo_);
BOOST_ASSERT(nullptr != storage_);
BOOST_ASSERT(nullptr != block_tree_);
BOOST_ASSERT(nullptr != runtime_core_);
Expand All @@ -43,7 +40,7 @@ namespace kagome::api {
const auto &block_hash =
block_hash_opt.value_or(block_tree_->getLastFinalized().hash);

OUTCOME_TRY(header, header_repo_->getBlockHeader(block_hash));
OUTCOME_TRY(header, block_tree_->getBlockHeader(block_hash));
OUTCOME_TRY(initial_trie_reader,
storage_->getEphemeralBatchAt(header.state_root));
OUTCOME_TRY(child_root, initial_trie_reader->get(child_storage_key));
Expand Down Expand Up @@ -81,7 +78,7 @@ namespace kagome::api {
const auto &block_hash =
block_hash_opt.value_or(block_tree_->getLastFinalized().hash);

OUTCOME_TRY(header, header_repo_->getBlockHeader(block_hash));
OUTCOME_TRY(header, block_tree_->getBlockHeader(block_hash));
OUTCOME_TRY(initial_trie_reader,
storage_->getEphemeralBatchAt(header.state_root));
OUTCOME_TRY(child_root, initial_trie_reader->get(child_storage_key));
Expand Down Expand Up @@ -123,7 +120,7 @@ namespace kagome::api {
const std::optional<primitives::BlockHash> &block_hash_opt) const {
auto at = block_hash_opt ? block_hash_opt.value()
: block_tree_->getLastFinalized().hash;
OUTCOME_TRY(header, header_repo_->getBlockHeader(at));
OUTCOME_TRY(header, block_tree_->getBlockHeader(at));
OUTCOME_TRY(trie_reader, storage_->getEphemeralBatchAt(header.state_root));
OUTCOME_TRY(child_root, trie_reader->get(child_storage_key));
OUTCOME_TRY(child_root_hash, common::Hash256::fromSpan(child_root));
Expand Down Expand Up @@ -154,7 +151,7 @@ namespace kagome::api {
const std::optional<primitives::BlockHash> &block_hash_opt) const {
auto at = block_hash_opt ? block_hash_opt.value()
: block_tree_->getLastFinalized().hash;
OUTCOME_TRY(header, header_repo_->getBlockHeader(at));
OUTCOME_TRY(header, block_tree_->getBlockHeader(at));
OUTCOME_TRY(trie_reader, storage_->getEphemeralBatchAt(header.state_root));
OUTCOME_TRY(child_root, trie_reader->get(child_storage_key));
OUTCOME_TRY(child_root_hash, common::Hash256::fromSpan(child_root));
Expand Down
3 changes: 0 additions & 3 deletions core/api/service/child_state/impl/child_state_api_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "api/service/child_state/child_state_api.hpp"

#include "blockchain/block_header_repository.hpp"
#include "blockchain/block_tree.hpp"
#include "injector/lazy.hpp"
#include "runtime/runtime_api/core.hpp"
Expand All @@ -20,7 +19,6 @@ namespace kagome::api {
class ChildStateApiImpl final : public ChildStateApi {
public:
ChildStateApiImpl(
std::shared_ptr<blockchain::BlockHeaderRepository> block_repo,
std::shared_ptr<const storage::trie::TrieStorage> trie_storage,
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<runtime::Core> runtime_core,
Expand Down Expand Up @@ -59,7 +57,6 @@ namespace kagome::api {
const override;

private:
std::shared_ptr<blockchain::BlockHeaderRepository> header_repo_;
std::shared_ptr<const storage::trie::TrieStorage> storage_;
std::shared_ptr<blockchain::BlockTree> block_tree_;
std::shared_ptr<runtime::Core> runtime_core_;
Expand Down
9 changes: 4 additions & 5 deletions core/api/service/impl/api_service_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,10 @@ namespace kagome::api {
auto &session = session_context.storage_sub;
const auto id = session->generateSubscriptionSetId();
const auto &best_block_hash = block_tree_->bestBlock().hash;
const auto &header =
block_tree_->getBlockHeader(best_block_hash);
BOOST_ASSERT(header.has_value());
auto batch_res = trie_storage_->getEphemeralBatchAt(
header.value().state_root);
OUTCOME_TRY(header,
block_tree_->getBlockHeader(best_block_hash));
auto batch_res =
trie_storage_->getEphemeralBatchAt(header.state_root);
if (!batch_res.has_value()) {
SL_ERROR(logger_,
"Failed to get storage state for block {}, required "
Expand Down
19 changes: 8 additions & 11 deletions core/api/service/state/impl/state_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,18 @@ OUTCOME_CPP_DEFINE_CATEGORY(kagome::api, StateApiImpl::Error, e) {
namespace kagome::api {

StateApiImpl::StateApiImpl(
std::shared_ptr<blockchain::BlockHeaderRepository> block_repo,
std::shared_ptr<const storage::trie::TrieStorage> trie_storage,
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<runtime::Core> runtime_core,
std::shared_ptr<runtime::Metadata> metadata,
std::shared_ptr<runtime::Executor> executor,
LazySPtr<api::ApiService> api_service)
: header_repo_{std::move(block_repo)},
storage_{std::move(trie_storage)},
: storage_{std::move(trie_storage)},
block_tree_{std::move(block_tree)},
runtime_core_{std::move(runtime_core)},
api_service_{api_service},
metadata_{std::move(metadata)},
executor_{std::move(executor)} {
BOOST_ASSERT(nullptr != header_repo_);
BOOST_ASSERT(nullptr != storage_);
BOOST_ASSERT(nullptr != block_tree_);
BOOST_ASSERT(nullptr != runtime_core_);
Expand Down Expand Up @@ -81,7 +78,7 @@ namespace kagome::api {
const auto &block_hash =
block_hash_opt.value_or(block_tree_->getLastFinalized().hash);

OUTCOME_TRY(header, header_repo_->getBlockHeader(block_hash));
OUTCOME_TRY(header, block_tree_->getBlockHeader(block_hash));
OUTCOME_TRY(initial_trie_reader,
storage_->getEphemeralBatchAt(header.state_root));
auto cursor = initial_trie_reader->trieCursor();
Expand Down Expand Up @@ -121,7 +118,7 @@ namespace kagome::api {

outcome::result<std::optional<common::Buffer>> StateApiImpl::getStorageAt(
common::BufferView key, const primitives::BlockHash &at) const {
OUTCOME_TRY(header, header_repo_->getBlockHeader(at));
OUTCOME_TRY(header, block_tree_->getBlockHeader(at));
OUTCOME_TRY(trie_reader, storage_->getEphemeralBatchAt(header.state_root));
auto res = trie_reader->tryGet(key);
return common::map_result_optional(
Expand All @@ -134,7 +131,7 @@ namespace kagome::api {
const std::optional<primitives::BlockHash> &block_hash_opt) const {
auto at = block_hash_opt ? block_hash_opt.value()
: block_tree_->getLastFinalized().hash;
OUTCOME_TRY(header, header_repo_->getBlockHeader(at));
OUTCOME_TRY(header, block_tree_->getBlockHeader(at));
OUTCOME_TRY(trie_reader, storage_->getEphemeralBatchAt(header.state_root));
OUTCOME_TRY(res, trie_reader->tryGet(key));
return res ? std::make_optional(res->size()) : std::nullopt;
Expand All @@ -152,8 +149,8 @@ namespace kagome::api {
}

if (from != to) {
OUTCOME_TRY(from_number, header_repo_->getNumberByHash(from));
OUTCOME_TRY(to_number, header_repo_->getNumberByHash(to));
OUTCOME_TRY(from_number, block_tree_->getNumberByHash(from));
OUTCOME_TRY(to_number, block_tree_->getNumberByHash(to));
if (to_number < from_number) {
return Error::END_BLOCK_LOWER_THAN_BEGIN_BLOCK;
}
Expand All @@ -169,7 +166,7 @@ namespace kagome::api {
// returning the whole vector with block ids
OUTCOME_TRY(range, block_tree_->getChainByBlocks(from, to));
for (auto &block : range) {
OUTCOME_TRY(header, header_repo_->getBlockHeader(block));
OUTCOME_TRY(header, block_tree_->getBlockHeader(block));
OUTCOME_TRY(batch, storage_->getEphemeralBatchAt(header.state_root));
StorageChangeSet change{.block = block};
for (auto &key : keys) {
Expand Down Expand Up @@ -206,7 +203,7 @@ namespace kagome::api {
auto at =
opt_at.has_value() ? opt_at.value() : block_tree_->bestBlock().hash;
storage::trie::OnRead db;
OUTCOME_TRY(header, header_repo_->getBlockHeader(at));
OUTCOME_TRY(header, block_tree_->getBlockHeader(at));
OUTCOME_TRY(
trie, storage_->getProofReaderBatchAt(header.state_root, db.onRead()));
for (auto &key : keys) {
Expand Down
5 changes: 1 addition & 4 deletions core/api/service/state/impl/state_api_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "api/service/state/state_api.hpp"

#include "blockchain/block_header_repository.hpp"
#include "blockchain/block_tree.hpp"
#include "injector/lazy.hpp"
#include "runtime/runtime_api/core.hpp"
Expand All @@ -32,8 +31,7 @@ namespace kagome::api {
static constexpr size_t kMaxBlockRange = 256;
static constexpr size_t kMaxKeySetSize = 64;

StateApiImpl(std::shared_ptr<blockchain::BlockHeaderRepository> block_repo,
std::shared_ptr<const storage::trie::TrieStorage> trie_storage,
StateApiImpl(std::shared_ptr<const storage::trie::TrieStorage> trie_storage,
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<runtime::Core> runtime_core,
std::shared_ptr<runtime::Metadata> metadata,
Expand Down Expand Up @@ -94,7 +92,6 @@ namespace kagome::api {
std::string_view hex_block_hash) override;

private:
std::shared_ptr<blockchain::BlockHeaderRepository> header_repo_;
std::shared_ptr<const storage::trie::TrieStorage> storage_;
std::shared_ptr<blockchain::BlockTree> block_tree_;
std::shared_ptr<runtime::Core> runtime_core_;
Expand Down
9 changes: 7 additions & 2 deletions core/application/app_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ namespace kagome::application {
*/
virtual uint32_t luckyPeers() const = 0;

/**
* @return maximum number of peer connections
*/
virtual uint32_t maxPeers() const = 0;

/**
* @return multiaddresses of bootstrat nodes
*/
Expand Down Expand Up @@ -213,8 +218,8 @@ namespace kagome::application {
* List of telemetry endpoints specified via CLI argument or config file
* @return a vector of parsed telemetry endpoints
*/
virtual const std::vector<telemetry::TelemetryEndpoint> &
telemetryEndpoints() const = 0;
virtual const std::vector<telemetry::TelemetryEndpoint>
&telemetryEndpoints() const = 0;

/**
* @return enum constant of the chosen sync method
Expand Down
Loading

0 comments on commit 22a9213

Please sign in to comment.