From 50929a0c0c5f014a25d54e50efa96fcf017efa43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:37:36 +0200 Subject: [PATCH] Fix handling of `gap_previous` (#4696) * Only handle `gap_previous` for live traffic * Use fwd header --- nano/node/bootstrap_ascending/service.cpp | 13 ++++++++----- nano/node/bootstrap_ascending/service.hpp | 18 ++---------------- nano/node/fwd.hpp | 2 ++ 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/nano/node/bootstrap_ascending/service.cpp b/nano/node/bootstrap_ascending/service.cpp index dc80c5b687..f0f1b531ad 100644 --- a/nano/node/bootstrap_ascending/service.cpp +++ b/nano/node/bootstrap_ascending/service.cpp @@ -42,7 +42,7 @@ nano::bootstrap_ascending::service::service (nano::node_config const & node_conf for (auto const & [result, context] : batch) { debug_assert (context.block != nullptr); - inspect (transaction, result, *context.block); + inspect (transaction, result, *context.block, context.source); } } condition.notify_all (); @@ -189,7 +189,7 @@ std::size_t nano::bootstrap_ascending::service::score_size () const - Marks an account as blocked if the result code is gap source as there is no reason request additional blocks for this account until the dependency is resolved - Marks an account as forwarded if it has been recently referenced by a block that has been inserted. */ -void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx, nano::block_status const & result, nano::block const & block) +void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx, nano::block_status const & result, nano::block const & block, nano::block_source source) { debug_assert (!mutex.try_lock ()); @@ -224,10 +224,13 @@ void nano::bootstrap_ascending::service::inspect (secure::transaction const & tx break; case nano::block_status::gap_previous: { - if (block.type () == block_type::state) + if (source == nano::block_source::live) { - const auto account = block.account_field ().value (); - accounts.priority_set (account); + if (block.type () == block_type::state) + { + const auto account = block.account_field ().value (); + accounts.priority_set (account); + } } } break; diff --git a/nano/node/bootstrap_ascending/service.hpp b/nano/node/bootstrap_ascending/service.hpp index 25d02846ad..90ff08106d 100644 --- a/nano/node/bootstrap_ascending/service.hpp +++ b/nano/node/bootstrap_ascending/service.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -22,23 +23,8 @@ namespace mi = boost::multi_index; -namespace nano::secure -{ -class transaction; -} - namespace nano { -class block_processor; -class ledger; -class network; -class node_config; - -namespace transport -{ - class channel; -} - namespace bootstrap_ascending { class service @@ -108,7 +94,7 @@ namespace bootstrap_ascending private: /* Inspects a block that has been processed by the block processor */ - void inspect (secure::transaction const &, nano::block_status const & result, nano::block const & block); + void inspect (secure::transaction const &, nano::block_status const & result, nano::block const & block, nano::block_source); void run_priorities (); void run_one_priority (); diff --git a/nano/node/fwd.hpp b/nano/node/fwd.hpp index 293c803637..d79581378d 100644 --- a/nano/node/fwd.hpp +++ b/nano/node/fwd.hpp @@ -8,6 +8,7 @@ namespace nano { class active_elections; class block; +class block_processor; class confirming_set; class ledger; class local_block_broadcaster; @@ -29,5 +30,6 @@ class vote_processor; class vote_router; class wallets; +enum class block_source; enum class vote_code; } \ No newline at end of file