Skip to content

Commit

Permalink
Bounded backlog
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 18, 2024
1 parent edab45c commit 7824d81
Show file tree
Hide file tree
Showing 18 changed files with 774 additions and 1 deletion.
21 changes: 21 additions & 0 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/ledger_set_confirmed.hpp>
#include <nano/secure/vote.hpp>
#include <nano/test_common/chains.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down Expand Up @@ -3698,3 +3699,23 @@ TEST (node, container_info)
ASSERT_NO_THROW (node1.container_info ());
ASSERT_NO_THROW (node2.container_info ());
}

TEST (node, bounded_backlog)
{
nano::test::system system;

nano::node_config node_config;
node_config.backlog.max_backlog = 10;
node_config.backlog.bucket_threshold = 2;
node_config.backlog_scan.enable = false;
auto & node = *system.add_node (node_config);

const int howmany_blocks = 64;
const int howmany_chains = 16;

auto chains = nano::test::setup_chains (system, node, howmany_chains, howmany_blocks, nano::dev::genesis_key, /* do not confirm */ false);

node.backlog_scan.trigger ();

ASSERT_TIMELY_EQ (20s, node.ledger.block_count (), 11); // 10 + genesis
}
1 change: 1 addition & 0 deletions nano/lib/logging_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ enum class type
local_block_broadcaster,
monitor,
confirming_set,
bounded_backlog,

// bootstrap
bulk_pull_client,
Expand Down
9 changes: 9 additions & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ enum class type
active_elections_cancelled,
active_elections_cemented,
backlog_scan,
bounded_backlog,
backlog,
unchecked,
election_scheduler,
Expand Down Expand Up @@ -563,6 +564,14 @@ enum class detail
blocks_by_account,
account_info_by_hash,

// bounded backlog,
gathered_targets,
performing_rollbacks,
no_targets,
rollback_missing_block,
rollback_skipped,
loop_scan,

_last // Must be the last enum
};

Expand Down
9 changes: 9 additions & 0 deletions nano/lib/thread_roles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ std::string nano::thread_role::get_string (nano::thread_role::name role)
case nano::thread_role::name::backlog_scan:
thread_role_name_string = "Backlog scan";
break;
case nano::thread_role::name::bounded_backlog:
thread_role_name_string = "Bounded backlog";
break;
case nano::thread_role::name::bounded_backlog_scan:
thread_role_name_string = "Bounded b scan";
break;
case nano::thread_role::name::bounded_backlog_notifications:
thread_role_name_string = "Bounded b notif";
break;
case nano::thread_role::name::vote_generator_queue:
thread_role_name_string = "Voting que";
break;
Expand Down
3 changes: 3 additions & 0 deletions nano/lib/thread_roles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ enum class name
db_parallel_traversal,
unchecked,
backlog_scan,
bounded_backlog,
bounded_backlog_scan,
bounded_backlog_notifications,
vote_generator_queue,
telemetry,
bootstrap,
Expand Down
2 changes: 2 additions & 0 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ add_library(
blockprocessor.cpp
bucketing.hpp
bucketing.cpp
bounded_backlog.hpp
bounded_backlog.cpp
bootstrap_weights_beta.hpp
bootstrap_weights_live.hpp
bootstrap/account_sets.hpp
Expand Down
10 changes: 10 additions & 0 deletions nano/node/bootstrap/bootstrap_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ nano::bootstrap_service::bootstrap_service (nano::node_config const & node_confi
condition.notify_all ();
});

// Unblock rolled back accounts as the dependency is no longer valid
block_processor.rolled_back.add ([this] (auto const & blocks, auto const & rollback_root) {
nano::lock_guard<nano::mutex> lock{ mutex };
for (auto const & block : blocks)
{
debug_assert (block != nullptr);
accounts.unblock (block->account ());
}
});

accounts.priority_set (node_config_a.network_params.ledger.genesis->account_field ().value ());
}

Expand Down
Loading

0 comments on commit 7824d81

Please sign in to comment.