From 171e3dea75effbc265e9a980a1c16db95cf6383a Mon Sep 17 00:00:00 2001 From: iceseer Date: Thu, 24 Nov 2022 12:00:55 +0300 Subject: [PATCH] project restructure consensus Signed-off-by: iceseer --- core/api/CMakeLists.txt | 2 +- core/consensus/CMakeLists.txt | 56 +++++++++- core/consensus/authority/CMakeLists.txt | 20 ---- core/consensus/authority/impl/CMakeLists.txt | 16 --- core/consensus/babe/CMakeLists.txt | 15 --- core/consensus/babe/impl/CMakeLists.txt | 103 ------------------ core/consensus/grandpa/CMakeLists.txt | 67 ------------ .../grandpa/vote_graph/CMakeLists.txt | 14 --- core/consensus/validation/CMakeLists.txt | 14 --- core/crypto/CMakeLists.txt | 1 + core/injector/CMakeLists.txt | 11 +- core/utils/CMakeLists.txt | 2 +- test/core/blockchain/CMakeLists.txt | 2 +- test/core/consensus/CMakeLists.txt | 2 +- test/core/consensus/authority/CMakeLists.txt | 2 +- test/core/consensus/babe/CMakeLists.txt | 11 +- test/core/consensus/grandpa/CMakeLists.txt | 8 +- .../grandpa/vote_graph/CMakeLists.txt | 4 +- .../grandpa/voting_round/CMakeLists.txt | 4 +- test/core/consensus/validation/CMakeLists.txt | 2 +- 20 files changed, 70 insertions(+), 286 deletions(-) delete mode 100644 core/consensus/authority/CMakeLists.txt delete mode 100644 core/consensus/authority/impl/CMakeLists.txt delete mode 100644 core/consensus/babe/CMakeLists.txt delete mode 100644 core/consensus/babe/impl/CMakeLists.txt delete mode 100644 core/consensus/grandpa/CMakeLists.txt delete mode 100644 core/consensus/grandpa/vote_graph/CMakeLists.txt delete mode 100644 core/consensus/validation/CMakeLists.txt diff --git a/core/api/CMakeLists.txt b/core/api/CMakeLists.txt index b2166429eb..0aa77a9865 100644 --- a/core/api/CMakeLists.txt +++ b/core/api/CMakeLists.txt @@ -64,7 +64,7 @@ target_link_libraries(api storage blob metadata_api - babe + consensus ss58_codec outcome build_version diff --git a/core/consensus/CMakeLists.txt b/core/consensus/CMakeLists.txt index c7817d2fae..023234a42a 100644 --- a/core/consensus/CMakeLists.txt +++ b/core/consensus/CMakeLists.txt @@ -3,7 +3,55 @@ # SPDX-License-Identifier: Apache-2.0 # -add_subdirectory(validation) -add_subdirectory(babe) -add_subdirectory(grandpa) -add_subdirectory(authority) +add_library(consensus + authority/impl/schedule_node.cpp + authority/impl/authority_manager_impl.cpp + authority/authority_update_observer_error.cpp + authority/authority_manager_error.cpp + babe/impl/babe_digests_util.cpp + babe/impl/babe_config_node.cpp + babe/impl/block_executor_impl.cpp + babe/impl/babe_impl.cpp + babe/impl/threshold_util.cpp + babe/impl/babe_lottery_impl.cpp + babe/impl/babe_config_repository_impl.cpp + babe/impl/block_appender_impl.cpp + babe/impl/consistency_keeper_impl.cpp + babe/babe_error.cpp + validation/babe_block_validator.cpp + grandpa/impl/vote_tracker_impl.cpp + grandpa/impl/vote_crypto_provider_impl.cpp + grandpa/impl/grandpa_impl.cpp + grandpa/impl/voting_round_impl.cpp + grandpa/impl/environment_impl.cpp + grandpa/vote_graph/vote_graph_error.cpp + grandpa/vote_graph/vote_graph_impl.cpp + grandpa/voter_set.cpp + grandpa/voting_round_error.cpp + ) +target_link_libraries(consensus + mp_utils + ed25519_types + Boost::boost + schnorrkel_crust::schnorrkel_crust + transaction_pool_error + hasher + vrf_provider + logger + scale::scale + primitives + blob + outcome + p2p::p2p_peer_id + storage + metrics + blockchain + telemetry + ) +kagome_install(consensus) +add_custom_command(TARGET consensus + POST_BUILD + COMMAND find ${CMAKE_CURRENT_BINARY_DIR} -name "*.o" -type f -delete + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Removing object files from '${CMAKE_CURRENT_BINARY_DIR}'" +) diff --git a/core/consensus/authority/CMakeLists.txt b/core/consensus/authority/CMakeLists.txt deleted file mode 100644 index e7e32208b9..0000000000 --- a/core/consensus/authority/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -add_subdirectory(impl) - -add_library(authority_manager_error - authority_manager_error.cpp - ) -target_link_libraries(authority_manager_error - outcome - ) - -add_library(authority_update_observer_error - authority_update_observer_error.cpp - ) -target_link_libraries(authority_update_observer_error - outcome - ) diff --git a/core/consensus/authority/impl/CMakeLists.txt b/core/consensus/authority/impl/CMakeLists.txt deleted file mode 100644 index d45502f773..0000000000 --- a/core/consensus/authority/impl/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -add_library(authority_manager - authority_manager_impl.cpp - schedule_node.cpp - ) -target_link_libraries(authority_manager - logger - authority_manager_error - authority_update_observer_error - blockchain - primitives - ) diff --git a/core/consensus/babe/CMakeLists.txt b/core/consensus/babe/CMakeLists.txt deleted file mode 100644 index 5c0cf95b6f..0000000000 --- a/core/consensus/babe/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -add_subdirectory(impl) - -add_library(babe_error - babe_error.cpp - babe_error.hpp - ) -target_link_libraries(babe_error - outcome - ) -kagome_install(babe_error) diff --git a/core/consensus/babe/impl/CMakeLists.txt b/core/consensus/babe/impl/CMakeLists.txt deleted file mode 100644 index 7d5ba77b3a..0000000000 --- a/core/consensus/babe/impl/CMakeLists.txt +++ /dev/null @@ -1,103 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -add_library(babe_lottery - babe_lottery_impl.cpp - babe_lottery_impl.hpp - ) -target_link_libraries(babe_lottery - hasher - vrf_provider - logger - scale::scale - ) - -add_library(threshold_util - threshold_util.cpp - ) -target_link_libraries(threshold_util - primitives - ) -kagome_install(threshold_util) - -add_library(babe_digests_util - babe_digests_util.cpp - ) -target_link_libraries(babe_digests_util - primitives - scale::scale - blockchain - ) -kagome_install(babe_digests_util) - -add_library(block_appender - block_appender_impl.cpp - ) -target_link_libraries(block_appender - logger - primitives - scale::scale - blockchain - threshold_util - babe_digests_util - ) - -add_library(block_executor - block_executor_impl.cpp - ) -target_link_libraries(block_executor - logger - primitives - scale::scale - blockchain - threshold_util - transaction_pool_error - babe_digests_util - metrics - telemetry - consistency_keeper - ) -kagome_install(block_executor) - -add_library(consistency_keeper - consistency_keeper_impl.cpp - ) -target_link_libraries(consistency_keeper - Boost::boost - blockchain - ) -kagome_install(consistency_keeper) - -add_library(babe_config_repository - babe_config_repository_impl.cpp - babe_config_node.cpp - ) -target_link_libraries(babe_config_repository - primitives - scale::scale - ) - -add_library(babe - babe_impl.cpp - babe_impl.hpp - ) -target_link_libraries(babe - babe_error - Boost::boost - schnorrkel_crust::schnorrkel_crust - logger - scale::scale - blob - outcome - p2p::p2p_peer_id - babe_digests_util - threshold_util - block_executor - storage - metrics - blockchain - telemetry - ) -kagome_install(babe) diff --git a/core/consensus/grandpa/CMakeLists.txt b/core/consensus/grandpa/CMakeLists.txt deleted file mode 100644 index a9d99eb26c..0000000000 --- a/core/consensus/grandpa/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -add_subdirectory(vote_graph) - -add_library(environment - impl/environment_impl.cpp - ) - -target_link_libraries(environment - scale::scale - logger - blob - ) - -add_library(vote_tracker - impl/vote_tracker_impl.cpp - ) -target_link_libraries(vote_tracker - blob - ) - -add_library(vote_crypto_provider - impl/vote_crypto_provider_impl.cpp - ) -target_link_libraries(vote_crypto_provider - scale::scale - outcome - ) - -add_library(voter_set - voter_set.cpp - ) -target_link_libraries(voter_set - ed25519_types - ) - -add_library(voting_round_error - voting_round_error.cpp - ) -target_link_libraries(voting_round_error - outcome - ) - -add_library(voting_round - impl/voting_round_impl.cpp - ) - -target_link_libraries(voting_round - logger - voter_set - voting_round_error - blockchain - ) - -add_library(grandpa - impl/grandpa_impl.cpp - ) -target_link_libraries(grandpa - voting_round - vote_crypto_provider - vote_graph - vote_tracker - metrics - ) diff --git a/core/consensus/grandpa/vote_graph/CMakeLists.txt b/core/consensus/grandpa/vote_graph/CMakeLists.txt deleted file mode 100644 index da958d8cee..0000000000 --- a/core/consensus/grandpa/vote_graph/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -add_library(vote_graph - vote_graph_impl.cpp - vote_graph_error.cpp - ) -target_link_libraries(vote_graph - Boost::boost - outcome - voting_round_error - ) diff --git a/core/consensus/validation/CMakeLists.txt b/core/consensus/validation/CMakeLists.txt deleted file mode 100644 index 40be19e3f8..0000000000 --- a/core/consensus/validation/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright Soramitsu Co., Ltd. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -add_library(block_validator - babe_block_validator.cpp - ) -target_link_libraries(block_validator - outcome - babe_digests_util - mp_utils - logger - ) diff --git a/core/crypto/CMakeLists.txt b/core/crypto/CMakeLists.txt index 3878f73fd4..059a9d98d0 100644 --- a/core/crypto/CMakeLists.txt +++ b/core/crypto/CMakeLists.txt @@ -43,6 +43,7 @@ target_link_libraries(vrf_provider blob p2p::p2p_random_generator # generator from libp2p ) +kagome_install(vrf_provider) add_library(sr25519_provider sr25519/sr25519_provider_impl.cpp diff --git a/core/injector/CMakeLists.txt b/core/injector/CMakeLists.txt index e38b8b6cf6..8dd343331e 100644 --- a/core/injector/CMakeLists.txt +++ b/core/injector/CMakeLists.txt @@ -17,12 +17,8 @@ target_link_libraries(application_injector authority_discovery_api print_chain_info_mode assets - authority_manager - babe storage babe_api - babe_lottery - babe_config_repository binaryen_executor_factory binaryen_runtime_external_interface binaryen_wasm_memory @@ -31,18 +27,15 @@ target_link_libraries(application_injector module_repository binaryen_module_factory bip39_provider - block_appender block_builder_api - block_executor + consensus blockchain - block_validator clock chain_spec core_api crypto_store ecdsa_provider ed25519_provider - environment transaction_pool host_api_factory key_file_storage @@ -75,10 +68,8 @@ target_link_libraries(application_injector trie_storage_provider vrf_provider waitable_timer - authority_manager assets grandpa_api - grandpa p2p::p2p_loopback_stream offchain_worker_factory offchain_worker_pool diff --git a/core/utils/CMakeLists.txt b/core/utils/CMakeLists.txt index d236fe9f60..9ae58b469b 100644 --- a/core/utils/CMakeLists.txt +++ b/core/utils/CMakeLists.txt @@ -9,7 +9,7 @@ add_executable(storage_explorer ) target_link_libraries(storage_explorer application_injector - authority_manager + consensus ) if (BACKWARD) add_backward(storage_explorer) diff --git a/test/core/blockchain/CMakeLists.txt b/test/core/blockchain/CMakeLists.txt index 694be0eec6..9c755c5eb2 100644 --- a/test/core/blockchain/CMakeLists.txt +++ b/test/core/blockchain/CMakeLists.txt @@ -18,7 +18,7 @@ addtest(block_tree_test target_link_libraries(block_tree_test blockchain network - babe_digests_util + consensus logger_for_tests dummy_error ) diff --git a/test/core/consensus/CMakeLists.txt b/test/core/consensus/CMakeLists.txt index c794378e6f..9ffdadfe43 100644 --- a/test/core/consensus/CMakeLists.txt +++ b/test/core/consensus/CMakeLists.txt @@ -12,6 +12,6 @@ addtest(babe_lottery_test babe_lottery_test.cpp ) target_link_libraries(babe_lottery_test - babe_lottery + consensus logger_for_tests ) diff --git a/test/core/consensus/authority/CMakeLists.txt b/test/core/consensus/authority/CMakeLists.txt index b0b3f0ed5f..7523a560c6 100644 --- a/test/core/consensus/authority/CMakeLists.txt +++ b/test/core/consensus/authority/CMakeLists.txt @@ -7,7 +7,7 @@ addtest(authority_manager_test authority_manager_test.cpp ) target_link_libraries(authority_manager_test - authority_manager + consensus scale::scale blob dummy_error diff --git a/test/core/consensus/babe/CMakeLists.txt b/test/core/consensus/babe/CMakeLists.txt index 7ed8dd0c8d..84a58e448e 100644 --- a/test/core/consensus/babe/CMakeLists.txt +++ b/test/core/consensus/babe/CMakeLists.txt @@ -7,7 +7,7 @@ addtest(babe_test babe_test.cpp ) target_link_libraries(babe_test - babe + consensus clock waitable_timer sr25519_types @@ -19,26 +19,23 @@ addtest(babe_config_repository_test babe_config_repository_test.cpp ) target_link_libraries(babe_config_repository_test - babe_config_repository + consensus clock storage logger_for_tests - babe_error - babe_digests_util ) addtest(threshold_util_test threshold_util_test.cpp ) target_link_libraries(threshold_util_test - threshold_util + consensus ) addtest(block_executor_test block_executor_test.cpp ) target_link_libraries(block_executor_test - block_executor + consensus log_configurator - voting_round_error ) diff --git a/test/core/consensus/grandpa/CMakeLists.txt b/test/core/consensus/grandpa/CMakeLists.txt index fc630e88f3..e9f3f3a9a2 100644 --- a/test/core/consensus/grandpa/CMakeLists.txt +++ b/test/core/consensus/grandpa/CMakeLists.txt @@ -9,7 +9,7 @@ addtest(chain_test chain_test.cpp ) target_link_libraries(chain_test - environment + consensus logger_for_tests ) @@ -17,19 +17,19 @@ addtest(vote_tracker_test vote_tracker_test.cpp ) target_link_libraries(vote_tracker_test - vote_tracker + consensus ) addtest(voter_set_test voter_set_test.cpp ) target_link_libraries(voter_set_test - voter_set + consensus ) addtest(vote_weight_test vote_weight_test.cpp ) target_link_libraries(vote_weight_test - voter_set + consensus ) diff --git a/test/core/consensus/grandpa/vote_graph/CMakeLists.txt b/test/core/consensus/grandpa/vote_graph/CMakeLists.txt index 472cf45347..7eb384ab39 100644 --- a/test/core/consensus/grandpa/vote_graph/CMakeLists.txt +++ b/test/core/consensus/grandpa/vote_graph/CMakeLists.txt @@ -16,9 +16,7 @@ addtest(vote_graph_test small_block_number_test.cpp ) target_link_libraries(vote_graph_test - vote_graph - vote_tracker - voter_set + consensus blob blockchain ) diff --git a/test/core/consensus/grandpa/voting_round/CMakeLists.txt b/test/core/consensus/grandpa/voting_round/CMakeLists.txt index f67e53bcf1..84450f55aa 100644 --- a/test/core/consensus/grandpa/voting_round/CMakeLists.txt +++ b/test/core/consensus/grandpa/voting_round/CMakeLists.txt @@ -8,9 +8,7 @@ addtest(voting_round_test ) target_link_libraries(voting_round_test - voting_round - vote_graph - vote_tracker + consensus blob clock logger_for_tests diff --git a/test/core/consensus/validation/CMakeLists.txt b/test/core/consensus/validation/CMakeLists.txt index c03132c57d..b97b4949fe 100644 --- a/test/core/consensus/validation/CMakeLists.txt +++ b/test/core/consensus/validation/CMakeLists.txt @@ -7,7 +7,7 @@ addtest(block_validator_test block_validator_test.cpp ) target_link_libraries(block_validator_test - block_validator + consensus p2p::p2p_peer_id testutil_primitives_generator sr25519_provider