Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ascending bootstrap dependency resolution #4692

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Max tags limit
  • Loading branch information
pwojcikdev committed Aug 5, 2024
commit 454d799cf2c109b08247a0417a44ed69836e35d4
4 changes: 2 additions & 2 deletions nano/core_test/bootstrap_ascending.cpp
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ TEST (bootstrap_ascending, config_serialization)
{
nano::bootstrap_ascending_config config1;
config1.requests_limit = 0x101;
config1.database_requests_limit = 0x102;
config1.database_rate_limit = 0x102;
config1.pull_count = 0x103;
config1.request_timeout = 0x104ms;
config1.throttle_coefficient = 0x105;
@@ -279,7 +279,7 @@ TEST (bootstrap_ascending, config_serialization)
nano::bootstrap_ascending_config config2;
ASSERT_FALSE (config2.deserialize (toml2));
ASSERT_EQ (config1.requests_limit, config2.requests_limit);
ASSERT_EQ (config1.database_requests_limit, config2.database_requests_limit);
ASSERT_EQ (config1.database_rate_limit, config2.database_rate_limit);
ASSERT_EQ (config1.pull_count, config2.pull_count);
ASSERT_EQ (config1.request_timeout, config2.request_timeout);
ASSERT_EQ (config1.throttle_coefficient, config2.throttle_coefficient);
4 changes: 2 additions & 2 deletions nano/node/bootstrap/bootstrap_config.cpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ nano::error nano::account_sets_config::serialize (nano::tomlconfig & toml) const
nano::error nano::bootstrap_ascending_config::deserialize (nano::tomlconfig & toml)
{
toml.get ("requests_limit", requests_limit);
toml.get ("database_requests_limit", database_requests_limit);
toml.get ("database_rate_limit", database_rate_limit);
toml.get ("pull_count", pull_count);
toml.get_duration ("timeout", request_timeout);
toml.get ("throttle_coefficient", throttle_coefficient);
@@ -49,7 +49,7 @@ nano::error nano::bootstrap_ascending_config::deserialize (nano::tomlconfig & to
nano::error nano::bootstrap_ascending_config::serialize (nano::tomlconfig & toml) const
{
toml.put ("requests_limit", requests_limit, "Request limit to ascending bootstrap after which requests will be dropped.\nNote: changing to unlimited (0) is not recommended.\ntype:uint64");
toml.put ("database_requests_limit", database_requests_limit, "Request limit for accounts from database after which requests will be dropped.\nNote: changing to unlimited (0) is not recommended as this operation competes for resources on querying the database.\ntype:uint64");
toml.put ("database_rate_limit", database_rate_limit, "Rate limit on scanning accounts and pending entries from database.\nNote: changing to unlimited (0) is not recommended as this operation competes for resources on querying the database.\ntype:uint64");
toml.put ("pull_count", pull_count, "Number of requested blocks for ascending bootstrap request.\ntype:uint64");
toml.put ("timeout", request_timeout.count (), "Timeout in milliseconds for incoming ascending bootstrap messages to be processed.\ntype:milliseconds");
toml.put ("throttle_coefficient", throttle_coefficient, "Scales the number of samples to track for bootstrap throttling.\ntype:uint64");
3 changes: 2 additions & 1 deletion nano/node/bootstrap/bootstrap_config.hpp
Original file line number Diff line number Diff line change
@@ -28,12 +28,13 @@ class bootstrap_ascending_config final

// Maximum number of un-responded requests per channel
std::size_t requests_limit{ 64 };
std::size_t database_requests_limit{ 1024 };
std::size_t database_rate_limit{ 1024 };
std::size_t pull_count{ nano::bootstrap_server::max_blocks };
std::chrono::milliseconds request_timeout{ 1000 * 5 };
std::size_t throttle_coefficient{ 16 };
std::chrono::milliseconds throttle_wait{ 100 };
std::size_t block_wait_count{ 1000 };
std::size_t max_requests{ 1024 * 16 }; // TODO: Adjust for live network

nano::account_sets_config account_sets;
};
4 changes: 2 additions & 2 deletions nano/node/bootstrap_ascending/service.cpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ nano::bootstrap_ascending::service::service (nano::node_config & config_a, nano:
iterator{ ledger },
throttle{ compute_throttle_size () },
scoring{ config.bootstrap_ascending, config.network_params.network },
database_limiter{ config.bootstrap_ascending.database_requests_limit, 1.0 }
database_limiter{ config.bootstrap_ascending.database_rate_limit, 1.0 }
{
// TODO: This is called from a very congested blockprocessor thread. Offload this work to a dedicated processing thread
block_processor.batch_processed.add ([this] (auto const & batch) {
@@ -253,7 +253,7 @@ void nano::bootstrap_ascending::service::wait_tags ()
{
auto predicate = [this] () {
debug_assert (!mutex.try_lock ());
return tags.size () < max_tags;
return tags.size () < config.bootstrap_ascending.max_requests;
};
wait_backoff (predicate, { 1ms, 1ms, 1ms, 5ms, 10ms, 20ms, 40ms, 80ms, 160ms });
}
2 changes: 0 additions & 2 deletions nano/node/bootstrap_ascending/service.hpp
Original file line number Diff line number Diff line change
@@ -204,8 +204,6 @@ namespace bootstrap_ascending
std::thread database_thread;
std::thread dependencies_thread;
std::thread timeout_thread;

static size_t constexpr max_tags{ 1024 };
};

nano::stat::detail to_stat_detail (service::query_type);