From 23fc8972b6913817fee8e32328780851ee250e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Sat, 28 Dec 2024 18:20:21 +0100 Subject: [PATCH 1/2] Rename blockprocessor file to block_processor for consistency --- nano/core_test/CMakeLists.txt | 2 +- nano/core_test/{blockprocessor.cpp => block_processor.cpp} | 0 nano/core_test/confirming_set.cpp | 2 +- nano/node/CMakeLists.txt | 4 ++-- nano/node/{blockprocessor.cpp => block_processor.cpp} | 2 +- nano/node/{blockprocessor.hpp => block_processor.hpp} | 0 nano/node/bootstrap/bootstrap_service.cpp | 2 +- nano/node/bounded_backlog.cpp | 2 +- nano/node/confirming_set.cpp | 2 +- nano/node/local_block_broadcaster.cpp | 2 +- nano/node/local_block_broadcaster.hpp | 2 +- nano/node/nodeconfig.hpp | 2 +- nano/node/process_live_dispatcher.cpp | 2 +- 13 files changed, 12 insertions(+), 12 deletions(-) rename nano/core_test/{blockprocessor.cpp => block_processor.cpp} (100%) rename nano/node/{blockprocessor.cpp => block_processor.cpp} (99%) rename nano/node/{blockprocessor.hpp => block_processor.hpp} (100%) diff --git a/nano/core_test/CMakeLists.txt b/nano/core_test/CMakeLists.txt index c6276c49ee..28f6f553a8 100644 --- a/nano/core_test/CMakeLists.txt +++ b/nano/core_test/CMakeLists.txt @@ -9,7 +9,7 @@ add_executable( backlog.cpp block.cpp block_store.cpp - blockprocessor.cpp + block_processor.cpp bootstrap.cpp bootstrap_server.cpp bucketing.cpp diff --git a/nano/core_test/blockprocessor.cpp b/nano/core_test/block_processor.cpp similarity index 100% rename from nano/core_test/blockprocessor.cpp rename to nano/core_test/block_processor.cpp diff --git a/nano/core_test/confirming_set.cpp b/nano/core_test/confirming_set.cpp index 0b891ee0dc..c49b4f44b3 100644 --- a/nano/core_test/confirming_set.cpp +++ b/nano/core_test/confirming_set.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/nano/node/CMakeLists.txt b/nano/node/CMakeLists.txt index 13a182adff..15ff27f8e0 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -20,8 +20,8 @@ add_library( backlog_scan.cpp bandwidth_limiter.hpp bandwidth_limiter.cpp - blockprocessor.hpp - blockprocessor.cpp + block_processor.hpp + block_processor.cpp bucketing.hpp bucketing.cpp bounded_backlog.hpp diff --git a/nano/node/blockprocessor.cpp b/nano/node/block_processor.cpp similarity index 99% rename from nano/node/blockprocessor.cpp rename to nano/node/block_processor.cpp index 544de7973c..eb86d6c895 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/block_processor.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/nano/node/blockprocessor.hpp b/nano/node/block_processor.hpp similarity index 100% rename from nano/node/blockprocessor.hpp rename to nano/node/block_processor.hpp diff --git a/nano/node/bootstrap/bootstrap_service.cpp b/nano/node/bootstrap/bootstrap_service.cpp index f11c3ac493..b4b0213e70 100644 --- a/nano/node/bootstrap/bootstrap_service.cpp +++ b/nano/node/bootstrap/bootstrap_service.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/nano/node/bounded_backlog.cpp b/nano/node/bounded_backlog.cpp index 4a800a60d3..b019d8c674 100644 --- a/nano/node/bounded_backlog.cpp +++ b/nano/node/bounded_backlog.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/nano/node/confirming_set.cpp b/nano/node/confirming_set.cpp index c9e79444ab..db7ca3e6a4 100644 --- a/nano/node/confirming_set.cpp +++ b/nano/node/confirming_set.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/nano/node/local_block_broadcaster.cpp b/nano/node/local_block_broadcaster.cpp index 31715309a7..6248de0042 100644 --- a/nano/node/local_block_broadcaster.cpp +++ b/nano/node/local_block_broadcaster.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/nano/node/local_block_broadcaster.hpp b/nano/node/local_block_broadcaster.hpp index 567244491f..7353f39fe5 100644 --- a/nano/node/local_block_broadcaster.hpp +++ b/nano/node/local_block_broadcaster.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index 4871b98711..63483c59d2 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/nano/node/process_live_dispatcher.cpp b/nano/node/process_live_dispatcher.cpp index 1f00b23249..9e4775bc82 100644 --- a/nano/node/process_live_dispatcher.cpp +++ b/nano/node/process_live_dispatcher.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include From 8ea3b2b619a2dfa69a563969a8307a3960068c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Sat, 28 Dec 2024 18:24:35 +0100 Subject: [PATCH 2/2] Rename remaining blockprocessor usages to block_processor --- nano/core_test/ledger.cpp | 2 +- nano/core_test/node.cpp | 2 +- nano/core_test/toml.cpp | 2 +- nano/lib/logging_enums.hpp | 4 +-- nano/lib/stats_enums.hpp | 10 +++--- nano/node/block_processor.cpp | 44 +++++++++++------------ nano/node/bootstrap/bootstrap_service.cpp | 10 +++--- nano/node/bootstrap/bootstrap_service.hpp | 4 +-- nano/store/write_queue.hpp | 2 +- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index 359804592f..74a72aec21 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -5854,7 +5854,7 @@ TEST (ledger_transaction, write_wait_order) WAIT (250ms); // Allow thread to start auto fut2 = std::async (std::launch::async, [&ctx, &acquired2, &latch2] { - auto tx = ctx.ledger ().tx_begin_write (nano::store::writer::blockprocessor); + auto tx = ctx.ledger ().tx_begin_write (nano::store::writer::block_processor); acquired2 = true; latch2.wait (); // Wait for the signal to drop tx }); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 7cbef18022..525efe2205 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -2404,7 +2404,7 @@ TEST (node, block_processor_reject_state) send1->signature.bytes[0] ^= 1; ASSERT_FALSE (node.block_or_pruned_exists (send1->hash ())); node.process_active (send1); - ASSERT_TIMELY_EQ (5s, 1, node.stats.count (nano::stat::type::blockprocessor_result, nano::stat::detail::bad_signature)); + ASSERT_TIMELY_EQ (5s, 1, node.stats.count (nano::stat::type::block_processor_result, nano::stat::detail::bad_signature)); ASSERT_FALSE (node.block_or_pruned_exists (send1->hash ())); auto send2 = builder.make_block () .account (nano::dev::genesis_key.pub) diff --git a/nano/core_test/toml.cpp b/nano/core_test/toml.cpp index cb635aecd1..3a2ad78057 100644 --- a/nano/core_test/toml.cpp +++ b/nano/core_test/toml.cpp @@ -1045,7 +1045,7 @@ TEST (toml_config, log_config_no_defaults) [log.levels] active_elections = "trace" - blockprocessor = "trace" + block_processor = "trace" )toml"; nano::tomlconfig toml; diff --git a/nano/lib/logging_enums.hpp b/nano/lib/logging_enums.hpp index cf087ead14..64f520bc62 100644 --- a/nano/lib/logging_enums.hpp +++ b/nano/lib/logging_enums.hpp @@ -47,7 +47,7 @@ enum class type tls, active_elections, election, - blockprocessor, + block_processor, network, message, channel, @@ -122,7 +122,7 @@ enum class detail election_expired, broadcast_vote, - // blockprocessor + // block_processor block_processed, // vote_processor diff --git a/nano/lib/stats_enums.hpp b/nano/lib/stats_enums.hpp index 3442ae4710..429741d2f3 100644 --- a/nano/lib/stats_enums.hpp +++ b/nano/lib/stats_enums.hpp @@ -60,10 +60,10 @@ enum class type vote_cache, vote_cache_processor, hinting, - blockprocessor, - blockprocessor_source, - blockprocessor_result, - blockprocessor_overfill, + block_processor, + block_processor_source, + block_processor_result, + block_processor_overfill, bootstrap, bootstrap_verify, bootstrap_verify_blocks, @@ -206,7 +206,7 @@ enum class detail representative_mismatch, block_position, - // blockprocessor + // block_processor process_blocking, process_blocking_timeout, force, diff --git a/nano/node/block_processor.cpp b/nano/node/block_processor.cpp index eb86d6c895..dd72521c8c 100644 --- a/nano/node/block_processor.cpp +++ b/nano/node/block_processor.cpp @@ -111,12 +111,12 @@ bool nano::block_processor::add (std::shared_ptr const & block, blo { if (network_params.work.validate_entry (*block)) // true => error { - stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::insufficient_work); + stats.inc (nano::stat::type::block_processor, nano::stat::detail::insufficient_work); return false; // Not added } - stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::process); - logger.debug (nano::log::type::blockprocessor, "Processing block (async): {} (source: {} {})", + stats.inc (nano::stat::type::block_processor, nano::stat::detail::process); + logger.debug (nano::log::type::block_processor, "Processing block (async): {} (source: {} {})", block->hash ().to_string (), to_string (source), channel ? channel->to_string () : ""); // TODO: Lazy eval @@ -126,8 +126,8 @@ bool nano::block_processor::add (std::shared_ptr const & block, blo std::optional nano::block_processor::add_blocking (std::shared_ptr const & block, block_source const source) { - stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::process_blocking); - logger.debug (nano::log::type::blockprocessor, "Processing block (blocking): {} (source: {})", block->hash ().to_string (), to_string (source)); + stats.inc (nano::stat::type::block_processor, nano::stat::detail::process_blocking); + logger.debug (nano::log::type::block_processor, "Processing block (blocking): {} (source: {})", block->hash ().to_string (), to_string (source)); context ctx{ block, source }; auto future = ctx.get_future (); @@ -140,8 +140,8 @@ std::optional nano::block_processor::add_blocking (std::shar } catch (std::future_error const &) { - stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::process_blocking_timeout); - logger.error (nano::log::type::blockprocessor, "Block dropped when processing: {}", block->hash ().to_string ()); + stats.inc (nano::stat::type::block_processor, nano::stat::detail::process_blocking_timeout); + logger.error (nano::log::type::block_processor, "Block dropped when processing: {}", block->hash ().to_string ()); } return std::nullopt; @@ -149,8 +149,8 @@ std::optional nano::block_processor::add_blocking (std::shar void nano::block_processor::force (std::shared_ptr const & block_a) { - stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::force); - logger.debug (nano::log::type::blockprocessor, "Forcing block: {}", block_a->hash ().to_string ()); + stats.inc (nano::stat::type::block_processor, nano::stat::detail::force); + logger.debug (nano::log::type::block_processor, "Forcing block: {}", block_a->hash ().to_string ()); add_impl (context{ block_a, block_source::forced }); } @@ -169,8 +169,8 @@ bool nano::block_processor::add_impl (context ctx, std::shared_ptrhash () != hash) { // Replace our block with the winner and roll back any dependent blocks - logger.debug (nano::log::type::blockprocessor, "Rolling back: {} and replacing with: {}", successor->hash ().to_string (), hash.to_string ()); + logger.debug (nano::log::type::block_processor, "Rolling back: {} and replacing with: {}", successor->hash ().to_string (), hash.to_string ()); std::deque> rollback_list; if (ledger.rollback (transaction, successor->hash (), rollback_list)) { stats.inc (nano::stat::type::ledger, nano::stat::detail::rollback_failed); - logger.error (nano::log::type::blockprocessor, "Failed to roll back: {} because it or a successor was confirmed", successor->hash ().to_string ()); + logger.error (nano::log::type::block_processor, "Failed to roll back: {} because it or a successor was confirmed", successor->hash ().to_string ()); } else { stats.inc (nano::stat::type::ledger, nano::stat::detail::rollback); - logger.debug (nano::log::type::blockprocessor, "Blocks rolled back: {}", rollback_list.size ()); + logger.debug (nano::log::type::block_processor, "Blocks rolled back: {}", rollback_list.size ()); } // Notify observers of the rolled back blocks on a background thread while not holding the ledger write lock @@ -215,7 +215,7 @@ void nano::block_processor::run () // It's possible that ledger processing happens faster than the notifications can be processed by other components, cooldown here while (workers.queued_tasks () >= config.max_queued_notifications) { - stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::cooldown); + stats.inc (nano::stat::type::block_processor, nano::stat::detail::cooldown); condition.wait_for (lock, 100ms, [this] { return stopped; }); if (stopped) { @@ -225,7 +225,7 @@ void nano::block_processor::run () if (log_interval.elapsed (15s)) { - logger.info (nano::log::type::blockprocessor, "{} blocks (+ {} forced) in processing queue", + logger.info (nano::log::type::block_processor, "{} blocks (+ {} forced) in processing queue", queue.size (), queue.size ({ nano::block_source::forced })); } @@ -236,7 +236,7 @@ void nano::block_processor::run () // Queue notifications to be dispatched in the background workers.post ([this, processed = std::move (processed)] () mutable { - stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::notify); + stats.inc (nano::stat::type::block_processor, nano::stat::detail::notify); // Set results for futures when not holding the lock for (auto & [result, context] : processed) { @@ -298,7 +298,7 @@ auto nano::block_processor::process_batch (nano::unique_lock & lock lock.unlock (); - auto transaction = ledger.tx_begin_write (nano::store::writer::blockprocessor); + auto transaction = ledger.tx_begin_write (nano::store::writer::block_processor); nano::timer timer; timer.start (); @@ -329,7 +329,7 @@ auto nano::block_processor::process_batch (nano::unique_lock & lock if (number_of_blocks_processed != 0 && timer.stop () > std::chrono::milliseconds (100)) { - logger.debug (nano::log::type::blockprocessor, "Processed {} blocks ({} forced) in {} {}", number_of_blocks_processed, number_of_forced_processed, timer.value ().count (), timer.unit ()); + logger.debug (nano::log::type::block_processor, "Processed {} blocks ({} forced) in {} {}", number_of_blocks_processed, number_of_forced_processed, timer.value ().count (), timer.unit ()); } return processed; @@ -341,10 +341,10 @@ nano::block_status nano::block_processor::process_one (secure::write_transaction auto const hash = block->hash (); nano::block_status result = ledger.process (transaction_a, block); - stats.inc (nano::stat::type::blockprocessor_result, to_stat_detail (result)); - stats.inc (nano::stat::type::blockprocessor_source, to_stat_detail (context.source)); + stats.inc (nano::stat::type::block_processor_result, to_stat_detail (result)); + stats.inc (nano::stat::type::block_processor_source, to_stat_detail (context.source)); - logger.trace (nano::log::type::blockprocessor, nano::log::detail::block_processed, + logger.trace (nano::log::type::block_processor, nano::log::detail::block_processed, nano::log::arg{ "result", result }, nano::log::arg{ "source", context.source }, nano::log::arg{ "arrival", nano::log::microseconds (context.arrival) }, diff --git a/nano/node/bootstrap/bootstrap_service.cpp b/nano/node/bootstrap/bootstrap_service.cpp index b4b0213e70..8f60f9924f 100644 --- a/nano/node/bootstrap/bootstrap_service.cpp +++ b/nano/node/bootstrap/bootstrap_service.cpp @@ -342,7 +342,7 @@ void nano::bootstrap_service::wait (std::function const & predicate) co } } -void nano::bootstrap_service::wait_blockprocessor () const +void nano::bootstrap_service::wait_block_processor () const { wait ([this] () { return block_processor.size (nano::block_source::bootstrap) < config.block_processor_threshold; @@ -569,7 +569,7 @@ bool nano::bootstrap_service::request_frontiers (nano::account start, std::share void nano::bootstrap_service::run_one_priority () { - wait_blockprocessor (); + wait_block_processor (); auto channel = wait_channel (); if (!channel) { @@ -611,7 +611,7 @@ void nano::bootstrap_service::run_priorities () void nano::bootstrap_service::run_one_database (bool should_throttle) { - wait_blockprocessor (); + wait_block_processor (); auto channel = wait_channel (); if (!channel) { @@ -641,7 +641,7 @@ void nano::bootstrap_service::run_database () void nano::bootstrap_service::run_one_dependency () { - // No need to wait for blockprocessor, as we are not processing blocks + // No need to wait for block_processor, as we are not processing blocks auto channel = wait_channel (); if (!channel) { @@ -669,7 +669,7 @@ void nano::bootstrap_service::run_dependencies () void nano::bootstrap_service::run_one_frontier () { - // No need to wait for blockprocessor, as we are not processing blocks + // No need to wait for block_processor, as we are not processing blocks wait ([this] () { return !accounts.priority_half_full (); }); diff --git a/nano/node/bootstrap/bootstrap_service.hpp b/nano/node/bootstrap/bootstrap_service.hpp index 7e881e5c9d..f28d3fbe14 100644 --- a/nano/node/bootstrap/bootstrap_service.hpp +++ b/nano/node/bootstrap/bootstrap_service.hpp @@ -113,8 +113,8 @@ class bootstrap_service /* Waits for a condition to be satisfied with incremental backoff */ void wait (std::function const & predicate) const; - /* Ensure there is enough space in blockprocessor for queuing new blocks */ - void wait_blockprocessor () const; + /* Ensure there is enough space in block_processor for queuing new blocks */ + void wait_block_processor () const; /* Waits for a channel that is not full */ std::shared_ptr wait_channel (); /* Waits until a suitable account outside of cooldown period is available */ diff --git a/nano/store/write_queue.hpp b/nano/store/write_queue.hpp index 9dc0843c29..95ae5a030a 100644 --- a/nano/store/write_queue.hpp +++ b/nano/store/write_queue.hpp @@ -13,7 +13,7 @@ enum class writer { generic, node, - blockprocessor, + block_processor, confirmation_height, pruning, voting_final,