Skip to content

Commit

Permalink
Clarify warning about too-few blocks
Browse files Browse the repository at this point in the history
Today, the warning about too-few blocks is not clear about what happened
versus what was expected; that's the main thing I want to address.

Clarifying this makes the message somewhat longer, so I reduce its length
by removing some redundant or meaningless (IMO) reasons for the symptoms.
  • Loading branch information
philipmw committed Sep 28, 2024
1 parent b089f9e commit ddc2d80
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ using namespace epee;
#include "cryptonote_config.h"
#include "misc_language.h"
#include "file_io_utils.h"
#include <cmath>
#include <csignal>
#include "checkpoints/checkpoints.h"
#include "ringct/rctTypes.h"
Expand Down Expand Up @@ -2051,11 +2052,13 @@ namespace cryptonote
unsigned int b = 0;
const time_t time_boundary = now - static_cast<time_t>(seconds[n]);
for (time_t ts: timestamps) b += ts >= time_boundary;
const double p = probability(b, seconds[n] / DIFFICULTY_TARGET_V2);
MDEBUG("blocks in the last " << seconds[n] / 60 << " minutes: " << b << " (probability " << p << ")");
const double dur = seconds[n] / DIFFICULTY_TARGET_V2; // duration of block generation we are measuring
const double p = probability(b, dur);
MDEBUG("blocks in the last " << seconds[n] / 60 << " minutes: " << b << " (probability actual " << p << ", expected >=" << threshold << ")");
if (p < threshold)
{
MWARNING("There were " << b << (b == max_blocks_checked ? " or more" : "") << " blocks in the last " << seconds[n] / 60 << " minutes, there might be large hash rate changes, or we might be partitioned, cut off from the Monero network or under attack, or your computer's time is off. Or it could be just sheer bad luck.");
const long b_min_exp = std::lround(threshold * dur); // lower bound on blocks we expect during measurement
MWARNING("There were " << b << (b == max_blocks_checked ? " or more" : "") << " blocks in the last " << seconds[n] / 60 << " minutes, while we expected >=" << b_min_exp << ". There might be large hash rate changes, we might be partitioned, cut off from the Monero network or under attack, or your computer's time is off.");

std::shared_ptr<tools::Notify> block_rate_notify = m_block_rate_notify;
if (block_rate_notify)
Expand Down

0 comments on commit ddc2d80

Please sign in to comment.