From d84df0b06585820f3c1f87ebc2e545e7e6f3f136 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 9 Aug 2024 08:38:52 -0500 Subject: [PATCH] GH-227 Remove vote metrics that are not useful as is --- plugins/chain_plugin/chain_plugin.cpp | 5 --- .../eosio/chain_plugin/chain_plugin.hpp | 2 -- .../eosio/chain_plugin/tracked_votes.hpp | 10 ------ plugins/chain_plugin/tracked_votes.cpp | 28 ++------------- plugins/prometheus_plugin/metrics.hpp | 36 ------------------- 5 files changed, 2 insertions(+), 79 deletions(-) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 28ba62945e..b35faab892 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -2735,11 +2735,6 @@ const controller::config& chain_plugin::chain_config() const { return *my->chain_config; } -void chain_plugin::register_update_vote_block_metrics(std::function&& m) { - assert(my->_last_tracked_votes); - my->_last_tracked_votes->register_update_vote_block_metrics(std::move(m)); -} - } // namespace eosio FC_REFLECT( eosio::chain_apis::detail::ram_market_exchange_state_t, (ignore1)(ignore2)(ignore3)(core_symbol)(ignore4) ) diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp index b345b769d8..c1606d3efb 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -1027,8 +1027,6 @@ class chain_plugin : public plugin { const controller::config& chain_config() const; - void register_update_vote_block_metrics(std::function&&); - private: unique_ptr my; diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/tracked_votes.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/tracked_votes.hpp index 14460265c2..02772e69b7 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/tracked_votes.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/tracked_votes.hpp @@ -12,13 +12,6 @@ namespace eosio::chain_apis { class tracked_votes { public: - struct vote_block_metrics { - uint32_t block_num = 0; - std::vector strong_votes; - std::vector weak_votes; - std::vector no_votes; - }; - /** * Instantiate a new tracked votes cache from the given chain controller * The caller is expected to manage lifetimes such that this controller reference does not go stale @@ -49,9 +42,6 @@ namespace eosio::chain_apis { // Returns last vote information by a given finalizer std::optional get_last_vote_info(const fc::crypto::blslib::bls_public_key& finalizer_pub_key) const; - // register prometheus callback - void register_update_vote_block_metrics(std::function&&); - private: std::unique_ptr _impl; }; diff --git a/plugins/chain_plugin/tracked_votes.cpp b/plugins/chain_plugin/tracked_votes.cpp index 40bedfd2d2..bd813f4c78 100644 --- a/plugins/chain_plugin/tracked_votes.cpp +++ b/plugins/chain_plugin/tracked_votes.cpp @@ -24,14 +24,11 @@ namespace eosio::chain_apis { // A handle to the controller. const chain::controller& controller; - // prometheus support - std::function _update_vote_block_metrics; - // Called on accepted_block signal. Retrieve vote information from // QC in the block and store it in last_votes. void on_accepted_block( const chain::signed_block_ptr& block, const chain::block_id_type& id ) { try { - if (!_update_vote_block_metrics && !tracking_enabled && !chain::vote_logger.is_enabled(fc::log_level::info)) + if (!tracking_enabled && !chain::vote_logger.is_enabled(fc::log_level::info)) return; // do not bother tracking/logging when syncing or replaying @@ -46,7 +43,7 @@ namespace eosio::chain_apis { return; } - if (tracking_enabled || _update_vote_block_metrics) { + if (tracking_enabled) { // Retrieve vote information from QC const auto& qc_ext = block->extract_extension(); chain::qc_vote_metrics_t vm = controller.vote_metrics(id, qc_ext.qc); @@ -73,9 +70,6 @@ namespace eosio::chain_apis { track_votes(vm.strong_votes, true); track_votes(vm.weak_votes, false); } - if (_update_vote_block_metrics) { - update_vote_block_metrics(block->block_num(), vm); - } log_missing_votes(block, id, vm.missing_votes, qc_ext.qc.block_num); } else if (chain::vote_logger.is_enabled(fc::log_level::info)) { const auto& qc_ext = block->extract_extension(); @@ -118,20 +112,6 @@ namespace eosio::chain_apis { } } - // update prometheus metrics - void update_vote_block_metrics(chain::block_num_type block_num, const chain::qc_vote_metrics_t& vm) { - tracked_votes::vote_block_metrics m; - m.block_num = block_num; - m.strong_votes.resize(vm.strong_votes.size()); - m.weak_votes.resize(vm.weak_votes.size()); - m.no_votes.resize(vm.missing_votes.size()); - - std::ranges::transform(vm.strong_votes, m.strong_votes.begin(), [](const auto& f) { return f.fin_auth->description; }); - std::ranges::transform(vm.weak_votes, m.weak_votes.begin(), [](const auto& f) { return f.fin_auth->description; }); - std::ranges::transform(vm.missing_votes, m.no_votes.begin(), [](const auto& f) { return f.fin_auth->description; }); - _update_vote_block_metrics(std::move(m)); - } - }; // tracked_votes_impl tracked_votes::tracked_votes( const chain::controller& controller, bool tracking_enabled ) @@ -149,8 +129,4 @@ namespace eosio::chain_apis { return _impl->get_last_vote_info(finalizer_pub_key); } - void tracked_votes::register_update_vote_block_metrics(std::function&& m) { - _impl->_update_vote_block_metrics = std::move(m); - } - } // namespace eosio::chain_apis diff --git a/plugins/prometheus_plugin/metrics.hpp b/plugins/prometheus_plugin/metrics.hpp index 47f96a97cf..a13d2b9363 100644 --- a/plugins/prometheus_plugin/metrics.hpp +++ b/plugins/prometheus_plugin/metrics.hpp @@ -65,13 +65,6 @@ struct catalog_type { }; p2p_connection_metrics p2p_metrics; - // producer plugin - struct vote_metrics { - Gauge& block_num; - prometheus::Family& voted; - }; - vote_metrics block_votes; - prometheus::Family& cpu_usage_us; prometheus::Family& net_usage_us; @@ -147,10 +140,6 @@ struct catalog_type { , .connection_start_time{family("nodeos_p2p_connection_start_time", "time of last connection to peer")} , .peer_addr{family("nodeos_p2p_peer_addr", "peer address")} } - , block_votes{ - .block_num{build("nodeos_block_num", "current block number")} - , .voted{family("nodeos_block_votes", "votes incorporated into a block, -1 weak, 1 strong, 0 no vote")} - } , cpu_usage_us(family("nodeos_cpu_usage_us_total", "total cpu usage in microseconds for blocks")) , net_usage_us(family("nodeos_net_usage_us_total", "total net usage in microseconds for blocks")) , last_irreversible(build("nodeos_last_irreversible", "last irreversible block number")) @@ -245,25 +234,6 @@ struct catalog_type { } } - void update(const chain_apis::tracked_votes::vote_block_metrics&& metrics) { - block_votes.block_num.Set(metrics.block_num); - - auto add_and_set_gauge = [&](auto& fam, const auto& prod, const auto& value) { - auto& gauge = fam.Add({{"producer", prod}}); - gauge.Set(value); - }; - - for (const auto& v : metrics.strong_votes) { - add_and_set_gauge(block_votes.voted, v, 1); - } - for (const auto& v : metrics.weak_votes) { - add_and_set_gauge(block_votes.voted, v, -1); - } - for (const auto& v : metrics.no_votes) { - add_and_set_gauge(block_votes.voted, v, 0); - } - } - void update(block_metrics& blk_metrics, const producer_plugin::speculative_block_metrics& metrics) { blk_metrics.num_blocks_created.Increment(1); blk_metrics.current_block_num.Set(metrics.block_num); @@ -353,12 +323,6 @@ struct catalog_type { [&strand, this](const producer_plugin::incoming_block_metrics& metrics) { strand.post([metrics, this]() { update(metrics); }); }); - - auto& chain = app().get_plugin(); - chain.register_update_vote_block_metrics( - [&strand, this](const chain_apis::tracked_votes::vote_block_metrics&& metrics) { - strand.post([metrics{std::move(metrics)}, this]() mutable { update(std::move(metrics)); }); - }); } };