Skip to content

Commit

Permalink
Finalize dip0003/dip0008 enforcement on mainnet. (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
barrystyle authored Nov 20, 2019
1 parent 43d3c77 commit 11cab95
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 54 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 14)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 3)
define(_CLIENT_VERSION_BUILD, 4)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2019)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
43 changes: 20 additions & 23 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].bit = 3;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nThreshold = 10;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nWindowSize = 2000;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nThreshold = 1000;

// Deployment of DIP0008
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].bit = 4;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nThreshold = 10;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nWindowSize = 3000;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nThreshold = 1500;

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000000000000000512d5"); // 332500
Expand Down Expand Up @@ -365,28 +365,25 @@ class CMainParams : public CChainParams {

checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 100, uint256S("0x000005065df82218140bc7c59cfd6913eaa5a88f3255ccc977c546cb0beb9ff0"))
( 7200, uint256S("0x00000000000b7d73439cae777bae147b8daaee692a9e5e06fd8466749de39465"))
( 43850, uint256S("0x0000000000000be675f137fbf5cbe5e9d8cb0ea509d30252a02c30944f16970f"))
( 50000, uint256S("0x00000000000007cdd43a784898eb9cb5be63ca7db5e5935a05a1baa01a658ca0"))
( 50620, uint256S("0x0000000000000349685ff23a2344db4d51ae9f169cda23c8a472fb783914b071"))
( 151380, uint256S("0x00000000000027377aa412aad9342c61c20973ac1636663b2ef06b3f7549876d"))
( 216000, uint256S("0x00000000000038a52e7bafb7fb091ed2989ec8bdd7a550db9925300687805d87"))
( 230000, uint256S("0x0000000000000e3cbc8c4e418677a796ff92212d4d5f3ee81fa370a1fe04074b"))
( 250000, uint256S("0x00000000000016fe843a827dc319b45d10c59ff45f8fcc1ee407ee964d3a6f7d"))
( 260000, uint256S("0x0000000000001377c02f7276615f1467936c7778785e30027b46e59c3e9e46e6"))
( 270000, uint256S("0x0000000000001ea31b8d2bf73d0471b57a41fe0b60e500e559af6f88a2bad9c2"))
( 280000, uint256S("0x0000000000003b2680a18e08c41719206c76b05e2eb32f8aa45730246d63b2b7"))
( 290000, uint256S("0x00000000000069c1ef2e4f3122e6021177b581fd944c174390f1d3cdcdcc6722"))
( 300000, uint256S("0x0000000000001f4f2650510e1ad032f356d2fcb001aafcd5e13a87a259f8e15e"))
( 330000, uint256S("0x816ef933e4ab900d99eecde8d6abb1d2f2b71c001d05f79f5d4b98a67facd143"))
( 331000, uint256S("0xec03918f66618c53742a0638d976b2b56807d3e3ca7a7de2d72e920f02fe521e"))
( 332000, uint256S("0xbee2c8b8c12ad020783e241e086440f92054c7ea557c7639c32bc7fa6430a0cd"))
( 333000, uint256S("0xa214b0d4da47f41900e6a1c0f3821cdec90b8a58b404f4eea0e9442520676594"))
( 334000, uint256S("0x1a8f4b80b5eb1200038ea80fac956546eb2d358c7c707af4de7eaff9ed48a4b5"))
( 335000, uint256S("0x2e2c7740b1349cad05b87e8e99085fbb942cfc9d5659f0a69f5b15480245acaa"))
( 338000, uint256S("0xfbbab860d2d5c18e5241b3c184c0ae6d38ddb8c3619ec86a6d67fb0b3f6e077f"))
( 340000, uint256S("0x006d214eae0d741af1302096f9ebdccd7bcddbd97da7e574bda7d6423e995c93"))
( 344000, uint256S("0xae6d411fca8ebda49838c6fead60d586b93742642ccdae6094f2d4c7a463f9d1"))
( 348000, uint256S("0xef51329d54c7219a5462acce5f794c82887ca2326cd52748173c89b7bf10d031"))
( 352000, uint256S("0xa4342f0a9ec9e46105bc8fd73aa46a4b931b2ec536bab36cc8103d1f9ed0dad8"))
( 356000, uint256S("0xbfd90a7cec6af4754fc7543bbcdfa2b9175b62235f9e93ab19d2b27935546d9e"))
( 358000, uint256S("0xd404c8f00eef86c2f6af2bb2d7eb0bee1b21bd479a328eeb2432f6e1e2ddfabb"))
};

chainTxData = ChainTxData{
1570098593, // * UNIX timestamp of last known number of transactions
980978, // * total number of transactions between genesis and that timestamp
1574166488, // * UNIX timestamp of last known number of transactions
1060113, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
0.1 // * estimated number of transactions per second after that timestamp
};
Expand Down Expand Up @@ -476,15 +473,15 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].bit = 3;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nThreshold = 10;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nWindowSize = 1000;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0003].nThreshold = 250;

// Deployment of DIP0008
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].bit = 4;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nThreshold = 10;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nWindowSize = 1000;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0008].nThreshold = 250;

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace llmq
{

// If true, we will connect to all new quorums and watch their communication
static const bool DEFAULT_WATCH_QUORUMS = false;
static const bool DEFAULT_WATCH_QUORUMS = true;

// Init/destroy LLMQ globals
void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests, bool fWipe = false);
Expand Down
22 changes: 5 additions & 17 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Pa
// Short-circuit most stuff in case its from the same node
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash);
if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) {
*pit = &itInFlight->second.second;
if (pit) {
*pit = &itInFlight->second.second;
}
return false;
}

Expand Down Expand Up @@ -1963,7 +1965,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
// Send the rest of the chain
if (pindex)
pindex = chainActive.Next(pindex);
int nLimit = 1000;
int nLimit = 500;
LogPrint("net", "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom->id);
for (; pindex; pindex = chainActive.Next(pindex))
{
Expand Down Expand Up @@ -2049,12 +2051,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
uint256 hashStop;
vRecv >> locator >> hashStop;

if (locator.vHave.size() > MAX_LOCATOR_SZ) {
LogPrint("net", "getheaders locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId());
pfrom->fDisconnect = true;
return true;
}

LOCK(cs_main);
if (IsInitialBlockDownload() && !pfrom->fWhitelisted) {
LogPrint("net", "Ignoring getheaders from peer=%d because node is in initial block download\n", pfrom->id);
Expand Down Expand Up @@ -2420,7 +2416,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
// If we end up treating this as a plain headers message, call that as well
// without cs_main.
bool fRevertToHeaderProcessing = false;
CDataStream vHeadersMsg(SER_NETWORK, PROTOCOL_VERSION);

// Keep a CBlock for "optimistic" compactblock reconstructions (see
// below)
Expand Down Expand Up @@ -2537,10 +2532,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return true;
} else {
// If this was an announce-cmpctblock, we want the same treatment as a header message
// Dirty hack to process as if it were just a headers message (TODO: move message handling into their own functions)
std::vector<CBlock> headers;
headers.push_back(cmpctblock.header);
vHeadersMsg << headers;
fRevertToHeaderProcessing = true;
}
}
Expand All @@ -2549,9 +2540,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
if (fProcessBLOCKTXN)
return ProcessMessage(pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman, interruptMsgProc);

if (fRevertToHeaderProcessing)
return ProcessMessage(pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman, interruptMsgProc);

if (fBlockReconstructed) {
// If we got here, we were able to optimistically reconstruct a
// block that is in flight from some other peer.
Expand Down Expand Up @@ -3371,7 +3359,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do.
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
// Only actively request headers from a single peer, unless we're close to end of initial download.
if ((nSyncStarted < 2 && fFetch) || chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - nMaxTipAge) {
if ((nSyncStarted < 4 && fFetch) || chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - nMaxTipAge) {
state.fSyncStarted = true;
state.nHeadersSyncTimeout = GetTimeMicros() + HEADERS_DOWNLOAD_TIMEOUT_BASE + HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER * (GetAdjustedTime() - pindexBestHeader->GetBlockTime())/(consensusParams.nPowTargetSpacing);
nSyncStarted++;
Expand Down
18 changes: 10 additions & 8 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2328,10 +2328,11 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd

bool isProofOfStake = !block.IsProofOfWork();
const auto& coinbaseTransaction = block.vtx[isProofOfStake];
if (!IsBlockPayeeValid(*block.vtx[isProofOfStake], pindex->nHeight, blockReward)) {
mapRejectedBlocks.insert(std::make_pair(block.GetHash(), GetTime()));
return state.DoS(0, error("ConnectBlock(PAC): couldn't find masternode or superblock payments"),
REJECT_INVALID, "bad-cb-payee");
if (FullDIP0003Mode()) {
if (!IsBlockPayeeValid(*block.vtx[isProofOfStake], pindex->nHeight, blockReward)) {
mapRejectedBlocks.insert(std::make_pair(block.GetHash(), GetTime()));
return state.DoS(0, error("ConnectBlock(PAC): couldn't find masternode or superblock payments"), REJECT_INVALID, "bad-cb-payee");
}
}

int64_t nTime5_4 = GetTimeMicros(); nTimePayeeValid += nTime5_4 - nTime5_3;
Expand Down Expand Up @@ -4821,9 +4822,10 @@ double GuessVerificationProgress(const ChainTxData& data, CBlockIndex *pindex) {

//! Returns the current minimum protocol version in use
int CurrentProtocol() {
return (Params().NetworkIDString() ==
CBaseChainParams::TESTNET ? MIN_PEER_PROTO_VERSION_TESTNET :
MIN_PEER_PROTO_VERSION_MAINNET);
if (Params().NetworkIDString() == CBaseChainParams::TESTNET)
return FullDIP0003Mode() ? MIN_PEER_PROTO_PHASE2_TESTNET : MIN_PEER_PROTO_PHASE1_TESTNET;
else
return FullDIP0003Mode() ? MIN_PEER_PROTO_PHASE2_MAINNET : MIN_PEER_PROTO_PHASE1_MAINNET;
}

//! Returns true if we can ignore sigops limits temporarily
Expand Down Expand Up @@ -4851,7 +4853,7 @@ int ConfirmationsPerNetwork() {

//! Returns whether full DIP3 enforcement is active
bool FullDIP0003Mode() {
return (chainActive.Height() > Params().GetConsensus().DIP0003EnforcementHeight);
return (chainActive.Height() >= Params().GetConsensus().DIP0003EnforcementHeight);
}

class CMainCleanup
Expand Down
12 changes: 8 additions & 4 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@
*/


static const int PROTOCOL_VERSION = 70216;
static const int PROTOCOL_VERSION = 70218;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;

//! In this version, 'getheaders' was introduced.
static const int GETHEADERS_VERSION = 70077;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION_MAINNET = 70216;
static const int MIN_PEER_PROTO_VERSION_TESTNET = 70216;
//! disconnect from peers older than this proto version (PoW -> PoS)
static const int MIN_PEER_PROTO_PHASE1_MAINNET = 70216;
static const int MIN_PEER_PROTO_PHASE1_TESTNET = 70216;

//! disconnect from peers older than this proto version (Full DIP0003)
static const int MIN_PEER_PROTO_PHASE2_MAINNET = 70218;
static const int MIN_PEER_PROTO_PHASE2_TESTNET = 70218;

//! nTime field added to CAddress, starting with this version;
//! if possible, avoid requesting addresses nodes older than this
Expand Down

0 comments on commit 11cab95

Please sign in to comment.