From ef70c5b2de4c6050184355d8e11bfbf2980a2344 Mon Sep 17 00:00:00 2001 From: miketout Date: Sat, 5 May 2018 07:52:02 -0700 Subject: [PATCH 1/3] Updated miner messages --- src/miner.cpp | 61 ++++++++++++++++++++++--------------------- src/wallet/wallet.cpp | 12 ++++----- src/wallet/wallet.h | 4 ++- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0f6b79d91..4c62aaaff 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -520,7 +520,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { - pblock->nTime = pindexPrev->nTime + 65; + pblock->nTime = pindexPrev->nTime + 60; //while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) // sleep(1); //fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60)); @@ -839,6 +839,11 @@ void static BitcoinMiner_noeq() arith_uint256 mask(ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]); Mining_start = 0; + + // try again if we're not ready + if ( pindexPrev != chainActive.Tip() ) + break; + while (true) { // for speed check multiples at a time @@ -853,9 +858,20 @@ void static BitcoinMiner_noeq() { SetThreadPriority(THREAD_PRIORITY_NORMAL); + int32_t unlockTime = komodo_block_unlocktime(Mining_height); + int64_t subsidy = (int64_t)(pblock->vtx[0].vout[0].nValue); + LogPrintf("KomodoMiner using %s algorithm:\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]); LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", pblock->GetHash().GetHex(), hashTarget.GetHex()); - printf("FOUND BLOCK %d! \n hash: %s \ntarget: %s\n", Mining_height, pblock->GetHash().GetHex().c_str(), hashTarget.GetHex().c_str()); + printf("Found block %d \n", Mining_height, ); + printf("mining reward %.8f %s!", (double)subsidy / (double)COIN, ASSETCHAINS_SYMBOL); + printf(" hash: %s \ntarget: %s\n", pblock->GetHash().GetHex().c_str(), hashTarget.GetHex().c_str()); + if (unlockTime > Mining_height && subsidy >= ASSETCHAINS_TIMELOCKGTE) + printf("- timelocked until block %i\n", unlockTime); + else + printf("\n"); + + #ifdef ENABLE_WALLET ProcessBlockFound(pblock, *pwallet, reservekey); #else @@ -869,11 +885,12 @@ void static BitcoinMiner_noeq() } break; } - // check if we're wrapping around on the nonce - if ((UintToArith256(pblock->nNonce) & mask) == mask) + else { - fprintf(stderr,"%lx, break\n", ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]); - break; + if ((UintToArith256(pblock->nNonce) & mask) == mask) + { + break; + } } } @@ -884,26 +901,26 @@ void static BitcoinMiner_noeq() { if ( Mining_height > ASSETCHAINS_MINHEIGHT ) { - fprintf(stderr,"no nodes, break\n"); + fprintf(stderr,"no nodes, attempting reconnect\n"); break; } } if ((UintToArith256(pblock->nNonce) & mask) == mask) { - fprintf(stderr,"%lx, break\n", ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]); + fprintf(stderr,"%lu hashes - working\n", ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]); break; } if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60) { - fprintf(stderr,"timeout, break\n"); + fprintf(stderr,"timeout, retrying\n"); break; } if ( pindexPrev != chainActive.Tip() ) { - fprintf(stderr,"Tip advanced, break\n"); + fprintf(stderr,"Tip advanced, block %i\n", chainActive.Tip()->nHeight); break; } @@ -1081,7 +1098,7 @@ void static BitcoinMiner() if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { int32_t dispflag = 0; - if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) ||notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 || notaryid == 62 ) + if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) &¬aryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) @@ -1203,26 +1220,9 @@ void static BitcoinMiner() for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); fprintf(stderr," POW\n");*/ - if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) - { - fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); - while ( GetAdjustedTime() < B.nTime ) - { - sleep(1); - if ( chainActive.Tip()->nHeight >= Mining_height ) - { - fprintf(stderr,"new block arrived\n"); - return(false); - } - } - } if ( ASSETCHAINS_STAKED == 0 ) { - if ( NOTARY_PUBKEY33[0] != 0 ) - { - MilliSleep((rand() % 2700) + 1000); - } - /*if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) + if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) { //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+roundrobin_delay-time(NULL))); //int32_t nseconds = Mining_start+roundrobin_delay-time(NULL); @@ -1233,12 +1233,13 @@ void static BitcoinMiner() else if ( ASSETCHAINS_SYMBOL[0] != 0 ) { sleep(rand() % 30); - }*/ + } } else { if ( NOTARY_PUBKEY33[0] != 0 ) { + printf("need to wait %d seconds to submit staked block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) sleep(1); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 110cc69ee..fc5cc36ae 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1470,7 +1470,7 @@ bool CWallet::IsMine(const CTransaction& tx) // special case handling for CLTV scripts, this does not error check to ensure the script is CLTV and is // only internal to the wallet for that reason. -isminetype CWallet::IsCLTVMine(CScript &script, CScriptID &scriptID, int64_t locktime) const +isminetype CWallet::IsCLTVMine(CScript &script, CScriptID &scriptID) const { uint8_t pushOp = script.data()[0]; uint32_t scriptStart = pushOp + 3; @@ -1527,10 +1527,9 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum) if (this->GetCScript(scriptID, subscript)) { // if this is a CLTV, handle it differently - int64_t lockTime; - if (subscript.IsCheckLockTimeVerify(&lockTime)) + if (subscript.IsCheckLockTimeVerify()) { - return this->IsCLTVMine(subscript, scriptID, lockTime); + return this->IsCLTVMine(subscript, scriptID); } else { @@ -1552,13 +1551,12 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum) { if (opretData.size() > 0 && opretData.data()[0] == OPRETTYPE_TIMELOCK) { - int64_t unlocktime; CScript opretScript = CScriptExt(opretData.begin() + 1, opretData.end()); if (CScriptID(opretScript) == scriptID && - opretScript.IsCheckLockTimeVerify(&unlocktime)) + opretScript.IsCheckLockTimeVerify()) { - return this->IsCLTVMine(opretScript, scriptID, unlocktime); + return this->IsCLTVMine(opretScript, scriptID); } } } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 033bc47ae..7662d3b44 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -761,7 +761,9 @@ protected: private: template void SyncMetaData(std::pair::iterator, typename TxSpendMap::iterator>); - isminetype IsCLTVMine(CScript &script, CScriptID &scriptID, int64_t locktime) const; + + // parses a CLTV script followed by a standard script and determines ownership + isminetype IsCLTVMine(CScript &subScript, CScriptID &scriptID) const; protected: bool UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx); From 14d104e93faa702a38135391f7271e380ac16f0b Mon Sep 17 00:00:00 2001 From: miketout Date: Sat, 5 May 2018 08:23:05 -0700 Subject: [PATCH 2/3] Fix error --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4c62aaaff..d619551f8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -863,7 +863,7 @@ void static BitcoinMiner_noeq() LogPrintf("KomodoMiner using %s algorithm:\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]); LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", pblock->GetHash().GetHex(), hashTarget.GetHex()); - printf("Found block %d \n", Mining_height, ); + printf("Found block %d \n", Mining_height ); printf("mining reward %.8f %s!", (double)subsidy / (double)COIN, ASSETCHAINS_SYMBOL); printf(" hash: %s \ntarget: %s\n", pblock->GetHash().GetHex().c_str(), hashTarget.GetHex().c_str()); if (unlockTime > Mining_height && subsidy >= ASSETCHAINS_TIMELOCKGTE) From bdc8bd41ddb33674bb9d1054acdf7129c1769110 Mon Sep 17 00:00:00 2001 From: miketout Date: Sat, 5 May 2018 14:01:40 -0700 Subject: [PATCH 3/3] raise minimum difficulty for Verus hash --- src/chainparams.cpp | 2 +- src/miner.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index b8bd32a80..4c3fd158c 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -102,7 +102,7 @@ public: consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 4000; if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH) - consensus.powLimit = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); + consensus.powLimit = uint256S("0000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); else consensus.powLimit = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); consensus.nPowAveragingWindow = 17; diff --git a/src/miner.cpp b/src/miner.cpp index d619551f8..0d038f41e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -871,7 +871,6 @@ void static BitcoinMiner_noeq() else printf("\n"); - #ifdef ENABLE_WALLET ProcessBlockFound(pblock, *pwallet, reservekey); #else