From 14474cb56b7815bf9fce9f937d3c455707b407da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:55:27 +0200 Subject: [PATCH 1/3] Proper block processor queue size check --- nano/node/bootstrap/bootstrap_bulk_pull.cpp | 2 +- nano/node/bootstrap/bootstrap_bulk_push.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nano/node/bootstrap/bootstrap_bulk_pull.cpp b/nano/node/bootstrap/bootstrap_bulk_pull.cpp index 2e2b585618..50b43469a0 100644 --- a/nano/node/bootstrap/bootstrap_bulk_pull.cpp +++ b/nano/node/bootstrap/bootstrap_bulk_pull.cpp @@ -120,7 +120,7 @@ void nano::bulk_pull_client::throttled_receive_block () return; } debug_assert (!network_error); - if (!node->block_processor.half_full () && !node->block_processor.flushing) + if (node->block_processor.size (nano::block_source::bootstrap_legacy) < 1024 && !node->block_processor.flushing) { receive_block (); } diff --git a/nano/node/bootstrap/bootstrap_bulk_push.cpp b/nano/node/bootstrap/bootstrap_bulk_push.cpp index 5c9f09d080..47508878a3 100644 --- a/nano/node/bootstrap/bootstrap_bulk_push.cpp +++ b/nano/node/bootstrap/bootstrap_bulk_push.cpp @@ -137,7 +137,7 @@ void nano::bulk_push_server::throttled_receive () { return; } - if (!node->block_processor.half_full ()) + if (node->block_processor.size (nano::block_source::bootstrap_legacy) < 1024) { receive (); } From 3276f24cb8359ec6d7213bab502566dade5928e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:57:33 +0200 Subject: [PATCH 2/3] Remove full and half_full queries --- nano/core_test/node.cpp | 45 ------------------------------------ nano/node/blockprocessor.cpp | 10 -------- nano/node/blockprocessor.hpp | 4 ---- 3 files changed, 59 deletions(-) diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 4fb8c69cdc..b2d1e338a1 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -2602,51 +2602,6 @@ TEST (node, block_processor_reject_state) ASSERT_TIMELY (5s, node.block_or_pruned_exists (send2->hash ())); } -TEST (node, block_processor_full) -{ - nano::test::system system; - nano::node_flags node_flags; - node_flags.force_use_write_queue = true; - node_flags.block_processor_full_size = 3; - auto & node = *system.add_node (nano::node_config (system.get_available_port ()), node_flags); - nano::state_block_builder builder; - auto send1 = builder.make_block () - .account (nano::dev::genesis_key.pub) - .previous (nano::dev::genesis->hash ()) - .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) - .link (nano::dev::genesis_key.pub) - .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) - .build (); - auto send2 = builder.make_block () - .account (nano::dev::genesis_key.pub) - .previous (nano::dev::genesis->hash ()) - .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) - .link (nano::dev::genesis_key.pub) - .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) - .build (); - auto send3 = builder.make_block () - .account (nano::dev::genesis_key.pub) - .previous (nano::dev::genesis->hash ()) - .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio) - .link (nano::dev::genesis_key.pub) - .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) - .build (); - node.block_processor.stop (); // Stop processing the block queue - node.block_processor.add (send1); - ASSERT_FALSE (node.block_processor.full ()); - node.block_processor.add (send2); - ASSERT_FALSE (node.block_processor.full ()); - node.block_processor.add (send3); - // Block processor may be not full during state blocks signatures verification - ASSERT_TIMELY (5s, node.block_processor.full ()); -} - TEST (node, confirm_back) { nano::test::system system (1); diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index ade835b2e2..4c36cd60d0 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -119,16 +119,6 @@ std::size_t nano::block_processor::size (nano::block_source source) const return queue.size ({ source }); } -bool nano::block_processor::full () const -{ - return size () >= node.flags.block_processor_full_size; -} - -bool nano::block_processor::half_full () const -{ - return size () >= node.flags.block_processor_full_size / 2; -} - bool nano::block_processor::add (std::shared_ptr const & block, block_source const source, std::shared_ptr const & channel) { if (node.network_params.work.validate_entry (*block)) // true => error diff --git a/nano/node/blockprocessor.hpp b/nano/node/blockprocessor.hpp index 3ad1caf4fb..8561c635f0 100644 --- a/nano/node/blockprocessor.hpp +++ b/nano/node/blockprocessor.hpp @@ -98,10 +98,6 @@ class block_processor final void force (std::shared_ptr const &); bool should_log (); - // TODO: Remove, used by legacy bootstrap - bool full () const; - bool half_full () const; - std::unique_ptr collect_container_info (std::string const & name); std::atomic flushing{ false }; From d0f75882ffb4118d9758ce005fbc25f80956428c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 4 Jul 2024 16:15:27 +0200 Subject: [PATCH 3/3] Iterate frontiers on bootstrap workers thread --- nano/node/bootstrap/bootstrap_frontier.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nano/node/bootstrap/bootstrap_frontier.cpp b/nano/node/bootstrap/bootstrap_frontier.cpp index 8a9d37517a..7f89775ef0 100644 --- a/nano/node/bootstrap/bootstrap_frontier.cpp +++ b/nano/node/bootstrap/bootstrap_frontier.cpp @@ -70,7 +70,9 @@ void nano::frontier_req_client::receive_frontier () // we simply get a size of 0. if (size_a == nano::frontier_req_client::size_frontier) { - this_l->received_frontier (ec, size_a); + node->bootstrap_workers.push_task ([this_l, ec, size_a] () { + this_l->received_frontier (ec, size_a); + }); } else {