diff --git a/core/application/app_configuration.hpp b/core/application/app_configuration.hpp index 24d0252109..261c9d9d88 100644 --- a/core/application/app_configuration.hpp +++ b/core/application/app_configuration.hpp @@ -257,12 +257,6 @@ namespace kagome::application { */ virtual bool usePvfSubprocess() const = 0; - /** - * Timeout for Pvf check calls execution. - * Effective only when usePvfSubprocess() == true. - */ - virtual std::chrono::milliseconds pvfSubprocessDeadline() const = 0; - /** * Max PVF execution threads or processes. */ diff --git a/core/application/impl/app_configuration_impl.cpp b/core/application/impl/app_configuration_impl.cpp index 70dc193657..5a78d0b10f 100644 --- a/core/application/impl/app_configuration_impl.cpp +++ b/core/application/impl/app_configuration_impl.cpp @@ -814,6 +814,7 @@ namespace kagome::application { desc.add_options() ("help,h", "show this help message") ("version,v", "show version information") + ("logcfg", po::value(), "optional, path to config file of logger") ("log,l", po::value>(), "Sets a custom logging filter. Syntax is `=`, e.g. -llibp2p=off.\n" "Log levels (most to least verbose) are trace, debug, verbose, info, warn, error, critical, off. By default, all targets log `info`.\n" @@ -898,8 +899,6 @@ namespace kagome::application { "Number of threads that precompile parachain runtime modules at node startup") ("parachain-single-process", po::bool_switch(), "Disables spawn of child pvf check processes, thus they could not be aborted by deadline timer") - ("parachain-check-deadline", po::value()->default_value(2000), - "Pvf check subprocess execution deadline in milliseconds") ("pvf-max-workers", po::value()->default_value(pvf_max_workers_), "Max PVF execution threads or processes.") ("insecure-validator-i-know-what-i-do", po::bool_switch(), "Allows a validator to run insecurely outside of Secure Validator Mode.") @@ -1520,11 +1519,6 @@ namespace kagome::application { } logger_->info("Parachain multi process: {}", use_pvf_subprocess_); - if (auto arg = find_argument(vm, "parachain-check-deadline"); - arg.has_value()) { - pvf_subprocess_deadline_ = std::chrono::milliseconds(*arg); - } - if (auto arg = find_argument(vm, "pvf-max-workers")) { pvf_max_workers_ = *arg; } diff --git a/core/application/impl/app_configuration_impl.hpp b/core/application/impl/app_configuration_impl.hpp index fa66748fbb..977da0306e 100644 --- a/core/application/impl/app_configuration_impl.hpp +++ b/core/application/impl/app_configuration_impl.hpp @@ -226,9 +226,6 @@ namespace kagome::application { bool usePvfSubprocess() const override { return use_pvf_subprocess_; } - std::chrono::milliseconds pvfSubprocessDeadline() const override { - return pvf_subprocess_deadline_; - } size_t pvfMaxWorkers() const override { return pvf_max_workers_; } @@ -387,7 +384,6 @@ namespace kagome::application { std::thread::hardware_concurrency() / 2; bool should_precompile_parachain_modules_{true}; bool use_pvf_subprocess_{true}; - std::chrono::milliseconds pvf_subprocess_deadline_{2000}; size_t pvf_max_workers_{ std::max(std::thread::hardware_concurrency(), 1)}; bool disable_secure_mode_{false}; diff --git a/core/application/impl/kagome_application_impl.cpp b/core/application/impl/kagome_application_impl.cpp index 397e53f5e7..eaab11dd0b 100644 --- a/core/application/impl/kagome_application_impl.cpp +++ b/core/application/impl/kagome_application_impl.cpp @@ -123,10 +123,8 @@ namespace kagome::application { } #ifdef __linux__ - if (!app_config_->disableSecureMode() - && app_config_->usePvfSubprocess() - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - && app_config_->roles().flags.authority) { + if (not app_config_->disableSecureMode() and app_config_->usePvfSubprocess() + and app_config_->roles().isAuthority()) { auto res = parachain::runSecureModeCheckProcess( *injector_.injectIoContext(), app_config_->runtimeCacheDirPath()); if (!res) { diff --git a/core/application/modes/precompile_wasm.cpp b/core/application/modes/precompile_wasm.cpp index fb6f563c4f..10e9e13ec6 100644 --- a/core/application/modes/precompile_wasm.cpp +++ b/core/application/modes/precompile_wasm.cpp @@ -78,7 +78,7 @@ namespace kagome::application::mode { auto code_hash = hasher_->blake2b_256(bytes); OUTCOME_TRY(config, parachain::sessionParams(*parachain_api_, block.hash)); - OUTCOME_TRY(module_factory_->precompile(code_hash, bytes, config)); + OUTCOME_TRY(module_factory_->precompile(code_hash, bytes, config.context_params)); } return outcome::success(); } diff --git a/core/authority_discovery/publisher/address_publisher.cpp b/core/authority_discovery/publisher/address_publisher.cpp index 964d588f58..f29fede33e 100644 --- a/core/authority_discovery/publisher/address_publisher.cpp +++ b/core/authority_discovery/publisher/address_publisher.cpp @@ -82,8 +82,7 @@ namespace kagome::authority_discovery { if (not libp2p_key_) { return true; } - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - if (not roles_.flags.authority) { + if (not roles_.isAuthority()) { return true; } interval_.start([weak_self{weak_from_this()}] { diff --git a/core/blockchain/impl/block_tree_impl.hpp b/core/blockchain/impl/block_tree_impl.hpp index 972e46b1e5..c2e2ee74a5 100644 --- a/core/blockchain/impl/block_tree_impl.hpp +++ b/core/blockchain/impl/block_tree_impl.hpp @@ -274,9 +274,9 @@ namespace kagome::blockchain { } block_tree_data_; - primitives::events::ExtrinsicSubscriptionEnginePtr - extrinsic_events_engine_ = {}; - primitives::events::ChainSubscriptionEnginePtr chain_events_engine_ = {}; + primitives::events::ChainSubscriptionEnginePtr chain_events_engine_; + std::shared_ptr main_pool_handler_; + primitives::events::ExtrinsicSubscriptionEnginePtr extrinsic_events_engine_; log::Logger log_ = log::createLogger("BlockTree", "block_tree"); // Metrics @@ -284,7 +284,6 @@ namespace kagome::blockchain { metrics::Gauge *metric_best_block_height_; metrics::Gauge *metric_finalized_block_height_; metrics::Gauge *metric_known_chain_leaves_; - std::shared_ptr main_pool_handler_; telemetry::Telemetry telemetry_ = telemetry::createTelemetryService(); }; } // namespace kagome::blockchain diff --git a/core/consensus/babe/impl/babe.cpp b/core/consensus/babe/impl/babe.cpp index 67aa4e5d31..93f5413532 100644 --- a/core/consensus/babe/impl/babe.cpp +++ b/core/consensus/babe/impl/babe.cpp @@ -118,8 +118,7 @@ namespace kagome::consensus::babe { offchain_worker_pool_(std::move(offchain_worker_pool)), main_pool_handler_{main_thread_pool.handler(app_state_manager)}, worker_pool_handler_{worker_thread_pool.handler(app_state_manager)}, - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - is_validator_by_config_(app_config.roles().flags.authority != 0), + is_validator_by_config_(app_config.roles().isAuthority()), telemetry_{telemetry::createTelemetryService()} { BOOST_ASSERT(block_tree_); BOOST_ASSERT(config_repo_); diff --git a/core/crypto/key_store/session_keys.cpp b/core/crypto/key_store/session_keys.cpp index 09daabc701..ffa5e6ea0e 100644 --- a/core/crypto/key_store/session_keys.cpp +++ b/core/crypto/key_store/session_keys.cpp @@ -18,8 +18,7 @@ namespace kagome::crypto { const KeySuiteStore &store, const std::vector &authorities, const Eq &eq) { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) - if (not roles_.flags.authority) { + if (not roles_.isAuthority()) { return std::nullopt; } if (cache) { diff --git a/core/log/CMakeLists.txt b/core/log/CMakeLists.txt index 1af550a70f..b352d26635 100644 --- a/core/log/CMakeLists.txt +++ b/core/log/CMakeLists.txt @@ -21,5 +21,6 @@ add_library(log_configurator ) target_link_libraries(log_configurator soralog::configurator_yaml + Boost::program_options ) kagome_install(log_configurator) diff --git a/core/log/configurator.cpp b/core/log/configurator.cpp index 73c05a29ea..cf7f11e384 100644 --- a/core/log/configurator.cpp +++ b/core/log/configurator.cpp @@ -6,6 +6,8 @@ #include "log/configurator.hpp" +#include + namespace kagome::log { namespace { @@ -138,4 +140,32 @@ namespace kagome::log { Configurator::Configurator(std::shared_ptr previous, filesystem::path path) : ConfiguratorFromYAML(std::move(previous), std::move(path)) {} + + std::optional Configurator::getLogConfigFile( + int argc, const char **argv) { + namespace po = boost::program_options; + po::options_description desc("General options"); + desc.add_options() + // clang-format off + ("logcfg", po::value(), "optional, path to logging config file") + // clang-format on + ; + + po::variables_map vm; + + po::parsed_options parsed = po::command_line_parser(argc, argv) + .options(desc) + .allow_unregistered() + .run(); + po::store(parsed, vm); + po::notify(vm); + + if (auto it = vm.find("logcfg"); it != vm.end()) { + if (not it->second.defaulted()) { + return it->second.as(); + } + } + return std::nullopt; + } + } // namespace kagome::log diff --git a/core/log/configurator.hpp b/core/log/configurator.hpp index d26962b238..e1503f3ac3 100644 --- a/core/log/configurator.hpp +++ b/core/log/configurator.hpp @@ -23,6 +23,9 @@ namespace kagome::log { explicit Configurator(std::shared_ptr previous, filesystem::path path); + + static std::optional getLogConfigFile(int argc, + const char **argv); }; } // namespace kagome::log diff --git a/core/log/formatters/optional.hpp b/core/log/formatters/optional.hpp index 5f92a41395..c2632217da 100644 --- a/core/log/formatters/optional.hpp +++ b/core/log/formatters/optional.hpp @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -14,54 +14,16 @@ #include -template -struct fmt::formatter> { +template