@@ -814,16 +814,17 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has
|
||||
{
|
||||
if ( nHeight < notarized_height )
|
||||
{
|
||||
fprintf(stderr,"nHeight.%d < NOTARIZED_HEIGHT.%d\n",nHeight,notarized_height);
|
||||
//fprintf(stderr,"[%s] nHeight.%d < NOTARIZED_HEIGHT.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height);
|
||||
return(-1);
|
||||
}
|
||||
else if ( nHeight == notarized_height && memcmp(&hash,¬arized_hash,sizeof(hash)) != 0 )
|
||||
{
|
||||
fprintf(stderr,"nHeight.%d == NOTARIZED_HEIGHT.%d, diff hash\n",nHeight,notarized_height);
|
||||
fprintf(stderr,"[%s] nHeight.%d == NOTARIZED_HEIGHT.%d, diff hash\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height);
|
||||
return(-1);
|
||||
}
|
||||
} else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight);
|
||||
} else if ( notarized_height > 0 && notarized_height != 73880 && notarized_height >= 170000 )
|
||||
} else fprintf(stderr,"[%s] unexpected error notary_hash %s ht.%d at ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,notary->nHeight);
|
||||
}
|
||||
else if ( notarized_height > 0 && notarized_height != 73880 && notarized_height >= 170000 )
|
||||
fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight);
|
||||
return(0);
|
||||
}
|
||||
|
||||
45
src/main.cpp
45
src/main.cpp
@@ -3372,7 +3372,14 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
if (pcheckpoint && (nHeight < pcheckpoint->nHeight || nHeight == 1 && chainActive.Tip() != 0 && chainActive.Tip()->nHeight > 1) )
|
||||
return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight));
|
||||
else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 )
|
||||
return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height));
|
||||
{
|
||||
CBlockIndex *heightblock = chainActive[nHeight];
|
||||
if ( heightblock != 0 && heightblock->GetBlockHash() == hash )
|
||||
{
|
||||
//fprintf(stderr,"got a pre notarization block that matches height.%d\n",(int32_t)nHeight);
|
||||
return true;
|
||||
} else return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height));
|
||||
}
|
||||
}
|
||||
// Reject block.nVersion < 4 blocks
|
||||
if (block.nVersion < 4)
|
||||
@@ -3430,6 +3437,40 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
||||
*ppindex = pindex;
|
||||
if (pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK)
|
||||
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
|
||||
if ( pindex != 0 && IsInitialBlockDownload() == 0 ) // jl777 debug test
|
||||
{
|
||||
if (!CheckBlockHeader(pindex->nHeight,pindex, block, state))
|
||||
{
|
||||
pindex->nStatus |= BLOCK_FAILED_MASK;
|
||||
fprintf(stderr,"known block failing CheckBlockHeader %d\n",(int32_t)pindex->nHeight);
|
||||
return false;
|
||||
}
|
||||
CBlockIndex* pindexPrev = NULL;
|
||||
if (hash != chainparams.GetConsensus().hashGenesisBlock)
|
||||
{
|
||||
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
|
||||
if (mi == mapBlockIndex.end())
|
||||
{
|
||||
pindex->nStatus |= BLOCK_FAILED_MASK;
|
||||
fprintf(stderr,"known block.%d failing to find prevblock\n",(int32_t)pindex->nHeight);
|
||||
return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
|
||||
}
|
||||
pindexPrev = (*mi).second;
|
||||
if (pindexPrev == 0 || (pindexPrev->nStatus & BLOCK_FAILED_MASK) )
|
||||
{
|
||||
pindex->nStatus |= BLOCK_FAILED_MASK;
|
||||
fprintf(stderr,"known block.%d found invalid prevblock\n",(int32_t)pindex->nHeight);
|
||||
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
|
||||
}
|
||||
}
|
||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||
{
|
||||
pindex->nStatus |= BLOCK_FAILED_MASK;
|
||||
fprintf(stderr,"known block.%d failing ContextualCheckBlockHeader\n",(int32_t)pindex->nHeight);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3441,7 +3482,9 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
||||
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
|
||||
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
|
||||
if (mi == mapBlockIndex.end())
|
||||
{
|
||||
return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
|
||||
}
|
||||
pindexPrev = (*mi).second;
|
||||
if (pindexPrev == 0 || (pindexPrev->nStatus & BLOCK_FAILED_MASK) )
|
||||
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
|
||||
|
||||
Reference in New Issue
Block a user