Test
This commit is contained in:
@@ -849,10 +849,10 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width) // depre
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t timestamp)
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t tiptime,uint32_t blocktime)
|
||||
{
|
||||
int32_t i,j,notaryid=0,minerid,limit,nid; uint8_t destpubkey33[33];
|
||||
komodo_chosennotary(¬aryid,height,pubkey33,timestamp);
|
||||
komodo_chosennotary(¬aryid,height,pubkey33,tiptime);
|
||||
if ( height >= 82000 )
|
||||
{
|
||||
if ( notaryid >= 0 )
|
||||
@@ -869,7 +869,12 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
|
||||
else break;
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
if ( blocktime < tiptime+60 )
|
||||
{
|
||||
fprintf(stderr,"n.%d l.%d\n",notaryid,blocktime-tiptime);
|
||||
if ( height > 807000 )
|
||||
return(-2);
|
||||
} else return(1);
|
||||
} else return(0);
|
||||
}
|
||||
else
|
||||
@@ -883,7 +888,7 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
|
||||
else limit = 66;
|
||||
for (i=1; i<limit; i++)
|
||||
{
|
||||
komodo_chosennotary(&nid,height-i,pubkey33,timestamp);
|
||||
komodo_chosennotary(&nid,height-i,pubkey33,tiptime);
|
||||
if ( nid == notaryid )
|
||||
{
|
||||
//for (j=0; j<66; j++)
|
||||
|
||||
@@ -1678,7 +1678,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos)
|
||||
}
|
||||
// Check the header
|
||||
komodo_block2pubkey33(pubkey33,(CBlock *)&block);
|
||||
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus())))
|
||||
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime)))
|
||||
{
|
||||
int32_t i; for (i=0; i<33; i++)
|
||||
fprintf(stderr,"%02x",pubkey33[i]);
|
||||
@@ -3751,7 +3751,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
|
||||
|
||||
// Check proof of work matches claimed amount
|
||||
/*komodo_index2pubkey33(pubkey33,pindex,height);
|
||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) )
|
||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus(),blockhdr.nTime) )
|
||||
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");*/
|
||||
return true;
|
||||
}
|
||||
@@ -3808,7 +3808,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
|
||||
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
|
||||
return state.DoS(100, error("CheckBlock(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
||||
komodo_block2pubkey33(pubkey33,(CBlock *)&block);
|
||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus()) )
|
||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime) )
|
||||
return state.DoS(1, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash");
|
||||
// Check the merkle root.
|
||||
if (fCheckMerkleRoot) {
|
||||
|
||||
16
src/pow.cpp
16
src/pow.cpp
@@ -117,7 +117,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
||||
}
|
||||
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t timestamp);
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t tiptime,uint32_t blocktime);
|
||||
int32_t komodo_currentheight();
|
||||
CBlockIndex *komodo_chainactive(int32_t height);
|
||||
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
|
||||
@@ -131,14 +131,16 @@ int32_t KOMODO_LOADINGBLOCKS = 1;
|
||||
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
|
||||
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
||||
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int nBits,const Consensus::Params& params,uint32_t blocktime)
|
||||
{
|
||||
extern int32_t KOMODO_REWIND;
|
||||
bool fNegative,fOverflow; uint8_t origpubkey33[33]; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t timestamp = 0; CBlockIndex *pindex=0;
|
||||
bool fNegative,fOverflow; uint8_t origpubkey33[33]; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t tiptime = 0;
|
||||
arith_uint256 bnTarget; uint8_t pubkeys[66][33];
|
||||
memcpy(origpubkey33,pubkey33,33);
|
||||
timestamp = komodo_chainactive_timestamp();
|
||||
tiptime = komodo_chainactive_timestamp();
|
||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||
if ( blocktime == 0 || tiptime == 0 )
|
||||
fprintf(stderr,"nul blocktime.%u or tiptime.%u\n",blocktime,tiptime);
|
||||
if ( height == 0 )
|
||||
{
|
||||
height = komodo_currentheight() + 1;
|
||||
@@ -146,7 +148,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
}
|
||||
if ( height > 34000 && ASSETCHAINS_SYMBOL[0] == 0 ) // 0 -> non-special notary
|
||||
{
|
||||
special = komodo_chosennotary(¬aryid,height,pubkey33,timestamp);
|
||||
special = komodo_chosennotary(¬aryid,height,pubkey33,tiptime);
|
||||
for (i=0; i<33; i++)
|
||||
{
|
||||
if ( pubkey33[i] != 0 )
|
||||
@@ -158,7 +160,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
return(true); // will come back via different path with pubkey set
|
||||
}
|
||||
flag = komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,height);
|
||||
special2 = komodo_is_special(pubkeys,mids,height,pubkey33,timestamp);
|
||||
special2 = komodo_is_special(pubkeys,mids,height,pubkey33,tiptime,blocktime);
|
||||
if ( notaryid >= 0 )
|
||||
{
|
||||
if ( height > 10000 && height < 80000 && (special != 0 || special2 > 0) )
|
||||
@@ -175,7 +177,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
flag = 0;
|
||||
else fprintf(stderr,"ht.%d notaryid.%d special.%d flag.%d special2.%d\n",height,notaryid,special,flag,special2);
|
||||
}
|
||||
if ( flag != 0 || special2 > 0 )
|
||||
if ( (flag != 0 || special2 > 0) && special2 != -2 )
|
||||
{
|
||||
//fprintf(stderr,"EASY MINING ht.%d\n",height);
|
||||
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
|
||||
@@ -25,7 +25,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||
bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&);
|
||||
|
||||
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
|
||||
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&);
|
||||
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&,uint32_t blocktime);
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block);
|
||||
|
||||
/** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */
|
||||
|
||||
@@ -257,7 +257,7 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
LOCK(cs_main);
|
||||
pblock->nSolution = soln;
|
||||
solutionTargetChecks.increment();
|
||||
return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus());
|
||||
return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus(),pblock->nTime);
|
||||
};
|
||||
bool found = EhBasicSolveUncancellable(n, k, curr_state, validBlock);
|
||||
ehSolverRuns.increment();
|
||||
|
||||
@@ -530,7 +530,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||
diskindex.ToString(), pindexNew->ToString());
|
||||
uint8_t pubkey33[33];
|
||||
komodo_index2pubkey33(pubkey33,pindexNew,pindexNew->nHeight);
|
||||
if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
|
||||
if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus(),pindexNew->nTime))
|
||||
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
|
||||
pcursor->Next();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user