Trying to fix the forking issue, which is now clearly a bug in sending and receiving headers. This checkin will enable debugging and may be a fix.
This commit is contained in:
@@ -3999,7 +3999,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
|
||||
{
|
||||
const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1;
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
bool checkBlockOne = (nHeight == 1);
|
||||
|
||||
// Check that all transactions are finalized
|
||||
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
|
||||
@@ -4087,7 +4086,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
|
||||
komodo_requestedhash = block.hashPrevBlock;
|
||||
komodo_requestedcount = 0;
|
||||
}*/
|
||||
LogPrintf("AcceptBlockHeader hashPrevBlock %s not found\n",block.hashPrevBlock.ToString().c_str());
|
||||
LogPrintf("AcceptBlockHeader %s\n hashPrevBlock %s not found\n", hash.ToString().c_str(), block.hashPrevBlock.ToString().c_str());
|
||||
return(false);
|
||||
//return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
|
||||
}
|
||||
@@ -6016,8 +6015,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
pindex = chainActive.Next(pindex);
|
||||
}
|
||||
|
||||
// we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
|
||||
vector<CBlock> vHeaders;
|
||||
// we should probably use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
|
||||
vector<CBlockHeader> vHeaders;
|
||||
int nLimit = MAX_HEADERS_RESULTS;
|
||||
LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id);
|
||||
//if ( pfrom->lasthdrsreq >= chainActive.Height()-MAX_HEADERS_RESULTS || pfrom->lasthdrsreq != (int32_t)(pindex ? pindex->nHeight : -1) )// no need to ever suppress this
|
||||
|
||||
@@ -546,6 +546,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake)
|
||||
// Fill in header
|
||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||
pblock->hashReserved = uint256();
|
||||
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || NOTARY_PUBKEY33[0] == 0 )
|
||||
{
|
||||
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||
@@ -777,16 +778,22 @@ int32_t waitForPeers(const CChainParams &chainparams)
|
||||
{
|
||||
if (chainparams.MiningRequiresPeers())
|
||||
{
|
||||
do {
|
||||
bool fvNodesEmpty;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
if (!fvNodesEmpty )
|
||||
break;
|
||||
MilliSleep(1000 + rand() % 1900);
|
||||
} while (true);
|
||||
bool fvNodesEmpty;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
if (fvNodesEmpty)
|
||||
{
|
||||
do {
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
} while (fvNodesEmpty);
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,18 +824,17 @@ void static VerusStaker(CWallet *pwallet)
|
||||
break;
|
||||
}
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
sleep(5);
|
||||
CBlockIndex *curTip = chainActive.Tip(), *lastTip;
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
CBlockIndex* pindexPrev;
|
||||
do {
|
||||
lastTip = curTip;
|
||||
printf("Verifying block height %d \n", lastTip->nHeight);
|
||||
MilliSleep(3000 + rand() % 1900);
|
||||
curTip = chainActive.Tip();
|
||||
} while (curTip != lastTip);
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
pindexPrev = chainActive.Tip();
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
} while (pindexPrev != chainActive.Tip());
|
||||
|
||||
sleep(5);
|
||||
printf("Staking height %d for %s\n", chainActive.Tip()->nHeight + 1, ASSETCHAINS_SYMBOL);
|
||||
@@ -940,11 +946,12 @@ void static VerusStaker(CWallet *pwallet)
|
||||
|
||||
ProcessBlockFound(pblock, *pwallet, reservekey);
|
||||
|
||||
sleep(3);
|
||||
// Check for stop or if block needs to be rebuilt
|
||||
boost::this_thread::interruption_point();
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
sleep(5);
|
||||
|
||||
// In regression test mode, stop mining after a block is found.
|
||||
if (chainparams.MineBlocksOnDemand()) {
|
||||
throw boost::thread_interrupted();
|
||||
@@ -993,18 +1000,15 @@ void static BitcoinMiner_noeq()
|
||||
break;
|
||||
}
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
CBlockIndex *curTip = chainActive.Tip(), *lastTip;
|
||||
CBlockIndex* pindexPrev;
|
||||
do {
|
||||
lastTip = curTip;
|
||||
printf("Verifying block height %d \n", lastTip->nHeight);
|
||||
MilliSleep(1000 + rand() % 5000);
|
||||
curTip = chainActive.Tip();
|
||||
} while (curTip != lastTip);
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
pindexPrev = chainActive.Tip();
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
} while (pindexPrev != chainActive.Tip());
|
||||
|
||||
printf("Mining height %d\n", chainActive.Tip()->nHeight + 1);
|
||||
|
||||
@@ -1017,16 +1021,16 @@ void static BitcoinMiner_noeq()
|
||||
miningTimer.stop();
|
||||
waitForPeers(chainparams);
|
||||
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
pindexPrev = chainActive.Tip();
|
||||
sleep(1);
|
||||
|
||||
// prevent forking on startup before the diff algorithm kicks in
|
||||
if (pindexPrev->nHeight < 70)
|
||||
if (pindexPrev->nHeight < 50 || pindexPrev != chainActive.Tip())
|
||||
{
|
||||
do {
|
||||
lastTip = pindexPrev;
|
||||
MilliSleep(3000 + rand() % 5000);
|
||||
pindexPrev = chainActive.Tip();
|
||||
} while (pindexPrev != lastTip);
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
} while (pindexPrev != chainActive.Tip());
|
||||
}
|
||||
miningTimer.start();
|
||||
|
||||
|
||||
@@ -76,7 +76,10 @@ public:
|
||||
|
||||
uint256 GetHash() const
|
||||
{
|
||||
return (this->*hashFunction)();
|
||||
if (hashPrevBlock.IsNull())
|
||||
return (this->GetSHA256DHash());
|
||||
else
|
||||
return (this->*hashFunction)();
|
||||
}
|
||||
|
||||
uint256 GetSHA256DHash() const;
|
||||
|
||||
Reference in New Issue
Block a user