Adding logging if blocks aren't being confirmed for an excessive amount of time.
This commit is contained in:
parent
447356005b
commit
e5ba6db926
3 changed files with 19 additions and 6 deletions
|
@ -216,7 +216,7 @@ TEST (node, node_receive_quorum)
|
|||
{
|
||||
auto info (system.nodes[0]->active.roots.find (previous));
|
||||
ASSERT_NE (system.nodes[0]->active.roots.end (), info);
|
||||
done = info->announcements > rai::active_transactions::contiguous_announcements;
|
||||
done = info->announcements > rai::active_transactions::announcement_min;
|
||||
system.poll ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
|
@ -1607,7 +1607,7 @@ TEST (node, confirm_quorum)
|
|||
ASSERT_FALSE (system.nodes[0]->active.roots.empty ());
|
||||
auto info (system.nodes[0]->active.roots.find (send1->hash ()));
|
||||
ASSERT_NE (system.nodes[0]->active.roots.end (), info);
|
||||
done = info->announcements > rai::active_transactions::contiguous_announcements;
|
||||
done = info->announcements > rai::active_transactions::announcement_min;
|
||||
system.poll ();
|
||||
++iterations;
|
||||
ASSERT_LT (iterations, 200);
|
||||
|
|
|
@ -3182,11 +3182,13 @@ void rai::active_transactions::announce_votes ()
|
|||
std::vector<rai::block_hash> inactive;
|
||||
rai::transaction transaction (node.store.environment, nullptr, false);
|
||||
std::lock_guard<std::mutex> lock (mutex);
|
||||
unsigned unconfirmed_count (0);
|
||||
unsigned unconfirmed_announcements (0);
|
||||
|
||||
for (auto i (roots.begin ()), n (roots.end ()); i != n; ++i)
|
||||
{
|
||||
auto election_l (i->election);
|
||||
if (!node.store.root_exists (transaction, election_l->votes.id) || (election_l->confirmed && i->announcements >= contiguous_announcements - 1))
|
||||
if (!node.store.root_exists (transaction, election_l->votes.id) || (election_l->confirmed && i->announcements >= announcement_min - 1))
|
||||
{
|
||||
if (election_l->confirmed)
|
||||
{
|
||||
|
@ -3200,8 +3202,13 @@ void rai::active_transactions::announce_votes ()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (i->announcements > announcement_long)
|
||||
{
|
||||
++unconfirmed_count;
|
||||
unconfirmed_announcements += i->announcements;
|
||||
}
|
||||
node.background ([election_l]() { election_l->broadcast_winner (); });
|
||||
if (i->announcements % contiguous_announcements == 2)
|
||||
if (i->announcements % announcement_min == 2)
|
||||
{
|
||||
auto reps (std::make_shared<std::vector<rai::peer_information>> (node.peers.representatives (std::numeric_limits<size_t>::max ())));
|
||||
|
||||
|
@ -3244,6 +3251,10 @@ void rai::active_transactions::announce_votes ()
|
|||
assert (roots.find (*i) != roots.end ());
|
||||
roots.erase (*i);
|
||||
}
|
||||
if (unconfirmed_count > 0)
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("%1% blocks have been unconfirmed averaging %2% announcements") % unconfirmed_count % (unconfirmed_announcements / unconfirmed_count));
|
||||
}
|
||||
auto now (std::chrono::steady_clock::now ());
|
||||
std::weak_ptr<rai::node> node_w (node.shared ());
|
||||
node.alarm.add (now + std::chrono::milliseconds (announce_interval_ms), [node_w]() {
|
||||
|
|
|
@ -112,8 +112,10 @@ public:
|
|||
std::mutex mutex;
|
||||
// Maximum number of conflicts to vote on per interval, lowest root hash first
|
||||
static unsigned constexpr announcements_per_interval = 32;
|
||||
// After this many successive vote announcements, block is confirmed
|
||||
static unsigned constexpr contiguous_announcements = 4;
|
||||
// Minimum number of block announcements
|
||||
static unsigned constexpr announcement_min = 4;
|
||||
// Threshold to start logging blocks haven't yet been confirmed
|
||||
static unsigned constexpr announcement_long = 20;
|
||||
static unsigned constexpr announce_interval_ms = (rai::rai_network == rai::rai_networks::rai_test_network) ? 10 : 16000;
|
||||
static size_t constexpr election_history_size = 2048;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue