Rename bootstrap_ascending namespace to simply bootstrap

This commit is contained in:
Piotr Wójcik 2024-10-29 14:24:14 +01:00
commit 596a559699
19 changed files with 326 additions and 335 deletions

View file

@ -33,7 +33,7 @@ TEST (account_sets, construction)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
} }
TEST (account_sets, empty_blocked) TEST (account_sets, empty_blocked)
@ -44,7 +44,7 @@ TEST (account_sets, empty_blocked)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
ASSERT_FALSE (sets.blocked (account)); ASSERT_FALSE (sets.blocked (account));
} }
@ -56,7 +56,7 @@ TEST (account_sets, block)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
sets.block (account, random_hash ()); sets.block (account, random_hash ());
ASSERT_TRUE (sets.blocked (account)); ASSERT_TRUE (sets.blocked (account));
} }
@ -69,7 +69,7 @@ TEST (account_sets, unblock)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
auto hash = random_hash (); auto hash = random_hash ();
sets.block (account, hash); sets.block (account, hash);
sets.unblock (account, hash); sets.unblock (account, hash);
@ -84,7 +84,7 @@ TEST (account_sets, priority_base)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
ASSERT_EQ (0.0, sets.priority (account)); ASSERT_EQ (0.0, sets.priority (account));
} }
@ -96,7 +96,7 @@ TEST (account_sets, priority_blocked)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
sets.block (account, random_hash ()); sets.block (account, random_hash ());
ASSERT_EQ (0.0, sets.priority (account)); ASSERT_EQ (0.0, sets.priority (account));
} }
@ -110,15 +110,15 @@ TEST (account_sets, priority_unblock_keep)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
sets.priority_up (account); sets.priority_up (account);
sets.priority_up (account); sets.priority_up (account);
ASSERT_EQ (sets.priority (account), nano::bootstrap_ascending::account_sets::priority_initial + nano::bootstrap_ascending::account_sets::priority_increase); ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_initial + nano::bootstrap::account_sets::priority_increase);
auto hash = random_hash (); auto hash = random_hash ();
sets.block (account, hash); sets.block (account, hash);
ASSERT_EQ (0.0, sets.priority (account)); ASSERT_EQ (0.0, sets.priority (account));
sets.unblock (account, hash); sets.unblock (account, hash);
ASSERT_EQ (sets.priority (account), nano::bootstrap_ascending::account_sets::priority_initial + nano::bootstrap_ascending::account_sets::priority_increase); ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_initial + nano::bootstrap::account_sets::priority_increase);
} }
TEST (account_sets, priority_up_down) TEST (account_sets, priority_up_down)
@ -129,11 +129,11 @@ TEST (account_sets, priority_up_down)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
sets.priority_up (account); sets.priority_up (account);
ASSERT_EQ (sets.priority (account), nano::bootstrap_ascending::account_sets::priority_initial); ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_initial);
sets.priority_down (account); sets.priority_down (account);
ASSERT_EQ (sets.priority (account), nano::bootstrap_ascending::account_sets::priority_initial / nano::bootstrap_ascending::account_sets::priority_divide); ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_initial / nano::bootstrap::account_sets::priority_divide);
} }
TEST (account_sets, priority_down_sat) TEST (account_sets, priority_down_sat)
@ -144,7 +144,7 @@ TEST (account_sets, priority_down_sat)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
sets.priority_down (account); sets.priority_down (account);
ASSERT_EQ (0.0, sets.priority (account)); ASSERT_EQ (0.0, sets.priority (account));
} }
@ -158,18 +158,18 @@ TEST (account_sets, saturate_priority)
auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants); auto store = nano::make_store (system.logger, nano::unique_path (), nano::dev::constants);
ASSERT_FALSE (store->init_error ()); ASSERT_FALSE (store->init_error ());
nano::account_sets_config config; nano::account_sets_config config;
nano::bootstrap_ascending::account_sets sets{ config, system.stats }; nano::bootstrap::account_sets sets{ config, system.stats };
for (int n = 0; n < 1000; ++n) for (int n = 0; n < 1000; ++n)
{ {
sets.priority_up (account); sets.priority_up (account);
} }
ASSERT_EQ (sets.priority (account), nano::bootstrap_ascending::account_sets::priority_max); ASSERT_EQ (sets.priority (account), nano::bootstrap::account_sets::priority_max);
} }
/** /**
* Tests the base case for returning * Tests the base case for returning
*/ */
TEST (bootstrap_ascending, account_base) TEST (bootstrap, account_base)
{ {
nano::node_flags flags; nano::node_flags flags;
nano::test::system system{ 1, nano::transport::transport_type::tcp, flags }; nano::test::system system{ 1, nano::transport::transport_type::tcp, flags };
@ -192,7 +192,7 @@ TEST (bootstrap_ascending, account_base)
/** /**
* Tests that bootstrap_ascending will return multiple new blocks in-order * Tests that bootstrap_ascending will return multiple new blocks in-order
*/ */
TEST (bootstrap_ascending, account_inductive) TEST (bootstrap, account_inductive)
{ {
nano::node_flags flags; nano::node_flags flags;
nano::test::system system{ 1, nano::transport::transport_type::tcp, flags }; nano::test::system system{ 1, nano::transport::transport_type::tcp, flags };
@ -228,7 +228,7 @@ TEST (bootstrap_ascending, account_inductive)
/** /**
* Tests that bootstrap_ascending will return multiple new blocks in-order * Tests that bootstrap_ascending will return multiple new blocks in-order
*/ */
TEST (bootstrap_ascending, trace_base) TEST (bootstrap, trace_base)
{ {
nano::node_flags flags; nano::node_flags flags;
flags.disable_legacy_bootstrap = true; flags.disable_legacy_bootstrap = true;
@ -272,7 +272,7 @@ TEST (bootstrap_ascending, trace_base)
/* /*
* Tests that bootstrap will prioritize existing accounts with outdated frontiers * Tests that bootstrap will prioritize existing accounts with outdated frontiers
*/ */
TEST (bootstrap_ascending, frontier_scan) TEST (bootstrap, frontier_scan)
{ {
nano::test::system system; nano::test::system system;
@ -368,7 +368,7 @@ TEST (bootstrap_ascending, frontier_scan)
/* /*
* Tests that bootstrap will prioritize not yet existing accounts with pending blocks * Tests that bootstrap will prioritize not yet existing accounts with pending blocks
*/ */
TEST (bootstrap_ascending, frontier_scan_pending) TEST (bootstrap, frontier_scan_pending)
{ {
nano::test::system system; nano::test::system system;
@ -450,7 +450,7 @@ TEST (bootstrap_ascending, frontier_scan_pending)
/* /*
* Bootstrap should not attempt to prioritize accounts that can't be immediately connected to the ledger (no pending blocks, no existing frontier) * Bootstrap should not attempt to prioritize accounts that can't be immediately connected to the ledger (no pending blocks, no existing frontier)
*/ */
TEST (bootstrap_ascending, frontier_scan_cannot_prioritize) TEST (bootstrap, frontier_scan_cannot_prioritize)
{ {
nano::test::system system; nano::test::system system;

View file

@ -4,13 +4,13 @@
TEST (throttle, construction) TEST (throttle, construction)
{ {
nano::bootstrap_ascending::throttle throttle{ 2 }; nano::bootstrap::throttle throttle{ 2 };
ASSERT_FALSE (throttle.throttled ()); ASSERT_FALSE (throttle.throttled ());
} }
TEST (throttle, throttled) TEST (throttle, throttled)
{ {
nano::bootstrap_ascending::throttle throttle{ 2 }; nano::bootstrap::throttle throttle{ 2 };
throttle.add (false); throttle.add (false);
ASSERT_FALSE (throttle.throttled ()); ASSERT_FALSE (throttle.throttled ());
throttle.add (false); throttle.add (false);
@ -19,7 +19,7 @@ TEST (throttle, throttled)
TEST (throttle, resize_up) TEST (throttle, resize_up)
{ {
nano::bootstrap_ascending::throttle throttle{ 2 }; nano::bootstrap::throttle throttle{ 2 };
throttle.add (false); throttle.add (false);
throttle.resize (4); throttle.resize (4);
ASSERT_FALSE (throttle.throttled ()); ASSERT_FALSE (throttle.throttled ());
@ -29,7 +29,7 @@ TEST (throttle, resize_up)
TEST (throttle, resize_down) TEST (throttle, resize_down)
{ {
nano::bootstrap_ascending::throttle throttle{ 4 }; nano::bootstrap::throttle throttle{ 4 };
throttle.add (false); throttle.add (false);
ASSERT_FALSE (throttle.throttled ()); ASSERT_FALSE (throttle.throttled ());
throttle.resize (2); throttle.resize (2);

View file

@ -11,13 +11,13 @@
* account_sets * account_sets
*/ */
nano::bootstrap_ascending::account_sets::account_sets (nano::account_sets_config const & config_a, nano::stats & stats_a) : nano::bootstrap::account_sets::account_sets (nano::account_sets_config const & config_a, nano::stats & stats_a) :
config{ config_a }, config{ config_a },
stats{ stats_a } stats{ stats_a }
{ {
} }
void nano::bootstrap_ascending::account_sets::priority_up (nano::account const & account) void nano::bootstrap::account_sets::priority_up (nano::account const & account)
{ {
if (account.is_zero ()) if (account.is_zero ())
{ {
@ -48,7 +48,7 @@ void nano::bootstrap_ascending::account_sets::priority_up (nano::account const &
} }
} }
void nano::bootstrap_ascending::account_sets::priority_down (nano::account const & account) void nano::bootstrap::account_sets::priority_down (nano::account const & account)
{ {
if (account.is_zero ()) if (account.is_zero ())
{ {
@ -79,7 +79,7 @@ void nano::bootstrap_ascending::account_sets::priority_down (nano::account const
} }
} }
void nano::bootstrap_ascending::account_sets::priority_set (nano::account const & account) void nano::bootstrap::account_sets::priority_set (nano::account const & account)
{ {
if (account.is_zero ()) if (account.is_zero ())
{ {
@ -102,7 +102,7 @@ void nano::bootstrap_ascending::account_sets::priority_set (nano::account const
} }
} }
void nano::bootstrap_ascending::account_sets::block (nano::account const & account, nano::block_hash const & dependency) void nano::bootstrap::account_sets::block (nano::account const & account, nano::block_hash const & dependency)
{ {
debug_assert (!account.is_zero ()); debug_assert (!account.is_zero ());
@ -120,7 +120,7 @@ void nano::bootstrap_ascending::account_sets::block (nano::account const & accou
trim_overflow (); trim_overflow ();
} }
void nano::bootstrap_ascending::account_sets::unblock (nano::account const & account, std::optional<nano::block_hash> const & hash) void nano::bootstrap::account_sets::unblock (nano::account const & account, std::optional<nano::block_hash> const & hash)
{ {
if (account.is_zero ()) if (account.is_zero ())
{ {
@ -153,7 +153,7 @@ void nano::bootstrap_ascending::account_sets::unblock (nano::account const & acc
} }
} }
void nano::bootstrap_ascending::account_sets::timestamp_set (const nano::account & account) void nano::bootstrap::account_sets::timestamp_set (const nano::account & account)
{ {
debug_assert (!account.is_zero ()); debug_assert (!account.is_zero ());
@ -166,7 +166,7 @@ void nano::bootstrap_ascending::account_sets::timestamp_set (const nano::account
} }
} }
void nano::bootstrap_ascending::account_sets::timestamp_reset (const nano::account & account) void nano::bootstrap::account_sets::timestamp_reset (const nano::account & account)
{ {
debug_assert (!account.is_zero ()); debug_assert (!account.is_zero ());
@ -179,7 +179,7 @@ void nano::bootstrap_ascending::account_sets::timestamp_reset (const nano::accou
} }
} }
void nano::bootstrap_ascending::account_sets::dependency_update (nano::block_hash const & hash, nano::account const & dependency_account) void nano::bootstrap::account_sets::dependency_update (nano::block_hash const & hash, nano::account const & dependency_account)
{ {
debug_assert (!dependency_account.is_zero ()); debug_assert (!dependency_account.is_zero ());
@ -208,7 +208,7 @@ void nano::bootstrap_ascending::account_sets::dependency_update (nano::block_has
} }
} }
void nano::bootstrap_ascending::account_sets::trim_overflow () void nano::bootstrap::account_sets::trim_overflow ()
{ {
while (priorities.size () > config.priorities_max) while (priorities.size () > config.priorities_max)
{ {
@ -224,7 +224,7 @@ void nano::bootstrap_ascending::account_sets::trim_overflow ()
} }
} }
nano::account nano::bootstrap_ascending::account_sets::next_priority (std::function<bool (nano::account const &)> const & filter) nano::account nano::bootstrap::account_sets::next_priority (std::function<bool (nano::account const &)> const & filter)
{ {
if (priorities.empty ()) if (priorities.empty ())
{ {
@ -249,7 +249,7 @@ nano::account nano::bootstrap_ascending::account_sets::next_priority (std::funct
return { 0 }; return { 0 };
} }
nano::block_hash nano::bootstrap_ascending::account_sets::next_blocking (std::function<bool (nano::block_hash const &)> const & filter) nano::block_hash nano::bootstrap::account_sets::next_blocking (std::function<bool (nano::block_hash const &)> const & filter)
{ {
if (blocking.empty ()) if (blocking.empty ())
{ {
@ -271,7 +271,7 @@ nano::block_hash nano::bootstrap_ascending::account_sets::next_blocking (std::fu
return { 0 }; return { 0 };
} }
void nano::bootstrap_ascending::account_sets::sync_dependencies () void nano::bootstrap::account_sets::sync_dependencies ()
{ {
// Sample all accounts with a known dependency account (> account 0) // Sample all accounts with a known dependency account (> account 0)
auto begin = blocking.get<tag_dependency_account> ().upper_bound (nano::account{ 0 }); auto begin = blocking.get<tag_dependency_account> ().upper_bound (nano::account{ 0 });
@ -296,37 +296,37 @@ void nano::bootstrap_ascending::account_sets::sync_dependencies ()
trim_overflow (); trim_overflow ();
} }
bool nano::bootstrap_ascending::account_sets::blocked (nano::account const & account) const bool nano::bootstrap::account_sets::blocked (nano::account const & account) const
{ {
return blocking.get<tag_account> ().contains (account); return blocking.get<tag_account> ().contains (account);
} }
bool nano::bootstrap_ascending::account_sets::prioritized (nano::account const & account) const bool nano::bootstrap::account_sets::prioritized (nano::account const & account) const
{ {
return priorities.get<tag_account> ().contains (account); return priorities.get<tag_account> ().contains (account);
} }
std::size_t nano::bootstrap_ascending::account_sets::priority_size () const std::size_t nano::bootstrap::account_sets::priority_size () const
{ {
return priorities.size (); return priorities.size ();
} }
std::size_t nano::bootstrap_ascending::account_sets::blocked_size () const std::size_t nano::bootstrap::account_sets::blocked_size () const
{ {
return blocking.size (); return blocking.size ();
} }
bool nano::bootstrap_ascending::account_sets::priority_half_full () const bool nano::bootstrap::account_sets::priority_half_full () const
{ {
return priorities.size () > config.priorities_max / 2; return priorities.size () > config.priorities_max / 2;
} }
bool nano::bootstrap_ascending::account_sets::blocked_half_full () const bool nano::bootstrap::account_sets::blocked_half_full () const
{ {
return blocking.size () > config.blocking_max / 2; return blocking.size () > config.blocking_max / 2;
} }
double nano::bootstrap_ascending::account_sets::priority (nano::account const & account) const double nano::bootstrap::account_sets::priority (nano::account const & account) const
{ {
if (!blocked (account)) if (!blocked (account))
{ {
@ -339,12 +339,12 @@ double nano::bootstrap_ascending::account_sets::priority (nano::account const &
return 0.0; return 0.0;
} }
auto nano::bootstrap_ascending::account_sets::info () const -> nano::bootstrap_ascending::account_sets::info_t auto nano::bootstrap::account_sets::info () const -> nano::bootstrap::account_sets::info_t
{ {
return { blocking, priorities }; return { blocking, priorities };
} }
nano::container_info nano::bootstrap_ascending::account_sets::container_info () const nano::container_info nano::bootstrap::account_sets::container_info () const
{ {
// Count blocking entries with their dependency account unknown // Count blocking entries with their dependency account unknown
auto blocking_unknown = blocking.get<tag_dependency_account> ().count (nano::account{ 0 }); auto blocking_unknown = blocking.get<tag_dependency_account> ().count (nano::account{ 0 });

View file

@ -21,7 +21,7 @@ namespace nano
{ {
class stats; class stats;
namespace bootstrap_ascending namespace bootstrap
{ {
/** This class tracks accounts various account sets which are shared among the multiple bootstrap threads */ /** This class tracks accounts various account sets which are shared among the multiple bootstrap threads */
class account_sets class account_sets

View file

@ -2,13 +2,13 @@
#include <nano/crypto_lib/random_pool.hpp> #include <nano/crypto_lib/random_pool.hpp>
namespace nano::bootstrap_ascending namespace nano::bootstrap
{ {
using id_t = uint64_t; using id_t = uint64_t;
static nano::bootstrap_ascending::id_t generate_id () static nano::bootstrap::id_t generate_id ()
{ {
nano::bootstrap_ascending::id_t id; nano::bootstrap::id_t id;
nano::random_pool::generate_block (reinterpret_cast<uint8_t *> (&id), sizeof (id)); nano::random_pool::generate_block (reinterpret_cast<uint8_t *> (&id), sizeof (id));
return id; return id;
} }
} // nano::bootstrap_ascending }

View file

@ -8,7 +8,7 @@
#include <optional> #include <optional>
namespace nano::bootstrap_ascending namespace nano::bootstrap
{ {
struct account_database_crawler struct account_database_crawler
{ {

View file

@ -12,14 +12,14 @@
* database_scan * database_scan
*/ */
nano::bootstrap_ascending::database_scan::database_scan (nano::ledger & ledger_a) : nano::bootstrap::database_scan::database_scan (nano::ledger & ledger_a) :
ledger{ ledger_a }, ledger{ ledger_a },
account_scanner{ ledger }, account_scanner{ ledger },
pending_scanner{ ledger } pending_scanner{ ledger }
{ {
} }
nano::account nano::bootstrap_ascending::database_scan::next (std::function<bool (nano::account const &)> const & filter) nano::account nano::bootstrap::database_scan::next (std::function<bool (nano::account const &)> const & filter)
{ {
if (queue.empty ()) if (queue.empty ())
{ {
@ -40,7 +40,7 @@ nano::account nano::bootstrap_ascending::database_scan::next (std::function<bool
return { 0 }; return { 0 };
} }
void nano::bootstrap_ascending::database_scan::fill () void nano::bootstrap::database_scan::fill ()
{ {
auto transaction = ledger.store.tx_begin_read (); auto transaction = ledger.store.tx_begin_read ();
@ -51,12 +51,12 @@ void nano::bootstrap_ascending::database_scan::fill ()
queue.insert (queue.end (), set2.begin (), set2.end ()); queue.insert (queue.end (), set2.begin (), set2.end ());
} }
bool nano::bootstrap_ascending::database_scan::warmed_up () const bool nano::bootstrap::database_scan::warmed_up () const
{ {
return account_scanner.completed > 0 && pending_scanner.completed > 0; return account_scanner.completed > 0 && pending_scanner.completed > 0;
} }
nano::container_info nano::bootstrap_ascending::database_scan::container_info () const nano::container_info nano::bootstrap::database_scan::container_info () const
{ {
nano::container_info info; nano::container_info info;
info.put ("accounts_iterator", account_scanner.completed); info.put ("accounts_iterator", account_scanner.completed);
@ -68,11 +68,11 @@ nano::container_info nano::bootstrap_ascending::database_scan::container_info ()
* account_database_scanner * account_database_scanner
*/ */
std::deque<nano::account> nano::bootstrap_ascending::account_database_scanner::next_batch (nano::store::transaction & transaction, size_t batch_size) std::deque<nano::account> nano::bootstrap::account_database_scanner::next_batch (nano::store::transaction & transaction, size_t batch_size)
{ {
std::deque<nano::account> result; std::deque<nano::account> result;
account_database_crawler crawler{ ledger.store, transaction, next }; nano::bootstrap::account_database_crawler crawler{ ledger.store, transaction, next };
for (size_t count = 0; crawler.current && count < batch_size; crawler.advance (), ++count) for (size_t count = 0; crawler.current && count < batch_size; crawler.advance (), ++count)
{ {
@ -96,11 +96,11 @@ std::deque<nano::account> nano::bootstrap_ascending::account_database_scanner::n
* pending_database_scanner * pending_database_scanner
*/ */
std::deque<nano::account> nano::bootstrap_ascending::pending_database_scanner::next_batch (nano::store::transaction & transaction, size_t batch_size) std::deque<nano::account> nano::bootstrap::pending_database_scanner::next_batch (nano::store::transaction & transaction, size_t batch_size)
{ {
std::deque<nano::account> result; std::deque<nano::account> result;
pending_database_crawler crawler{ ledger.store, transaction, next }; nano::bootstrap::pending_database_crawler crawler{ ledger.store, transaction, next };
for (size_t count = 0; crawler.current && count < batch_size; crawler.advance (), ++count) for (size_t count = 0; crawler.current && count < batch_size; crawler.advance (), ++count)
{ {

View file

@ -7,7 +7,7 @@
#include <deque> #include <deque>
namespace nano::bootstrap_ascending namespace nano::bootstrap
{ {
struct account_database_scanner struct account_database_scanner
{ {

View file

@ -3,7 +3,7 @@
#include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_int.hpp>
nano::bootstrap_ascending::frontier_scan::frontier_scan (frontier_scan_config const & config_a, nano::stats & stats_a) : nano::bootstrap::frontier_scan::frontier_scan (frontier_scan_config const & config_a, nano::stats & stats_a) :
config{ config_a }, config{ config_a },
stats{ stats_a } stats{ stats_a }
{ {
@ -23,7 +23,7 @@ nano::bootstrap_ascending::frontier_scan::frontier_scan (frontier_scan_config co
release_assert (!heads.empty ()); release_assert (!heads.empty ());
} }
nano::account nano::bootstrap_ascending::frontier_scan::next () nano::account nano::bootstrap::frontier_scan::next ()
{ {
auto const cutoff = std::chrono::steady_clock::now () - config.cooldown; auto const cutoff = std::chrono::steady_clock::now () - config.cooldown;
@ -54,7 +54,7 @@ nano::account nano::bootstrap_ascending::frontier_scan::next ()
return { 0 }; return { 0 };
} }
bool nano::bootstrap_ascending::frontier_scan::process (nano::account start, std::deque<std::pair<nano::account, nano::block_hash>> const & response) bool nano::bootstrap::frontier_scan::process (nano::account start, std::deque<std::pair<nano::account, nano::block_hash>> const & response)
{ {
debug_assert (std::all_of (response.begin (), response.end (), [&] (auto const & pair) { return pair.first.number () >= start.number (); })); debug_assert (std::all_of (response.begin (), response.end (), [&] (auto const & pair) { return pair.first.number () >= start.number (); }));
@ -124,7 +124,7 @@ bool nano::bootstrap_ascending::frontier_scan::process (nano::account start, std
return done; return done;
} }
nano::container_info nano::bootstrap_ascending::frontier_scan::container_info () const nano::container_info nano::bootstrap::frontier_scan::container_info () const
{ {
auto collect_progress = [&] () { auto collect_progress = [&] () {
nano::container_info info; nano::container_info info;

View file

@ -17,7 +17,7 @@
namespace mi = boost::multi_index; namespace mi = boost::multi_index;
namespace nano::bootstrap_ascending namespace nano::bootstrap
{ {
/* /*
* Frontier scan divides the account space into ranges and scans each range for outdated frontiers in parallel. * Frontier scan divides the account space into ranges and scans each range for outdated frontiers in parallel.

View file

@ -6,13 +6,13 @@
* peer_scoring * peer_scoring
*/ */
nano::bootstrap_ascending::peer_scoring::peer_scoring (bootstrap_ascending_config const & config_a, nano::network_constants const & network_constants_a) : nano::bootstrap::peer_scoring::peer_scoring (bootstrap_ascending_config const & config_a, nano::network_constants const & network_constants_a) :
config{ config_a }, config{ config_a },
network_constants{ network_constants_a } network_constants{ network_constants_a }
{ {
} }
bool nano::bootstrap_ascending::peer_scoring::try_send_message (std::shared_ptr<nano::transport::channel> channel) bool nano::bootstrap::peer_scoring::try_send_message (std::shared_ptr<nano::transport::channel> channel)
{ {
auto & index = scoring.get<tag_channel> (); auto & index = scoring.get<tag_channel> ();
auto existing = index.find (channel.get ()); auto existing = index.find (channel.get ());
@ -38,7 +38,7 @@ bool nano::bootstrap_ascending::peer_scoring::try_send_message (std::shared_ptr<
return false; return false;
} }
void nano::bootstrap_ascending::peer_scoring::received_message (std::shared_ptr<nano::transport::channel> channel) void nano::bootstrap::peer_scoring::received_message (std::shared_ptr<nano::transport::channel> channel)
{ {
auto & index = scoring.get<tag_channel> (); auto & index = scoring.get<tag_channel> ();
auto existing = index.find (channel.get ()); auto existing = index.find (channel.get ());
@ -55,7 +55,7 @@ void nano::bootstrap_ascending::peer_scoring::received_message (std::shared_ptr<
} }
} }
std::shared_ptr<nano::transport::channel> nano::bootstrap_ascending::peer_scoring::channel () std::shared_ptr<nano::transport::channel> nano::bootstrap::peer_scoring::channel ()
{ {
auto & index = scoring.get<tag_outstanding> (); auto & index = scoring.get<tag_outstanding> ();
for (auto const & score : index) for (auto const & score : index)
@ -74,12 +74,12 @@ std::shared_ptr<nano::transport::channel> nano::bootstrap_ascending::peer_scorin
return nullptr; return nullptr;
} }
std::size_t nano::bootstrap_ascending::peer_scoring::size () const std::size_t nano::bootstrap::peer_scoring::size () const
{ {
return scoring.size (); return scoring.size ();
} }
void nano::bootstrap_ascending::peer_scoring::timeout () void nano::bootstrap::peer_scoring::timeout ()
{ {
auto & index = scoring.get<tag_channel> (); auto & index = scoring.get<tag_channel> ();
@ -102,7 +102,7 @@ void nano::bootstrap_ascending::peer_scoring::timeout ()
} }
} }
void nano::bootstrap_ascending::peer_scoring::sync (std::deque<std::shared_ptr<nano::transport::channel>> const & list) void nano::bootstrap::peer_scoring::sync (std::deque<std::shared_ptr<nano::transport::channel>> const & list)
{ {
auto & index = scoring.get<tag_channel> (); auto & index = scoring.get<tag_channel> ();
for (auto const & channel : list) for (auto const & channel : list)
@ -124,8 +124,7 @@ void nano::bootstrap_ascending::peer_scoring::sync (std::deque<std::shared_ptr<n
* peer_score * peer_score
*/ */
nano::bootstrap_ascending::peer_scoring::peer_score::peer_score ( nano::bootstrap::peer_scoring::peer_score::peer_score (std::shared_ptr<nano::transport::channel> const & channel_a, uint64_t outstanding_a, uint64_t request_count_total_a, uint64_t response_count_total_a) :
std::shared_ptr<nano::transport::channel> const & channel_a, uint64_t outstanding_a, uint64_t request_count_total_a, uint64_t response_count_total_a) :
channel{ channel_a }, channel{ channel_a },
channel_ptr{ channel_a.get () }, channel_ptr{ channel_a.get () },
outstanding{ outstanding_a }, outstanding{ outstanding_a },

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <nano/node/fwd.hpp>
#include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp> #include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/ordered_index.hpp>
@ -13,12 +15,8 @@ namespace mi = boost::multi_index;
namespace nano namespace nano
{ {
class bootstrap_ascending_config; class bootstrap_ascending_config;
class network_constants;
namespace transport namespace bootstrap
{
class channel;
}
namespace bootstrap_ascending
{ {
// Container for tracking and scoring peers with respect to bootstrapping // Container for tracking and scoring peers with respect to bootstrapping
class peer_scoring class peer_scoring

View file

@ -17,11 +17,7 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
/* nano::bootstrap_service::bootstrap_service (nano::node_config const & node_config_a, nano::block_processor & block_processor_a, nano::ledger & ledger_a, nano::network & network_a, nano::stats & stat_a, nano::logger & logger_a) :
* bootstrap_ascending
*/
nano::bootstrap_ascending::service::service (nano::node_config const & node_config_a, nano::block_processor & block_processor_a, nano::ledger & ledger_a, nano::network & network_a, nano::stats & stat_a, nano::logger & logger_a) :
config{ node_config_a.bootstrap_ascending }, config{ node_config_a.bootstrap_ascending },
network_constants{ node_config_a.network_params.network }, network_constants{ node_config_a.network_params.network },
block_processor{ block_processor_a }, block_processor{ block_processor_a },
@ -55,7 +51,7 @@ nano::bootstrap_ascending::service::service (nano::node_config const & node_conf
accounts.priority_set (node_config_a.network_params.ledger.genesis->account_field ().value ()); accounts.priority_set (node_config_a.network_params.ledger.genesis->account_field ().value ());
} }
nano::bootstrap_ascending::service::~service () nano::bootstrap_service::~bootstrap_service ()
{ {
// All threads must be stopped before destruction // All threads must be stopped before destruction
debug_assert (!priorities_thread.joinable ()); debug_assert (!priorities_thread.joinable ());
@ -66,7 +62,7 @@ nano::bootstrap_ascending::service::~service ()
debug_assert (!workers.alive ()); debug_assert (!workers.alive ());
} }
void nano::bootstrap_ascending::service::start () void nano::bootstrap_service::start ()
{ {
debug_assert (!priorities_thread.joinable ()); debug_assert (!priorities_thread.joinable ());
debug_assert (!database_thread.joinable ()); debug_assert (!database_thread.joinable ());
@ -120,7 +116,7 @@ void nano::bootstrap_ascending::service::start ()
}); });
} }
void nano::bootstrap_ascending::service::stop () void nano::bootstrap_service::stop ()
{ {
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
@ -137,7 +133,7 @@ void nano::bootstrap_ascending::service::stop ()
workers.stop (); workers.stop ();
} }
bool nano::bootstrap_ascending::service::send (std::shared_ptr<nano::transport::channel> const & channel, async_tag tag) bool nano::bootstrap_service::send (std::shared_ptr<nano::transport::channel> const & channel, async_tag tag)
{ {
debug_assert (tag.type != query_type::invalid); debug_assert (tag.type != query_type::invalid);
debug_assert (tag.source != query_source::invalid); debug_assert (tag.source != query_source::invalid);
@ -202,31 +198,31 @@ bool nano::bootstrap_ascending::service::send (std::shared_ptr<nano::transport::
return true; // TODO: Return channel send result return true; // TODO: Return channel send result
} }
std::size_t nano::bootstrap_ascending::service::priority_size () const std::size_t nano::bootstrap_service::priority_size () const
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
return accounts.priority_size (); return accounts.priority_size ();
} }
std::size_t nano::bootstrap_ascending::service::blocked_size () const std::size_t nano::bootstrap_service::blocked_size () const
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
return accounts.blocked_size (); return accounts.blocked_size ();
} }
std::size_t nano::bootstrap_ascending::service::score_size () const std::size_t nano::bootstrap_service::score_size () const
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
return scoring.size (); return scoring.size ();
} }
bool nano::bootstrap_ascending::service::prioritized (nano::account const & account) const bool nano::bootstrap_service::prioritized (nano::account const & account) const
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
return accounts.prioritized (account); return accounts.prioritized (account);
} }
bool nano::bootstrap_ascending::service::blocked (nano::account const & account) const bool nano::bootstrap_service::blocked (nano::account const & account) const
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
return accounts.blocked (account); return accounts.blocked (account);
@ -236,7 +232,7 @@ bool nano::bootstrap_ascending::service::blocked (nano::account const & account)
- Marks an account as blocked if the result code is gap source as there is no reason request additional blocks for this account until the dependency is resolved - Marks an account as blocked if the result code is gap source as there is no reason request additional blocks for this account until the dependency is resolved
- Marks an account as forwarded if it has been recently referenced by a block that has been inserted. - Marks an account as forwarded if it has been recently referenced by a block that has been inserted.
*/ */
void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx, nano::block_status const & result, nano::block const & block, nano::block_source source) void nano::bootstrap_service::inspect (secure::transaction const & tx, nano::block_status const & result, nano::block const & block, nano::block_source source)
{ {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
@ -294,7 +290,7 @@ void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx
} }
} }
void nano::bootstrap_ascending::service::wait (std::function<bool ()> const & predicate) const void nano::bootstrap_service::wait (std::function<bool ()> const & predicate) const
{ {
std::unique_lock<nano::mutex> lock{ mutex }; std::unique_lock<nano::mutex> lock{ mutex };
std::chrono::milliseconds interval = 5ms; std::chrono::milliseconds interval = 5ms;
@ -305,7 +301,7 @@ void nano::bootstrap_ascending::service::wait (std::function<bool ()> const & pr
} }
} }
void nano::bootstrap_ascending::service::wait_tags () const void nano::bootstrap_service::wait_tags () const
{ {
wait ([this] () { wait ([this] () {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
@ -313,14 +309,14 @@ void nano::bootstrap_ascending::service::wait_tags () const
}); });
} }
void nano::bootstrap_ascending::service::wait_blockprocessor () const void nano::bootstrap_service::wait_blockprocessor () const
{ {
wait ([this] () { wait ([this] () {
return block_processor.size (nano::block_source::bootstrap) < config.block_processor_threshold; return block_processor.size (nano::block_source::bootstrap) < config.block_processor_threshold;
}); });
} }
std::shared_ptr<nano::transport::channel> nano::bootstrap_ascending::service::wait_channel () std::shared_ptr<nano::transport::channel> nano::bootstrap_service::wait_channel ()
{ {
std::shared_ptr<nano::transport::channel> channel; std::shared_ptr<nano::transport::channel> channel;
wait ([this, &channel] () { wait ([this, &channel] () {
@ -331,21 +327,21 @@ std::shared_ptr<nano::transport::channel> nano::bootstrap_ascending::service::wa
return channel; return channel;
} }
size_t nano::bootstrap_ascending::service::count_tags (nano::account const & account, query_source source) const size_t nano::bootstrap_service::count_tags (nano::account const & account, query_source source) const
{ {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
auto [begin, end] = tags.get<tag_account> ().equal_range (account); auto [begin, end] = tags.get<tag_account> ().equal_range (account);
return std::count_if (begin, end, [source] (auto const & tag) { return tag.source == source; }); return std::count_if (begin, end, [source] (auto const & tag) { return tag.source == source; });
} }
size_t nano::bootstrap_ascending::service::count_tags (nano::block_hash const & hash, query_source source) const size_t nano::bootstrap_service::count_tags (nano::block_hash const & hash, query_source source) const
{ {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
auto [begin, end] = tags.get<tag_hash> ().equal_range (hash); auto [begin, end] = tags.get<tag_hash> ().equal_range (hash);
return std::count_if (begin, end, [source] (auto const & tag) { return tag.source == source; }); return std::count_if (begin, end, [source] (auto const & tag) { return tag.source == source; });
} }
std::pair<nano::account, double> nano::bootstrap_ascending::service::next_priority () std::pair<nano::account, double> nano::bootstrap_service::next_priority ()
{ {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
@ -362,7 +358,7 @@ std::pair<nano::account, double> nano::bootstrap_ascending::service::next_priori
return { account, accounts.priority (account) }; return { account, accounts.priority (account) };
} }
std::pair<nano::account, double> nano::bootstrap_ascending::service::wait_priority () std::pair<nano::account, double> nano::bootstrap_service::wait_priority ()
{ {
std::pair<nano::account, double> result{ 0, 0 }; std::pair<nano::account, double> result{ 0, 0 };
wait ([this, &result] () { wait ([this, &result] () {
@ -377,7 +373,7 @@ std::pair<nano::account, double> nano::bootstrap_ascending::service::wait_priori
return result; return result;
} }
nano::account nano::bootstrap_ascending::service::next_database (bool should_throttle) nano::account nano::bootstrap_service::next_database (bool should_throttle)
{ {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
debug_assert (config.database_warmup_ratio > 0); debug_assert (config.database_warmup_ratio > 0);
@ -398,7 +394,7 @@ nano::account nano::bootstrap_ascending::service::next_database (bool should_thr
return account; return account;
} }
nano::account nano::bootstrap_ascending::service::wait_database (bool should_throttle) nano::account nano::bootstrap_service::wait_database (bool should_throttle)
{ {
nano::account result{ 0 }; nano::account result{ 0 };
wait ([this, &result, should_throttle] () { wait ([this, &result, should_throttle] () {
@ -413,7 +409,7 @@ nano::account nano::bootstrap_ascending::service::wait_database (bool should_thr
return result; return result;
} }
nano::block_hash nano::bootstrap_ascending::service::next_blocking () nano::block_hash nano::bootstrap_service::next_blocking ()
{ {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
@ -428,7 +424,7 @@ nano::block_hash nano::bootstrap_ascending::service::next_blocking ()
return blocking; return blocking;
} }
nano::block_hash nano::bootstrap_ascending::service::wait_blocking () nano::block_hash nano::bootstrap_service::wait_blocking ()
{ {
nano::block_hash result{ 0 }; nano::block_hash result{ 0 };
wait ([this, &result] () { wait ([this, &result] () {
@ -443,7 +439,7 @@ nano::block_hash nano::bootstrap_ascending::service::wait_blocking ()
return result; return result;
} }
nano::account nano::bootstrap_ascending::service::wait_frontier () nano::account nano::bootstrap_service::wait_frontier ()
{ {
nano::account result{ 0 }; nano::account result{ 0 };
wait ([this, &result] () { wait ([this, &result] () {
@ -459,7 +455,7 @@ nano::account nano::bootstrap_ascending::service::wait_frontier ()
return result; return result;
} }
bool nano::bootstrap_ascending::service::request (nano::account account, size_t count, std::shared_ptr<nano::transport::channel> const & channel, query_source source) bool nano::bootstrap_service::request (nano::account account, size_t count, std::shared_ptr<nano::transport::channel> const & channel, query_source source)
{ {
debug_assert (count > 0); debug_assert (count > 0);
debug_assert (count <= nano::bootstrap_server::max_blocks); debug_assert (count <= nano::bootstrap_server::max_blocks);
@ -511,7 +507,7 @@ bool nano::bootstrap_ascending::service::request (nano::account account, size_t
return send (channel, tag); return send (channel, tag);
} }
bool nano::bootstrap_ascending::service::request_info (nano::block_hash hash, std::shared_ptr<nano::transport::channel> const & channel, query_source source) bool nano::bootstrap_service::request_info (nano::block_hash hash, std::shared_ptr<nano::transport::channel> const & channel, query_source source)
{ {
async_tag tag{}; async_tag tag{};
tag.type = query_type::account_info_by_hash; tag.type = query_type::account_info_by_hash;
@ -521,7 +517,7 @@ bool nano::bootstrap_ascending::service::request_info (nano::block_hash hash, st
return send (channel, tag); return send (channel, tag);
} }
bool nano::bootstrap_ascending::service::request_frontiers (nano::account start, std::shared_ptr<nano::transport::channel> const & channel, query_source source) bool nano::bootstrap_service::request_frontiers (nano::account start, std::shared_ptr<nano::transport::channel> const & channel, query_source source)
{ {
async_tag tag{}; async_tag tag{};
tag.type = query_type::frontiers; tag.type = query_type::frontiers;
@ -530,7 +526,7 @@ bool nano::bootstrap_ascending::service::request_frontiers (nano::account start,
return send (channel, tag); return send (channel, tag);
} }
void nano::bootstrap_ascending::service::run_one_priority () void nano::bootstrap_service::run_one_priority ()
{ {
wait_tags (); wait_tags ();
wait_blockprocessor (); wait_blockprocessor ();
@ -549,7 +545,7 @@ void nano::bootstrap_ascending::service::run_one_priority ()
request (account, count, channel, query_source::priority); request (account, count, channel, query_source::priority);
} }
void nano::bootstrap_ascending::service::run_priorities () void nano::bootstrap_service::run_priorities ()
{ {
nano::unique_lock<nano::mutex> lock{ mutex }; nano::unique_lock<nano::mutex> lock{ mutex };
while (!stopped) while (!stopped)
@ -561,7 +557,7 @@ void nano::bootstrap_ascending::service::run_priorities ()
} }
} }
void nano::bootstrap_ascending::service::run_one_database (bool should_throttle) void nano::bootstrap_service::run_one_database (bool should_throttle)
{ {
wait_tags (); wait_tags ();
wait_blockprocessor (); wait_blockprocessor ();
@ -578,7 +574,7 @@ void nano::bootstrap_ascending::service::run_one_database (bool should_throttle)
request (account, 2, channel, query_source::database); request (account, 2, channel, query_source::database);
} }
void nano::bootstrap_ascending::service::run_database () void nano::bootstrap_service::run_database ()
{ {
nano::unique_lock<nano::mutex> lock{ mutex }; nano::unique_lock<nano::mutex> lock{ mutex };
while (!stopped) while (!stopped)
@ -592,7 +588,7 @@ void nano::bootstrap_ascending::service::run_database ()
} }
} }
void nano::bootstrap_ascending::service::run_one_blocking () void nano::bootstrap_service::run_one_blocking ()
{ {
wait_tags (); wait_tags ();
wait_blockprocessor (); wait_blockprocessor ();
@ -609,7 +605,7 @@ void nano::bootstrap_ascending::service::run_one_blocking ()
request_info (blocking, channel, query_source::blocking); request_info (blocking, channel, query_source::blocking);
} }
void nano::bootstrap_ascending::service::run_dependencies () void nano::bootstrap_service::run_dependencies ()
{ {
nano::unique_lock<nano::mutex> lock{ mutex }; nano::unique_lock<nano::mutex> lock{ mutex };
while (!stopped) while (!stopped)
@ -621,7 +617,7 @@ void nano::bootstrap_ascending::service::run_dependencies ()
} }
} }
void nano::bootstrap_ascending::service::run_one_frontier () void nano::bootstrap_service::run_one_frontier ()
{ {
wait ([this] () { wait ([this] () {
return !accounts.priority_half_full (); return !accounts.priority_half_full ();
@ -646,7 +642,7 @@ void nano::bootstrap_ascending::service::run_one_frontier ()
request_frontiers (frontier, channel, query_source::frontiers); request_frontiers (frontier, channel, query_source::frontiers);
} }
void nano::bootstrap_ascending::service::run_frontiers () void nano::bootstrap_service::run_frontiers ()
{ {
nano::unique_lock<nano::mutex> lock{ mutex }; nano::unique_lock<nano::mutex> lock{ mutex };
while (!stopped) while (!stopped)
@ -658,7 +654,7 @@ void nano::bootstrap_ascending::service::run_frontiers ()
} }
} }
void nano::bootstrap_ascending::service::cleanup_and_sync () void nano::bootstrap_service::cleanup_and_sync ()
{ {
debug_assert (!mutex.try_lock ()); debug_assert (!mutex.try_lock ());
@ -687,7 +683,7 @@ void nano::bootstrap_ascending::service::cleanup_and_sync ()
} }
} }
void nano::bootstrap_ascending::service::run_timeouts () void nano::bootstrap_service::run_timeouts ()
{ {
nano::unique_lock<nano::mutex> lock{ mutex }; nano::unique_lock<nano::mutex> lock{ mutex };
while (!stopped) while (!stopped)
@ -698,7 +694,7 @@ void nano::bootstrap_ascending::service::run_timeouts ()
} }
} }
void nano::bootstrap_ascending::service::process (nano::asc_pull_ack const & message, std::shared_ptr<nano::transport::channel> const & channel) void nano::bootstrap_service::process (nano::asc_pull_ack const & message, std::shared_ptr<nano::transport::channel> const & channel)
{ {
nano::unique_lock<nano::mutex> lock{ mutex }; nano::unique_lock<nano::mutex> lock{ mutex };
@ -759,7 +755,7 @@ void nano::bootstrap_ascending::service::process (nano::asc_pull_ack const & mes
condition.notify_all (); condition.notify_all ();
} }
void nano::bootstrap_ascending::service::process (const nano::asc_pull_ack::blocks_payload & response, const async_tag & tag) void nano::bootstrap_service::process (const nano::asc_pull_ack::blocks_payload & response, const async_tag & tag)
{ {
debug_assert (tag.type == query_type::blocks_by_hash || tag.type == query_type::blocks_by_account); debug_assert (tag.type == query_type::blocks_by_hash || tag.type == query_type::blocks_by_account);
@ -829,7 +825,7 @@ void nano::bootstrap_ascending::service::process (const nano::asc_pull_ack::bloc
} }
} }
void nano::bootstrap_ascending::service::process (const nano::asc_pull_ack::account_info_payload & response, const async_tag & tag) void nano::bootstrap_service::process (const nano::asc_pull_ack::account_info_payload & response, const async_tag & tag)
{ {
debug_assert (tag.type == query_type::account_info_by_hash); debug_assert (tag.type == query_type::account_info_by_hash);
debug_assert (!tag.hash.is_zero ()); debug_assert (!tag.hash.is_zero ());
@ -850,7 +846,7 @@ void nano::bootstrap_ascending::service::process (const nano::asc_pull_ack::acco
} }
} }
void nano::bootstrap_ascending::service::process (const nano::asc_pull_ack::frontiers_payload & response, const async_tag & tag) void nano::bootstrap_service::process (const nano::asc_pull_ack::frontiers_payload & response, const async_tag & tag)
{ {
debug_assert (tag.type == query_type::frontiers); debug_assert (tag.type == query_type::frontiers);
debug_assert (!tag.start.is_zero ()); debug_assert (!tag.start.is_zero ());
@ -902,13 +898,13 @@ void nano::bootstrap_ascending::service::process (const nano::asc_pull_ack::fron
} }
} }
void nano::bootstrap_ascending::service::process (const nano::empty_payload & response, const async_tag & tag) void nano::bootstrap_service::process (const nano::empty_payload & response, const async_tag & tag)
{ {
stats.inc (nano::stat::type::bootstrap_ascending_process, nano::stat::detail::empty); stats.inc (nano::stat::type::bootstrap_ascending_process, nano::stat::detail::empty);
debug_assert (false, "empty payload"); // Should not happen debug_assert (false, "empty payload"); // Should not happen
} }
void nano::bootstrap_ascending::service::process_frontiers (std::deque<std::pair<nano::account, nano::block_hash>> const & frontiers) void nano::bootstrap_service::process_frontiers (std::deque<std::pair<nano::account, nano::block_hash>> const & frontiers)
{ {
release_assert (!frontiers.empty ()); release_assert (!frontiers.empty ());
@ -929,8 +925,8 @@ void nano::bootstrap_ascending::service::process_frontiers (std::deque<std::pair
auto transaction = ledger.tx_begin_read (); auto transaction = ledger.tx_begin_read ();
auto const start = frontiers.front ().first; auto const start = frontiers.front ().first;
account_database_crawler account_crawler{ ledger.store, transaction, start }; nano::bootstrap::account_database_crawler account_crawler{ ledger.store, transaction, start };
pending_database_crawler pending_crawler{ ledger.store, transaction, start }; nano::bootstrap::pending_database_crawler pending_crawler{ ledger.store, transaction, start };
auto block_exists = [&] (nano::block_hash const & hash) { auto block_exists = [&] (nano::block_hash const & hash) {
return ledger.any.block_exists_or_pruned (transaction, hash); return ledger.any.block_exists_or_pruned (transaction, hash);
@ -988,7 +984,7 @@ void nano::bootstrap_ascending::service::process_frontiers (std::deque<std::pair
} }
} }
nano::bootstrap_ascending::service::verify_result nano::bootstrap_ascending::service::verify (const nano::asc_pull_ack::blocks_payload & response, const nano::bootstrap_ascending::service::async_tag & tag) const auto nano::bootstrap_service::verify (const nano::asc_pull_ack::blocks_payload & response, const async_tag & tag) const -> verify_result
{ {
auto const & blocks = response.blocks; auto const & blocks = response.blocks;
@ -1047,7 +1043,7 @@ nano::bootstrap_ascending::service::verify_result nano::bootstrap_ascending::ser
return verify_result::ok; return verify_result::ok;
} }
nano::bootstrap_ascending::service::verify_result nano::bootstrap_ascending::service::verify (nano::asc_pull_ack::frontiers_payload const & response, async_tag const & tag) const auto nano::bootstrap_service::verify (nano::asc_pull_ack::frontiers_payload const & response, async_tag const & tag) const -> verify_result
{ {
auto const & frontiers = response.frontiers; auto const & frontiers = response.frontiers;
@ -1076,13 +1072,13 @@ nano::bootstrap_ascending::service::verify_result nano::bootstrap_ascending::ser
return verify_result::ok; return verify_result::ok;
} }
auto nano::bootstrap_ascending::service::info () const -> nano::bootstrap_ascending::account_sets::info_t auto nano::bootstrap_service::info () const -> nano::bootstrap::account_sets::info_t
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
return accounts.info (); return accounts.info ();
} }
std::size_t nano::bootstrap_ascending::service::compute_throttle_size () const std::size_t nano::bootstrap_service::compute_throttle_size () const
{ {
auto ledger_size = ledger.account_count (); auto ledger_size = ledger.account_count ();
size_t target = ledger_size > 0 ? config.throttle_coefficient * static_cast<size_t> (std::log (ledger_size)) : 0; size_t target = ledger_size > 0 ? config.throttle_coefficient * static_cast<size_t> (std::log (ledger_size)) : 0;
@ -1090,7 +1086,7 @@ std::size_t nano::bootstrap_ascending::service::compute_throttle_size () const
return std::max (target, min_size); return std::max (target, min_size);
} }
nano::container_info nano::bootstrap_ascending::service::container_info () const nano::container_info nano::bootstrap_service::container_info () const
{ {
nano::lock_guard<nano::mutex> lock{ mutex }; nano::lock_guard<nano::mutex> lock{ mutex };
@ -1109,7 +1105,7 @@ nano::container_info nano::bootstrap_ascending::service::container_info () const
* *
*/ */
nano::stat::detail nano::bootstrap_ascending::to_stat_detail (nano::bootstrap_ascending::service::query_type type) nano::stat::detail nano::to_stat_detail (nano::bootstrap_service::query_type type)
{ {
return nano::enum_util::cast<nano::stat::detail> (type); return nano::enum_util::cast<nano::stat::detail> (type);
} }

View file

@ -27,189 +27,189 @@ namespace mi = boost::multi_index;
namespace nano namespace nano
{ {
namespace bootstrap_ascending class bootstrap_service
{ {
class service public:
bootstrap_service (nano::node_config const &, nano::block_processor &, nano::ledger &, nano::network &, nano::stats &, nano::logger &);
~bootstrap_service ();
void start ();
void stop ();
/**
* Process `asc_pull_ack` message coming from network
*/
void process (nano::asc_pull_ack const & message, std::shared_ptr<nano::transport::channel> const &);
std::size_t blocked_size () const;
std::size_t priority_size () const;
std::size_t score_size () const;
bool prioritized (nano::account const &) const;
bool blocked (nano::account const &) const;
nano::container_info container_info () const;
nano::bootstrap::account_sets::info_t info () const;
private: // Dependencies
bootstrap_ascending_config const & config;
nano::network_constants const & network_constants;
nano::block_processor & block_processor;
nano::ledger & ledger;
nano::network & network;
nano::stats & stats;
nano::logger & logger;
public: // Tag
enum class query_type
{ {
public: invalid = 0, // Default initialization
service (nano::node_config const &, nano::block_processor &, nano::ledger &, nano::network &, nano::stats &, nano::logger &); blocks_by_hash,
~service (); blocks_by_account,
account_info_by_hash,
void start (); frontiers,
void stop ();
/**
* Process `asc_pull_ack` message coming from network
*/
void process (nano::asc_pull_ack const & message, std::shared_ptr<nano::transport::channel> const &);
std::size_t blocked_size () const;
std::size_t priority_size () const;
std::size_t score_size () const;
bool prioritized (nano::account const &) const;
bool blocked (nano::account const &) const;
nano::container_info container_info () const;
nano::bootstrap_ascending::account_sets::info_t info () const;
private: // Dependencies
bootstrap_ascending_config const & config;
nano::network_constants const & network_constants;
nano::block_processor & block_processor;
nano::ledger & ledger;
nano::network & network;
nano::stats & stats;
nano::logger & logger;
public: // Tag
enum class query_type
{
invalid = 0, // Default initialization
blocks_by_hash,
blocks_by_account,
account_info_by_hash,
frontiers,
};
enum class query_source
{
invalid,
priority,
database,
blocking,
frontiers,
};
struct async_tag
{
query_type type{ query_type::invalid };
query_source source{ query_source::invalid };
nano::hash_or_account start{ 0 };
nano::account account{ 0 };
nano::block_hash hash{ 0 };
size_t count{ 0 };
id_t id{ generate_id () };
std::chrono::steady_clock::time_point timestamp{ std::chrono::steady_clock::now () };
};
private:
/* Inspects a block that has been processed by the block processor */
void inspect (secure::transaction const &, nano::block_status const & result, nano::block const & block, nano::block_source);
void run_priorities ();
void run_one_priority ();
void run_database ();
void run_one_database (bool should_throttle);
void run_dependencies ();
void run_one_blocking ();
void run_one_frontier ();
void run_frontiers ();
void run_timeouts ();
void cleanup_and_sync ();
/* Waits for a condition to be satisfied with incremental backoff */
void wait (std::function<bool ()> const & predicate) const;
/* Avoid too many in-flight requests */
void wait_tags () const;
/* Ensure there is enough space in blockprocessor for queuing new blocks */
void wait_blockprocessor () const;
/* Waits for a channel that is not full */
std::shared_ptr<nano::transport::channel> wait_channel ();
/* Waits until a suitable account outside of cool down period is available */
std::pair<nano::account, double> next_priority ();
std::pair<nano::account, double> wait_priority ();
/* Gets the next account from the database */
nano::account next_database (bool should_throttle);
nano::account wait_database (bool should_throttle);
/* Waits for next available blocking block */
nano::block_hash next_blocking ();
nano::block_hash wait_blocking ();
/* Waits for next available frontier scan range */
nano::account wait_frontier ();
bool request (nano::account, size_t count, std::shared_ptr<nano::transport::channel> const &, query_source);
bool request_info (nano::block_hash, std::shared_ptr<nano::transport::channel> const &, query_source);
bool request_frontiers (nano::account, std::shared_ptr<nano::transport::channel> const &, query_source);
bool send (std::shared_ptr<nano::transport::channel> const &, async_tag tag);
void process (nano::asc_pull_ack::blocks_payload const & response, async_tag const & tag);
void process (nano::asc_pull_ack::account_info_payload const & response, async_tag const & tag);
void process (nano::asc_pull_ack::frontiers_payload const & response, async_tag const & tag);
void process (nano::empty_payload const & response, async_tag const & tag);
void process_frontiers (std::deque<std::pair<nano::account, nano::block_hash>> const & frontiers);
enum class verify_result
{
ok,
nothing_new,
invalid,
};
/**
* Verifies whether the received response is valid. Returns:
* - invalid: when received blocks do not correspond to requested hash/account or they do not make a valid chain
* - nothing_new: when received response indicates that the account chain does not have more blocks
* - ok: otherwise, if all checks pass
*/
verify_result verify (nano::asc_pull_ack::blocks_payload const & response, async_tag const & tag) const;
verify_result verify (nano::asc_pull_ack::frontiers_payload const & response, async_tag const & tag) const;
size_t count_tags (nano::account const & account, query_source source) const;
size_t count_tags (nano::block_hash const & hash, query_source source) const;
// Calculates a lookback size based on the size of the ledger where larger ledgers have a larger sample count
std::size_t compute_throttle_size () const;
private:
nano::bootstrap_ascending::account_sets accounts;
nano::bootstrap_ascending::database_scan database_scan;
nano::bootstrap_ascending::throttle throttle;
nano::bootstrap_ascending::peer_scoring scoring;
nano::bootstrap_ascending::frontier_scan frontiers;
// clang-format off
class tag_sequenced {};
class tag_id {};
class tag_account {};
class tag_hash {};
using ordered_tags = boost::multi_index_container<async_tag,
mi::indexed_by<
mi::sequenced<mi::tag<tag_sequenced>>,
mi::hashed_unique<mi::tag<tag_id>,
mi::member<async_tag, nano::bootstrap_ascending::id_t, &async_tag::id>>,
mi::hashed_non_unique<mi::tag<tag_account>,
mi::member<async_tag, nano::account , &async_tag::account>>,
mi::hashed_non_unique<mi::tag<tag_hash>,
mi::member<async_tag, nano::block_hash, &async_tag::hash>>
>>;
// clang-format on
ordered_tags tags;
// Requests for accounts from database have much lower hitrate and could introduce strain on the network
// A separate (lower) limiter ensures that we always reserve resources for querying accounts from priority queue
nano::rate_limiter database_limiter;
nano::rate_limiter frontiers_limiter;
nano::interval sync_dependencies_interval;
bool stopped{ false };
mutable nano::mutex mutex;
mutable nano::condition_variable condition;
std::thread priorities_thread;
std::thread database_thread;
std::thread dependencies_thread;
std::thread frontiers_thread;
std::thread timeout_thread;
nano::thread_pool workers;
nano::random_generator_mt rng;
}; };
nano::stat::detail to_stat_detail (service::query_type); enum class query_source
} {
invalid,
priority,
database,
blocking,
frontiers,
};
struct async_tag
{
using id_t = nano::bootstrap::id_t;
query_type type{ query_type::invalid };
query_source source{ query_source::invalid };
nano::hash_or_account start{ 0 };
nano::account account{ 0 };
nano::block_hash hash{ 0 };
size_t count{ 0 };
id_t id{ nano::bootstrap::generate_id () };
std::chrono::steady_clock::time_point timestamp{ std::chrono::steady_clock::now () };
};
private:
/* Inspects a block that has been processed by the block processor */
void inspect (secure::transaction const &, nano::block_status const & result, nano::block const & block, nano::block_source);
void run_priorities ();
void run_one_priority ();
void run_database ();
void run_one_database (bool should_throttle);
void run_dependencies ();
void run_one_blocking ();
void run_one_frontier ();
void run_frontiers ();
void run_timeouts ();
void cleanup_and_sync ();
/* Waits for a condition to be satisfied with incremental backoff */
void wait (std::function<bool ()> const & predicate) const;
/* Avoid too many in-flight requests */
void wait_tags () const;
/* Ensure there is enough space in blockprocessor for queuing new blocks */
void wait_blockprocessor () const;
/* Waits for a channel that is not full */
std::shared_ptr<nano::transport::channel> wait_channel ();
/* Waits until a suitable account outside of cool down period is available */
std::pair<nano::account, double> next_priority ();
std::pair<nano::account, double> wait_priority ();
/* Gets the next account from the database */
nano::account next_database (bool should_throttle);
nano::account wait_database (bool should_throttle);
/* Waits for next available blocking block */
nano::block_hash next_blocking ();
nano::block_hash wait_blocking ();
/* Waits for next available frontier scan range */
nano::account wait_frontier ();
bool request (nano::account, size_t count, std::shared_ptr<nano::transport::channel> const &, query_source);
bool request_info (nano::block_hash, std::shared_ptr<nano::transport::channel> const &, query_source);
bool request_frontiers (nano::account, std::shared_ptr<nano::transport::channel> const &, query_source);
bool send (std::shared_ptr<nano::transport::channel> const &, async_tag tag);
void process (nano::asc_pull_ack::blocks_payload const & response, async_tag const & tag);
void process (nano::asc_pull_ack::account_info_payload const & response, async_tag const & tag);
void process (nano::asc_pull_ack::frontiers_payload const & response, async_tag const & tag);
void process (nano::empty_payload const & response, async_tag const & tag);
void process_frontiers (std::deque<std::pair<nano::account, nano::block_hash>> const & frontiers);
enum class verify_result
{
ok,
nothing_new,
invalid,
};
/**
* Verifies whether the received response is valid. Returns:
* - invalid: when received blocks do not correspond to requested hash/account or they do not make a valid chain
* - nothing_new: when received response indicates that the account chain does not have more blocks
* - ok: otherwise, if all checks pass
*/
verify_result verify (nano::asc_pull_ack::blocks_payload const & response, async_tag const & tag) const;
verify_result verify (nano::asc_pull_ack::frontiers_payload const & response, async_tag const & tag) const;
size_t count_tags (nano::account const & account, query_source source) const;
size_t count_tags (nano::block_hash const & hash, query_source source) const;
// Calculates a lookback size based on the size of the ledger where larger ledgers have a larger sample count
std::size_t compute_throttle_size () const;
private:
nano::bootstrap::account_sets accounts;
nano::bootstrap::database_scan database_scan;
nano::bootstrap::throttle throttle;
nano::bootstrap::peer_scoring scoring;
nano::bootstrap::frontier_scan frontiers;
// clang-format off
class tag_sequenced {};
class tag_id {};
class tag_account {};
class tag_hash {};
using ordered_tags = boost::multi_index_container<async_tag,
mi::indexed_by<
mi::sequenced<mi::tag<tag_sequenced>>,
mi::hashed_unique<mi::tag<tag_id>,
mi::member<async_tag, nano::bootstrap::id_t, &async_tag::id>>,
mi::hashed_non_unique<mi::tag<tag_account>,
mi::member<async_tag, nano::account , &async_tag::account>>,
mi::hashed_non_unique<mi::tag<tag_hash>,
mi::member<async_tag, nano::block_hash, &async_tag::hash>>
>>;
// clang-format on
ordered_tags tags;
// Requests for accounts from database have much lower hitrate and could introduce strain on the network
// A separate (lower) limiter ensures that we always reserve resources for querying accounts from priority queue
nano::rate_limiter database_limiter;
nano::rate_limiter frontiers_limiter;
nano::interval sync_dependencies_interval;
bool stopped{ false };
mutable nano::mutex mutex;
mutable nano::condition_variable condition;
std::thread priorities_thread;
std::thread database_thread;
std::thread dependencies_thread;
std::thread frontiers_thread;
std::thread timeout_thread;
nano::thread_pool workers;
nano::random_generator_mt rng;
};
nano::stat::detail to_stat_detail (bootstrap_service::query_type);
} }

View file

@ -1,19 +1,19 @@
#include <nano/lib/utility.hpp> #include <nano/lib/utility.hpp>
#include <nano/node/bootstrap/throttle.hpp> #include <nano/node/bootstrap/throttle.hpp>
nano::bootstrap_ascending::throttle::throttle (std::size_t size) : nano::bootstrap::throttle::throttle (std::size_t size) :
successes_m{ size } successes_m{ size }
{ {
samples.insert (samples.end (), size, true); samples.insert (samples.end (), size, true);
debug_assert (size > 0); debug_assert (size > 0);
} }
bool nano::bootstrap_ascending::throttle::throttled () const bool nano::bootstrap::throttle::throttled () const
{ {
return successes_m == 0; return successes_m == 0;
} }
void nano::bootstrap_ascending::throttle::add (bool sample) void nano::bootstrap::throttle::add (bool sample)
{ {
debug_assert (!samples.empty ()); debug_assert (!samples.empty ());
pop (); pop ();
@ -24,7 +24,7 @@ void nano::bootstrap_ascending::throttle::add (bool sample)
} }
} }
void nano::bootstrap_ascending::throttle::resize (std::size_t size) void nano::bootstrap::throttle::resize (std::size_t size)
{ {
debug_assert (size > 0); debug_assert (size > 0);
while (size < samples.size ()) while (size < samples.size ())
@ -37,17 +37,17 @@ void nano::bootstrap_ascending::throttle::resize (std::size_t size)
} }
} }
std::size_t nano::bootstrap_ascending::throttle::size () const std::size_t nano::bootstrap::throttle::size () const
{ {
return samples.size (); return samples.size ();
} }
std::size_t nano::bootstrap_ascending::throttle::successes () const std::size_t nano::bootstrap::throttle::successes () const
{ {
return successes_m; return successes_m;
} }
void nano::bootstrap_ascending::throttle::pop () void nano::bootstrap::throttle::pop ()
{ {
if (samples.front ()) if (samples.front ())
{ {

View file

@ -2,7 +2,7 @@
#include <deque> #include <deque>
namespace nano::bootstrap_ascending namespace nano::bootstrap
{ {
// Class used to throttle the ascending bootstrapper once it reaches a steady state // Class used to throttle the ascending bootstrapper once it reaches a steady state
// Tracks verify_result samples and signals throttling if no tracked samples have gotten results // Tracks verify_result samples and signals throttling if no tracked samples have gotten results
@ -26,4 +26,4 @@ private:
std::deque<bool> samples; std::deque<bool> samples;
std::size_t successes_m; std::size_t successes_m;
}; };
} // nano::boostrap_ascending }

View file

@ -16,6 +16,8 @@ namespace nano
{ {
class active_elections; class active_elections;
class block_processor; class block_processor;
class bootstrap_server;
class bootstrap_service;
class confirming_set; class confirming_set;
class election; class election;
class ledger; class ledger;

View file

@ -151,7 +151,7 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
wallets (wallets_store.init_error (), *this), wallets (wallets_store.init_error (), *this),
backlog_impl{ std::make_unique<nano::backlog_population> (config.backlog_population, scheduler, ledger, stats) }, backlog_impl{ std::make_unique<nano::backlog_population> (config.backlog_population, scheduler, ledger, stats) },
backlog{ *backlog_impl }, backlog{ *backlog_impl },
ascendboot_impl{ std::make_unique<nano::bootstrap_ascending::service> (config, block_processor, ledger, network, stats, logger) }, ascendboot_impl{ std::make_unique<nano::bootstrap_service> (config, block_processor, ledger, network, stats, logger) },
ascendboot{ *ascendboot_impl }, ascendboot{ *ascendboot_impl },
websocket{ config.websocket_config, observers, wallets, ledger, io_ctx, logger }, websocket{ config.websocket_config, observers, wallets, ledger, io_ctx, logger },
epoch_upgrader{ *this, ledger, store, network_params, logger }, epoch_upgrader{ *this, ledger, store, network_params, logger },

View file

@ -58,10 +58,6 @@ namespace transport
{ {
class tcp_listener; class tcp_listener;
} }
namespace bootstrap_ascending
{
class service;
}
namespace rocksdb namespace rocksdb
{ {
} // Declare a namespace rocksdb inside nano so all references to the rocksdb library need to be globally scoped e.g. ::rocksdb::Slice } // Declare a namespace rocksdb inside nano so all references to the rocksdb library need to be globally scoped e.g. ::rocksdb::Slice
@ -214,8 +210,8 @@ public:
nano::wallets wallets; nano::wallets wallets;
std::unique_ptr<nano::backlog_population> backlog_impl; std::unique_ptr<nano::backlog_population> backlog_impl;
nano::backlog_population & backlog; nano::backlog_population & backlog;
std::unique_ptr<nano::bootstrap_ascending::service> ascendboot_impl; std::unique_ptr<nano::bootstrap_service> ascendboot_impl;
nano::bootstrap_ascending::service & ascendboot; nano::bootstrap_service & ascendboot;
nano::websocket_server websocket; nano::websocket_server websocket;
nano::epoch_upgrader epoch_upgrader; nano::epoch_upgrader epoch_upgrader;
std::unique_ptr<nano::local_block_broadcaster> local_block_broadcaster_impl; std::unique_ptr<nano::local_block_broadcaster> local_block_broadcaster_impl;