Skip to content

Commit

Permalink
Merge bitcoin#2015: [Net] Prevent un-necessary disconnections in vers…
Browse files Browse the repository at this point in the history
…ion handshake

9aae20b [Net] Prevent un-necessary disconnections in version handshake (Fuzzbawls)

Pull request description:

  Discard known stale protocol enforcement spork data during startup.

  Quick workaround for clients that have not yet seen the new spork 15 broadcast since they last ran.

  This evaluates the signing time of spork 15 (used to disconnect peers in the version handshake) and
  discards the data of known-stale information. This will prevent the need for such clients to manually
  delete the `sporks` folder in their datadir.

ACKs for top commit:
  furszy:
    looking good now, utACK 9aae20b
  random-zebra:
    utACK 9aae20b

Tree-SHA512: d132abb6ad414624930e19deb3dab7b41068d635582821166f43f257342d935676a72845ec2fb63a439ef847b65ecbce4f7218f60efd093716dd858164b046f2
  • Loading branch information
random-zebra committed Dec 2, 2020
2 parents 0371b10 + 9aae20b commit 860064b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/spork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ void CSporkManager::LoadSporksFromDB()
continue;
}

// TODO: Temporary workaround for v5.0 clients to ensure up-to-date protocol version spork
if (spork.nSporkID == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) {
LogPrintf("%s : Spork 15 signed at %d\n", __func__, spork.nTimeSigned);
// 1578338986 is the timestamp that spork 15 was last signed at for mainnet for the previous
// protocol bump. If the timestamp in the DB is equal or lower than this, we know that
// the value is stale and should ignore it to prevent un-necessary disconnections in the
// version handshake process. This value is also suitable for testnet as the timestamp
// for this spork on that network was signed shortly after this.
if (spork.nTimeSigned <= 1578338986 ) {
LogPrintf("%s : Stale spork 15 detected, clearing...\n", __func__);
CSporkManager::Clear();
return;
}
}

// add spork to memory
mapSporks[spork.GetHash()] = spork;
mapSporksActive[spork.nSporkID] = spork;
Expand Down

0 comments on commit 860064b

Please sign in to comment.