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

Handle gap_epoch_open_pending block status when bootstrapping #4821

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
1 change: 1 addition & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ enum class detail
blocking_overflow,
priority_insert,
priority_set,
priority_erase,
priority_unblocked,
erase_by_threshold,
erase_by_blocking,
Expand Down
13 changes: 13 additions & 0 deletions nano/node/bootstrap/account_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ void nano::bootstrap::account_sets::priority_set (nano::account const & account,
}
}

void nano::bootstrap::account_sets::priority_erase (nano::account const & account)
{
if (account.is_zero ())
{
return;
}

if (priorities.get<tag_account> ().erase (account) > 0)
{
stats.inc (nano::stat::type::bootstrap_account_sets, nano::stat::detail::priority_erase);
}
}

void nano::bootstrap::account_sets::block (nano::account const & account, nano::block_hash const & dependency)
{
debug_assert (!account.is_zero ());
Expand Down
10 changes: 1 addition & 9 deletions nano/node/bootstrap/account_sets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,10 @@ class account_sets
public:
account_sets (account_sets_config const &, nano::stats &);

/**
* If an account is not blocked, increase its priority.
* If the account does not exist in priority set and is not blocked, inserts a new entry.
* Current implementation increases priority by 1.0f each increment
*/
void priority_up (nano::account const & account);
/**
* Decreases account priority
* Current implementation divides priority by 2.0f and saturates down to 1.0f.
*/
void priority_down (nano::account const & account);
void priority_set (nano::account const & account, double priority = priority_initial);
void priority_erase (nano::account const & account);

void block (nano::account const & account, nano::block_hash const & dependency);
void unblock (nano::account const & account, std::optional<nano::block_hash> const & hash = std::nullopt);
Expand Down
9 changes: 9 additions & 0 deletions nano/node/bootstrap/bootstrap_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,16 @@ void nano::bootstrap_service::inspect (secure::transaction const & tx, nano::blo
}
}
break;
case nano::block_status::gap_epoch_open_pending:
{
// Epoch open blocks for accounts that don't have any pending blocks yet
debug_assert (block.type () == block_type::state); // Only state blocks can have epoch open pending status
const auto account = block.account_field ().value_or (0);
accounts.priority_erase (account);
}
break;
default: // No need to handle other cases
// TODO: If we receive blocks that are invalid (bad signature, fork, etc.), we should penalize the peer that sent them
break;
}
}
Expand Down
Loading