Skip to content

Commit

Permalink
GH-3 Change default --vote-threads to 0 to be disabled by default. EO…
Browse files Browse the repository at this point in the history
…S_ASSERT if configured as a producer with vote processing disabled.
  • Loading branch information
heifner committed Apr 15, 2024
1 parent 1641a07 commit 4b4eca6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion libraries/chain/include/eosio/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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 @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class chain_plugin_impl {
std::filesystem::path state_dir;
bool readonly = false;
flat_map<uint32_t, block_id_type> loaded_checkpoints;
bool accept_votes = false;
bool accept_transactions = false;
bool api_accept_transactions = true;
bool account_queries_enabled = false;
Expand Down Expand Up @@ -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<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(config::default_vote_thread_pool_size),
("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).")
("contracts-console", bpo::bool_switch()->default_value(false),
"print contract's output to console")
Expand Down Expand Up @@ -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<uint32_t>();
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ class chain_plugin : public plugin<chain_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);

Expand Down
3 changes: 3 additions & 0 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4b4eca6

Please sign in to comment.