Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy bootstrap throttling #4669

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2602,51 +2602,6 @@ TEST (node, block_processor_reject_state)
ASSERT_TIMELY (5s, node.block_or_pruned_exists (send2->hash ()));
}

TEST (node, block_processor_full)
{
nano::test::system system;
nano::node_flags node_flags;
node_flags.force_use_write_queue = true;
node_flags.block_processor_full_size = 3;
auto & node = *system.add_node (nano::node_config (system.get_available_port ()), node_flags);
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 (*node.work_generate_blocking (nano::dev::genesis->hash ()))
.build ();
auto send2 = 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 - 2 * nano::Gxrb_ratio)
.link (nano::dev::genesis_key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*node.work_generate_blocking (nano::dev::genesis->hash ()))
.build ();
auto send3 = 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 - 3 * nano::Gxrb_ratio)
.link (nano::dev::genesis_key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*node.work_generate_blocking (nano::dev::genesis->hash ()))
.build ();
node.block_processor.stop (); // Stop processing the block queue
node.block_processor.add (send1);
ASSERT_FALSE (node.block_processor.full ());
node.block_processor.add (send2);
ASSERT_FALSE (node.block_processor.full ());
node.block_processor.add (send3);
// Block processor may be not full during state blocks signatures verification
ASSERT_TIMELY (5s, node.block_processor.full ());
}

TEST (node, confirm_back)
{
nano::test::system system (1);
Expand Down
10 changes: 0 additions & 10 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ std::size_t nano::block_processor::size (nano::block_source source) const
return queue.size ({ source });
}

bool nano::block_processor::full () const
{
return size () >= node.flags.block_processor_full_size;
}

bool nano::block_processor::half_full () const
{
return size () >= node.flags.block_processor_full_size / 2;
}

bool nano::block_processor::add (std::shared_ptr<nano::block> const & block, block_source const source, std::shared_ptr<nano::transport::channel> const & channel)
{
if (node.network_params.work.validate_entry (*block)) // true => error
Expand Down
4 changes: 0 additions & 4 deletions nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ class block_processor final
void force (std::shared_ptr<nano::block> const &);
bool should_log ();

// TODO: Remove, used by legacy bootstrap
bool full () const;
bool half_full () const;

std::unique_ptr<container_info_component> collect_container_info (std::string const & name);

std::atomic<bool> flushing{ false };
Expand Down
2 changes: 1 addition & 1 deletion nano/node/bootstrap/bootstrap_bulk_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void nano::bulk_pull_client::throttled_receive_block ()
return;
}
debug_assert (!network_error);
if (!node->block_processor.half_full () && !node->block_processor.flushing)
if (node->block_processor.size (nano::block_source::bootstrap_legacy) < 1024 && !node->block_processor.flushing)
{
receive_block ();
}
Expand Down
2 changes: 1 addition & 1 deletion nano/node/bootstrap/bootstrap_bulk_push.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void nano::bulk_push_server::throttled_receive ()
{
return;
}
if (!node->block_processor.half_full ())
if (node->block_processor.size (nano::block_source::bootstrap_legacy) < 1024)
{
receive ();
}
Expand Down
4 changes: 3 additions & 1 deletion nano/node/bootstrap/bootstrap_frontier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ void nano::frontier_req_client::receive_frontier ()
// we simply get a size of 0.
if (size_a == nano::frontier_req_client::size_frontier)
{
this_l->received_frontier (ec, size_a);
node->bootstrap_workers.push_task ([this_l, ec, size_a] () {
this_l->received_frontier (ec, size_a);
});
}
else
{
Expand Down
Loading