Enqueue all blocks from block_processor::add_impl in to block_processor::blocks regardless of type.

Negative testing for signatures of state/epoch blocks is done with ledger.fail_state_bad_signature and ledger.fail_epoch_bad_signature. Signature checking is always done within the block verification functions themselves since https://github.com/nanocurrency/nano-node/pull/4021
This commit is contained in:
Colin LeMahieu 2023-08-22 12:41:49 +01:00
commit dd7a4e11b9
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
2 changed files with 3 additions and 39 deletions

View file

@ -39,32 +39,3 @@ TEST (block_processor, broadcast_block_on_arrival)
// Checks whether the block was broadcast.
ASSERT_TIMELY (5s, node2->ledger.block_or_pruned_exists (send1->hash ()));
}
TEST (block_processor, add_blocking_invalid_block)
{
nano::test::system system;
nano::node_config config = system.default_config ();
config.block_process_timeout = std::chrono::seconds{ 1 };
auto & node = *system.add_node (config);
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 (*system.work.generate (nano::dev::genesis->hash ()))
.build_shared ();
send1->signature.clear ();
auto background = std::async (std::launch::async, [&] () {
return node.process_local (send1);
});
ASSERT_TIMELY (5s, background.wait_for (std::chrono::seconds (0)) == std::future_status::ready);
ASSERT_FALSE (background.get ().has_value ());
}

View file

@ -245,18 +245,11 @@ void nano::block_processor::process_verified_state_blocks (std::deque<nano::stat
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
{
{
nano::lock_guard<nano::mutex> guard{ mutex };
blocks.emplace_back (block);
}
condition.notify_all ();
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>