Test
This commit is contained in:
@@ -651,6 +651,7 @@ int32_t komodo_block2height(CBlock *block)
|
||||
}
|
||||
if ( height != height2 )
|
||||
{
|
||||
//fprintf(stderr,"block2height height.%d vs height2.%d, match.%d mismatch.%d\n",height,height2,match,mismatch);
|
||||
mismatch++;
|
||||
if ( height2 >= 0 )
|
||||
height = height2;
|
||||
@@ -803,7 +804,7 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
||||
return(komodo_electednotary(&numnotaries,pubkey33,height,timestamp));
|
||||
}*/
|
||||
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height)
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height)
|
||||
{
|
||||
int32_t i,j,n,duplicate; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33];
|
||||
memset(mids,-1,sizeof(*mids)*66);
|
||||
@@ -812,6 +813,7 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *non
|
||||
{
|
||||
if ( (pindex= komodo_chainactive(height-i)) != 0 )
|
||||
{
|
||||
blocktimes[i] = pindex->nTime;
|
||||
if ( komodo_blockload(block,pindex) == 0 )
|
||||
{
|
||||
komodo_block2pubkey33(pubkeys[i],&block);
|
||||
@@ -848,10 +850,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],uint32_t blocktimes[66],int32_t height,uint8_t pubkey33[33],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,blocktimes[0]);
|
||||
if ( height >= 82000 )
|
||||
{
|
||||
if ( notaryid >= 0 )
|
||||
@@ -860,14 +862,21 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
|
||||
{
|
||||
if ( mids[i] == notaryid )
|
||||
{
|
||||
//for (j=0; j<66; j++)
|
||||
// fprintf(stderr,"%d ",mids[j]);
|
||||
//fprintf(stderr,"ht.%d repeat notaryid.%d in mids[%d]\n",height,notaryid,i);
|
||||
if ( height > 792000 )
|
||||
{
|
||||
for (j=0; j<66; j++)
|
||||
fprintf(stderr,"%d ",mids[j]);
|
||||
fprintf(stderr,"ht.%d repeat notaryid.%d in mids[%d]\n",height,notaryid,i);
|
||||
return(-1);
|
||||
else break;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
if ( blocktime != 0 && blocktimes[1] != 0 && blocktime < blocktimes[1]+57 )
|
||||
{
|
||||
fprintf(stderr,"lag.%d ht.%d n.%d blocktimes[%u vs %u %u]\n",blocktime-blocktimes[1],height,notaryid,blocktime,blocktimes[0],blocktimes[1]);
|
||||
if ( height > 807000 )
|
||||
return(-2);
|
||||
}
|
||||
return(1);
|
||||
} else return(0);
|
||||
}
|
||||
@@ -882,7 +891,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,blocktimes[i]);
|
||||
if ( nid == notaryid )
|
||||
{
|
||||
//for (j=0; j<66; j++)
|
||||
@@ -899,7 +908,7 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
|
||||
int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
|
||||
{
|
||||
int32_t depth,notarized_ht; uint256 MoM,kmdtxid;
|
||||
depth = komodo_MoMdata(¬arized_ht,&MoM,&kmdtxid,nHeight,MoMoMp,MoMoMoffsetp,MoMoMdepthp,kmdstartip,kmdendip);
|
||||
@@ -914,7 +923,6 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
|
||||
}
|
||||
return(depth);
|
||||
}
|
||||
*/
|
||||
|
||||
int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
|
||||
{
|
||||
|
||||
47
src/pow.cpp
47
src/pow.cpp
@@ -116,9 +116,8 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t komodo_chainactive_timestamp();
|
||||
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],uint32_t blocktimes[66],int32_t height,uint8_t pubkey33[33],uint32_t blocktime);
|
||||
int32_t komodo_currentheight();
|
||||
CBlockIndex *komodo_chainactive(int32_t height);
|
||||
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
|
||||
@@ -127,18 +126,19 @@ extern uint64_t ASSETCHAINS_STAKED;
|
||||
extern char ASSETCHAINS_SYMBOL[];
|
||||
#define KOMODO_ELECTION_GAP 2000
|
||||
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
|
||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height);
|
||||
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,blocktimes[66];
|
||||
arith_uint256 bnTarget; uint8_t pubkeys[66][33];
|
||||
memcpy(origpubkey33,pubkey33,33);
|
||||
timestamp = komodo_chainactive_timestamp();
|
||||
memset(blocktimes,0,sizeof(blocktimes));
|
||||
tiptime = komodo_chainactive_timestamp();
|
||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||
if ( height == 0 )
|
||||
{
|
||||
@@ -147,7 +147,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,8 +158,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
//fprintf(stderr,"ht.%d null pubkey checkproof return\n",height);
|
||||
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);
|
||||
flag = komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,height);
|
||||
special2 = komodo_is_special(pubkeys,mids,blocktimes,height,pubkey33,blocktime);
|
||||
if ( notaryid >= 0 )
|
||||
{
|
||||
if ( height > 10000 && height < 80000 && (special != 0 || special2 > 0) )
|
||||
@@ -176,7 +176,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);
|
||||
@@ -191,11 +191,38 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
|
||||
if ( KOMODO_LOADINGBLOCKS != 0 )
|
||||
return true;
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 || height > 792000 )
|
||||
{
|
||||
if ( 1 && height > 792000 )
|
||||
{
|
||||
for (i=31; i>=0; i--)
|
||||
printf("%02x",((uint8_t *)&hash)[i]);
|
||||
printf(" hash vs ");
|
||||
for (i=31; i>=0; i--)
|
||||
printf("%02x",((uint8_t *)&bnTarget)[i]);
|
||||
printf(" ht.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,special,notaryid,height,(height % 35));
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",pubkey33[i]);
|
||||
printf(" <- pubkey\n");
|
||||
for (i=0; i<33; i++)
|
||||
printf("%02x",origpubkey33[i]);
|
||||
printf(" <- origpubkey\n");
|
||||
for (i=0; i<66; i++)
|
||||
printf("%d ",mids[i]);
|
||||
printf(" minerids from ht.%d\n",height);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
fprintf(stderr," hash vs ");
|
||||
for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
|
||||
fprintf(stderr," height.%d notaryid.%d PoW valid\n",height,notaryid);*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block)
|
||||
{
|
||||
arith_uint256 bnTarget;
|
||||
|
||||
Reference in New Issue
Block a user