Skip to content

Commit

Permalink
GH-3 Add better descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Apr 16, 2024
1 parent 117f02d commit 027d278
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,8 +1393,8 @@ struct controller_impl {

block_num_type latest_known_lib_num() const {
block_id_type irreversible_block_id = if_irreversible_block_id.load();
block_num_type if_lib_num = block_header::num_from_id(irreversible_block_id);
return if_lib_num > 0 ? if_lib_num : fork_db_head_irreversible_blocknum();
block_num_type savanna_lib_num = block_header::num_from_id(irreversible_block_id);
return savanna_lib_num > 0 ? savanna_lib_num : fork_db_head_irreversible_blocknum();
}

void log_irreversible() {
Expand Down Expand Up @@ -3606,7 +3606,7 @@ struct controller_impl {
// net plugin subscribed to this signal. it will broadcast the vote message on receiving the signal
emit(voted_block, std::tuple{uint32_t{0}, vote_status::success, std::cref(vote)});

// also aggregate our own vote into the pending_qc for this block.
// also aggregate our own vote into the pending_qc for this block, 0 connection_id indicates our own vote
process_vote_message(0, vote);
});
}
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace eosio::chain {
using trx_meta_cache_lookup = std::function<transaction_metadata_ptr( const transaction_id_type&)>;

using block_signal_params = std::tuple<const signed_block_ptr&, const block_id_type&>;
// connection_id, vote result status, vote_message processed
using vote_signal_params = std::tuple<uint32_t, vote_status, const vote_message_ptr&>;

enum class db_read_mode {
Expand Down
5 changes: 4 additions & 1 deletion libraries/chain/include/eosio/chain/vote_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ namespace eosio { namespace chain {
* Process votes in a dedicated thread pool.
*/
class vote_processor_t {
static constexpr size_t max_votes_per_connection = 2500; // 3000 is less than 1MB per connection
// Even 3000 vote structs are less than 1MB per connection.
// 2500 is should never be reached unless a specific connection is sending garbage.
static constexpr size_t max_votes_per_connection = 2500;
static constexpr std::chrono::milliseconds block_wait_time{10};

struct by_block_num;
Expand Down Expand Up @@ -209,6 +211,7 @@ class vote_processor_t {
}

void process_vote_message(uint32_t connection_id, const vote_message_ptr& msg) {
assert(msg);
boost::asio::post(thread_pool.get_executor(), [this, connection_id, msg] {
std::unique_lock g(mtx);
if (++num_messages[connection_id] > max_votes_per_connection) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
("chain-threads", bpo::value<uint16_t>()->default_value(config::default_controller_thread_pool_size),
"Number of worker threads in controller thread pool")
("vote-threads", bpo::value<uint16_t>()->default_value(0),
"Number of worker threads in vote processor thread pool. Voting disabled if set to 0 (votes are not propagatged on P2P network).")
"Number of worker threads in vote processor thread pool. If set to 0, voting disabled, votes are not propagatged on P2P network.")
("contracts-console", bpo::bool_switch()->default_value(false),
"print contract's output to console")
("deep-mind", bpo::bool_switch()->default_value(false),
Expand Down Expand Up @@ -643,7 +643,7 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) {
if( options.count( "vote-threads" )) {
chain_config->vote_thread_pool_size = options.at( "vote-threads" ).as<uint16_t>();
EOS_ASSERT( chain_config->vote_thread_pool_size > 1 || chain_config->vote_thread_pool_size == 0, plugin_config_exception,
"vote-threads ${num} must be greater than 1 or 0. "
"vote-threads ${num} must be greater than 1, or equal to 0 to disable. "
"Voting disabled if set to 0 (votes are not propagatged on P2P network).",
("num", chain_config->vote_thread_pool_size) );
accept_votes = chain_config->vote_thread_pool_size > 0;
Expand Down

0 comments on commit 027d278

Please sign in to comment.