From 408660b582d4d39401a83b54ba814384fb912614 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Tue, 22 Aug 2023 12:41:49 +0100 Subject: [PATCH] This removes use of the signature checking threads/classes from the node. These classes add complexity around critical code. Even where performance optimizations could be made through multi threading, it would be better implemented using standard c++ instead of a custom class. It's unclear if these classes are helping performance at all so we're opting to remove them until/if a performance improvement is needed. --- nano/node/blockprocessor.cpp | 22 +++++++++++++++++----- nano/node/vote_processor.cpp | 26 +------------------------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/nano/node/blockprocessor.cpp b/nano/node/blockprocessor.cpp index 5fc10808dd..387acf1153 100644 --- a/nano/node/blockprocessor.cpp +++ b/nano/node/blockprocessor.cpp @@ -247,16 +247,28 @@ void nano::block_processor::add_impl (std::shared_ptr block) { if (block->type () == nano::block_type::state || block->type () == nano::block_type::open) { - state_block_signature_verification.add ({ block }); - } - else - { + auto & epochs = node.ledger.constants.epochs; + if (epochs.is_epoch_link (block->link ())) + { + nano::lock_guard guard{ mutex }; + blocks.emplace_back (block); + } + else if (!nano::validate_message (block->account (), block->hash (), block->block_signature ())) { nano::lock_guard guard{ mutex }; blocks.emplace_back (block); } - condition.notify_all (); + else + { + // Incorrect signature + } } + else + { + nano::lock_guard guard{ mutex }; + blocks.emplace_back (block); + } + condition.notify_all (); } auto nano::block_processor::process_batch (nano::unique_lock & lock_a) -> std::deque diff --git a/nano/node/vote_processor.cpp b/nano/node/vote_processor.cpp index fd6d5696cb..8dbc1005ce 100644 --- a/nano/node/vote_processor.cpp +++ b/nano/node/vote_processor.cpp @@ -134,36 +134,12 @@ bool nano::vote_processor::vote (std::shared_ptr const & vote_a, std void nano::vote_processor::verify_votes (decltype (votes) const & votes_a) { - auto size (votes_a.size ()); - std::vector messages; - messages.reserve (size); - std::vector hashes; - hashes.reserve (size); - std::vector lengths (size, sizeof (nano::block_hash)); - std::vector pub_keys; - pub_keys.reserve (size); - std::vector signatures; - signatures.reserve (size); - std::vector verifications; - verifications.resize (size); for (auto const & vote : votes_a) { - hashes.push_back (vote.first->hash ()); - messages.push_back (hashes.back ().bytes.data ()); - pub_keys.push_back (vote.first->account.bytes.data ()); - signatures.push_back (vote.first->signature.bytes.data ()); - } - nano::signature_check_set check = { size, messages.data (), lengths.data (), pub_keys.data (), signatures.data (), verifications.data () }; - checker.verify (check); - auto i (0); - for (auto const & vote : votes_a) - { - debug_assert (verifications[i] == 1 || verifications[i] == 0); - if (verifications[i] == 1) + if (!nano::validate_message (vote.first->account, vote.first->hash (), vote.first->signature)) { vote_blocking (vote.first, vote.second, true); } - ++i; } }