diff --git a/src/clientversion.h b/src/clientversion.h index 33056403b..db38f0bf4 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -17,7 +17,7 @@ #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 0 #define CLIENT_VERSION_REVISION 5 -#define CLIENT_VERSION_BUILD 50 +#define CLIENT_VERSION_BUILD 51 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true diff --git a/src/init.cpp b/src/init.cpp index bf4e8a722..2336a9101 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1244,10 +1244,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n", MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288)); } - if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), - GetArg("-checkblocks", 288))) { - strLoadError = _("Corrupted block database detected"); - break; + extern int32_t KOMODO_REWIND; + if ( KOMODO_REWIND == 0 ) + { + if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), + GetArg("-checkblocks", 288))) { + strLoadError = _("Corrupted block database detected"); + break; + } } } catch (const std::exception& e) { if (fDebug) LogPrintf("%s\n", e.what()); diff --git a/src/komodo.h b/src/komodo.h index 27e8a53e4..94fb1347c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -338,6 +338,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr if ( i == 0 && j == 0 && memcmp(NOTARY_PUBKEY33,scriptbuf+1,33) == 0 ) { printf("%s KOMODO_LASTMINED.%d -> %d\n",ASSETCHAINS_SYMBOL,KOMODO_LASTMINED,height); + prevKOMODO_LASTMINED = KOMODO_LASTMINED; KOMODO_LASTMINED = height; } decode_hex(crypto777,33,(char *)CRYPTO777_PUBSECPSTR); @@ -415,9 +416,9 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } if ( opretlen > len && scriptbuf[len] == 'A' ) { - for (i=0; i= 235300 && block.vtx[0].vout[1].nValue >= 100000*COIN ) + block.vtx[0].vout[1].nValue = 0; + break; + } + } + }*/ len = block.vtx[i].vout[j].scriptPubKey.size(); if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) { diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2a29b1dc9..d575b02b1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -781,7 +781,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp) if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) *kmdheightp = sp->CURRENT_HEIGHT; else *kmdheightp = 0; - if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight == (int32_t)komodo_longestchain() ) + if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight >= (int32_t)komodo_longestchain() ) return(1); else return(0); } diff --git a/src/komodo_events.h b/src/komodo_events.h index 14a9478af..2652aaa58 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -116,6 +116,12 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) struct komodo_event *ep; if ( sp != 0 ) { + if ( ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_LASTMINED && prevKOMODO_LASTMINED != 0 ) + { + printf("undo KOMODO_LASTMINED %d <- %d\n",KOMODO_LASTMINED,prevKOMODO_LASTMINED); + KOMODO_LASTMINED = prevKOMODO_LASTMINED; + prevKOMODO_LASTMINED = 0; + } while ( sp->Komodo_events != 0 && sp->Komodo_numevents > 0 ) { if ( (ep= sp->Komodo_events[sp->Komodo_numevents-1]) != 0 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 62b544da6..57aeebdfe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -495,9 +495,19 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to continue; { #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE - if ( kmdsp != 0 && (kmdsp->NOTARIZED_HEIGHT >= pax->height || kmdsp->CURRENT_HEIGHT > pax->height+30) ) // assumes same chain as notarize - pax->validated = pax->komodoshis; //kmdsp->NOTARIZED_HEIGHT; - else pax->validated = pax->ready = 0; + if ( pax->height > 236000 ) + { + if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) + pax->validated = pax->komodoshis; + else if ( kmdsp->CURRENT_HEIGHT > pax->height+30 ) + pax->validated = pax->ready = 0; + } + else + { + if ( kmdsp != 0 && (kmdsp->NOTARIZED_HEIGHT >= pax->height || kmdsp->CURRENT_HEIGHT > pax->height+30) ) // assumes same chain as notarize + pax->validated = pax->komodoshis; + else pax->validated = pax->ready = 0; + } #else pax->validated = pax->komodoshis; #endif @@ -588,20 +598,77 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to return(0); } +const char *banned_txids[] = +{ + "78cb4e21245c26b015b888b14c4f5096e18137d2741a6de9734d62b07014dfca", //233559 + "00697be658e05561febdee1aafe368b821ca33fbb89b7027365e3d77b5dfede5", //234172 + "e909465788b32047c472d73e882d79a92b0d550f90be008f76e1edaee6d742ea", //234187 + "f56c6873748a327d0b92b8108f8ec8505a2843a541b1926022883678fb24f9dc", //234188 + "abf08be07d8f5b3a433ddcca7ef539e79a3571632efd6d0294ec0492442a0204", //234213 + "3b854b996cc982fba8c06e76cf507ae7eed52ab92663f4c0d7d10b3ed879c3b0", //234367 + "fa9e474c2cda3cb4127881a40eb3f682feaba3f3328307d518589024a6032cc4", //234635 + "ca746fa13e0113c4c0969937ea2c66de036d20274efad4ce114f6b699f1bc0f3", //234662 + "43ce88438de4973f21b1388ffe66e68fda592da38c6ef939be10bb1b86387041", //234697 + "0aeb748de82f209cd5ff7d3a06f65543904c4c17387c9d87c65fd44b14ad8f8c", //234899 + "bbd3a3d9b14730991e1066bd7c626ca270acac4127131afe25f877a5a886eb25", //235252 + "fa9943525f2e6c32cbc243294b08187e314d83a2870830180380c3c12a9fd33c", //235253 + "a01671c8775328a41304e31a6693bbd35e9acbab28ab117f729eaba9cb769461", //235265 + "2ef49d2d27946ad7c5d5e4ab5c089696762ff04e855f8ab48e83bdf0cc68726d", //235295 + "c85dcffb16d5a45bd239021ad33443414d60224760f11d535ae2063e5709efee", //235296 +}; + +void komodo_bannedset(uint256 *array,int32_t max) +{ + int32_t i; + for (i=0; i COIN/10 ) + { + //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); + if ( height >= 235300 ) + return(-1); + } + return(0); + } + //fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE); + if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 || return(0); offset += komodo_scriptitemlen(&opretlen,&script[offset]); if ( ASSETCHAINS_SYMBOL[0] == 0 ) @@ -700,8 +767,18 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } } } + else + { + printf("no opreturn entries to check\n"); + return(-1); + } //printf("opretlen.%d num.%d\n",opretlen,num); } + else + { + printf("not proper vout with opreturn format\n"); + return(-1); + } return(0); } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 1faf91a26..9af4d0b36 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -24,6 +24,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp); uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); +void komodo_bannedset(uint256 *array,int32_t max); pthread_mutex_t komodo_mutex; @@ -40,7 +41,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; -int32_t KOMODO_LASTMINED; +int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; @@ -55,4 +56,4 @@ char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t BITCOIND_PORT = 7771; uint64_t PENDING_KOMODO_TX; struct komodo_kv *KOMODO_KV; -pthread_mutex_t KOMODO_KV_mutex; \ No newline at end of file +pthread_mutex_t KOMODO_KV_mutex; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 52b7972b0..b727d3f58 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -124,7 +124,7 @@ const char *Notaries_elected[][2] = int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height) { - char pubkeystr[67]; int32_t i; + char pubkeystr[67]; int32_t i; uint8_t legacy33[33]; for (i=0; i<33; i++) sprintf(&pubkeystr[i*2],"%02x",pubkey33[i]); pubkeystr[66] = 0; @@ -137,6 +137,20 @@ int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height) return(i); } } + /*if ( height < 300000 ) + { + for (i=0; i elected %s\n",i,(char *)Notaries_elected[i][1]); + return(i+64); + } + } + decode_hex(legacy33,33,(char *)"0252b6185bf8ea7efe8bbc345ddc8da87329149f30233088387abd716d4aa9e974"); + if ( memcmp(pubkey33,legacy33,33) == 0 ) + return(128); + }*/ return(-1); } @@ -246,6 +260,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33) return(modval); } } + if ( height >= 300000 ) + return(-1); htind = height / KOMODO_ELECTION_GAP; pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); @@ -258,7 +274,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33) modval = ((height % numnotaries) == kp->notaryid); //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval); } else printf("unexpected zero notaries at height.%d\n",height); - } + } //else printf("cant find kp at htind.%d ht.%d\n",htind,height); //int32_t i; for (i=0; i<33; i++) // printf("%02x",pubkey33[i]); //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries); @@ -352,7 +368,7 @@ void komodo_init(int32_t height) // Minerids[i] = -2; didinit = 1; } - else if ( height == KOMODO_MAINNET_START ) + else if ( 0 && height == KOMODO_MAINNET_START ) { n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected)); for (k=0; k KOMODO_PAXMAX ) { printf("paxcalc overflow %.8f\n",dstr(basevolume)); @@ -382,10 +382,20 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba { if ( relid == MAX_CURRENCIES ) { - if ( kmdbtc == 0 ) - kmdbtc = pvals[MAX_CURRENCIES]; - if ( btcusd == 0 ) - btcusd = pvals[MAX_CURRENCIES + 1]; + if ( height < 236000 ) + { + if ( kmdbtc == 0 ) + kmdbtc = pvals[MAX_CURRENCIES]; + if ( btcusd == 0 ) + btcusd = pvals[MAX_CURRENCIES + 1]; + } + else + { + if ( (kmdbtc= pvals[MAX_CURRENCIES]) == 0 ) + kmdbtc = refkmdbtc; + if ( (btcusd= pvals[MAX_CURRENCIES + 1]) == 0 ) + btcusd = refbtcusd; + } if ( kmdbtc < 25000000 ) kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) @@ -393,9 +403,16 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; - //printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); - //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)); + if ( height >= 236000-10 ) + { + usdkmd = ((uint64_t)kmdbtc * btcusd) / 1000000000; + price = ((uint64_t)10000000000 * MINDENOMS[USD] / MINDENOMS[baseid]) / komodo_paxvol(usdvol,usdkmd); + //fprintf(stderr,"ht.%d kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",height,(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); + //fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)),(long long)price); + //fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); + //price = (uint64_t)((long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid])); + } else price = (MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)); + return(price); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) @@ -442,7 +459,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha } //portable_mutex_unlock(&komodo_mutex); if ( kmdbtc != 0 && btcusd != 0 ) - return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); + return(komodo_paxcalc(height,&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); else return(0); } } @@ -512,12 +529,18 @@ uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint { if ( (votes[numvotes-1-i]= _komodo_paxprice(0,0,height-i,base,rel,100000,kmdbtc,btcusd)) == 0 ) zeroes++; - else nonz++; + else + { + nonz++; + sum += votes[numvotes-1-i]; + //if ( (i % 10) == 0 ) + // fprintf(stderr,"[%llu] ",(long long)votes[numvotes-1-i]); + } } + //fprintf(stderr,"kmdbtc %llu btcusd %llu ",(long long)kmdbtc,(long long)btcusd); + //fprintf(stderr,"komodo_paxprice nonz.%d of numvotes.%d seed.%llu %.8f\n",nonz,numvotes,(long long)seed,nonz!=0?dstr(1000. * (double)sum/nonz):0); if ( nonz <= (numvotes >> 1) ) { - //printf("kmdbtc %llu btcusd %llu ",(long long)kmdbtc,(long long)btcusd); - //printf("komodo_paxprice nonz.%d of numvotes.%d seed.%llu\n",nonz,numvotes,(long long)seed); return(0); } return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000); @@ -561,7 +584,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin break; } } - if ( height < 165000 ) + if ( height < 165000 || height > 236000 ) break; } portable_mutex_unlock(&komodo_mutex); @@ -580,7 +603,7 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas { ptr = &PVALS[36 * i]; heights[num] = *ptr; - prices[num] = komodo_paxcalc(&ptr[1],baseid,relid,COIN,0,0); + prices[num] = komodo_paxcalc(*ptr,&ptr[1],baseid,relid,COIN,0,0); num++; if ( num >= max ) return(num); diff --git a/src/main.cpp b/src/main.cpp index 25d74eb1a..31ee26c8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -863,7 +863,24 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in bool CheckTransaction(const CTransaction& tx, CValidationState &state, libzcash::ProofVerifier& verifier) { - // Don't count coinbase transactions because mining skews the count + static uint256 array[15]; int32_t j,k,n; + if ( *(int32_t *)&array[0] == 0 ) + komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); + n = tx.vin.size(); + for (j=0; jnHeight,j); + return(false); + } + } + } + // Don't count coinbase transactions because mining skews the count if (!tx.IsCoinBase()) { transactionsValidated.increment(); } @@ -1527,7 +1544,7 @@ bool IsInitialBlockDownload() } bool state; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - state = (chainActive.Height() < pindexBestHeader->nHeight - 24*6) || + state = (chainActive.Height() > 236000 && chainActive.Height() < pindexBestHeader->nHeight - 24*6) || pindexBestHeader->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()); else state = (chainActive.Height() < pindexBestHeader->nHeight - 100); if (!state) @@ -3189,7 +3206,12 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat return state.DoS(100, error("CheckBlock(): out-of-bounds SigOpCount"), REJECT_INVALID, "bad-blk-sigops", true); if ( komodo_check_deposit(height,block) < 0 ) + { + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"check deposit rejection\n"); return(false); + } return true; } @@ -3206,7 +3228,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta int nHeight = pindexPrev->nHeight+1; // Check proof of work - if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) + if ( (nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) { cout << block.nBits << " block.nBits vs. calc " << GetNextWorkRequired(pindexPrev, &block, consensusParams) << endl; return state.DoS(100, error("%s: incorrect proof of work", __func__), @@ -3412,6 +3434,8 @@ bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBloc bool fRequested = MarkBlockAsReceived(pblock->GetHash()); fRequested |= fForceProcessing; if (!checked) { + if ( pfrom != 0 ) + Misbehaving(pfrom->GetId(), 1); return error("%s: CheckBlock FAILED", __func__); } @@ -3446,13 +3470,25 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex // NOTE: CheckBlockHeader is called by CheckBlock if (!ContextualCheckBlockHeader(block, state, pindexPrev)) + { + fprintf(stderr,"TestBlockValidity failure A\n"); return false; + } if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot)) + { + fprintf(stderr,"TestBlockValidity failure B\n"); return false; + } if (!ContextualCheckBlock(block, state, pindexPrev)) + { + fprintf(stderr,"TestBlockValidity failure C\n"); return false; + } if (!ConnectBlock(block, state, &indexDummy, viewNew, true)) + { + fprintf(stderr,"TestBlockValidity failure D\n"); return false; + } assert(state.IsValid()); return true; @@ -3872,6 +3908,7 @@ bool LoadBlockIndex() return false; } KOMODO_LOADINGBLOCKS = 0; + fprintf(stderr,"finished loading blocks\n"); return true; } diff --git a/src/miner.cpp b/src/miner.cpp index 6dc5ec03b..597b5e400 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -121,7 +121,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Create new block unique_ptr pblocktemplate(new CBlockTemplate()); if(!pblocktemplate.get()) + { + fprintf(stderr,"pblocktemplate.get() failure\n"); return NULL; + } CBlock *pblock = &pblocktemplate->block; // pointer for convenience if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= ASSETCHAINS_MINHEIGHT ) { @@ -423,7 +426,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CValidationState state; if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) { - fprintf(stderr,"warning: testblockvalidity failed\n"); + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"warning: testblockvalidity failed\n"); return(0); //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); } @@ -469,7 +474,9 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) else { if (!reservekey.GetReservedKey(pubkey)) + { return NULL; + } scriptPubKey.resize(35); ptr = (uint8_t *)pubkey.begin(); script = (uint8_t *)scriptPubKey.data(); @@ -522,7 +529,7 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese int32_t komodo_baseid(char *origbase); int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height); -int32_t FOUND_BLOCK; +int32_t FOUND_BLOCK,KOMODO_MAYBEMINED; extern int32_t KOMODO_LASTMINED; void static BitcoinMiner(CWallet *pwallet) @@ -539,7 +546,7 @@ void static BitcoinMiner(CWallet *pwallet) unsigned int n = chainparams.EquihashN(); unsigned int k = chainparams.EquihashK(); int32_t notaryid = -1; - while ( ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0 ) + while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->nHeight != 235300 && { sleep(1); if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 ) @@ -554,7 +561,7 @@ void static BitcoinMiner(CWallet *pwallet) assert(solver == "tromp" || solver == "default"); LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k); if ( ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"Mining with %s\n",solver.c_str()); + fprintf(stderr,"notaryid.%d Mining with %s\n",notaryid,solver.c_str()); std::mutex m_cs; bool cancelSolver = false; boost::signals2::connection c = uiInterface.NotifyBlockTip.connect( @@ -569,7 +576,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; @@ -610,7 +617,9 @@ void static BitcoinMiner(CWallet *pwallet) CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) { - fprintf(stderr,"created illegal block, retry\n"); + static uint32_t counter; + if ( counter++ < 100 ) + fprintf(stderr,"created illegal block, retry\n"); continue; } unique_ptr pblocktemplate(ptr); @@ -631,7 +640,7 @@ void static BitcoinMiner(CWallet *pwallet) if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )//komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) { j = 65; - if ( (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) + if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) @@ -667,7 +676,7 @@ void static BitcoinMiner(CWallet *pwallet) if ( mids[j] == notaryid ) break; } else fprintf(stderr,"no nonz pubkeys\n"); - if ( j == 65 && Mining_height > KOMODO_LASTMINED+64 ) + if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+3 && Mining_height > KOMODO_LASTMINED+64) ) { hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); @@ -709,8 +718,8 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"missed target\n"); + //if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + // fprintf(stderr," missed target\n"); return false; } if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY ) @@ -792,6 +801,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); FOUND_BLOCK = 1; + KOMODO_MAYBEMINED = Mining_height; break; } } catch (EhSolverCancelledException&) { @@ -814,7 +824,7 @@ void static BitcoinMiner(CWallet *pwallet) { if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height > ASSETCHAINS_MINHEIGHT ) { - //fprintf(stderr,"no nodes, break\n"); + fprintf(stderr,"no nodes, break\n"); break; } } diff --git a/src/pow.cpp b/src/pow.cpp index 7d8097486..cfdaea121 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -19,7 +19,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); - // Genesis block if (pindexLast == NULL ) return nProofOfWorkLimit; @@ -156,7 +155,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in // Check proof of work matches claimed amount if ( UintToArith256(hash) > bnTarget ) { - if ( KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0 + if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0 { int32_t i; for (i=31; i>=0; i--) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c53cfd56e..334d18090 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -447,7 +447,7 @@ Value kvsearch(const Array& params, bool fHelp) Value minerids(const Array& params, bool fHelp) { - Object ret; Array a; uint8_t minerids[2000],pubkeys[64][33]; int32_t i,j,n,numnotaries,tally[65]; + Object ret; Array a; uint8_t minerids[2000],pubkeys[65][33]; int32_t i,j,n,numnotaries,tally[129]; if ( fHelp || params.size() != 1 ) throw runtime_error("minerids needs height\n"); LOCK(cs_main); @@ -463,7 +463,7 @@ Value minerids(const Array& params, bool fHelp) for (i=0; i= numnotaries ) - tally[64]++; + tally[128]++; else tally[minerids[i]]++; } for (i=0; i<64; i++) @@ -488,7 +488,7 @@ Value minerids(const Array& params, bool fHelp) } Object item; item.push_back(Pair("pubkey", (char *)"external miners")); - item.push_back(Pair("blocks", tally[64])); + item.push_back(Pair("blocks", tally[128])); a.push_back(item); } ret.push_back(Pair("mined", a)); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index b1be854e3..77d4de1b6 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -697,6 +697,7 @@ Value getblocktemplate(const Array& params, bool fHelp) result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); + //fprintf(stderr,"return complete template\n"); return result; } #endif