Skip to content

Commit

Permalink
GH-376 Provide less for set of finalizer_authority_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jul 23, 2024
1 parent 8b65f7e commit 035055e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,7 @@ struct controller_impl {
}


std::set<finalizer_authority_ptr> missing_votes(const block_id_type& id, const qc_t& qc) const {
qc_vote_metrics_t::fin_auth_set missing_votes(const block_id_type& id, const qc_t& qc) const {
block_state_ptr bsp = fork_db_fetch_bsp_on_branch_by_num(id, qc.block_num);
if (!bsp)
return {};
Expand Down Expand Up @@ -5431,7 +5431,7 @@ qc_vote_metrics_t controller::vote_metrics(const block_id_type& id, const qc_t&
return my->vote_metrics(id, qc);
}

std::set<finalizer_authority_ptr> controller::missing_votes(const block_id_type& id, const qc_t& qc) const {
qc_vote_metrics_t::fin_auth_set controller::missing_votes(const block_id_type& id, const qc_t& qc) const {
return my->missing_votes(id, qc);
}

Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/finality/qc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ bool open_qc_t::is_quorum_met() const {
qc_vote_metrics_t open_qc_t::vote_metrics(const qc_t& qc) const {
qc_vote_metrics_t result;

auto add_votes = [&](const finalizer_policy_ptr& finalizer_policy, const auto& votes, std::set<finalizer_authority_ptr>& results) {
auto add_votes = [&](const finalizer_policy_ptr& finalizer_policy, const auto& votes, qc_vote_metrics_t::fin_auth_set& results) {
assert(votes.size() == finalizer_policy->finalizers.size());
size_t added = 0;
for (size_t i = 0; i < votes.size(); ++i) {
Expand Down Expand Up @@ -485,9 +485,9 @@ qc_vote_metrics_t open_qc_t::vote_metrics(const qc_t& qc) const {
return result;
}

std::set<finalizer_authority_ptr> open_qc_t::missing_votes(const qc_t& qc) const {
qc_vote_metrics_t::fin_auth_set open_qc_t::missing_votes(const qc_t& qc) const {
// all asserts are verified by verify_qc()
std::set<finalizer_authority_ptr> not_voted;
qc_vote_metrics_t::fin_auth_set not_voted;

auto check_other = [](const auto& other_votes, size_t i) {
return other_votes && (*other_votes)[i];
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ namespace eosio::chain {
qc_vote_metrics_t vote_metrics(const block_id_type& id, const qc_t& qc) const;
// return qc missing vote's finalizers, use instead of vote_metrics when only missing votes are needed
// thread-safe
std::set<finalizer_authority_ptr> missing_votes(const block_id_type& id, const qc_t& qc) const;
qc_vote_metrics_t::fin_auth_set missing_votes(const block_id_type& id, const qc_t& qc) const;

void set_savanna_lib_id(const block_id_type& id);

Expand Down
13 changes: 9 additions & 4 deletions libraries/chain/include/eosio/chain/finality/qc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,14 @@ namespace eosio::chain {

// finalizer authority of strong, weak, or missing votes
struct qc_vote_metrics_t {
std::set<finalizer_authority_ptr> strong_votes;
std::set<finalizer_authority_ptr> weak_votes;
std::set<finalizer_authority_ptr> missing_votes;
static bool fin_auth_less(const finalizer_authority_ptr& lhs, const finalizer_authority_ptr& rhs) {
return lhs->public_key < rhs->public_key;
};
using fin_auth_set = std::set<finalizer_authority_ptr, decltype(&fin_auth_less)>;

fin_auth_set strong_votes;
fin_auth_set weak_votes;
fin_auth_set missing_votes;
};

/**
Expand All @@ -227,7 +232,7 @@ namespace eosio::chain {
void verify_qc(const qc_t& qc, const digest_type& strong_digest, const weak_digest_t& weak_digest) const;
qc_vote_metrics_t vote_metrics(const qc_t& qc) const;
// return qc missing vote's finalizers
std::set<finalizer_authority_ptr> missing_votes(const qc_t& qc) const;
qc_vote_metrics_t::fin_auth_set missing_votes(const qc_t& qc) const;
// return true if better qc
bool set_received_qc(const qc_t& qc);
bool received_qc_is_strong() const;
Expand Down
2 changes: 1 addition & 1 deletion plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ class producer_plugin_impl : public std::enable_shared_from_this<producer_plugin
}

void log_missing_votes(const signed_block_ptr& block, const block_id_type& id,
const std::set<finalizer_authority_ptr>& missing_votes) {
const qc_vote_metrics_t::fin_auth_set& missing_votes) {
if (vote_logger.is_enabled(fc::log_level::info)) {
if (fc::time_point::now() - block->timestamp < fc::minutes(5) || (block->block_num() % 1000 == 0)) {
std::string not_voted;
Expand Down

0 comments on commit 035055e

Please sign in to comment.