Skip to content

Commit

Permalink
This removes use of the signature checking threads/classes from the n…
Browse files Browse the repository at this point in the history
…ode.

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.
  • Loading branch information
clemahieu committed Oct 3, 2023
1 parent 30a6bc5 commit 408660b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
22 changes: 17 additions & 5 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,28 @@ void nano::block_processor::add_impl (std::shared_ptr<nano::block> 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<nano::mutex> guard{ mutex };
blocks.emplace_back (block);
}
else if (!nano::validate_message (block->account (), block->hash (), block->block_signature ()))
{
nano::lock_guard<nano::mutex> guard{ mutex };
blocks.emplace_back (block);
}
condition.notify_all ();
else
{
// Incorrect signature
}
}
else
{
nano::lock_guard<nano::mutex> guard{ mutex };
blocks.emplace_back (block);
}
condition.notify_all ();
}

auto nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock_a) -> std::deque<processed_t>
Expand Down
26 changes: 1 addition & 25 deletions nano/node/vote_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,12 @@ bool nano::vote_processor::vote (std::shared_ptr<nano::vote> const & vote_a, std

void nano::vote_processor::verify_votes (decltype (votes) const & votes_a)
{
auto size (votes_a.size ());
std::vector<unsigned char const *> messages;
messages.reserve (size);
std::vector<nano::block_hash> hashes;
hashes.reserve (size);
std::vector<std::size_t> lengths (size, sizeof (nano::block_hash));
std::vector<unsigned char const *> pub_keys;
pub_keys.reserve (size);
std::vector<unsigned char const *> signatures;
signatures.reserve (size);
std::vector<int> 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;
}
}

Expand Down

0 comments on commit 408660b

Please sign in to comment.