Skip to content

Commit

Permalink
Merge pull request #4790 from pwojcikdev/backlog-scan-reworks
Browse files Browse the repository at this point in the history
Backlog scan refactoring
  • Loading branch information
pwojcikdev authored Nov 27, 2024
2 parents b946549 + 59b0532 commit 238a7fa
Show file tree
Hide file tree
Showing 37 changed files with 472 additions and 321 deletions.
24 changes: 12 additions & 12 deletions nano/core_test/active_elections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ TEST (active_elections, DISABLED_keep_local)
// Bound to 2, won't drop wallet created transactions, but good to test dropping remote
node_config.active_elections.size = 2;
// Disable frontier confirmation to allow the test to finish before
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;

auto & node = *system.add_node (node_config);
auto & wallet (*system.wallet (0));
Expand Down Expand Up @@ -330,7 +330,7 @@ TEST (inactive_votes_cache, existing_vote)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node = *system.add_node (node_config);
nano::block_hash latest (node.latest (nano::dev::genesis_key.pub));
nano::keypair key;
Expand Down Expand Up @@ -384,7 +384,7 @@ TEST (inactive_votes_cache, multiple_votes)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node = *system.add_node (node_config);
nano::keypair key1;
nano::block_builder builder;
Expand Down Expand Up @@ -437,7 +437,7 @@ TEST (inactive_votes_cache, election_start)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
node_config.priority_scheduler.enable = false;
node_config.optimistic_scheduler.enable = false;
auto & node = *system.add_node (node_config);
Expand Down Expand Up @@ -543,7 +543,7 @@ TEST (active_elections, vote_replays)
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.enable_voting = false;
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node = *system.add_node (node_config);
nano::keypair key;
nano::state_block_builder builder;
Expand Down Expand Up @@ -699,7 +699,7 @@ TEST (active_elections, republish_winner)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node1 = *system.add_node (node_config);
node_config.peering_port = system.get_available_port ();
auto & node2 = *system.add_node (node_config);
Expand Down Expand Up @@ -765,7 +765,7 @@ TEST (active_elections, fork_filter_cleanup)
nano::test::system system{};

nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;

auto & node1 = *system.add_node (node_config);
nano::keypair key{};
Expand Down Expand Up @@ -846,7 +846,7 @@ TEST (active_elections, fork_replacement_tally)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node1 (*system.add_node (node_config));

size_t const reps_count = 20;
Expand Down Expand Up @@ -1003,7 +1003,7 @@ TEST (active_elections, confirmation_consistency)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node = *system.add_node (node_config);
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
for (unsigned i = 0; i < 10; ++i)
Expand Down Expand Up @@ -1095,7 +1095,7 @@ TEST (active_elections, activate_account_chain)
nano::test::system system;
nano::node_flags flags;
nano::node_config config = system.default_config ();
config.backlog_population.enable = false;
config.backlog_scan.enable = false;
auto & node = *system.add_node (config, flags);

nano::keypair key;
Expand Down Expand Up @@ -1187,7 +1187,7 @@ TEST (active_elections, activate_inactive)
nano::test::system system;
nano::node_flags flags;
nano::node_config config = system.default_config ();
config.backlog_population.enable = false;
config.backlog_scan.enable = false;
auto & node = *system.add_node (config, flags);

nano::keypair key;
Expand Down Expand Up @@ -1337,7 +1337,7 @@ TEST (active_elections, limit_vote_hinted_elections)
nano::test::system system;
nano::node_config config = system.default_config ();
const int aec_limit = 10;
config.backlog_population.enable = false;
config.backlog_scan.enable = false;
config.optimistic_scheduler.enable = false;
config.active_elections.size = aec_limit;
config.active_elections.hinted_limit_percentage = 10; // Should give us a limit of 1 hinted election
Expand Down
8 changes: 5 additions & 3 deletions nano/core_test/backlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ TEST (backlog, population)
nano::test::system system{};
auto & node = *system.add_node ();

node.backlog.activate_callback.add ([&] (nano::secure::transaction const & transaction, nano::account const & account) {
node.backlog_scan.batch_activated.add ([&] (auto const & batch) {
nano::lock_guard<nano::mutex> lock{ mutex };

activated.insert (account);
for (auto const & info : batch)
{
activated.insert (info.account);
}
});

auto blocks = nano::test::setup_independent_blocks (system, node, 256);
Expand Down
6 changes: 3 additions & 3 deletions nano/core_test/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ TEST (bootstrap, frontier_scan)
config.bootstrap.enable_scan = false;
config.bootstrap.enable_dependency_walker = false;
// Disable election activation
config.backlog_population.enable = false;
config.backlog_scan.enable = false;
config.priority_scheduler.enable = false;
config.optimistic_scheduler.enable = false;
config.hinted_scheduler.enable = false;
Expand Down Expand Up @@ -395,7 +395,7 @@ TEST (bootstrap, frontier_scan_pending)
config.bootstrap.enable_scan = false;
config.bootstrap.enable_dependency_walker = false;
// Disable election activation
config.backlog_population.enable = false;
config.backlog_scan.enable = false;
config.priority_scheduler.enable = false;
config.optimistic_scheduler.enable = false;
config.hinted_scheduler.enable = false;
Expand Down Expand Up @@ -477,7 +477,7 @@ TEST (bootstrap, frontier_scan_cannot_prioritize)
config.bootstrap.enable_scan = false;
config.bootstrap.enable_dependency_walker = false;
// Disable election activation
config.backlog_population.enable = false;
config.backlog_scan.enable = false;
config.priority_scheduler.enable = false;
config.optimistic_scheduler.enable = false;
config.hinted_scheduler.enable = false;
Expand Down
6 changes: 3 additions & 3 deletions nano/core_test/confirming_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TEST (confirmation_callback, observer_callbacks)
nano::test::system system;
nano::node_flags node_flags;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto node = system.add_node (node_config, node_flags);

system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
Expand Down Expand Up @@ -145,7 +145,7 @@ TEST (confirmation_callback, confirmed_history)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
node_config.bootstrap.enable = false;
auto node = system.add_node (node_config);

Expand Down Expand Up @@ -217,7 +217,7 @@ TEST (confirmation_callback, dependent_election)
nano::test::system system;
nano::node_flags node_flags;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto node = system.add_node (node_config, node_flags);

nano::block_hash latest (node->latest (nano::dev::genesis_key.pub));
Expand Down
10 changes: 5 additions & 5 deletions nano/core_test/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST (election, quorum_minimum_flip_success)

nano::node_config node_config = system.default_config ();
node_config.online_weight_minimum = nano::dev::constants.genesis_amount;
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;

auto & node1 = *system.add_node (node_config);
auto const latest_hash = nano::dev::genesis->hash ();
Expand Down Expand Up @@ -86,7 +86,7 @@ TEST (election, quorum_minimum_flip_fail)
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.online_weight_minimum = nano::dev::constants.genesis_amount;
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node = *system.add_node (node_config);
nano::state_block_builder builder;

Expand Down Expand Up @@ -137,7 +137,7 @@ TEST (election, quorum_minimum_confirm_success)
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.online_weight_minimum = nano::dev::constants.genesis_amount;
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node1 = *system.add_node (node_config);
nano::keypair key1;
nano::block_builder builder;
Expand Down Expand Up @@ -167,7 +167,7 @@ TEST (election, quorum_minimum_confirm_fail)
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.online_weight_minimum = nano::dev::constants.genesis_amount;
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node1 = *system.add_node (node_config);

nano::block_builder builder;
Expand Down Expand Up @@ -205,7 +205,7 @@ TEST (election, quorum_minimum_update_weight_before_quorum_checks)
nano::test::system system;

nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;

auto & node1 = *system.add_node (node_config);
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/election_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ TEST (election_scheduler, no_vacancy)

nano::node_config config = system.default_config ();
config.active_elections.size = 1;
config.backlog_population.enable = false;
config.backlog_scan.enable = false;
auto & node = *system.add_node (config);

nano::state_block_builder builder{};
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ TEST (votes, add_existing)
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.online_weight_minimum = nano::dev::constants.genesis_amount;
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node1 = *system.add_node (node_config);
nano::keypair key1;
nano::block_builder builder;
Expand Down Expand Up @@ -4267,7 +4267,7 @@ TEST (ledger, unchecked_epoch_invalid)
{
nano::test::system system;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto & node1 (*system.add_node (node_config));
nano::keypair destination;
nano::block_builder builder;
Expand Down
8 changes: 4 additions & 4 deletions nano/core_test/ledger_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ TEST (ledger_confirm, multiple_accounts)
nano::test::system system;
nano::node_flags node_flags;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto node = system.add_node (node_config, node_flags);
nano::keypair key1;
nano::keypair key2;
Expand Down Expand Up @@ -232,7 +232,7 @@ TEST (ledger_confirm, send_receive_between_2_accounts)
nano::test::system system;
nano::node_flags node_flags;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto node = system.add_node (node_config, node_flags);
nano::keypair key1;
nano::block_hash latest (node->latest (nano::dev::genesis_key.pub));
Expand Down Expand Up @@ -361,7 +361,7 @@ TEST (ledger_confirm, send_receive_self)
nano::test::system system;
nano::node_flags node_flags;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto node = system.add_node (node_config, node_flags);
nano::block_hash latest (node->latest (nano::dev::genesis_key.pub));

Expand Down Expand Up @@ -449,7 +449,7 @@ TEST (ledger_confirm, all_block_types)
nano::test::system system;
nano::node_flags node_flags;
nano::node_config node_config = system.default_config ();
node_config.backlog_population.enable = false;
node_config.backlog_scan.enable = false;
auto node = system.add_node (node_config, node_flags);
nano::block_hash latest (node->latest (nano::dev::genesis_key.pub));
nano::keypair key1;
Expand Down
Loading

0 comments on commit 238a7fa

Please sign in to comment.