Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Clang Format #2043

Merged
merged 13 commits into from
Apr 16, 2024
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ 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
./housekeeping/clang-tidy-diff.sh

coverage-self-hosted:
Expand Down
1 change: 1 addition & 0 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ find_package(scale CONFIG REQUIRED)
hunter_add_package(zstd)
find_package(zstd CONFIG REQUIRED)


if ("${WASM_COMPILER}" STREQUAL "WAVM")
hunter_add_package(wavm)
find_package(LLVM CONFIG REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions core/application/app_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<telemetry::TelemetryEndpoint>
&telemetryEndpoints() const = 0;
virtual const std::vector<telemetry::TelemetryEndpoint> &
telemetryEndpoints() const = 0;

/**
* @return enum constant of the chosen sync method
Expand Down
7 changes: 4 additions & 3 deletions core/application/chain_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

#pragma once

#include <libp2p/peer/peer_info.hpp>
#include <set>

#include <libp2p/peer/peer_info.hpp>

#include "crypto/ed25519_types.hpp"
#include "crypto/sr25519_types.hpp"
#include "primitives/block.hpp"
Expand Down Expand Up @@ -37,8 +38,8 @@ namespace kagome::application {
virtual const std::vector<libp2p::multi::Multiaddress> &bootNodes()
const = 0;

virtual const std::vector<std::pair<std::string, size_t>>
&telemetryEndpoints() const = 0;
virtual const std::vector<std::pair<std::string, size_t>> &
telemetryEndpoints() const = 0;

virtual const std::string &protocolId() const = 0;

Expand Down
2 changes: 1 addition & 1 deletion core/authority_discovery/publisher/address_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions core/authorship/impl/block_builder_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/common/buffer_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace kagome::common {
public:
using span::span;

BufferView(std::initializer_list<uint8_t>&&) = delete;
BufferView(std::initializer_list<uint8_t> &&) = delete;

BufferView(const span &other) noexcept : span(other) {}

Expand Down
3 changes: 2 additions & 1 deletion core/common/monadic_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ namespace kagome::common {
typename E,
typename F,
typename R = std::invoke_result_t<F, const T &>>
outcome::result<R, E> map_result(const outcome::result<T, E> &res, const F &f) {
outcome::result<R, E> map_result(const outcome::result<T, E> &res,
const F &f) {
if (res.has_value()) {
return outcome::result<R, E>{f(res.value())};
}
Expand Down
3 changes: 3 additions & 0 deletions core/common/optref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#pragma once

#include <type_traits>
#include <optional>

#include <boost/assert.hpp>

namespace kagome {
template <typename T>
Expand Down
8 changes: 5 additions & 3 deletions core/common/outcome_throw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ namespace kagome::common {
boost::throw_exception(std::system_error(t.value(), t.category()));
}

template<typename T, typename E>
void raise_on_err(const outcome::result<T, E>& res) {
if (res.has_error()) raise(res.error());
template <typename T, typename E>
void raise_on_err(const outcome::result<T, E> &res) {
if (res.has_error()) {
raise(res.error());
}
}
} // namespace kagome::common
2 changes: 1 addition & 1 deletion core/common/size_limited_containers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace kagome::common {
template <typename Format, typename... Args>
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 <typename BaseContainer, std::size_t MaxSize>
Expand Down
2 changes: 1 addition & 1 deletion core/common/visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ namespace kagome {
constexpr decltype(auto) match_in_place(T &&t, Fs &&...fs) {
return match(std::forward<T>(t), make_visitor(std::forward<Fs>(fs)...));
}
} // namespace kagome::common
} // namespace kagome
2 changes: 1 addition & 1 deletion core/consensus/babe/impl/babe_lottery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/grandpa/voting_round.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
1 change: 0 additions & 1 deletion core/crypto/hasher/hasher_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions core/crypto/key_store/session_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ namespace kagome::crypto {
using FnGetKeypair = outcome::result<typename T::Keypair> (
KeySuiteStore<T>::*)(KeyType, const typename T::PublicKey &) const;

template <Suite T,
typename A,
typename Eq>
template <Suite T, typename A, typename Eq>
KeypairWithIndexOpt<typename T::Keypair> find(
KeypairWithIndexOpt<typename T::Keypair> &cache,
KeyType type,
Expand Down
5 changes: 3 additions & 2 deletions core/host_api/host_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/host_api/impl/host_api_factory_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/host_api/impl/host_api_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/host_api/impl/storage_extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "storage/trie/serialization/polkadot_codec.hpp"

namespace kagome::crypto {
class Hasher;
class Hasher;
}

namespace kagome::runtime {
Expand Down
4 changes: 3 additions & 1 deletion core/injector/get_peer_keypair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
#include <fstream>

#include "application/app_configuration.hpp"
#include "application/chain_spec.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.hpp"
#include "crypto/random_generator.hpp"

namespace kagome::injector {
inline std::shared_ptr<libp2p::crypto::KeyPair> get_peer_keypair(
Expand Down
2 changes: 1 addition & 1 deletion core/parachain/approval/approval_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,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;
}
Expand Down
2 changes: 1 addition & 1 deletion core/parachain/pvf/pvf_worker_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 2 additions & 1 deletion core/runtime/binaryen/module/module_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ namespace kagome::runtime::binaryen {
std::shared_ptr<const ModuleFactory> module_factory,
const common::Hash256 &code_hash);

outcome::result<std::shared_ptr<ModuleInstance>> instantiate() const override;
outcome::result<std::shared_ptr<ModuleInstance>> instantiate()
const override;

ModuleImpl(std::unique_ptr<wasm::Module> &&module,
std::shared_ptr<const ModuleFactory> module_factory,
Expand Down
6 changes: 3 additions & 3 deletions core/runtime/common/runtime_execution_error.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
6 changes: 3 additions & 3 deletions core/runtime/common/runtime_execution_error.hpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions core/runtime/common/uncompress_code_if_needed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void, UncompressError> uncompressCodeIfNeeded(common::BufferView buf,
common::Buffer &res) {
outcome::result<void, UncompressError> 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
Expand Down
2 changes: 1 addition & 1 deletion core/runtime/common/uncompress_code_if_needed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ namespace kagome::runtime {
inline auto format_as(UncompressError e) {
return make_error_code(e);
}
}
} // namespace kagome::runtime
1 change: 0 additions & 1 deletion core/runtime/module_repository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace kagome::runtime {
*/
class ModuleRepository {
public:

virtual ~ModuleRepository() = default;

/**
Expand Down
2 changes: 1 addition & 1 deletion core/runtime/runtime_api/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
3 changes: 1 addition & 2 deletions core/runtime/wasm_edge/module_factory_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion core/runtime/wavm/intrinsics/intrinsic_resolver_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace kagome::runtime::wavm {

class IntrinsicResolverImpl final : public IntrinsicResolver {
public:
IntrinsicResolverImpl(std::shared_ptr<CompartmentWrapper> compartment,
IntrinsicResolverImpl(
std::shared_ptr<CompartmentWrapper> compartment,
std::shared_ptr<IntrinsicModuleInstance> module_instance);

bool resolve(const std::string &moduleName,
Expand Down
4 changes: 2 additions & 2 deletions core/runtime/wavm/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ namespace kagome::runtime::wavm {
std::shared_ptr<IntrinsicModuleInstance>(
intrinsic_module_->instantiate());

auto resolver =
std::make_shared<IntrinsicResolverImpl>(compartment_, new_intrinsic_module_instance);
auto resolver = std::make_shared<IntrinsicResolverImpl>(
compartment_, new_intrinsic_module_instance);

auto internal_instance =
WAVM::Runtime::instantiateModule(compartment_->getCompartment(),
Expand Down
16 changes: 12 additions & 4 deletions core/scale/kagome_scale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ namespace kagome::scale {
template <typename F>
constexpr void encode(const F &func, const network::BlocksResponse &b);

template <typename F, typename ElementType, size_t MaxSize, typename Allocator>
template <typename F,
typename ElementType,
size_t MaxSize,
typename Allocator>
constexpr void encode(
const F &func, const common::SLVector<ElementType, MaxSize, Allocator> &c);
const F &func,
const common::SLVector<ElementType, MaxSize, Allocator> &c);

template <typename F, typename T, typename Tag, typename Base>
constexpr void encode(const F &func, const Tagged<T, Tag, Base> &c);
Expand Down Expand Up @@ -122,9 +126,13 @@ namespace kagome::scale {
}
}

template <typename F, typename ElementType, size_t MaxSize, typename Allocator>
template <typename F,
typename ElementType,
size_t MaxSize,
typename Allocator>
constexpr void encode(
const F &func, const common::SLVector<ElementType, MaxSize, Allocator> &c) {
const F &func,
const common::SLVector<ElementType, MaxSize, Allocator> &c) {
encode(func, static_cast<const std::vector<ElementType, Allocator> &>(c));
}

Expand Down
3 changes: 1 addition & 2 deletions core/scale/std_variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ namespace scale {
Stream &operator>>(Stream &stream, std::variant<Options...> &variant) {
uint8_t index;
stream >> index;
using Decoder =
void (*)(Stream & stream, std::variant<Options...> & variant);
using Decoder = void (*)(Stream &stream, std::variant<Options...> &variant);
constexpr Decoder decoders[]{
make_decoder<Options, Stream, Options...>()...};
decoders[index](stream, variant);
Expand Down
Loading
Loading