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

Some confirmed block observer callbacks being missed #2723

Merged
merged 10 commits into from
Apr 23, 2020
6 changes: 5 additions & 1 deletion nano/node/confirmation_height_bounded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,11 @@ bool nano::confirmation_height_bounded::cement_blocks (nano::write_guard & scope
scoped_write_guard_a.release ();
notify_observers_callback (cemented_blocks);
}
debug_assert (ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed) == ledger.stats.count (nano::stat::type::observer, nano::stat::detail::all, nano::stat::dir::out));
// Tests should check this already at the end, but not all blocks may have elections (e.g from manual calls to confirmation_height_processor::add), this should catch any inconsistencies on live/beta though
if (!network_params.network.is_test_network ())
guilhermelawless marked this conversation as resolved.
Show resolved Hide resolved
{
debug_assert (ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed) == ledger.stats.count (nano::stat::type::observer, nano::stat::detail::all, nano::stat::dir::out));
}

debug_assert (pending_writes.empty ());
debug_assert (pending_writes_size == 0);
Expand Down
6 changes: 5 additions & 1 deletion nano/node/confirmation_height_unbounded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ bool nano::confirmation_height_unbounded::cement_blocks (nano::write_guard & sco
scoped_write_guard_a.release ();
notify_observers_callback (cemented_blocks);

debug_assert (ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed) == ledger.stats.count (nano::stat::type::observer, nano::stat::detail::all, nano::stat::dir::out));
// Tests should check this already at the end, but not all blocks may have elections (e.g from manual calls to confirmation_height_processor::add), this should catch any inconsistencies on live/beta though
if (!network_params.network.is_test_network ())
{
debug_assert (ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed) == ledger.stats.count (nano::stat::type::observer, nano::stat::detail::all, nano::stat::dir::out));
}
debug_assert (pending_writes.empty ());
return false;
}
Expand Down
1 change: 1 addition & 0 deletions nano/node/confirmation_height_unbounded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class confirmation_height_unbounded final
void collect_unconfirmed_receive_and_sources_for_account (uint64_t, uint64_t, nano::block_hash const &, nano::account const &, nano::read_transaction const &, std::vector<receive_source_pair> &, std::vector<nano::block_hash> &);
void prepare_iterated_blocks_for_cementing (preparation_data &);

nano::network_params network_params;
nano::ledger & ledger;
nano::write_database_queue & write_database_queue;
std::chrono::milliseconds batch_separate_pending_min_time;
Expand Down