Skip to content

Commit

Permalink
Make block benchmark (#1569)
Browse files Browse the repository at this point in the history
* Make block benchmark

* Replace std::filesystem mentions with kagome::filesystem to allow easier fallback to boost::filesystem if needed
  • Loading branch information
Harrm authored May 4, 2023
1 parent f5988cb commit d93fb38
Show file tree
Hide file tree
Showing 75 changed files with 862 additions and 230 deletions.
7 changes: 7 additions & 0 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ hunter_config(
KEEP_PACKAGE_SOURCES
)

hunter_config(
benchmark
URL https://github.com/google/benchmark/archive/refs/tags/v1.7.1.zip
SHA1 988246a257b0eeb1a8b112cff6ab3edfbe162912
CMAKE_ARGS BENCHMARK_ENABLE_TESTING=OFF
)

hunter_config(
soralog
VERSION 0.1.5
Expand Down
4 changes: 4 additions & 0 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ find_package(xxhash CONFIG REQUIRED)
hunter_add_package(binaryen)
find_package(binaryen CONFIG REQUIRED)

# https://docs.hunter.sh/en/latest/packages/pkg/benchmark.html
hunter_add_package(benchmark)
find_package(benchmark CONFIG REQUIRED)

# https://github.com/soramitsu/libp2p
hunter_add_package(libp2p)
find_package(libp2p CONFIG REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ add_subdirectory(application)
add_subdirectory(authority_discovery)
add_subdirectory(authorship)
add_subdirectory(assets)
add_subdirectory(benchmark)
add_subdirectory(blockchain)
add_subdirectory(clock)
add_subdirectory(common)
add_subdirectory(consensus)
add_subdirectory(crypto)
add_subdirectory(filesystem)
add_subdirectory(host_api)
add_subdirectory(injector)
add_subdirectory(log)
Expand Down
2 changes: 1 addition & 1 deletion core/api/service/author/impl/author_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ namespace kagome::api {
AuthorApiImpl::removeExtrinsic(
const std::vector<primitives::ExtrinsicKey> &keys) {
BOOST_ASSERT_MSG(false, "not implemented"); // NOLINT
return outcome::failure(boost::system::error_code{});
return outcome::failure(std::errc::not_supported);
}

outcome::result<AuthorApi::SubscriptionId>
Expand Down
9 changes: 5 additions & 4 deletions core/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_library(application_util
impl/util.cpp
)
target_link_libraries(application_util
Boost::filesystem
filesystem
outcome
)

Expand Down Expand Up @@ -42,7 +42,7 @@ add_library(chain_spec
impl/chain_spec_impl.cpp
)
target_link_libraries(chain_spec
Boost::filesystem
filesystem
p2p::p2p_multiaddress
p2p::p2p_peer_id
sr25519_types
Expand All @@ -57,12 +57,13 @@ target_link_libraries(app_state_manager
)
kagome_install(app_state_manager)

add_library(print_chain_info_mode
add_library(application_modes
modes/print_chain_info_mode.cpp
)
target_link_libraries(print_chain_info_mode
target_link_libraries(application_modes
hexutil
RapidJSON::rapidjson
benchmark::benchmark
)

add_library(recovery_mode
Expand Down
Empty file removed core/application/ExecutionMode.hpp
Empty file.
31 changes: 21 additions & 10 deletions core/application/app_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include <string>

#include <boost/asio/ip/tcp.hpp>
#include <boost/filesystem.hpp>
#include <libp2p/multi/multiaddress.hpp>

#include "crypto/ed25519_types.hpp"
#include "filesystem/common.hpp"
#include "log/logger.hpp"
#include "network/peering_config.hpp"
#include "network/types/roles.hpp"
Expand All @@ -23,6 +23,16 @@

namespace kagome::application {

enum class Subcommand { ChainInfo };

struct BlockBenchmarkConfig {
primitives::BlockNumber from;
primitives::BlockNumber to;
uint16_t times;
};

using BenchmarkConfigSection = std::variant<BlockBenchmarkConfig>;

/**
* Parse and store application config.
*/
Expand All @@ -45,36 +55,34 @@ namespace kagome::application {
/**
* @return file path with genesis configuration.
*/
virtual boost::filesystem::path chainSpecPath() const = 0;
virtual kagome::filesystem::path chainSpecPath() const = 0;

/**
* @return path to precompiled WAVM runtime cache directory
*/
virtual boost::filesystem::path runtimeCacheDirPath() const = 0;
virtual kagome::filesystem::path runtimeCacheDirPath() const = 0;

/**
* @return path to cached precompiled WAVM runtime
*/
virtual boost::filesystem::path runtimeCachePath(
virtual kagome::filesystem::path runtimeCachePath(
std::string runtime_hash) const = 0;

/**
* @return path to the node's directory for the chain \arg chain_id
* (contains key storage and database)
*/
virtual boost::filesystem::path chainPath(std::string chain_id) const = 0;
virtual kagome::filesystem::path chainPath(std::string chain_id) const = 0;

/**
* @return path to the node's database for the chain \arg chain_id
*/
virtual boost::filesystem::path databasePath(
std::string chain_id) const = 0;
virtual kagome::filesystem::path databasePath(std::string chain_id) const = 0;

/**
* @return path to the node's keystore for the chain \arg chain_id
*/
virtual boost::filesystem::path keystorePath(
std::string chain_id) const = 0;
virtual kagome::filesystem::path keystorePath(std::string chain_id) const = 0;

/**
* @return the secret key to use for libp2p networking
Expand Down Expand Up @@ -236,7 +244,7 @@ namespace kagome::application {

virtual bool isOffchainIndexingEnabled() const = 0;

virtual bool subcommandChainInfo() const = 0;
virtual std::optional<Subcommand> subcommand() const = 0;

virtual std::optional<primitives::BlockId> recoverState() const = 0;

Expand All @@ -257,6 +265,9 @@ namespace kagome::application {
enum class AllowUnsafeRpc : uint8_t { kAuto, kUnsafe, kSafe };

virtual AllowUnsafeRpc allowUnsafeRpc() const = 0;

virtual std::optional<BenchmarkConfigSection> getBenchmarkConfig()
const = 0;
};

} // namespace kagome::application
Expand Down
Loading

0 comments on commit d93fb38

Please sign in to comment.