Make minimum representative weight configurable
This commit is contained in:
parent
dc783a7971
commit
5be0924c82
10 changed files with 32 additions and 7 deletions
|
|
@ -175,6 +175,7 @@ TEST (toml, daemon_config_deserialize_defaults)
|
|||
ASSERT_EQ (conf.node.background_threads, defaults.node.background_threads);
|
||||
ASSERT_EQ (conf.node.secondary_work_peers, defaults.node.secondary_work_peers);
|
||||
ASSERT_EQ (conf.node.online_weight_minimum, defaults.node.online_weight_minimum);
|
||||
ASSERT_EQ (conf.node.representative_vote_weight_minimum, defaults.node.representative_vote_weight_minimum);
|
||||
ASSERT_EQ (conf.node.rep_crawler_weight_minimum, defaults.node.rep_crawler_weight_minimum);
|
||||
ASSERT_EQ (conf.node.password_fanout, defaults.node.password_fanout);
|
||||
ASSERT_EQ (conf.node.peering_port, defaults.node.peering_port);
|
||||
|
|
@ -404,6 +405,7 @@ TEST (toml, daemon_config_deserialize_no_defaults)
|
|||
network_threads = 999
|
||||
background_threads = 999
|
||||
online_weight_minimum = "999"
|
||||
representative_vote_weight_minimum = "999"
|
||||
rep_crawler_weight_minimum = "999"
|
||||
password_fanout = 999
|
||||
peering_port = 999
|
||||
|
|
@ -597,6 +599,7 @@ TEST (toml, daemon_config_deserialize_no_defaults)
|
|||
ASSERT_NE (conf.node.max_pruning_age, defaults.node.max_pruning_age);
|
||||
ASSERT_NE (conf.node.max_pruning_depth, defaults.node.max_pruning_depth);
|
||||
ASSERT_NE (conf.node.online_weight_minimum, defaults.node.online_weight_minimum);
|
||||
ASSERT_NE (conf.node.representative_vote_weight_minimum, defaults.node.representative_vote_weight_minimum);
|
||||
ASSERT_NE (conf.node.rep_crawler_weight_minimum, defaults.node.rep_crawler_weight_minimum);
|
||||
ASSERT_NE (conf.node.password_fanout, defaults.node.password_fanout);
|
||||
ASSERT_NE (conf.node.peering_port, defaults.node.peering_port);
|
||||
|
|
|
|||
|
|
@ -176,8 +176,10 @@ TEST (vote_processor, no_broadcast_local)
|
|||
nano::node_flags flags;
|
||||
flags.disable_request_loop = true;
|
||||
nano::node_config config1, config2;
|
||||
config1.representative_vote_weight_minimum = 0;
|
||||
config1.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled;
|
||||
auto & node (*system.add_node (config1, flags));
|
||||
config2.representative_vote_weight_minimum = 0;
|
||||
config2.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled;
|
||||
config2.peering_port = system.get_available_port ();
|
||||
system.add_node (config2, flags);
|
||||
|
|
@ -229,8 +231,10 @@ TEST (vote_processor, local_broadcast_without_a_representative)
|
|||
nano::node_flags flags;
|
||||
flags.disable_request_loop = true;
|
||||
nano::node_config config1, config2;
|
||||
config1.representative_vote_weight_minimum = 0;
|
||||
config1.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled;
|
||||
auto & node (*system.add_node (config1, flags));
|
||||
config2.representative_vote_weight_minimum = 0;
|
||||
config2.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled;
|
||||
config2.peering_port = system.get_available_port ();
|
||||
system.add_node (config2, flags);
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, std::filesystem::path cons
|
|||
unchecked{ config.max_unchecked_blocks, stats, flags.disable_block_processor_unchecked_deletion },
|
||||
wallets_store_impl (std::make_unique<nano::mdb_wallets_store> (application_path_a / "wallets.ldb", config_a.lmdb_config)),
|
||||
wallets_store (*wallets_store_impl),
|
||||
ledger_impl{ std::make_unique<nano::ledger> (store, stats, network_params.ledger, flags_a.generate_cache) },
|
||||
ledger_impl{ std::make_unique<nano::ledger> (store, stats, network_params.ledger, flags_a.generate_cache, config_a.representative_vote_weight_minimum.number ()) },
|
||||
ledger{ *ledger_impl },
|
||||
outbound_limiter{ outbound_bandwidth_limiter_config (config) },
|
||||
// empty `config.peering_port` means the user made no port choice at all;
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ nano::error nano::node_config::serialize_toml (nano::tomlconfig & toml) const
|
|||
toml.put ("bootstrap_fraction_numerator", bootstrap_fraction_numerator, "Change bootstrap threshold (online stake / 256 * bootstrap_fraction_numerator).\ntype:uint32");
|
||||
toml.put ("receive_minimum", receive_minimum.to_string_dec (), "Minimum receive amount. Only affects node wallets. A large amount is recommended to avoid automatic work generation for tiny transactions.\ntype:string,amount,raw");
|
||||
toml.put ("online_weight_minimum", online_weight_minimum.to_string_dec (), "When calculating online weight, the node is forced to assume at least this much voting weight is online, thus setting a floor for voting weight to confirm transactions at online_weight_minimum * \"quorum delta\".\ntype:string,amount,raw");
|
||||
toml.put ("representative_vote_weight_minimum", representative_vote_weight_minimum.to_string_dec (), "Minimum vote weight that a representative must have for its vote to be counted.\nAll representatives above this weight will be kept in memory!\ntype:string,amount,raw");
|
||||
toml.put ("password_fanout", password_fanout, "Password fanout factor.\ntype:uint64");
|
||||
toml.put ("io_threads", io_threads, "Number of threads dedicated to I/O operations. Defaults to the number of CPU threads, and at least 4.\ntype:uint64");
|
||||
toml.put ("network_threads", network_threads, "Number of threads dedicated to processing network messages. Defaults to the number of CPU threads, and at least 4.\ntype:uint64");
|
||||
|
|
@ -340,6 +341,16 @@ nano::error nano::node_config::deserialize_toml (nano::tomlconfig & toml)
|
|||
toml.get_error ().set ("online_weight_minimum contains an invalid decimal amount");
|
||||
}
|
||||
|
||||
auto representative_vote_weight_minimum_l{ representative_vote_weight_minimum.to_string_dec () };
|
||||
if (toml.has_key ("representative_vote_weight_minimum"))
|
||||
{
|
||||
representative_vote_weight_minimum_l = toml.get<std::string> ("representative_vote_weight_minimum");
|
||||
}
|
||||
if (representative_vote_weight_minimum.decode_dec (representative_vote_weight_minimum_l))
|
||||
{
|
||||
toml.get_error ().set ("representative_vote_weight_minimum contains an invalid decimal amount");
|
||||
}
|
||||
|
||||
auto vote_minimum_l (vote_minimum.to_string_dec ());
|
||||
if (toml.has_key ("vote_minimum"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,6 +64,11 @@ public:
|
|||
std::chrono::milliseconds vote_generator_delay{ std::chrono::milliseconds (100) };
|
||||
unsigned vote_generator_threshold{ 3 };
|
||||
nano::amount online_weight_minimum{ 60000 * nano::Gxrb_ratio };
|
||||
/*
|
||||
* The minimum vote weight that a representative must have for its vote to be counted.
|
||||
* All representatives above this weight will be kept in memory!
|
||||
*/
|
||||
nano::amount representative_vote_weight_minimum{ 10 * nano::Mxrb_ratio };
|
||||
unsigned password_fanout{ 1024 };
|
||||
unsigned io_threads{ std::max (4u, nano::hardware_concurrency ()) };
|
||||
unsigned network_threads{ std::max (4u, nano::hardware_concurrency ()) };
|
||||
|
|
|
|||
|
|
@ -749,10 +749,10 @@ void representative_visitor::state_block (nano::state_block const & block_a)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
nano::ledger::ledger (nano::store::component & store_a, nano::stats & stat_a, nano::ledger_constants & constants, nano::generate_cache_flags const & generate_cache_flags_a) :
|
||||
nano::ledger::ledger (nano::store::component & store_a, nano::stats & stat_a, nano::ledger_constants & constants, nano::generate_cache_flags const & generate_cache_flags_a, nano::uint128_t min_rep_weight_a) :
|
||||
constants{ constants },
|
||||
store{ store_a },
|
||||
cache{ store_a.rep_weight },
|
||||
cache{ store_a.rep_weight, min_rep_weight_a },
|
||||
stats{ stat_a },
|
||||
check_bootstrap_weights{ true }
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class ledger final
|
|||
friend class receivable_iterator;
|
||||
|
||||
public:
|
||||
ledger (nano::store::component &, nano::stats &, nano::ledger_constants & constants, nano::generate_cache_flags const & = nano::generate_cache_flags{});
|
||||
ledger (nano::store::component &, nano::stats &, nano::ledger_constants & constants, nano::generate_cache_flags const & = nano::generate_cache_flags{}, nano::uint128_t min_rep_weight_a = 0);
|
||||
/**
|
||||
* Returns the account for a given hash
|
||||
* Returns std::nullopt if the block doesn't exist or has been pruned
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/secure/ledger_cache.hpp>
|
||||
|
||||
nano::ledger_cache::ledger_cache (nano::store::rep_weight & rep_weight_store_a) :
|
||||
rep_weights{ rep_weight_store_a }
|
||||
nano::ledger_cache::ledger_cache (nano::store::rep_weight & rep_weight_store_a, nano::uint128_t min_rep_weight_a) :
|
||||
rep_weights{ rep_weight_store_a, min_rep_weight_a }
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/secure/rep_weights.hpp>
|
||||
#include <nano/store/rep_weight.hpp>
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ namespace nano
|
|||
class ledger_cache
|
||||
{
|
||||
public:
|
||||
explicit ledger_cache (nano::store::rep_weight & rep_weight_store_a);
|
||||
explicit ledger_cache (nano::store::rep_weight & rep_weight_store_a, nano::uint128_t min_rep_weight_a = 0);
|
||||
nano::rep_weights rep_weights;
|
||||
std::atomic<uint64_t> cemented_count{ 0 };
|
||||
std::atomic<uint64_t> block_count{ 0 };
|
||||
|
|
|
|||
|
|
@ -579,6 +579,7 @@ void nano::test::system::stop ()
|
|||
nano::node_config nano::test::system::default_config ()
|
||||
{
|
||||
nano::node_config config{ get_available_port () };
|
||||
config.representative_vote_weight_minimum = 0;
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue