Fixed checkpoint data that was put into codebase without proper check for blockchain, breaking other blockchains or asset chains

This commit is contained in:
miketout
2018-08-27 12:11:33 -07:00
parent 21337a4992
commit 64d6048f4a
3 changed files with 45 additions and 31 deletions

View File

@@ -235,12 +235,6 @@ void *chainparams_commandline(void *ptr)
mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
// only require coinbase protection on Verus from the Komodo family of coins
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
mainParams.consensus.fCoinbaseMustBeProtected = true;
}
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH)
{ {
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
@@ -262,6 +256,10 @@ void *chainparams_commandline(void *ptr)
mainParams.consensus.nLwmaPOSAjustedWeight = 46531; mainParams.consensus.nLwmaPOSAjustedWeight = 46531;
} }
// only require coinbase protection on Verus from the Komodo family of coins
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
mainParams.consensus.fCoinbaseMustBeProtected = true;
checkpointData = //(Checkpoints::CCheckpointData) checkpointData = //(Checkpoints::CCheckpointData)
{ {
boost::assign::map_list_of boost::assign::map_list_of
@@ -277,7 +275,19 @@ void *chainparams_commandline(void *ptr)
(double)2777 // * estimated number of transactions per day after checkpoint (double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24)) // total number of tx / (checkpoint block height / (24 * 24))
}; };
}
else
{
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, mainParams.consensus.hashGenesisBlock),
(int64_t)1231006505,
(int64_t)1,
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
}
} }
else else
{ {

View File

@@ -1906,7 +1906,7 @@ bool IsInitialBlockDownload()
} }
if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints())) if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints()))
{ {
//fprintf(stderr,"IsInitialBlockDownload: checkpoint -> initialdownload\n"); //fprintf(stderr,"IsInitialBlockDownload: checkpoint -> initialdownload - %d blocks\n", Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints()));
return true; return true;
} }
static bool lockIBDState = false; static bool lockIBDState = false;
@@ -1949,7 +1949,7 @@ bool IsInSync()
pbi = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints()); pbi = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints());
if (fCheckpointsEnabled && pbi && (chainActive.Height() < pbi->nHeight)) if (fCheckpointsEnabled && pbi && (chainActive.Height() < pbi->nHeight))
{ {
//fprintf(stderr,"IsInSync: checkpoint -> initialdownload\n"); //fprintf(stderr,"IsInSync: checkpoint -> initialdownload chainActive.Height().%d pbi->nHeight.%d\n", chainActive.Height(), pbi->nHeight);
return false; return false;
} }
} }
@@ -5948,8 +5948,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
CAddress addrMe; CAddress addrMe;
CAddress addrFrom; CAddress addrFrom;
uint64_t nNonce = 1; uint64_t nNonce = 1;
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; int nVersion; // use temporary for version, don't set version number until validated as connected
if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe;
if (nVersion < MIN_PEER_PROTO_VERSION)
{ {
// disconnect from peers older than this proto version // disconnect from peers older than this proto version
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
@@ -5962,9 +5963,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// When Overwinter is active, reject incoming connections from non-Overwinter nodes // When Overwinter is active, reject incoming connections from non-Overwinter nodes
const Consensus::Params& params = Params().GetConsensus(); const Consensus::Params& params = Params().GetConsensus();
if (NetworkUpgradeActive(GetHeight(), params, Consensus::UPGRADE_OVERWINTER) if (NetworkUpgradeActive(GetHeight(), params, Consensus::UPGRADE_OVERWINTER)
&& pfrom->nVersion < params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion) && nVersion < params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion)
{ {
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, nVersion);
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", strprintf("Version must be %d or greater",
params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion)); params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion));
@@ -5972,8 +5973,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
return false; return false;
} }
if (pfrom->nVersion == 10300) if (nVersion == 10300)
pfrom->nVersion = 300; nVersion = 300;
if (!vRecv.empty()) if (!vRecv.empty())
vRecv >> addrFrom >> nNonce; vRecv >> addrFrom >> nNonce;
if (!vRecv.empty()) { if (!vRecv.empty()) {
@@ -5995,6 +5996,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
return true; return true;
} }
pfrom->nVersion = nVersion;
pfrom->addrLocal = addrMe; pfrom->addrLocal = addrMe;
if (pfrom->fInbound && addrMe.IsRoutable()) if (pfrom->fInbound && addrMe.IsRoutable())
{ {

View File

@@ -799,6 +799,7 @@ int32_t waitForPeers(const CChainParams &chainparams)
if (fvNodesEmpty || !IsInSync()) if (fvNodesEmpty || !IsInSync())
{ {
do { do {
if (fvNodesEmpty)
MilliSleep(1000 + rand() % 4000); MilliSleep(1000 + rand() % 4000);
{ {
LOCK(cs_vNodes); LOCK(cs_vNodes);