diff --git a/libraries/chain/include/eosio/chain/config.hpp b/libraries/chain/include/eosio/chain/config.hpp index 74af7b59ca..9dd10a1b85 100644 --- a/libraries/chain/include/eosio/chain/config.hpp +++ b/libraries/chain/include/eosio/chain/config.hpp @@ -80,7 +80,6 @@ const static uint16_t default_max_auth_depth = 6; const static uint32_t default_sig_cpu_bill_pct = 50 * percent_1; // billable percentage of signature recovery const static uint32_t default_produce_block_offset_ms = 450; const static uint16_t default_controller_thread_pool_size = 2; -const static uint16_t default_vote_thread_pool_size = 4; const static uint32_t default_max_variable_signature_length = 16384u; const static uint32_t default_max_action_return_value_size = 256; diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index dcd1a18303..1978b1c21b 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -89,7 +89,7 @@ namespace eosio::chain { uint64_t state_guard_size = chain::config::default_state_guard_size; uint32_t sig_cpu_bill_pct = chain::config::default_sig_cpu_bill_pct; uint16_t chain_thread_pool_size = chain::config::default_controller_thread_pool_size; - uint16_t vote_thread_pool_size = chain::config::default_vote_thread_pool_size; + uint16_t vote_thread_pool_size = 0; bool read_only = false; bool force_all_checks = false; bool disable_replay_opts = false; diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 526bd18104..324e861ea4 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -158,6 +158,7 @@ class chain_plugin_impl { std::filesystem::path state_dir; bool readonly = false; flat_map loaded_checkpoints; + bool accept_votes = false; bool accept_transactions = false; bool api_accept_transactions = true; bool account_queries_enabled = false; @@ -291,7 +292,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip "Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50%") ("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(config::default_vote_thread_pool_size), + ("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).") ("contracts-console", bpo::bool_switch()->default_value(false), "print contract's output to console") @@ -645,6 +646,7 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) { "vote-threads ${num} must be greater than 1 or 0. " "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; } chain_config->sig_cpu_bill_pct = options.at("signature-cpu-billable-pct").as(); @@ -1232,6 +1234,10 @@ void chain_plugin::enable_accept_transactions() { my->enable_accept_transactions(); } +bool chain_plugin::accept_votes() const { + return my->accept_votes; +} + void chain_plugin_impl::log_guard_exception(const chain::guard_exception&e ) { if (e.code() == chain::database_guard_exception::code_value) { 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 45576abe0e..33441f652c 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -987,6 +987,8 @@ class chain_plugin : public plugin { // set true by other plugins if any plugin allows transactions bool accept_transactions() const; void enable_accept_transactions(); + // true if vote processing is enabled + bool accept_votes() const; static void handle_guard_exception(const chain::guard_exception& e); diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 91f23c1798..2a339b73ad 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -1338,6 +1338,9 @@ void producer_plugin_impl::plugin_startup() { EOS_ASSERT(_producers.empty() || chain_plug->accept_transactions(), plugin_config_exception, "node cannot have any producer-name configured because no block production is possible with no [api|p2p]-accepted-transactions"); + EOS_ASSERT(_producers.empty() || chain_plug->accept_votes(), plugin_config_exception, + "node cannot have any producer-name configured because --vote-threads is defaulted to 0. Enable vote processing for block production."); + chain.set_node_finalizer_keys(_finalizer_keys); _accepted_block_connection.emplace(chain.accepted_block().connect([this](const block_signal_params& t) { diff --git a/tests/TestHarness/Cluster.py b/tests/TestHarness/Cluster.py index 292adaae21..1f4a11b7e0 100644 --- a/tests/TestHarness/Cluster.py +++ b/tests/TestHarness/Cluster.py @@ -256,6 +256,8 @@ def launch(self, pnodes=1, unstartedNodes=0, totalNodes=1, prodCount=21, topo="m if self.staging: argsArr.append("--nogen") nodeosArgs="" + if "--vote-threads" not in extraNodeosArgs: + nodeosArgs += " --vote-threads 3" if "--max-transaction-time" not in extraNodeosArgs: nodeosArgs += " --max-transaction-time -1" if "--abi-serializer-max-time-ms" not in extraNodeosArgs: