add active_transaction_config to nodeconfig

- remove old config variables
This commit is contained in:
gr0vity-dev 2024-05-06 12:03:44 +02:00
commit b3bb7af9ff
2 changed files with 18 additions and 15 deletions

View file

@ -34,6 +34,7 @@ nano::node_config::node_config (const std::optional<uint16_t> & peering_port_a,
ipc_config{ network_params.network }, ipc_config{ network_params.network },
external_address{ boost::asio::ip::address_v6{}.to_string () }, external_address{ boost::asio::ip::address_v6{}.to_string () },
rep_crawler{ network_params.network }, rep_crawler{ network_params.network },
active_transactions{ network_params.network },
block_processor{ network_params.network }, block_processor{ network_params.network },
peer_history{ network_params.network }, peer_history{ network_params.network },
tcp{ network_params.network } tcp{ network_params.network }
@ -119,9 +120,7 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const
toml.put ("external_port", external_port, "The external port number of this node (NAT). Only used if external_address is set.\ntype:uint16"); toml.put ("external_port", external_port, "The external port number of this node (NAT). Only used if external_address is set.\ntype:uint16");
toml.put ("tcp_incoming_connections_max", tcp_incoming_connections_max, "Maximum number of incoming TCP connections.\ntype:uint64"); toml.put ("tcp_incoming_connections_max", tcp_incoming_connections_max, "Maximum number of incoming TCP connections.\ntype:uint64");
toml.put ("use_memory_pools", use_memory_pools, "If true, allocate memory from memory pools. Enabling this may improve performance. Memory is never released to the OS.\ntype:bool"); toml.put ("use_memory_pools", use_memory_pools, "If true, allocate memory from memory pools. Enabling this may improve performance. Memory is never released to the OS.\ntype:bool");
toml.put ("confirmation_history_size", confirmation_history_size, "Maximum confirmation history size. If tracking the rate of block confirmations, the websocket feature is recommended instead.\ntype:uint64");
toml.put ("active_elections_size", active_elections_size, "Number of active elections. Elections beyond this limit have limited survival time.\nWarning: modifying this value may result in a lower confirmation rate.\ntype:uint64,[250..]");
toml.put ("bandwidth_limit", bandwidth_limit, "Outbound traffic limit in bytes/sec after which messages will be dropped.\nNote: changing to unlimited bandwidth (0) is not recommended for limited connections.\ntype:uint64"); toml.put ("bandwidth_limit", bandwidth_limit, "Outbound traffic limit in bytes/sec after which messages will be dropped.\nNote: changing to unlimited bandwidth (0) is not recommended for limited connections.\ntype:uint64");
toml.put ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio, "Burst ratio for outbound traffic shaping.\ntype:double"); toml.put ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio, "Burst ratio for outbound traffic shaping.\ntype:double");
@ -218,6 +217,10 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const
rep_crawler.serialize (rep_crawler_l); rep_crawler.serialize (rep_crawler_l);
toml.put_child ("rep_crawler", rep_crawler_l); toml.put_child ("rep_crawler", rep_crawler_l);
nano::tomlconfig active_transactions_l;
active_transactions.serialize (active_transactions_l);
toml.put_child ("active_transactions", active_transactions_l);
nano::tomlconfig block_processor_l; nano::tomlconfig block_processor_l;
block_processor.serialize (block_processor_l); block_processor.serialize (block_processor_l);
toml.put_child ("block_processor", block_processor_l); toml.put_child ("block_processor", block_processor_l);
@ -311,6 +314,12 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
rep_crawler.deserialize (config_l); rep_crawler.deserialize (config_l);
} }
if (toml.has_key ("active_transactions"))
{
auto config_l = toml.get_required_child ("active_transactions");
active_transactions.deserialize (config_l);
}
if (toml.has_key ("block_processor")) if (toml.has_key ("block_processor"))
{ {
auto config_l = toml.get_required_child ("block_processor"); auto config_l = toml.get_required_child ("block_processor");
@ -459,9 +468,7 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
toml.get (pow_sleep_interval_key, pow_sleep_interval_l); toml.get (pow_sleep_interval_key, pow_sleep_interval_l);
pow_sleep_interval = std::chrono::nanoseconds (pow_sleep_interval_l); pow_sleep_interval = std::chrono::nanoseconds (pow_sleep_interval_l);
toml.get<bool> ("use_memory_pools", use_memory_pools); toml.get<bool> ("use_memory_pools", use_memory_pools);
toml.get<std::size_t> ("confirmation_history_size", confirmation_history_size);
toml.get<std::size_t> ("active_elections_size", active_elections_size);
toml.get<std::size_t> ("bandwidth_limit", bandwidth_limit); toml.get<std::size_t> ("bandwidth_limit", bandwidth_limit);
toml.get<double> ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio); toml.get<double> ("bandwidth_limit_burst_ratio", bandwidth_limit_burst_ratio);
@ -524,9 +531,9 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
{ {
toml.get_error ().set ("io_threads must be non-zero"); toml.get_error ().set ("io_threads must be non-zero");
} }
if (active_elections_size <= 250 && !network_params.network.is_dev_network ()) if (active_transactions.size <= 250 && !network_params.network.is_dev_network ())
{ {
toml.get_error ().set ("active_elections_size must be greater than 250"); toml.get_error ().set ("active_transactions.size must be greater than 250");
} }
if (bandwidth_limit > std::numeric_limits<std::size_t>::max ()) if (bandwidth_limit > std::numeric_limits<std::size_t>::max ())
{ {

View file

@ -8,6 +8,7 @@
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
#include <nano/lib/rocksdbconfig.hpp> #include <nano/lib/rocksdbconfig.hpp>
#include <nano/lib/stats.hpp> #include <nano/lib/stats.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/blockprocessor.hpp> #include <nano/node/blockprocessor.hpp>
#include <nano/node/bootstrap/bootstrap_config.hpp> #include <nano/node/bootstrap/bootstrap_config.hpp>
#include <nano/node/bootstrap/bootstrap_server.hpp> #include <nano/node/bootstrap/bootstrap_server.hpp>
@ -90,7 +91,6 @@ public:
uint32_t bootstrap_frontier_request_count{ 1024 * 1024 }; uint32_t bootstrap_frontier_request_count{ 1024 * 1024 };
nano::websocket::config websocket_config; nano::websocket::config websocket_config;
nano::diagnostics_config diagnostics_config; nano::diagnostics_config diagnostics_config;
std::size_t confirmation_history_size{ 2048 };
std::string callback_address; std::string callback_address;
uint16_t callback_port{ 0 }; uint16_t callback_port{ 0 };
std::string callback_target; std::string callback_target;
@ -104,12 +104,7 @@ public:
/** Timeout for initiated async operations */ /** Timeout for initiated async operations */
std::chrono::seconds tcp_io_timeout{ (network_params.network.is_dev_network () && !is_sanitizer_build ()) ? std::chrono::seconds (5) : std::chrono::seconds (15) }; std::chrono::seconds tcp_io_timeout{ (network_params.network.is_dev_network () && !is_sanitizer_build ()) ? std::chrono::seconds (5) : std::chrono::seconds (15) };
std::chrono::nanoseconds pow_sleep_interval{ 0 }; std::chrono::nanoseconds pow_sleep_interval{ 0 };
// TODO: Move related settings to `active_transactions_config` class
std::size_t active_elections_size{ 5000 };
/** Limit of hinted elections as percentage of `active_elections_size` */
std::size_t active_elections_hinted_limit_percentage{ 20 };
/** Limit of optimistic elections as percentage of `active_elections_size` */
std::size_t active_elections_optimistic_limit_percentage{ 10 };
/** Default maximum incoming TCP connections, including realtime network & bootstrap */ /** Default maximum incoming TCP connections, including realtime network & bootstrap */
unsigned tcp_incoming_connections_max{ 2048 }; unsigned tcp_incoming_connections_max{ 2048 };
bool use_memory_pools{ true }; bool use_memory_pools{ true };
@ -142,6 +137,7 @@ public:
nano::vote_cache_config vote_cache; nano::vote_cache_config vote_cache;
nano::rep_crawler_config rep_crawler; nano::rep_crawler_config rep_crawler;
nano::block_processor_config block_processor; nano::block_processor_config block_processor;
nano::active_transactions_config active_transactions;
nano::vote_processor_config vote_processor; nano::vote_processor_config vote_processor;
nano::peer_history_config peer_history; nano::peer_history_config peer_history;
nano::transport::tcp_config tcp; nano::transport::tcp_config tcp;