From 92f9cd82001311a71d7df4feecce804ebcc54d6f Mon Sep 17 00:00:00 2001 From: Harrm Date: Mon, 15 Apr 2024 16:19:45 +0300 Subject: [PATCH 01/10] Format --- core/application/app_configuration.hpp | 4 +-- core/application/chain_spec.hpp | 4 +-- .../publisher/address_publisher.hpp | 2 +- core/authorship/impl/block_builder_impl.hpp | 4 +-- core/common/buffer_view.hpp | 2 +- core/common/monadic_utils.hpp | 3 ++- core/common/outcome_throw.hpp | 8 +++--- core/common/size_limited_containers.hpp | 2 +- core/common/visitor.hpp | 2 +- .../consensus/babe/impl/babe_lottery_impl.cpp | 2 +- core/consensus/grandpa/voting_round.hpp | 2 +- core/crypto/hasher/hasher_impl.cpp | 1 - core/crypto/key_store/session_keys.hpp | 4 +-- core/host_api/host_api.hpp | 5 ++-- core/host_api/impl/host_api_factory_impl.hpp | 2 +- core/host_api/impl/host_api_impl.hpp | 2 +- core/host_api/impl/storage_extension.hpp | 2 +- core/injector/get_peer_keypair.hpp | 2 +- .../approval/approval_distribution.hpp | 2 +- core/parachain/pvf/pvf_worker_types.hpp | 2 +- core/runtime/binaryen/module/module_impl.hpp | 3 ++- .../common/runtime_execution_error.cpp | 6 ++--- .../common/runtime_execution_error.hpp | 6 ++--- .../common/uncompress_code_if_needed.cpp | 4 +-- .../common/uncompress_code_if_needed.hpp | 2 +- core/runtime/module_repository.hpp | 1 - core/runtime/runtime_api/core.hpp | 2 +- .../runtime/wasm_edge/module_factory_impl.hpp | 3 +-- .../intrinsics/intrinsic_resolver_impl.hpp | 3 ++- core/runtime/wavm/module.cpp | 4 +-- core/scale/kagome_scale.hpp | 16 +++++++++--- core/scale/std_variant.hpp | 3 +-- core/scale/tie.hpp | 6 +++-- core/scale/tie_hash.hpp | 6 +++-- .../trie/serialization/ordered_trie_hash.hpp | 8 +++--- .../trie/serialization/polkadot_codec.hpp | 5 ++-- .../trie_pruner/impl/trie_pruner_impl.cpp | 15 ++++++----- core/telemetry/impl/connection_impl.cpp | 4 +-- core/utils/kagome_db_editor.cpp | 2 +- core/utils/storage_explorer.cpp | 25 ++++++++++++------- core/utils/struct_to_tuple.hpp | 6 +++-- 41 files changed, 105 insertions(+), 82 deletions(-) diff --git a/core/application/app_configuration.hpp b/core/application/app_configuration.hpp index 5f9201064a..d06c615c3d 100644 --- a/core/application/app_configuration.hpp +++ b/core/application/app_configuration.hpp @@ -207,8 +207,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 - &telemetryEndpoints() const = 0; + virtual const std::vector & + telemetryEndpoints() const = 0; /** * @return enum constant of the chosen sync method diff --git a/core/application/chain_spec.hpp b/core/application/chain_spec.hpp index 85973132b4..98f239920d 100644 --- a/core/application/chain_spec.hpp +++ b/core/application/chain_spec.hpp @@ -37,8 +37,8 @@ namespace kagome::application { virtual const std::vector &bootNodes() const = 0; - virtual const std::vector> - &telemetryEndpoints() const = 0; + virtual const std::vector> & + telemetryEndpoints() const = 0; virtual const std::string &protocolId() const = 0; diff --git a/core/authority_discovery/publisher/address_publisher.hpp b/core/authority_discovery/publisher/address_publisher.hpp index 33d498e424..db4e869245 100644 --- a/core/authority_discovery/publisher/address_publisher.hpp +++ b/core/authority_discovery/publisher/address_publisher.hpp @@ -8,8 +8,8 @@ #include "application/app_state_manager.hpp" #include "blockchain/block_tree.hpp" -#include "crypto/key_store/session_keys.hpp" #include "crypto/ed25519_provider.hpp" +#include "crypto/key_store/session_keys.hpp" #include "crypto/sr25519_provider.hpp" #include "log/logger.hpp" #include "runtime/runtime_api/authority_discovery_api.hpp" diff --git a/core/authorship/impl/block_builder_impl.hpp b/core/authorship/impl/block_builder_impl.hpp index 8a98b8311f..4810765304 100644 --- a/core/authorship/impl/block_builder_impl.hpp +++ b/core/authorship/impl/block_builder_impl.hpp @@ -72,10 +72,10 @@ namespace kagome::authorship { /** * Estimates the size of the block based on - * + * * This function calculates the size of the block by encoding it * using the ScaleEncoderStream - * + * * @return The estimated size of the block. */ size_t estimateBlockSize() const override; diff --git a/core/common/buffer_view.hpp b/core/common/buffer_view.hpp index f9468292af..01eb448a4a 100644 --- a/core/common/buffer_view.hpp +++ b/core/common/buffer_view.hpp @@ -30,7 +30,7 @@ namespace kagome::common { public: using span::span; - BufferView(std::initializer_list&&) = delete; + BufferView(std::initializer_list &&) = delete; BufferView(const span &other) noexcept : span(other) {} diff --git a/core/common/monadic_utils.hpp b/core/common/monadic_utils.hpp index bfe42e4e75..73752681e2 100644 --- a/core/common/monadic_utils.hpp +++ b/core/common/monadic_utils.hpp @@ -51,7 +51,8 @@ namespace kagome::common { typename E, typename F, typename R = std::invoke_result_t> - outcome::result map_result(const outcome::result &res, const F &f) { + outcome::result map_result(const outcome::result &res, + const F &f) { if (res.has_value()) { return outcome::result{f(res.value())}; } diff --git a/core/common/outcome_throw.hpp b/core/common/outcome_throw.hpp index ee92f62887..0b17033f30 100644 --- a/core/common/outcome_throw.hpp +++ b/core/common/outcome_throw.hpp @@ -33,8 +33,10 @@ namespace kagome::common { boost::throw_exception(std::system_error(t.value(), t.category())); } - template - void raise_on_err(const outcome::result& res) { - if (res.has_error()) raise(res.error()); + template + void raise_on_err(const outcome::result &res) { + if (res.has_error()) { + raise(res.error()); + } } } // namespace kagome::common diff --git a/core/common/size_limited_containers.hpp b/core/common/size_limited_containers.hpp index 8c96fd1357..fdf57c3d85 100644 --- a/core/common/size_limited_containers.hpp +++ b/core/common/size_limited_containers.hpp @@ -22,7 +22,7 @@ namespace kagome::common { template MaxSizeException(const Format &format, Args &&...args) : std::length_error( - fmt::vformat(format, fmt::make_format_args(args...))) {} + fmt::vformat(format, fmt::make_format_args(args...))) {} }; template diff --git a/core/common/visitor.hpp b/core/common/visitor.hpp index 6edefebdf6..e8f8249f22 100644 --- a/core/common/visitor.hpp +++ b/core/common/visitor.hpp @@ -155,4 +155,4 @@ namespace kagome { constexpr decltype(auto) match_in_place(T &&t, Fs &&...fs) { return match(std::forward(t), make_visitor(std::forward(fs)...)); } -} // namespace kagome::common +} // namespace kagome diff --git a/core/consensus/babe/impl/babe_lottery_impl.cpp b/core/consensus/babe/impl/babe_lottery_impl.cpp index 20ac6ede00..c419527713 100644 --- a/core/consensus/babe/impl/babe_lottery_impl.cpp +++ b/core/consensus/babe/impl/babe_lottery_impl.cpp @@ -9,8 +9,8 @@ #include "consensus/babe/babe_config_repository.hpp" #include "consensus/babe/impl/prepare_transcript.hpp" #include "consensus/babe/impl/threshold_util.hpp" -#include "crypto/key_store/session_keys.hpp" #include "crypto/hasher.hpp" +#include "crypto/key_store/session_keys.hpp" #include "crypto/vrf_provider.hpp" namespace kagome::consensus::babe { diff --git a/core/consensus/grandpa/voting_round.hpp b/core/consensus/grandpa/voting_round.hpp index 792e7d5adc..425d09c063 100644 --- a/core/consensus/grandpa/voting_round.hpp +++ b/core/consensus/grandpa/voting_round.hpp @@ -6,10 +6,10 @@ #pragma once +#include "common/optref.hpp" #include "common/tagged.hpp" #include "consensus/grandpa/movable_round_state.hpp" #include "consensus/grandpa/round_observer.hpp" -#include "common/optref.hpp" namespace kagome::consensus::grandpa { diff --git a/core/crypto/hasher/hasher_impl.cpp b/core/crypto/hasher/hasher_impl.cpp index 52279ae0a8..9078269cd0 100644 --- a/core/crypto/hasher/hasher_impl.cpp +++ b/core/crypto/hasher/hasher_impl.cpp @@ -34,7 +34,6 @@ namespace kagome::crypto { Hash128 HasherImpl::blake2b_128(common::BufferView data) const { return blake2b<16>(data); - } Hash256 HasherImpl::twox_256(common::BufferView data) const { diff --git a/core/crypto/key_store/session_keys.hpp b/core/crypto/key_store/session_keys.hpp index 8ea4917a2e..db561c7748 100644 --- a/core/crypto/key_store/session_keys.hpp +++ b/core/crypto/key_store/session_keys.hpp @@ -102,9 +102,7 @@ namespace kagome::crypto { using FnGetKeypair = outcome::result ( KeySuiteStore::*)(KeyType, const typename T::PublicKey &) const; - template + template KeypairWithIndexOpt find( KeypairWithIndexOpt &cache, KeyType type, diff --git a/core/host_api/host_api.hpp b/core/host_api/host_api.hpp index b194115b7d..a72b36cb89 100644 --- a/core/host_api/host_api.hpp +++ b/core/host_api/host_api.hpp @@ -185,9 +185,10 @@ namespace kagome::host_api { ext_trie_blake2_256_ordered_root_version_2( runtime::WasmSpan values_data, runtime::WasmI32 state_version) = 0; - [[nodiscard]] virtual runtime::WasmPointer ext_trie_keccak_256_ordered_root_version_2( + [[nodiscard]] virtual runtime::WasmPointer + ext_trie_keccak_256_ordered_root_version_2( runtime::WasmSpan values_data, runtime::WasmI32 state_version) = 0; - + // ------------------------- Memory extensions v1 -------------------------- /** * @see Extension::ext_malloc diff --git a/core/host_api/impl/host_api_factory_impl.hpp b/core/host_api/impl/host_api_factory_impl.hpp index 791ee94a59..d5f7a5e580 100644 --- a/core/host_api/impl/host_api_factory_impl.hpp +++ b/core/host_api/impl/host_api_factory_impl.hpp @@ -8,10 +8,10 @@ #include "host_api/host_api_factory.hpp" -#include "crypto/key_store.hpp" #include "crypto/ecdsa_provider.hpp" #include "crypto/ed25519_provider.hpp" #include "crypto/hasher.hpp" +#include "crypto/key_store.hpp" #include "crypto/secp256k1_provider.hpp" #include "crypto/sr25519_provider.hpp" #include "host_api/impl/offchain_extension.hpp" diff --git a/core/host_api/impl/host_api_impl.hpp b/core/host_api/impl/host_api_impl.hpp index 60de93ce50..018a8a285a 100644 --- a/core/host_api/impl/host_api_impl.hpp +++ b/core/host_api/impl/host_api_impl.hpp @@ -105,7 +105,7 @@ namespace kagome::host_api { runtime::WasmPointer ext_trie_keccak_256_ordered_root_version_2( runtime::WasmSpan values_data, runtime::WasmI32 state_version) override; - + // ------------------------Memory extensions v1------------------------- runtime::WasmPointer ext_allocator_malloc_version_1( runtime::WasmSize size) override; diff --git a/core/host_api/impl/storage_extension.hpp b/core/host_api/impl/storage_extension.hpp index 48f3a5dc03..2a94e0041e 100644 --- a/core/host_api/impl/storage_extension.hpp +++ b/core/host_api/impl/storage_extension.hpp @@ -14,7 +14,7 @@ #include "storage/trie/serialization/polkadot_codec.hpp" namespace kagome::crypto { - class Hasher; + class Hasher; } namespace kagome::runtime { diff --git a/core/injector/get_peer_keypair.hpp b/core/injector/get_peer_keypair.hpp index 56ede33f01..5346dff5cb 100644 --- a/core/injector/get_peer_keypair.hpp +++ b/core/injector/get_peer_keypair.hpp @@ -11,8 +11,8 @@ #include "application/app_configuration.hpp" #include "common/bytestr.hpp" #include "common/outcome_throw.hpp" -#include "crypto/key_store/key_store_impl.hpp" #include "crypto/ed25519_provider.hpp" +#include "crypto/key_store/key_store_impl.hpp" namespace kagome::injector { inline std::shared_ptr get_peer_keypair( diff --git a/core/parachain/approval/approval_distribution.hpp b/core/parachain/approval/approval_distribution.hpp index b7e641593d..ee5ab168e4 100644 --- a/core/parachain/approval/approval_distribution.hpp +++ b/core/parachain/approval/approval_distribution.hpp @@ -152,7 +152,7 @@ namespace kagome::parachain { } // Note that our assignment is triggered. No-op if already triggered. - MaybeCert trigger_our_assignment(network::Tick const tick_now) { + MaybeCert trigger_our_assignment(const network::Tick tick_now) { if (!our_assignment || our_assignment->triggered) { return std::nullopt; } diff --git a/core/parachain/pvf/pvf_worker_types.hpp b/core/parachain/pvf/pvf_worker_types.hpp index 41d62b2669..aa0d391fed 100644 --- a/core/parachain/pvf/pvf_worker_types.hpp +++ b/core/parachain/pvf/pvf_worker_types.hpp @@ -7,9 +7,9 @@ #pragma once #include "common/buffer.hpp" +#include "runtime/runtime_context.hpp" #include "scale/scale.hpp" #include "scale/tie.hpp" -#include "runtime/runtime_context.hpp" namespace kagome::parachain { diff --git a/core/runtime/binaryen/module/module_impl.hpp b/core/runtime/binaryen/module/module_impl.hpp index 6687cea64b..5cf5b567e6 100644 --- a/core/runtime/binaryen/module/module_impl.hpp +++ b/core/runtime/binaryen/module/module_impl.hpp @@ -51,7 +51,8 @@ namespace kagome::runtime::binaryen { std::shared_ptr module_factory, const common::Hash256 &code_hash); - outcome::result> instantiate() const override; + outcome::result> instantiate() + const override; ModuleImpl(std::unique_ptr &&module, std::shared_ptr module_factory, diff --git a/core/runtime/common/runtime_execution_error.cpp b/core/runtime/common/runtime_execution_error.cpp index cc7b7d8645..89f5b28e4d 100644 --- a/core/runtime/common/runtime_execution_error.cpp +++ b/core/runtime/common/runtime_execution_error.cpp @@ -1,7 +1,7 @@ /** -* Copyright Quadrivium LLC All Rights Reserved. -* SPDX-License-Identifier: Apache-2.0 -*/ + * Copyright Quadrivium LLC All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #include "runtime/common/runtime_execution_error.hpp" diff --git a/core/runtime/common/runtime_execution_error.hpp b/core/runtime/common/runtime_execution_error.hpp index 7e438bfee6..618054b956 100644 --- a/core/runtime/common/runtime_execution_error.hpp +++ b/core/runtime/common/runtime_execution_error.hpp @@ -1,7 +1,7 @@ /** -* Copyright Quadrivium LLC All Rights Reserved. -* SPDX-License-Identifier: Apache-2.0 -*/ + * Copyright Quadrivium LLC All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/core/runtime/common/uncompress_code_if_needed.cpp b/core/runtime/common/uncompress_code_if_needed.cpp index d9baa53a46..bb3713c692 100644 --- a/core/runtime/common/uncompress_code_if_needed.cpp +++ b/core/runtime/common/uncompress_code_if_needed.cpp @@ -31,8 +31,8 @@ namespace kagome::runtime { // https://github.com/paritytech/substrate/blob/polkadot-v0.9.8/primitives/maybe-compressed-blob/src/lib.rs#L35 constexpr size_t kCodeBlobBombLimit = 50 * 1024 * 1024; - outcome::result uncompressCodeIfNeeded(common::BufferView buf, - common::Buffer &res) { + outcome::result uncompressCodeIfNeeded( + common::BufferView buf, common::Buffer &res) { if (startsWith(buf, kZstdPrefix)) { auto zstd = buf.subspan(std::size(kZstdPrefix)); // here we can check that blob is really ZSTD compressed diff --git a/core/runtime/common/uncompress_code_if_needed.hpp b/core/runtime/common/uncompress_code_if_needed.hpp index ef88c757ef..264558f081 100644 --- a/core/runtime/common/uncompress_code_if_needed.hpp +++ b/core/runtime/common/uncompress_code_if_needed.hpp @@ -24,4 +24,4 @@ namespace kagome::runtime { inline auto format_as(UncompressError e) { return make_error_code(e); } -} +} // namespace kagome::runtime diff --git a/core/runtime/module_repository.hpp b/core/runtime/module_repository.hpp index 1c6c1f050c..e76fb5b8b2 100644 --- a/core/runtime/module_repository.hpp +++ b/core/runtime/module_repository.hpp @@ -28,7 +28,6 @@ namespace kagome::runtime { */ class ModuleRepository { public: - virtual ~ModuleRepository() = default; /** diff --git a/core/runtime/runtime_api/core.hpp b/core/runtime/runtime_api/core.hpp index fedc4bdf0c..4cb348aa73 100644 --- a/core/runtime/runtime_api/core.hpp +++ b/core/runtime/runtime_api/core.hpp @@ -11,8 +11,8 @@ #include "primitives/block.hpp" #include "primitives/common.hpp" #include "primitives/version.hpp" -#include "storage/changes_trie/changes_tracker.hpp" #include "runtime/runtime_context.hpp" +#include "storage/changes_trie/changes_tracker.hpp" namespace kagome::runtime { diff --git a/core/runtime/wasm_edge/module_factory_impl.hpp b/core/runtime/wasm_edge/module_factory_impl.hpp index ac6c29886a..d2a0e8e6c7 100644 --- a/core/runtime/wasm_edge/module_factory_impl.hpp +++ b/core/runtime/wasm_edge/module_factory_impl.hpp @@ -43,8 +43,7 @@ namespace kagome::runtime::wasm_edge { }; struct Config { Config(ExecType exec) - : exec{exec}, - compiled_module_dir{"/tmp/kagome/wasm-edge"} {} + : exec{exec}, compiled_module_dir{"/tmp/kagome/wasm-edge"} {} ExecType exec; std::filesystem::path compiled_module_dir; diff --git a/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.hpp b/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.hpp index 7a47310a3f..203110ceed 100644 --- a/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.hpp +++ b/core/runtime/wavm/intrinsics/intrinsic_resolver_impl.hpp @@ -31,7 +31,8 @@ namespace kagome::runtime::wavm { class IntrinsicResolverImpl final : public IntrinsicResolver { public: - IntrinsicResolverImpl(std::shared_ptr compartment, + IntrinsicResolverImpl( + std::shared_ptr compartment, std::shared_ptr module_instance); bool resolve(const std::string &moduleName, diff --git a/core/runtime/wavm/module.cpp b/core/runtime/wavm/module.cpp index 6400aefe57..8c2ec3adcb 100644 --- a/core/runtime/wavm/module.cpp +++ b/core/runtime/wavm/module.cpp @@ -103,8 +103,8 @@ namespace kagome::runtime::wavm { std::shared_ptr( intrinsic_module_->instantiate()); - auto resolver = - std::make_shared(compartment_, new_intrinsic_module_instance); + auto resolver = std::make_shared( + compartment_, new_intrinsic_module_instance); auto internal_instance = WAVM::Runtime::instantiateModule(compartment_->getCompartment(), diff --git a/core/scale/kagome_scale.hpp b/core/scale/kagome_scale.hpp index ed452557df..1b36d368e2 100644 --- a/core/scale/kagome_scale.hpp +++ b/core/scale/kagome_scale.hpp @@ -47,9 +47,13 @@ namespace kagome::scale { template constexpr void encode(const F &func, const network::BlocksResponse &b); - template + template constexpr void encode( - const F &func, const common::SLVector &c); + const F &func, + const common::SLVector &c); template constexpr void encode(const F &func, const Tagged &c); @@ -122,9 +126,13 @@ namespace kagome::scale { } } - template + template constexpr void encode( - const F &func, const common::SLVector &c) { + const F &func, + const common::SLVector &c) { encode(func, static_cast &>(c)); } diff --git a/core/scale/std_variant.hpp b/core/scale/std_variant.hpp index bea6949ea7..36cae2dc5d 100644 --- a/core/scale/std_variant.hpp +++ b/core/scale/std_variant.hpp @@ -33,8 +33,7 @@ namespace scale { Stream &operator>>(Stream &stream, std::variant &variant) { uint8_t index; stream >> index; - using Decoder = - void (*)(Stream & stream, std::variant & variant); + using Decoder = void (*)(Stream &stream, std::variant &variant); constexpr Decoder decoders[]{ make_decoder()...}; decoders[index](stream, variant); diff --git a/core/scale/tie.hpp b/core/scale/tie.hpp index e5a194657e..cdc50693ba 100644 --- a/core/scale/tie.hpp +++ b/core/scale/tie.hpp @@ -26,8 +26,10 @@ return !operator==(r); \ } -#define SCALE_TIE_ONLY(...) \ - auto as_tie() { return std::tie(__VA_ARGS__); } \ +#define SCALE_TIE_ONLY(...) \ + auto as_tie() { \ + return std::tie(__VA_ARGS__); \ + } \ SCALE_TIE_EQ #define SCALE_TIE(N) \ diff --git a/core/scale/tie_hash.hpp b/core/scale/tie_hash.hpp index 894afd27ab..0d785a8b66 100644 --- a/core/scale/tie_hash.hpp +++ b/core/scale/tie_hash.hpp @@ -16,8 +16,10 @@ namespace scale { } } // namespace scale -#define SCALE_TIE_HASH_BOOST(type) \ - friend auto hash_value(const type &v) { return ::scale::tieHash(v); } +#define SCALE_TIE_HASH_BOOST(type) \ + friend auto hash_value(const type &v) { \ + return ::scale::tieHash(v); \ + } #define SCALE_TIE_HASH_STD(type) \ template <> \ diff --git a/core/storage/trie/serialization/ordered_trie_hash.hpp b/core/storage/trie/serialization/ordered_trie_hash.hpp index 30e10f5844..995c2c7788 100644 --- a/core/storage/trie/serialization/ordered_trie_hash.hpp +++ b/core/storage/trie/serialization/ordered_trie_hash.hpp @@ -24,11 +24,11 @@ namespace kagome::storage::trie { * @tparam It an iterator type of a container of common::Buffers * @return the Merkle tree root hash of the tree containing provided values */ - template + template outcome::result calculateOrderedTrieHash(StateVersion version, const It &begin, const It &end, - const RootHashFunc& hash) { + const RootHashFunc &hash) { auto trie = storage::trie::PolkadotTrieImpl::createEmpty(); PolkadotCodec codec{hash}; // empty root @@ -50,7 +50,9 @@ namespace kagome::storage::trie { template outcome::result calculateOrderedTrieHash( - StateVersion version, const ContainerType &container, const RootHashFunc& hash) { + StateVersion version, + const ContainerType &container, + const RootHashFunc &hash) { return calculateOrderedTrieHash( version, container.begin(), container.end(), hash); } diff --git a/core/storage/trie/serialization/polkadot_codec.hpp b/core/storage/trie/serialization/polkadot_codec.hpp index 721c45a16a..b2e49585e1 100644 --- a/core/storage/trie/serialization/polkadot_codec.hpp +++ b/core/storage/trie/serialization/polkadot_codec.hpp @@ -32,7 +32,8 @@ namespace kagome::storage::trie { NO_NODE_VALUE ///< leaf node without value }; - PolkadotCodec(RootHashFunc hash_func = crypto::blake2b<32>): hash_func_{hash_func} {} + PolkadotCodec(RootHashFunc hash_func = crypto::blake2b<32>) + : hash_func_{hash_func} {} ~PolkadotCodec() override = default; @@ -88,7 +89,7 @@ namespace kagome::storage::trie { bool shouldBeHashed(const ValueAndHash &value, StateVersion version) const override; - RootHashFunc hash_func_; + RootHashFunc hash_func_; }; } // namespace kagome::storage::trie diff --git a/core/storage/trie_pruner/impl/trie_pruner_impl.cpp b/core/storage/trie_pruner/impl/trie_pruner_impl.cpp index b6ce610e36..2b762f563c 100644 --- a/core/storage/trie_pruner/impl/trie_pruner_impl.cpp +++ b/core/storage/trie_pruner/impl/trie_pruner_impl.cpp @@ -215,12 +215,12 @@ namespace kagome::storage::trie_pruner { return outcome::success(); } - OUTCOME_TRY(forEachChildTrie( - *trie, - [this, &node_batch](common::BufferView child_key, - const trie::RootHash &child_hash) { - return prune(node_batch, child_hash); - })); + OUTCOME_TRY( + forEachChildTrie(*trie, + [this, &node_batch](common::BufferView child_key, + const trie::RootHash &child_hash) { + return prune(node_batch, child_hash); + })); size_t nodes_removed = 0; size_t values_removed = 0; @@ -407,8 +407,7 @@ namespace kagome::storage::trie_pruner { auto value_hash_opt = encoder.getValueHash(*node, version); if (value_hash_opt) { auto &value_ref_count = value_ref_count_[*value_hash_opt]; - OUTCOME_TRY(contains_value, - node_storage_->contains(*value_hash_opt)); + OUTCOME_TRY(contains_value, node_storage_->contains(*value_hash_opt)); if (value_ref_count == 0 && contains_value && !thorough_pruning_) { value_ref_count++; } diff --git a/core/telemetry/impl/connection_impl.cpp b/core/telemetry/impl/connection_impl.cpp index 3b17fd5897..166504070a 100644 --- a/core/telemetry/impl/connection_impl.cpp +++ b/core/telemetry/impl/connection_impl.cpp @@ -150,8 +150,8 @@ namespace kagome::telemetry { } } - boost::beast::lowest_layer_type - &TelemetryConnectionImpl::stream_lowest_layer() { + boost::beast::lowest_layer_type & + TelemetryConnectionImpl::stream_lowest_layer() { return secure_ ? boost::beast::get_lowest_layer( *boost::relaxed_get(ws_)) : boost::beast::get_lowest_layer( diff --git a/core/utils/kagome_db_editor.cpp b/core/utils/kagome_db_editor.cpp index 2a354328d5..1bf43cb72c 100644 --- a/core/utils/kagome_db_editor.cpp +++ b/core/utils/kagome_db_editor.cpp @@ -26,8 +26,8 @@ #include "blockchain/impl/block_tree_impl.hpp" #include "blockchain/impl/storage_util.hpp" #include "common/outcome_throw.hpp" -#include "crypto/hasher/hasher_impl.hpp" #include "crypto/blake2/blake2b.h" +#include "crypto/hasher/hasher_impl.hpp" #include "network/impl/extrinsic_observer_impl.hpp" #include "runtime/common/runtime_upgrade_tracker_impl.hpp" #include "storage/predefined_keys.hpp" diff --git a/core/utils/storage_explorer.cpp b/core/utils/storage_explorer.cpp index f1a96f9d10..998a2a3711 100644 --- a/core/utils/storage_explorer.cpp +++ b/core/utils/storage_explorer.cpp @@ -6,8 +6,8 @@ #include -#include "application/impl/app_configuration_impl.hpp" #include "application/chain_spec.hpp" +#include "application/impl/app_configuration_impl.hpp" #include "blockchain/block_storage.hpp" #include "blockchain/impl/block_header_repository_impl.hpp" #include "blockchain/impl/block_tree_impl.hpp" @@ -545,7 +545,6 @@ class ChainInfoCommand final : public Command { std::shared_ptr block_tree; }; - class DbStatsCommand : public Command { public: DbStatsCommand(std::filesystem::path db_path) @@ -578,11 +577,16 @@ class DbStatsCommand : public Command { std::vector columns_data; db->GetAllColumnFamilyMetaData(&columns_data); - fmt::print(out, "{:{}} | {:{}} | {:{}} |\n", "NAME", 30, "SIZE", 10, "COUNT", 5); + fmt::print(out, + "{:{}} | {:{}} | {:{}} |\n", + "NAME", + 30, + "SIZE", + 10, + "COUNT", + 5); for (auto column_data : columns_data) { - constexpr std::array sizes { - "B ", "KB", "MB", "GB", "TB" - }; + constexpr std::array sizes{"B ", "KB", "MB", "GB", "TB"}; double size = column_data.size; int idx = 0; while (size > 1024.0) { @@ -591,10 +595,13 @@ class DbStatsCommand : public Command { } fmt::print(out, "{:{}} | {:{}.2f} {} | {:{}} |\n", - column_data.name, 30, - size, 10, + column_data.name, + 30, + size, + 10, sizes[idx], - column_data.file_count, 5); + column_data.file_count, + 5); } } diff --git a/core/utils/struct_to_tuple.hpp b/core/utils/struct_to_tuple.hpp index 34e7b847cf..bd21c9069e 100644 --- a/core/utils/struct_to_tuple.hpp +++ b/core/utils/struct_to_tuple.hpp @@ -60,8 +60,10 @@ return std::make_tuple(REPEATY_REF(ONES, p)); \ } -#define TO_TUPLE1 \ - TO_TUPLE_N(1) else { return std::make_tuple(); } +#define TO_TUPLE1 \ + TO_TUPLE_N(1) else { \ + return std::make_tuple(); \ + } #define TO_TUPLE2 TO_TUPLE_N(2) else TO_TUPLE1 #define TO_TUPLE3 TO_TUPLE_N(3) else TO_TUPLE2 #define TO_TUPLE4 TO_TUPLE_N(4) else TO_TUPLE3 From edda55afbd4873a545f3e4d450da3e6bdbc32fe1 Mon Sep 17 00:00:00 2001 From: Harrm Date: Mon, 15 Apr 2024 18:19:41 +0300 Subject: [PATCH 02/10] Update optref.hpp --- core/common/optref.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/common/optref.hpp b/core/common/optref.hpp index 35a3684ad5..4f81b01025 100644 --- a/core/common/optref.hpp +++ b/core/common/optref.hpp @@ -7,6 +7,7 @@ #pragma once #include +#include namespace kagome { template From 4408bb583dd466de319ca15462c9efc1555253ec Mon Sep 17 00:00:00 2001 From: Harrm Date: Mon, 15 Apr 2024 18:33:04 +0300 Subject: [PATCH 03/10] Update optref.hpp --- core/common/optref.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/common/optref.hpp b/core/common/optref.hpp index 4f81b01025..13b01378e5 100644 --- a/core/common/optref.hpp +++ b/core/common/optref.hpp @@ -9,6 +9,8 @@ #include #include +#include + namespace kagome { template class OptRef { From dbd5a43ecdefa93fbd2f8540027eeeeda7bb714e Mon Sep 17 00:00:00 2001 From: Harrm Date: Mon, 15 Apr 2024 19:51:49 +0300 Subject: [PATCH 04/10] Fix clang-tidy for wavm --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c012237d83..808729c319 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -170,8 +170,11 @@ jobs: env: # build only generated files, so clang-tidy will work correctly BUILD_FINAL_TARGET: generated + # run build for both WAVM and WasmEdge to download both, otherwise clang-tidy + # isn't able to find headers run: | - ./housekeeping/make_build.sh + ./housekeeping/make_build.sh -DWASM_COMPILER=WAVM + ./housekeeping/make_build.sh -DWASM_COMPILER=WasmEdge ./housekeeping/clang-tidy-diff.sh coverage-self-hosted: From 239aea464851fd69bc399160914a45ed6f93a132 Mon Sep 17 00:00:00 2001 From: Harrm Date: Tue, 16 Apr 2024 14:15:29 +0300 Subject: [PATCH 05/10] Try a fix --- .github/workflows/test.yml | 3 +-- cmake/dependencies.cmake | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 808729c319..a506f8a835 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -173,8 +173,7 @@ jobs: # run build for both WAVM and WasmEdge to download both, otherwise clang-tidy # isn't able to find headers run: | - ./housekeeping/make_build.sh -DWASM_COMPILER=WAVM - ./housekeeping/make_build.sh -DWASM_COMPILER=WasmEdge + ./housekeeping/make_build.sh ./housekeeping/clang-tidy-diff.sh coverage-self-hosted: diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 7037ae0a89..9db38fba52 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -77,8 +77,9 @@ find_package(scale CONFIG REQUIRED) hunter_add_package(zstd) find_package(zstd CONFIG REQUIRED) +hunter_add_package(wavm) + if ("${WASM_COMPILER}" STREQUAL "WAVM") - hunter_add_package(wavm) find_package(LLVM CONFIG REQUIRED) find_package(WAVM CONFIG REQUIRED) endif () From 661aca1129044c2b6e532c69193d3de30f475541 Mon Sep 17 00:00:00 2001 From: Harrm Date: Tue, 16 Apr 2024 16:43:38 +0300 Subject: [PATCH 06/10] Try fix --- .clang-tidy-ignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.clang-tidy-ignore b/.clang-tidy-ignore index 510e63dacb..07000f49ca 100644 --- a/.clang-tidy-ignore +++ b/.clang-tidy-ignore @@ -5,3 +5,7 @@ test/.* deps/.* .*\.pb\.h .*\.pb\.cc + +# meant as a temporary solution because clang-tidy on CI doesn't have +# WAVM headers when kagome is built with WasmEdge +core/runtime/wavm/.* From a88c524165cf85ce977c21d49456368635d8e9f2 Mon Sep 17 00:00:00 2001 From: Harrm Date: Tue, 16 Apr 2024 16:50:18 +0300 Subject: [PATCH 07/10] Try fix --- cmake/dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 9db38fba52..08e3f23d29 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -77,9 +77,9 @@ find_package(scale CONFIG REQUIRED) hunter_add_package(zstd) find_package(zstd CONFIG REQUIRED) -hunter_add_package(wavm) if ("${WASM_COMPILER}" STREQUAL "WAVM") + hunter_add_package(wavm) find_package(LLVM CONFIG REQUIRED) find_package(WAVM CONFIG REQUIRED) endif () From 242454aa315fc394447fb67cd58c9aacc51e3ecd Mon Sep 17 00:00:00 2001 From: Harrm Date: Tue, 16 Apr 2024 17:33:09 +0300 Subject: [PATCH 08/10] Try fix --- core/application/chain_spec.hpp | 3 ++- core/injector/get_peer_keypair.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/application/chain_spec.hpp b/core/application/chain_spec.hpp index 98f239920d..7536f0d922 100644 --- a/core/application/chain_spec.hpp +++ b/core/application/chain_spec.hpp @@ -6,9 +6,10 @@ #pragma once -#include #include +#include + #include "crypto/ed25519_types.hpp" #include "crypto/sr25519_types.hpp" #include "primitives/block.hpp" diff --git a/core/injector/get_peer_keypair.hpp b/core/injector/get_peer_keypair.hpp index 5346dff5cb..63e4767ca0 100644 --- a/core/injector/get_peer_keypair.hpp +++ b/core/injector/get_peer_keypair.hpp @@ -9,10 +9,10 @@ #include #include "application/app_configuration.hpp" +#include "application/chain_spec.hpp" #include "common/bytestr.hpp" #include "common/outcome_throw.hpp" #include "crypto/ed25519_provider.hpp" -#include "crypto/key_store/key_store_impl.hpp" namespace kagome::injector { inline std::shared_ptr get_peer_keypair( From 399bd52fa00ce2b168536a757dd93981f57a7680 Mon Sep 17 00:00:00 2001 From: Harrm Date: Tue, 16 Apr 2024 18:22:37 +0300 Subject: [PATCH 09/10] Try fix --- core/injector/get_peer_keypair.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/injector/get_peer_keypair.hpp b/core/injector/get_peer_keypair.hpp index 63e4767ca0..4cb79e638d 100644 --- a/core/injector/get_peer_keypair.hpp +++ b/core/injector/get_peer_keypair.hpp @@ -13,6 +13,8 @@ #include "common/bytestr.hpp" #include "common/outcome_throw.hpp" #include "crypto/ed25519_provider.hpp" +#include "crypto/key_store.hpp" +#include "crypto/random_generator.hpp" namespace kagome::injector { inline std::shared_ptr get_peer_keypair( From de2f44c8cc86431be65bd34bba4cb86f0e3f415d Mon Sep 17 00:00:00 2001 From: Harrm Date: Tue, 16 Apr 2024 18:46:05 +0300 Subject: [PATCH 10/10] Try fix --- .clang-tidy-ignore | 4 ---- housekeeping/clang-tidy-diff.sh | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.clang-tidy-ignore b/.clang-tidy-ignore index 07000f49ca..510e63dacb 100644 --- a/.clang-tidy-ignore +++ b/.clang-tidy-ignore @@ -5,7 +5,3 @@ test/.* deps/.* .*\.pb\.h .*\.pb\.cc - -# meant as a temporary solution because clang-tidy on CI doesn't have -# WAVM headers when kagome is built with WasmEdge -core/runtime/wavm/.* diff --git a/housekeeping/clang-tidy-diff.sh b/housekeeping/clang-tidy-diff.sh index f03e396bc9..97d7a48399 100755 --- a/housekeeping/clang-tidy-diff.sh +++ b/housekeeping/clang-tidy-diff.sh @@ -8,5 +8,6 @@ BUILD_DIR="${BUILD_DIR:-build}" cd $(dirname $0)/.. -git diff -U0 origin/master | clang-tidy-diff.py -p1 -path $BUILD_DIR -iregex '(core|node)\/.*\.(h|c|hpp|cpp)' -clang-tidy-binary clang-tidy-15 | tee clang-tidy.log +# exclude WAVM because on CI clang-tidy is run on a WasmEdge build +git diff -U0 origin/master -- . ':!core/runtime/wavm' | clang-tidy-diff.py -p1 -path $BUILD_DIR -iregex '(core|node)\/.*\.(h|c|hpp|cpp)' -clang-tidy-binary clang-tidy-15 | tee clang-tidy.log ! grep ': error:' clang-tidy.log