Skip to content

Commit

Permalink
Merge pull request #6489
Browse files Browse the repository at this point in the history
f261f19 Give a better error message if system clock is bad (Casey Rodarmor)
  • Loading branch information
laanwj committed Aug 5, 2015
2 parents 9bb4dd8 + f261f19 commit c9c017a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,18 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
}

{
LOCK(cs_main);
CBlockIndex* tip = chainActive.Tip();
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
strLoadError = _("The block database contains a block which appears to be from the future. "
"This may be due to your computer's date and time being set incorrectly. "
"Only rebuild the block database if you are sure that your computer's date and time are correct");
break;
}
}

if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
GetArg("-checkblocks", 288))) {
strLoadError = _("Corrupted block database detected");
Expand Down

3 comments on commit c9c017a

@zawy12
Copy link

@zawy12 zawy12 commented on c9c017a Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause the node to get stuck for 70 minutes if a Sybil attack on the node's peer time removes 70 minutes from local time right after it sees a block with a timestamp that is 120 minutes in the future?

@sipa
Copy link
Member

@sipa sipa commented on c9c017a Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code didn't change semantics at all, it only shows a warning to the user when the clock seems off. It's also 5 years old.

@zawy12
Copy link

@zawy12 zawy12 commented on c9c017a Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so it is only a message and does not cause a problem in the node's functioning? I'm trying to understand why ZEC's sudden security fix (that replaces allowed peer offset of 70 minutes with 0 and makes future time limit FTL based on MTP instead of local time) reportedly fixes this:

Nodes would permanently reject blocks based on their timestamps using subjective information.

https://electriccoin.co/blog/new-releases-2-1-1-and-hotfix-2-1-1-1/

Please sign in to comment.