Skip to content

Commit

Permalink
GH-3 Default vote-threads to 4 when a block producer
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Apr 16, 2024
1 parent 027d278 commit 8f26a50
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 27 deletions.
1 change: 0 additions & 1 deletion docs/01_nodeos/02_usage/01_nodeos-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ The example below shows a typical usage of `nodeos` when starting a block produc
```sh
nodeos \
-e -p eosio \
--vote-threads 3 \
--data-dir /users/mydir/eosio/data \
--config-dir /users/mydir/eosio/config \
--plugin eosio::producer_plugin \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Open one "terminal" window and perform the following steps:
Start your own single-node blockchain with this single command:

```sh
nodeos -e -p eosio --vote-threads 3 --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
```

[[info | Nodeos Minimal Options]]
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ 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
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/thread_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ namespace eosio { namespace chain {
}

/// destroy work guard, stop io_context, join thread_pool
/// not thread safe, expected to only be called from thread that called start()
void stop() {
if (_thread_pool.size() > 0) {
_ioc_work.reset();
Expand Down
11 changes: 9 additions & 2 deletions libraries/chain/include/eosio/chain/vote_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class vote_processor_t {
std::map<uint32_t, uint16_t> num_messages;

std::atomic<block_num_type> lib{0};
std::atomic<bool> stopped{false};
std::atomic<bool> stopped{true};
named_thread_pool<vote> thread_pool;

private:
Expand Down Expand Up @@ -136,7 +136,10 @@ class vote_processor_t {
}

void start(size_t num_threads, decltype(thread_pool)::on_except_t&& on_except) {
assert(num_threads > 1); // need at least two as one is used for coordinatation
if (num_threads == 0)
return;

stopped = false;
thread_pool.start( num_threads, std::move(on_except));

// one coordinator thread
Expand Down Expand Up @@ -210,7 +213,11 @@ class vote_processor_t {
lib = block_num;
}

/// called from net threads and controller's thread pool
/// msg is ignored vote_processor not start()ed
void process_vote_message(uint32_t connection_id, const vote_message_ptr& msg) {
if (stopped)
return;
assert(msg);
boost::asio::post(thread_pool.get_executor(), [this, connection_id, msg] {
std::unique_lock g(mtx);
Expand Down
11 changes: 7 additions & 4 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ 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(0),
"Number of worker threads in vote processor thread pool. If set to 0, voting disabled, votes are not propagatged on P2P network.")
("vote-threads", bpo::value<uint16_t>(),
"Number of worker threads in vote processor thread pool. If set to 0, voting disabled, votes are not propagatged on P2P network. Defaults to 4 on producer nodes.")
("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 @@ -640,8 +640,11 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) {
"chain-threads ${num} must be greater than 0", ("num", chain_config->chain_thread_pool_size) );
}

if( options.count( "vote-threads" )) {
chain_config->vote_thread_pool_size = options.at( "vote-threads" ).as<uint16_t>();
if (options.count("producer-name") || options.count("vote-threads")) {
chain_config->vote_thread_pool_size = options.count("vote-threads") ? options.at("vote-threads").as<uint16_t>() : 0;
if (chain_config->vote_thread_pool_size == 0 && options.count("producer-name")) {
chain_config->vote_thread_pool_size = config::default_vote_thread_pool_size;
}
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 equal to 0 to disable. "
"Voting disabled if set to 0 (votes are not propagatged on P2P network).",
Expand Down
3 changes: 0 additions & 3 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,6 @@ 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: 1 addition & 1 deletion plugins/producer_plugin/test/test_disallow_delayed_trx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(delayed_trx) {
fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug);
std::vector<const char*> argv =
{"test", "--data-dir", temp_dir_str.c_str(), "--config-dir", temp_dir_str.c_str(),
"-p", "eosio", "-e", "--vote-threads", "3", "--disable-subjective-p2p-billing=true" };
"-p", "eosio", "-e", "--disable-subjective-p2p-billing=true" };
app->initialize<chain_plugin, producer_plugin>( argv.size(), (char**) &argv[0] );
app->startup();
plugin_promise.set_value(
Expand Down
2 changes: 1 addition & 1 deletion plugins/producer_plugin/test/test_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(state_dir) {
"--data-dir", temp_dir_str.c_str(),
"--state-dir", custom_state_dir_str.c_str(),
"--config-dir", temp_dir_str.c_str(),
"-p", "eosio", "--vote-threads", "3", "-e" };
"-p", "eosio", "-e" };
app->initialize<chain_plugin, producer_plugin>( argv.size(), (char**) &argv[0] );
app->startup();
plugin_promise.set_value( {app->find_plugin<producer_plugin>(), app->find_plugin<chain_plugin>()} );
Expand Down
2 changes: 1 addition & 1 deletion plugins/producer_plugin/test/test_trx_full.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(producer) {
fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug);
std::vector<const char*> argv =
{"test", "--data-dir", temp_dir_str.c_str(), "--config-dir", temp_dir_str.c_str(),
"-p", "eosio", "-e", "--vote-threads", "3", "--disable-subjective-p2p-billing=true" };
"-p", "eosio", "-e", "--disable-subjective-p2p-billing=true" };
app->initialize<chain_plugin, producer_plugin>( argv.size(), (char**) &argv[0] );
app->startup();
plugin_promise.set_value(
Expand Down
2 changes: 0 additions & 2 deletions tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ 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
2 changes: 1 addition & 1 deletion tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def abi_file_with_nodeos_test():
os.makedirs(data_dir, exist_ok=True)
walletMgr = WalletMgr(True)
walletMgr.launch()
cmd = "./programs/nodeos/nodeos -e -p eosio --vote-threads 2 --plugin eosio::trace_api_plugin --trace-no-abis --plugin eosio::producer_plugin --plugin eosio::producer_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::chain_plugin --plugin eosio::http_plugin --access-control-allow-origin=* --http-validate-host=false --max-transaction-time=-1 --resource-monitor-not-shutdown-on-threshold-exceeded " + "--data-dir " + data_dir + " --config-dir " + data_dir
cmd = "./programs/nodeos/nodeos -e -p eosio --plugin eosio::trace_api_plugin --trace-no-abis --plugin eosio::producer_plugin --plugin eosio::producer_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::chain_plugin --plugin eosio::http_plugin --access-control-allow-origin=* --http-validate-host=false --max-transaction-time=-1 --resource-monitor-not-shutdown-on-threshold-exceeded " + "--data-dir " + data_dir + " --config-dir " + data_dir
node = Node('localhost', 8888, nodeId, data_dir=Path(data_dir), config_dir=Path(data_dir), cmd=shlex.split(cmd), launch_time=datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S'), walletMgr=walletMgr)
time.sleep(5)
node.waitForBlock(1)
Expand Down
2 changes: 1 addition & 1 deletion tests/db_modes_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ EOSIO_STUFF_DIR=$(mktemp -d)
trap "rm -rf $EOSIO_STUFF_DIR" EXIT
NODEOS_LAUNCH_PARAMS="./programs/nodeos/nodeos --resource-monitor-not-shutdown-on-threshold-exceeded -d $EOSIO_STUFF_DIR --config-dir $EOSIO_STUFF_DIR \
--chain-state-db-size-mb 8 --chain-state-db-guard-size-mb 0 \
-e -peosio --vote-threads 3"
-e -peosio"

run_nodeos() {
if (( $VERBOSE == 0 )); then
Expand Down
2 changes: 1 addition & 1 deletion tests/gelf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def gelfServer(stop):

data_dir = Path(Utils.getNodeDataDir(node_id))
config_dir = Path(Utils.getNodeConfigDir(node_id))
start_nodeos_cmd = shlex.split(f"{Utils.EosServerPath} -e -p eosio --vote-threads 2 --data-dir={data_dir} --config-dir={config_dir}")
start_nodeos_cmd = shlex.split(f"{Utils.EosServerPath} -e -p eosio --data-dir={data_dir} --config-dir={config_dir}")
if os.path.exists(data_dir):
shutil.rmtree(data_dir)
os.makedirs(data_dir)
Expand Down
2 changes: 0 additions & 2 deletions tests/p2p_no_listen_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
'-e',
'-p',
'eosio',
'--vote-threads',
'3',
'--p2p-listen-endpoint',
'',
'--plugin',
Expand Down
2 changes: 1 addition & 1 deletion tests/plugin_http_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def startEnv(self) :
"--p2p-peer-address localhost:9011 --resource-monitor-not-shutdown-on-threshold-exceeded ") % (self.data_dir, self.config_dir, self.data_dir, "\'*\'", "false")
nodeos_flags += category_config.nodeosArgs()

start_nodeos_cmd = ("%s -e -p eosio --vote-threads 2 %s %s ") % (Utils.EosServerPath, nodeos_plugins, nodeos_flags)
start_nodeos_cmd = ("%s -e -p eosio %s %s ") % (Utils.EosServerPath, nodeos_plugins, nodeos_flags)
self.nodeos = Node(TestHelper.LOCAL_HOST, TestHelper.DEFAULT_PORT, self.node_id, self.data_dir, self.config_dir, shlex.split(start_nodeos_cmd), walletMgr=self.keosd)
time.sleep(self.sleep_s*2)
self.nodeos.waitForBlock(1, timeout=30)
Expand Down
2 changes: 1 addition & 1 deletion tests/resource_monitor_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def prepareDirectories():
def runNodeos(extraNodeosArgs, myTimeout):
"""Startup nodeos, wait for timeout (before forced shutdown) and collect output."""
if debug: Print("Launching nodeos process.")
cmd="programs/nodeos/nodeos --config-dir rsmStaging/etc -e -p eosio --vote-threads 2 --plugin eosio::chain_api_plugin --data-dir " + dataDir + " "
cmd="programs/nodeos/nodeos --config-dir rsmStaging/etc -e -p eosio --plugin eosio::chain_api_plugin --data-dir " + dataDir + " "

cmd=cmd + extraNodeosArgs
if debug: Print("cmd: %s" % (cmd))
Expand Down
2 changes: 1 addition & 1 deletion tests/split_blocklog_replay_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
os.makedirs(config_dir)

try:
start_nodeos_cmd = f"{Utils.EosServerPath} -e -p eosio --vote-threads 2 --data-dir={data_dir} --config-dir={config_dir} --blocks-log-stride 10" \
start_nodeos_cmd = f"{Utils.EosServerPath} -e -p eosio --data-dir={data_dir} --config-dir={config_dir} --blocks-log-stride 10" \
" --plugin=eosio::http_plugin --plugin=eosio::chain_api_plugin --http-server-address=localhost:8888"

nodeos.launchCmd(start_nodeos_cmd, node_id)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_read_only_trx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void test_trxs_common(std::vector<const char*>& specific_args, bool test_disable
fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug);
std::vector<const char*> argv = {
"test", // dummy executible name
"-p", "eosio", "--vote-threads", "3", "-e", // actual arguments follow
"-p", "eosio", "-e", // actual arguments follow
"--data-dir", temp_dir_str.c_str(),
"--config-dir", temp_dir_str.c_str(),
"--max-transaction-time=100",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_snapshot_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(snapshot_scheduler_test) {
fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug);
std::vector<const char*> argv =
{"test", "--data-dir", temp.c_str(), "--config-dir", temp.c_str(),
"-p", "eosio", "--vote-threads", "3", "-e"};
"-p", "eosio", "-e"};
app->initialize<chain_plugin, producer_plugin>(argv.size(), (char**) &argv[0]);
app->startup();

Expand Down
1 change: 0 additions & 1 deletion tutorials/bios-boot-tutorial/bios-boot-tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def startNode(nodeIndex, account):
' --p2p-max-nodes-per-host ' + str(maxClients) +
' --enable-stale-production'
' --producer-name ' + account['name'] +
' --vote-threads 3'
' --signature-provider ' + account['pub'] + '=KEY:' + account['pvt'] +
' --plugin eosio::http_plugin'
' --plugin eosio::chain_api_plugin'
Expand Down

0 comments on commit 8f26a50

Please sign in to comment.