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

Clarify warning about too-few blocks #9483

Open
wants to merge 1 commit into
base: release-v0.18
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 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 @@ -2048,14 +2049,17 @@ namespace cryptonote
static const unsigned int seconds[] = { 5400, 3600, 1800, 1200, 600 };
for (size_t n = 0; n < sizeof(seconds)/sizeof(seconds[0]); ++n)
{
unsigned int b = 0;
unsigned int b = 0; // quantity of blocks between `time_boundary` and `now`
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 << ")");
// expected qty of blocks in the time measured = (time measured) / (expected time per block)
const double b_exp = seconds[n] / DIFFICULTY_TARGET_V2;
const double p = probability(b, b_exp);
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 * b_exp); // 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.");

philipmw marked this conversation as resolved.
Show resolved Hide resolved
std::shared_ptr<tools::Notify> block_rate_notify = m_block_rate_notify;
if (block_rate_notify)
Expand Down
Loading