Skip to content

Commit

Permalink
Approval voting broadcast.
Browse files Browse the repository at this point in the history
Signed-off-by: iceseer <iceseer@gmail.com>
  • Loading branch information
iceseer committed Nov 18, 2022
2 parents 539f209 + 96ab3f7 commit 2893cab
Show file tree
Hide file tree
Showing 162 changed files with 2,901 additions and 1,585 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
fail-fast: false
matrix:
options:
- name: "Linux: gcc-9 ASAN No Toolchain"
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/gcc-9_cxx17.cmake -DASAN=ON
- name: "Linux: gcc-10 ASAN No Toolchain"
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/gcc-10_cxx17.cmake -DASAN=ON
- name: "Linux: gcc-12 ASAN No Toolchain"
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/gcc-12_cxx17.cmake -DASAN=ON
- name: "Linux: clang-11 TSAN"
Expand All @@ -53,8 +53,8 @@ jobs:
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-11_cxx17.cmake -DUBSAN=ON
- name: "Linux: clang-11 External Project"
run: ./housekeeping/make_external_build.sh -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain/clang-11_cxx17.cmake
- name: "Linux: clang-14 UBSAN"
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-14_cxx17.cmake -DUBSAN=ON
- name: "Linux: clang-15 UBSAN"
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-15_cxx17.cmake -DUBSAN=ON

name: "${{ matrix.options.name }}"
runs-on: ubuntu-latest
Expand All @@ -65,8 +65,6 @@ jobs:
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ github.job }}-${{ matrix.options.name }}-${{ env.CACHE_VERSION }}
- name: Install mold
run: ./housekeeping/ci_install_mold.sh --make-default
- name: "${{ matrix.options.name }}"
run: "${{ matrix.options.run }}"

Expand All @@ -91,7 +89,7 @@ jobs:
./housekeeping/clang-tidy-diff.sh
coverage:
name: "Linux: gcc-9 coverage/sonar"
name: "Linux: gcc-10 coverage/sonar"
runs-on: ubuntu-latest
container: soramitsu/kagome-dev:4-minideb
steps:
Expand All @@ -100,12 +98,10 @@ jobs:
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ github.job }}-${{ env.CACHE_VERSION }}
- name: Install mold
run: ./housekeeping/ci_install_mold.sh --make-default
- name: makeBuild
env:
BUILD_FINAL_TARGET: ctest_coverage
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/gcc-9_cxx17.cmake -DCOVERAGE=ON
run: ./housekeeping/make_build.sh -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/gcc-10_cxx17.cmake -DCOVERAGE=ON
- if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
name: Submit Coverage
env:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
config/__pycahe__
**/__pycache__/*
__pycache__/*
build/*
build-*/*
**/build/*
**/build-*/*
*.DS_Store
*.vscode/
*.swp
Expand Down
2 changes: 1 addition & 1 deletion cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ hunter_config(

hunter_config(
libp2p
VERSION 0.1.7
VERSION 0.1.8
KEEP_PACKAGE_SOURCES
)

Expand Down
1 change: 0 additions & 1 deletion cmake/Hunter/hunter-gate-url.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

HunterGate(
URL "https://github.com/soramitsu/soramitsu-hunter/archive/refs/tags/v0.23.257-soramitsu35.zip"
SHA1 "d0ca69603681f322884c6066161b0dea09af4905"
Expand Down
2 changes: 1 addition & 1 deletion cmake/toolchain/clang-11_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/clang-11.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
3 changes: 3 additions & 0 deletions cmake/toolchain/clang-11_mold_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/clang-11.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/linker/mold.cmake)
2 changes: 0 additions & 2 deletions cmake/toolchain/clang-14_cxx17.cmake

This file was deleted.

2 changes: 2 additions & 0 deletions cmake/toolchain/clang-15_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/clang-15.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
3 changes: 3 additions & 0 deletions cmake/toolchain/clang-15_mold_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/clang-15.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/linker/mold.cmake)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if(DEFINED POLLY_COMPILER_CLANG_14_CMAKE)
if(DEFINED POLLY_COMPILER_CLANG_15_CMAKE)
return()
else()
set(POLLY_COMPILER_CLANG_14_CMAKE 1)
set(POLLY_COMPILER_CLANG_15_CMAKE 1)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/../../print.cmake)
Expand All @@ -13,15 +13,15 @@ if(XCODE_VERSION)
fatal_error(${_err})
endif()

find_program(CMAKE_C_COMPILER clang-14)
find_program(CMAKE_CXX_COMPILER clang++-14)
find_program(CMAKE_C_COMPILER clang-15)
find_program(CMAKE_CXX_COMPILER clang++-15)

if(NOT CMAKE_C_COMPILER)
fatal_error("clang-14 not found")
fatal_error("clang-15 not found")
endif()

if(NOT CMAKE_CXX_COMPILER)
fatal_error("clang++-14 not found")
fatal_error("clang++-15 not found")
endif()

set(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
if(DEFINED POLLY_COMPILER_GCC_9_CMAKE_)
if(DEFINED POLLY_COMPILER_GCC_10_CMAKE_)
return()
else()
set(POLLY_COMPILER_GCC_9_CMAKE_ 1)
set(POLLY_COMPILER_GCC_10_CMAKE_ 1)
endif()

find_program(CMAKE_C_COMPILER gcc-9)
find_program(CMAKE_CXX_COMPILER g++-9)
find_program(CMAKE_C_COMPILER gcc-10)
find_program(CMAKE_CXX_COMPILER g++-10)

if(NOT CMAKE_C_COMPILER)
fatal_error("gcc-9 not found")
fatal_error("gcc-10 not found")
endif()

if(NOT CMAKE_CXX_COMPILER)
fatal_error("g++-9 not found")
fatal_error("g++-10 not found")
endif()

set(
Expand Down
2 changes: 2 additions & 0 deletions cmake/toolchain/gcc-10_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/gcc-10.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
3 changes: 3 additions & 0 deletions cmake/toolchain/gcc-10_mold_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/gcc-10.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/linker/mold.cmake)
2 changes: 1 addition & 1 deletion cmake/toolchain/gcc-12_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/gcc-12.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
3 changes: 3 additions & 0 deletions cmake/toolchain/gcc-12_mold_cxx17.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(${CMAKE_CURRENT_LIST_DIR}/compiler/gcc-12.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/cxx17.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/linker/mold.cmake)
2 changes: 0 additions & 2 deletions cmake/toolchain/gcc-9_cxx17.cmake

This file was deleted.

16 changes: 16 additions & 0 deletions cmake/toolchain/linker/mold.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2014, Ruslan Baratov
# All rights reserved.

if (DEFINED POLLY_FLAGS_LINKER_MOLD_CMAKE_)
return()
else ()
set(POLLY_FLAGS_LINKER_MOLD_CMAKE_ 1)
endif ()

find_program(MOLD_FOUND mold)
if(NOT MOLD_FOUND)
fatal_error("mold not found")
endif()

include(${CMAKE_CURRENT_LIST_DIR}/../../add_cache_flag.cmake)
add_cache_flag(CMAKE_EXE_LINKER_FLAGS -fuse-ld=mold)
9 changes: 3 additions & 6 deletions core/api/service/child_state/impl/child_state_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "api/service/child_state/impl/child_state_api_impl.hpp"

#include <boost/algorithm/string/predicate.hpp>
#include <unordered_map>
#include <utility>

Expand Down Expand Up @@ -64,9 +65,7 @@ namespace kagome::api {
BOOST_ASSERT(key.has_value());

// make sure our key begins with prefix
auto min_size = std::min(prefix.size(), key->size());
if (not std::equal(
prefix.begin(), prefix.begin() + min_size, key.value().begin())) {
if (!boost::starts_with(key.value(), prefix)) {
break;
}
result.push_back(cursor->key().value());
Expand Down Expand Up @@ -114,9 +113,7 @@ namespace kagome::api {
BOOST_ASSERT(key.has_value());

// make sure our key begins with prefix
auto min_size = std::min(prefix.size(), key->size());
if (not std::equal(
prefix.begin(), prefix.begin() + min_size, key.value().begin())) {
if (!boost::starts_with(key.value(), prefix)) {
break;
}
result.push_back(cursor->key().value());
Expand Down
13 changes: 9 additions & 4 deletions core/api/service/impl/api_service_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "common/hexutil.hpp"
#include "primitives/common.hpp"
#include "primitives/transaction.hpp"
#include "runtime/runtime_api/core.hpp"
#include "storage/trie/trie_storage.hpp"
#include "subscription/extrinsic_event_key_repository.hpp"
#include "subscription/subscriber.hpp"
Expand Down Expand Up @@ -127,20 +128,23 @@ namespace kagome::api {
std::shared_ptr<subscription::ExtrinsicEventKeyRepository>
extrinsic_event_key_repo,
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<storage::trie::TrieStorage> trie_storage)
std::shared_ptr<storage::trie::TrieStorage> trie_storage,
std::shared_ptr<runtime::Core> core)
: thread_pool_(std::move(thread_pool)),
listeners_(std::move(listeners.listeners)),
server_(std::move(server)),
logger_{log::createLogger("ApiService", "api")},
block_tree_{std::move(block_tree)},
trie_storage_{std::move(trie_storage)},
core_(std::move(core)),
subscription_engines_{.storage = std::move(storage_sub_engine),
.chain = std::move(chain_sub_engine),
.ext = std::move(ext_sub_engine)},
extrinsic_event_key_repo_{std::move(extrinsic_event_key_repo)} {
BOOST_ASSERT(thread_pool_);
BOOST_ASSERT(block_tree_);
BOOST_ASSERT(trie_storage_);
BOOST_ASSERT(core_);
BOOST_ASSERT(
std::all_of(listeners_.cbegin(), listeners_.cend(), [](auto &listener) {
return listener != nullptr;
Expand Down Expand Up @@ -402,14 +406,15 @@ namespace kagome::api {
session->subscribe(
id, primitives::events::ChainEventType::kFinalizedRuntimeVersion);

auto ver = block_tree_->runtimeVersion();
if (ver) {
auto version_res = core_->version(block_tree_->getLastFinalized().hash);
if (version_res.has_value()) {
const auto &version = version_res.value();
session_context.messages = uploadMessagesListFromCache();
forJsonData(server_,
logger_,
id,
kRpcEventRuntimeVersion,
makeValue(*ver),
makeValue(version),
[&](const auto &result) {
session_context.messages->emplace_back(
uploadFromCache(result.data()));
Expand Down
7 changes: 6 additions & 1 deletion core/api/service/impl/api_service_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ namespace kagome::primitives {
namespace kagome::storage::trie {
class TrieStorage;
}
namespace kagome::runtime {
class Core;
}
namespace kagome::subscription {
class ExtrinsicEventKeyRepository;
}
Expand Down Expand Up @@ -135,7 +138,8 @@ namespace kagome::api {
std::shared_ptr<subscription::ExtrinsicEventKeyRepository>
extrinsic_event_key_repo,
std::shared_ptr<blockchain::BlockTree> block_tree,
std::shared_ptr<storage::trie::TrieStorage> trie_storage);
std::shared_ptr<storage::trie::TrieStorage> trie_storage,
std::shared_ptr<runtime::Core> core);

~ApiServiceImpl() override = default;

Expand Down Expand Up @@ -241,6 +245,7 @@ namespace kagome::api {
log::Logger logger_;
std::shared_ptr<blockchain::BlockTree> block_tree_;
std::shared_ptr<storage::trie::TrieStorage> trie_storage_;
std::shared_ptr<runtime::Core> core_;

std::mutex subscribed_sessions_cs_;
std::unordered_map<Session::SessionId,
Expand Down
5 changes: 2 additions & 3 deletions core/api/service/state/impl/state_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "api/service/state/impl/state_api_impl.hpp"

#include <boost/algorithm/string/predicate.hpp>
#include <unordered_map>
#include <utility>

Expand Down Expand Up @@ -102,9 +103,7 @@ namespace kagome::api {
BOOST_ASSERT(key.has_value());

// make sure our key begins with prefix
auto min_size = std::min<ssize_t>(prefix.size(), key->size());
if (not std::equal(
prefix.begin(), prefix.begin() + min_size, key.value().begin())) {
if (!boost::starts_with(key.value(), prefix)) {
break;
}
result.push_back(cursor->key().value());
Expand Down
9 changes: 9 additions & 0 deletions core/blockchain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ target_link_libraries(block_tree_error
outcome
)
kagome_install(block_tree_error)

add_library(digest_tracker
impl/digest_tracker_impl.cpp
)
target_link_libraries(digest_tracker
blockchain_common
)
kagome_install(digest_tracker)

15 changes: 0 additions & 15 deletions core/blockchain/block_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ namespace kagome::blockchain {
virtual outcome::result<primitives::Justification> getBlockJustification(
const primitives::BlockId &block) const = 0;

/**
* Method to get actual runtime version.
* @return runtime version.
*/
virtual std::optional<primitives::Version> runtimeVersion() const = 0;

/**
* Adds header to the storage
* @param header that we are adding
Expand Down Expand Up @@ -224,15 +218,6 @@ namespace kagome::blockchain {
* @return hash of the block
*/
virtual primitives::BlockInfo getLastFinalized() const = 0;

/**
* Finds epoch descriptor for epoch with index {@param epoch_number}.
* Search starts of block with hash {@param block_hash}.
* @returns epoch descriptor, or error if it impossible.
*/
virtual outcome::result<consensus::EpochDigest> getEpochDigest(
consensus::EpochNumber epoch_number,
primitives::BlockHash block_hash) const = 0;
};

} // namespace kagome::blockchain
Expand Down
Loading

0 comments on commit 2893cab

Please sign in to comment.