diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index c5b5faa218..815f1fc357 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -3254,45 +3254,6 @@ TEST (node, peer_cache_restart) } } -TEST (node, unchecked_cleanup) -{ - nano::test::system system{}; - nano::node_flags node_flags{}; - node_flags.disable_unchecked_cleanup = true; - nano::keypair key{}; - auto & node = *system.add_node (node_flags); - auto open = nano::state_block_builder () - .account (key.pub) - .previous (0) - .representative (key.pub) - .balance (1) - .link (key.pub) - .sign (key.prv, key.pub) - .work (*system.work.generate (key.pub)) - .build_shared (); - std::vector bytes; - { - nano::vectorstream stream (bytes); - open->serialize (stream); - } - // Add to the blocks filter - // Should be cleared after unchecked cleanup - ASSERT_FALSE (node.network.publish_filter.apply (bytes.data (), bytes.size ())); - node.process_active (open); - // Waits for the open block to get saved in the database - ASSERT_TIMELY_EQ (15s, 1, node.unchecked.count ()); - node.config.unchecked_cutoff_time = std::chrono::seconds (2); - ASSERT_EQ (1, node.unchecked.count ()); - std::this_thread::sleep_for (std::chrono::seconds (1)); - node.unchecked_cleanup (); - ASSERT_TRUE (node.network.publish_filter.apply (bytes.data (), bytes.size ())); - ASSERT_EQ (1, node.unchecked.count ()); - std::this_thread::sleep_for (std::chrono::seconds (2)); - node.unchecked_cleanup (); - ASSERT_FALSE (node.network.publish_filter.apply (bytes.data (), bytes.size ())); - ASSERT_EQ (0, node.unchecked.count ()); -} - /** This checks that a node can be opened (without being blocked) when a write lock is held elsewhere */ TEST (node, dont_write_lock_node) { diff --git a/nano/node/bootstrap/bootstrap_legacy.cpp b/nano/node/bootstrap/bootstrap_legacy.cpp index 25605c91b5..446d094646 100644 --- a/nano/node/bootstrap/bootstrap_legacy.cpp +++ b/nano/node/bootstrap/bootstrap_legacy.cpp @@ -244,10 +244,6 @@ void nano::bootstrap_attempt_legacy::run () { request_push (lock); } - if (!stopped) - { - node->unchecked_cleanup (); - } } lock.unlock (); stop (); diff --git a/nano/node/cli.cpp b/nano/node/cli.cpp index ce9369fc14..bc829fcbb5 100644 --- a/nano/node/cli.cpp +++ b/nano/node/cli.cpp @@ -131,8 +131,6 @@ std::error_code nano::update_flags (nano::node_flags & flags_a, boost::program_o flags_a.disable_bootstrap_listener = (vm.count ("disable_bootstrap_listener") > 0); } flags_a.disable_providing_telemetry_metrics = (vm.count ("disable_providing_telemetry_metrics") > 0); - flags_a.disable_unchecked_cleanup = (vm.count ("disable_unchecked_cleanup") > 0); - flags_a.disable_unchecked_drop = (vm.count ("disable_unchecked_drop") > 0); flags_a.disable_block_processor_unchecked_deletion = (vm.count ("disable_block_processor_unchecked_deletion") > 0); flags_a.enable_pruning = (vm.count ("enable_pruning") > 0); flags_a.allow_bootstrap_peers_duplicates = (vm.count ("allow_bootstrap_peers_duplicates") > 0); diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 52ab7f1afd..399fe821b9 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -433,13 +433,6 @@ nano::node::node (boost::asio::io_context & io_ctx_a, std::filesystem::path cons logger.info (nano::log::type::node, "************************************ ================= ************************************"); } - - // Drop unchecked blocks if initial bootstrap is completed - if (!flags.disable_unchecked_drop && !use_bootstrap_weight && !flags.read_only) - { - logger.info (nano::log::type::node, "Dropping unchecked blocks..."); - unchecked.clear (); - } } ledger.pruning = flags.enable_pruning || store.pruned.count (store.tx_begin_read ()) > 0; @@ -610,13 +603,6 @@ void nano::node::start () { ongoing_bootstrap (); } - if (!flags.disable_unchecked_cleanup) - { - auto this_l (shared ()); - workers.push_task ([this_l] () { - this_l->ongoing_unchecked_cleanup (); - }); - } if (flags.enable_pruning) { auto this_l (shared ()); @@ -947,56 +933,6 @@ void nano::node::bootstrap_wallet () } } -void nano::node::unchecked_cleanup () -{ - std::vector digests; - std::deque cleaning_list; - auto const attempt (bootstrap_initiator.current_attempt ()); - const bool long_attempt (attempt != nullptr && std::chrono::duration_cast (std::chrono::steady_clock::now () - attempt->attempt_start).count () > config.unchecked_cutoff_time.count ()); - // Collect old unchecked keys - if (ledger.cache.block_count >= ledger.bootstrap_weight_max_blocks && !long_attempt) - { - auto const now (nano::seconds_since_epoch ()); - auto const transaction (store.tx_begin_read ()); - // Max 1M records to clean, max 2 minutes reading to prevent slow i/o systems issues - unchecked.for_each ( - [this, &digests, &cleaning_list, &now] (nano::unchecked_key const & key, nano::unchecked_info const & info) { - if ((now - info.modified ()) > static_cast (config.unchecked_cutoff_time.count ())) - { - digests.push_back (network.publish_filter.hash (info.block)); - cleaning_list.push_back (key); - } }, [iterations = 0, count = 1024 * 1024] () mutable { return iterations++ < count; }); - } - if (!cleaning_list.empty ()) - { - logger.info (nano::log::type::node, "Deleting {} old unchecked blocks", cleaning_list.size ()); - } - // Delete old unchecked keys in batches - while (!cleaning_list.empty ()) - { - std::size_t deleted_count (0); - while (deleted_count++ < 2 * 1024 && !cleaning_list.empty ()) - { - auto key (cleaning_list.front ()); - cleaning_list.pop_front (); - if (unchecked.exists (key)) - { - unchecked.del (key); - } - } - } - // Delete from the duplicate filter - network.publish_filter.clear (digests); -} - -void nano::node::ongoing_unchecked_cleanup () -{ - unchecked_cleanup (); - workers.add_timed_task (std::chrono::steady_clock::now () + network_params.node.unchecked_cleaning_interval, [this_l = shared ()] () { - this_l->ongoing_unchecked_cleanup (); - }); -} - bool nano::node::collect_ledger_pruning_targets (std::deque & pruning_targets_a, nano::account & last_account_a, uint64_t const batch_read_size_a, uint64_t const max_depth_a, uint64_t const cutoff_time_a) { uint64_t read_operations (0); diff --git a/nano/node/node.hpp b/nano/node/node.hpp index 65d85830f0..dcdffdcf8d 100644 --- a/nano/node/node.hpp +++ b/nano/node/node.hpp @@ -101,11 +101,9 @@ class node final : public std::enable_shared_from_this void ongoing_rep_calculation (); void ongoing_bootstrap (); void ongoing_peer_store (); - void ongoing_unchecked_cleanup (); void backup_wallet (); void search_receivable_all (); void bootstrap_wallet (); - void unchecked_cleanup (); bool collect_ledger_pruning_targets (std::deque &, nano::account &, uint64_t const, uint64_t const, uint64_t const); void ledger_pruning (uint64_t const, bool); void ongoing_ledger_pruning (); diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index c4f8a9693b..d1a42fa370 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -152,8 +152,6 @@ class node_flags final bool disable_rep_crawler{ false }; bool disable_request_loop{ false }; // For testing only bool disable_tcp_realtime{ false }; - bool disable_unchecked_cleanup{ false }; - bool disable_unchecked_drop{ true }; bool disable_providing_telemetry_metrics{ false }; bool disable_ongoing_telemetry_requests{ false }; bool disable_block_processor_unchecked_deletion{ false };