Browse Source

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

pull/4/head
miketout 6 years ago
parent
commit
64d6048f4a
  1. 54
      src/chainparams.cpp
  2. 19
      src/main.cpp
  3. 3
      src/miner.cpp

54
src/chainparams.cpp

@ -235,12 +235,6 @@ void *chainparams_commandline(void *ptr)
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);
// 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)
{
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
@ -262,22 +256,38 @@ void *chainparams_commandline(void *ptr)
mainParams.consensus.nLwmaPOSAjustedWeight = 46531;
}
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, mainParams.consensus.hashGenesisBlock)
(10000, uint256S("0xac2cd7d37177140ea4991cf630c0b9c7f94d707b84fb0351bf3a44856d2ae5dc"))
(20000, uint256S("0xb0e8cb9f77aaa7ff5bd90d6c08d06f4c4bf03e00c2b8a35a042e760845590c8a"))
(30000, uint256S("0xf2112ca577338ad7104bf905fa6a63d36b17a86f914c97b73cd31d43fcd7557c"))
(40000, uint256S("0x00000000008f83378dab727864b763ce91a4ea5f75d55939c0c1390cfb8c38f1"))
(49170, uint256S("0x2add646c0089871ec2379f02f7cd60b3af6efd9c152a6f16fc10925458c270cc")),
(int64_t)1529910234, // * UNIX timestamp of last checkpoint block
(int64_t)63661, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
// 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)
{
boost::assign::map_list_of
(0, mainParams.consensus.hashGenesisBlock)
(10000, uint256S("0xac2cd7d37177140ea4991cf630c0b9c7f94d707b84fb0351bf3a44856d2ae5dc"))
(20000, uint256S("0xb0e8cb9f77aaa7ff5bd90d6c08d06f4c4bf03e00c2b8a35a042e760845590c8a"))
(30000, uint256S("0xf2112ca577338ad7104bf905fa6a63d36b17a86f914c97b73cd31d43fcd7557c"))
(40000, uint256S("0x00000000008f83378dab727864b763ce91a4ea5f75d55939c0c1390cfb8c38f1"))
(49170, uint256S("0x2add646c0089871ec2379f02f7cd60b3af6efd9c152a6f16fc10925458c270cc")),
(int64_t)1529910234, // * UNIX timestamp of last checkpoint block
(int64_t)63661, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
(double)2777 // * estimated number of transactions per day after checkpoint
// 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
{

19
src/main.cpp

@ -1906,7 +1906,7 @@ bool IsInitialBlockDownload()
}
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;
}
static bool lockIBDState = false;
@ -1949,7 +1949,7 @@ bool IsInSync()
pbi = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints());
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;
}
}
@ -5948,8 +5948,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
CAddress addrMe;
CAddress addrFrom;
uint64_t nNonce = 1;
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
if (pfrom->nVersion < MIN_PEER_PROTO_VERSION)
int nVersion; // use temporary for version, don't set version number until validated as connected
vRecv >> nVersion >> pfrom->nServices >> nTime >> addrMe;
if (nVersion < MIN_PEER_PROTO_VERSION)
{
// disconnect from peers older than this proto version
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
const Consensus::Params& params = Params().GetConsensus();
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,
strprintf("Version must be %d or greater",
params.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion));
@ -5972,8 +5973,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
return false;
}
if (pfrom->nVersion == 10300)
pfrom->nVersion = 300;
if (nVersion == 10300)
nVersion = 300;
if (!vRecv.empty())
vRecv >> addrFrom >> nNonce;
if (!vRecv.empty()) {
@ -5994,6 +5995,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pfrom->fDisconnect = true;
return true;
}
pfrom->nVersion = nVersion;
pfrom->addrLocal = addrMe;
if (pfrom->fInbound && addrMe.IsRoutable())

3
src/miner.cpp

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

Loading…
Cancel
Save