Skip to content

Commit

Permalink
change AcceptBlock() rules at 2040000
Browse files Browse the repository at this point in the history
  • Loading branch information
justinvforvendetta committed Apr 5, 2018
1 parent 66673a5 commit a3dd53f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2304,8 +2304,20 @@ bool CBlock::AcceptBlock()
return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake"));

// Check timestamp against prev
if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + nMaxClockDrift < pindexPrev->GetBlockTime())
return error("AcceptBlock() : block's timestamp is too early");

This comment has been minimized.

Copy link
@DZGoldman

DZGoldman Apr 7, 2018

Can somebody explain why exactly this conditional was insufficient? Might be worth it to add a comment in the code to prevent future confusion/errors.

This comment has been minimized.

Copy link
@justinvforvendetta

justinvforvendetta Apr 7, 2018

Author Member

see the newer commits

if (nHeight <= TIMESTAMP_RULES_SWITCH_BLOCK)
{
const unsigned oldMaxDrift = 7200; //2 hours
if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + oldMaxDrift < pindexPrev->GetBlockTime())
return error("AcceptBlock() : block's timestamp is too early");
}
else
{
if (GetBlockTime() < pindexPrev->GetBlockTime())
return error("AcceptBlock() : block's timestamp is too early");

if (GetBlockTime() > GetAdjustedTime() + nMaxClockDrift)
return error("AcceptBlock() : block too much in the future");
}

// Check that all transactions are finalized
BOOST_FOREACH(const CTransaction& tx, vtx)
Expand Down
3 changes: 2 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class CNode;

static const int MULTI_ALGO_SWITCH_BLOCK = 340000;
static const int STEALTH_TX_SWITCH_BLOCK = 1824150;
static const int TIMESTAMP_RULES_SWITCH_BLOCK = 2040000;
static const unsigned int MAX_BLOCK_SIZE = 1000000;
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
Expand All @@ -56,7 +57,7 @@ static const int fHaveUPnP = false;
static const uint256 hashGenesisBlockOfficial("0x00000fc63692467faeb20cdb3b53200dc601d75bdfa1001463304cc790d77278");
static const uint256 hashGenesisBlockTestNet("0x65b4e101cacf3e1e4f3a9237e3a74ffd1186e595d8b78fa8ea22c21ef5bf9347");

static const int64 nMaxClockDrift = 2 * 60 * 60; // two hours - will mod into fork
static const int64 nMaxClockDrift = 60 * 20; // 20 minutes

extern CScript COINBASE_FLAGS;

Expand Down

6 comments on commit a3dd53f

@Dakarai
Copy link

@Dakarai Dakarai commented on a3dd53f Apr 5, 2018

Choose a reason for hiding this comment

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

Do you even know what you're doing? This doesn't fix the problem...

@sabbir883
Copy link

Choose a reason for hiding this comment

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

@thebluefish You are reading it wrong . After fork at 2040000 the max drift will be 20 minutes. Only else statement will work after the fork.

@thebluefish
Copy link

Choose a reason for hiding this comment

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

@sabbir883 Ah right, whoops! Thanks for clarifying m8.

@justinvforvendetta
Copy link
Member Author

Choose a reason for hiding this comment

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

how so @Dakarai

@justinvforvendetta
Copy link
Member Author

Choose a reason for hiding this comment

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

@jonDoe01 what seemed wrong about the statement?

@justinvforvendetta
Copy link
Member Author

Choose a reason for hiding this comment

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

@jonDoe01 we will make sure no blocks from the past are submitted. did you have another suggestion?

Please sign in to comment.