diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 9e74d85e63..c172e1dc08 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -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() { @@ -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); }); } diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index 1978b1c21b..490b69b540 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -58,6 +58,7 @@ namespace eosio::chain { using trx_meta_cache_lookup = std::function; using block_signal_params = std::tuple; + // connection_id, vote result status, vote_message processed using vote_signal_params = std::tuple; enum class db_read_mode { diff --git a/libraries/chain/include/eosio/chain/vote_processor.hpp b/libraries/chain/include/eosio/chain/vote_processor.hpp index 68f599ab0a..47489b207e 100644 --- a/libraries/chain/include/eosio/chain/vote_processor.hpp +++ b/libraries/chain/include/eosio/chain/vote_processor.hpp @@ -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; @@ -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) { diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 324e861ea4..fcc202ac6b 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -293,7 +293,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip ("chain-threads", bpo::value()->default_value(config::default_controller_thread_pool_size), "Number of worker threads in controller thread pool") ("vote-threads", bpo::value()->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), @@ -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(); 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;