From 0de30bbbd15a6f29d86b3d6692e992a19857b647 Mon Sep 17 00:00:00 2001 From: DanS Date: Thu, 27 Aug 2026 13:25:17 -0500 Subject: [PATCH] =?UTF-8?q?hygiene:=20Phase=203=20follow-up=20=E2=80=94=20?= =?UTF-8?q?sweep=20commented-out=20debug=20cruft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove ~116 commented-out debug/dead-code lines the audit flagged as noise (findings F6/F7/F15/F22): the Komodo "%s tikN" step-tracer comments and other commented-out fprintf/printf/LogPrintf/std::cerr calls threaded through AppInit2 (init.cpp), CreateNewBlock and the miner loops (miner.cpp), plus a few commented-out dead-code fragments (sendmany SetLockTime/nLockTime, the CCtx CC_vinselect random-pick block and AddNormalinputsLocal remote-mypk redirect, miner adaptive-PoW assignments). Comments only — no compiled behavior changes; the tree builds clean. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/cc/CCtx.cpp | 17 ------ src/init.cpp | 30 ----------- src/miner.cpp | 64 ----------------------- src/wallet/asyncrpcoperation_sendmany.cpp | 5 -- 4 files changed, 116 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 9ea6fcee2..1c43ecb55 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -72,11 +72,6 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * abovei = belowi = -1; for (above=below=i=0; i 200 ) { - // if ( (rand() % 100) < 90 ) - // continue; - //} if ( (atx_value= utxos[i].nValue) <= 0 ) continue; if ( atx_value == value ) @@ -103,13 +98,11 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * belowi = i; } } - //printf("value %.8f gap %.8f abovei.%d %.8f belowi.%d %.8f\n",dstr(value),dstr(gap),abovei,dstr(above),belowi,dstr(below)); } *aboveip = abovei; *abovep = above; *belowip = belowi; *belowp = below; - //printf("above.%d below.%d\n",abovei,belowi); if ( abovei >= 0 && belowi >= 0 ) { if ( above < (below >> 1) ) @@ -127,8 +120,6 @@ int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total if ( HUSH_NSPV_SUPERLITE ) return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U)); - // if (mypk != pubkey2pk(Mypubkey())) //remote superlite mypk, do not use wallet since it is not locked for non-equal pks (see rpcs with nspv support)! - // return(AddNormalinputs3(mtx, mypk, total, maxinputs)); #ifdef ENABLE_WALLET assert(pwalletMain != NULL); @@ -150,7 +141,6 @@ int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total vout = out.i; if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 ) { - //fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout); if ( mtx.vin.size() > 0 ) { for (i=0; inValue = out.tx->vout[out.i].nValue; up->vout = vout; sum += up->nValue; - //fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos); if ( n >= maxinputs || sum >= total ) break; } @@ -207,14 +196,12 @@ int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total remains -= up->nValue; utxos[ind] = utxos[--n]; memset(&utxos[n],0,sizeof(utxos[n])); - //fprintf(stderr,"totalinputs %.8f vs total %.8f i.%d vs max.%d\n",(double)totalinputs/COIN,(double)total/COIN,i,maxinputs); if ( totalinputs >= total || (i+1) >= maxinputs ) break; } free(utxos); if ( totalinputs >= total ) { - //fprintf(stderr,"return totalinputs %.8f\n",(double)totalinputs/COIN); return(totalinputs); } #endif @@ -252,7 +239,6 @@ int64_t AddNormalinputsRemote(CMutableTransaction &mtx, CPubKey mypk, int64_t to continue; if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 ) { - //fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout); if ( mtx.vin.size() > 0 ) { for (i=0; inValue = it->second.satoshis; up->vout = vout; sum += up->nValue; - //fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos); if ( n >= maxinputs || sum >= total ) break; } @@ -308,14 +293,12 @@ int64_t AddNormalinputsRemote(CMutableTransaction &mtx, CPubKey mypk, int64_t to remains -= up->nValue; utxos[ind] = utxos[--n]; memset(&utxos[n],0,sizeof(utxos[n])); - //fprintf(stderr,"totalinputs %.8f vs total %.8f i.%d vs max.%d\n",(double)totalinputs/COIN,(double)total/COIN,i,maxinputs); if ( totalinputs >= total || (i+1) >= maxinputs ) break; } free(utxos); if ( totalinputs >= total ) { - //fprintf(stderr,"return totalinputs %.8f\n",(double)totalinputs/COIN); return(totalinputs); } return(0); diff --git a/src/init.cpp b/src/init.cpp index fa51c3963..f4f665a87 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1124,7 +1124,6 @@ static void AdjustCoinCacheForMemoryPressure() bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) { - //fprintf(stderr,"%s start\n", __FUNCTION__); // ********************************************************* Step 1: setup #ifdef _MSC_VER // Turn off Microsoft heap dump noise @@ -1161,7 +1160,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError("Error: -sysperms is not allowed in combination with enabled wallet functionality"); #endif } else { - //fprintf(stderr,"%s setting umask\n", __FUNCTION__); umask(077); } @@ -1179,12 +1177,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) std::set_new_handler(new_handler_terminate); - //fprintf(stderr,"%s: set signal handlers\n", __FUNCTION__); // ********************************************************* Step 2: parameter interactions const CChainParams& chainparams = Params(); - //fprintf(stderr,"%s: got chain params\n", __FUNCTION__); // Set this early so that experimental features are correctly enabled/disabled fExperimentalMode = GetBoolArg("-experimentalfeatures", true); @@ -1199,7 +1195,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(_("Wallet encryption requires -experimentalfeatures.")); } } - //fprintf(stderr,"%s tik2\n", __FUNCTION__); // Set this early so that parameter interactions go to console fPrintToConsole = GetBoolArg("-printtoconsole", false); @@ -1228,7 +1223,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("%s: parameter interaction: -allowbind set -> setting -listen=1\n", __func__); } - //fprintf(stderr,"%s tik3\n", __FUNCTION__); if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { // when only connecting to trusted nodes, do not seed via DNS, or listen by default if (SoftSetBoolArg("-dnsseed", false)) @@ -1351,12 +1345,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (SoftSetBoolArg("-rescan", true)) LogPrintf("%s: parameter interaction: -zapwallettxes= -> setting -rescan=1\n", __func__); } - //fprintf(stderr,"%s tik4\n", __FUNCTION__); // Make sure enough file descriptors are available int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-allowbind"), 1); nMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); - //fprintf(stderr,"nMaxConnections %d\n",nMaxConnections); nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0); int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS); fprintf(stderr,"nMaxConnections %d FD_SETSIZE.%d nBind.%d expr.%d \n",nMaxConnections,FD_SETSIZE,nBind,(int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)); @@ -1364,7 +1356,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(_("Not enough file descriptors available.")); if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections) nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS; - //fprintf(stderr,"nMaxConnections %d\n",nMaxConnections); // if using block pruning, then disable txindex // also disable the wallet (for now, until SPV support is implemented in wallet) if (GetArg("-prune", 0)) { @@ -1413,7 +1404,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fprintf(stderr,"%s: enabled randomx debug\n", __func__); } - //fprintf(stderr,"%s tik5\n", __FUNCTION__); // Check for -debugnet if (GetBoolArg("-debugnet", false)) InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net.")); @@ -1472,7 +1462,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("Bulk block streaming: %s\n", fBulkBlockSync ? "enabled" : "disabled"); fServer = GetBoolArg("-server", false); - //fprintf(stderr,"%s tik6\n", __FUNCTION__); // block pruning; get the amount of disk space (in MB) to allot for block & undo files int64_t nSignedPruneTarget = GetArg("-prune", 0) * 1024 * 1024; @@ -1560,7 +1549,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) expiryDelta = GetArg("-txexpirydelta", DEFAULT_TX_EXPIRY_DELTA); bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", true); fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false); - //fprintf(stderr,"%s tik7\n", __FUNCTION__); std::string strWalletFile = GetArg("-wallet", "wallet.dat"); #endif // ENABLE_WALLET @@ -1577,7 +1565,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) nLocalServices |= NODE_BLOOM; } nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); - //fprintf(stderr,"%s tik8\n", __FUNCTION__); #ifdef ENABLE_MINING if (mapArgs.count("-mineraddress")) { @@ -1600,7 +1587,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - //fprintf(stderr,"%s tik9\n", __FUNCTION__); if (!mapMultiArgs["-nuparams"].empty()) { // Allow overriding network upgrade parameters for testing if (Params().NetworkIDString() != "regtest") { @@ -1649,7 +1635,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) std::string sha256_algo = SHA256AutoDetect(); LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo); - //fprintf(stderr,"%s tik10\n", __FUNCTION__); // Sanity check if (!InitSanityCheck()) return InitError(_("Initialization sanity check failed. Please check for insanity. Hush is shutting down!")); @@ -1666,7 +1651,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (file) fclose(file); - //fprintf(stderr,"%s tik11\n", __FUNCTION__); fprintf(stderr,"Attempting to obtain lock %s\n", pathLockFile.string().c_str()); try { static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); @@ -1682,7 +1666,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (GetBoolArg("-shrinkdebugfile", !fDebug)) ShrinkDebugFile(); - //fprintf(stderr,"%s tik12\n", __FUNCTION__); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); LogPrintf("Hush version %s\n", FormatFullVersion()); @@ -1715,7 +1698,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) threadGroup.create_thread(&ThreadRandomXVerify); } - //fprintf(stderr,"%s tik13\n", __FUNCTION__); // Start the lightweight task scheduler thread CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler); @@ -1723,7 +1705,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Count uptime MarkStartTime(); - //fprintf(stderr,"%s tik14\n", __FUNCTION__); if ((chainparams.NetworkIDString() != "regtest") && GetBoolArg("-showmetrics", 0) && @@ -1733,7 +1714,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) threadGroup.create_thread(&ThreadShowMetricsScreen); } - //fprintf(stderr,"%s tik15\n", __FUNCTION__); if ( HUSH_NSPV_FULLNODE ) { @@ -1751,7 +1731,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (!AppInitServers(threadGroup)) return InitError(_("Unable to start HTTP server. See debug log for details.")); } - //fprintf(stderr,"%s tik16\n", __FUNCTION__); int64_t nStart; @@ -1778,7 +1757,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #endif // ENABLE_WALLET // ********************************************************* Step 6: network initialization - //fprintf(stderr,"%s tik17\n", __FUNCTION__); RegisterNodeSignals(GetNodeSignals()); // sanitize comments per BIP-0014, format user agent and check total size @@ -1794,7 +1772,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.", strSubVersion.size(), MAX_SUBVERSION_LENGTH)); } - //fprintf(stderr,"%s tik18\n", __FUNCTION__); // Disable clearnet peers if -clearnet=0 for this node or -ac_clearnet=0 for this chain if (ASSETCHAINS_CLEARNET == 0 || !GetBoolArg("-clearnet", DEFAULT_CLEARNET)) { @@ -1853,7 +1830,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) SetReachable(NET_IPV4, false); } - //fprintf(stderr,"%s tik19\n", __FUNCTION__); if (mapArgs.count("-allowlist")) { BOOST_FOREACH(const std::string& net, mapMultiArgs["-allowlist"]) { CSubNet subnet; @@ -1916,7 +1892,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fDiscover = GetBoolArg("-discover", true); fNameLookup = GetBoolArg("-dns", true); - //fprintf(stderr,"%s tik22\n", __FUNCTION__); bool fBound = false; if (fListen) { if (mapArgs.count("-bind") || mapArgs.count("-allowbind")) { @@ -1955,7 +1930,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - //fprintf(stderr,"%s tik23\n", __FUNCTION__); BOOST_FOREACH(const std::string& strDest, mapMultiArgs["-seednode"]) AddOneShot(strDest); @@ -1991,7 +1965,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) return !fRequestShutdown; } // ********************************************************* Step 7: load block chain - //fprintf(stderr,"%s tik24\n", __FUNCTION__); fReindex = GetBoolArg("-reindex", false); @@ -2238,7 +2211,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) mempool.ReadFeeEstimates(est_filein); fFeeEstimatesInitialized = true; - //fprintf(stderr,"%s tik25\n", __FUNCTION__); // ********************************************************* Step 8: load wallet #ifdef ENABLE_WALLET @@ -2452,7 +2424,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } for (int i = 0; i < vSweep.size(); i++) { - // LogPrintf("Sweep Address: %s\n", vSweep[i]); auto zSweep = DecodePaymentAddress(vSweep[i]); if (!IsValidPaymentAddress(zSweep)) { return InitError("Invalid zsweep address"); @@ -2800,7 +2771,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // ********************************************************* Step 11: start node - //fprintf(stderr,"Checking disk space...\n"); if (!CheckDiskSpace()) return false; diff --git a/src/miner.cpp b/src/miner.cpp index b215bd7b6..f87257c31 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -160,7 +160,6 @@ bool hush_appendACscriptpub(); CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake) { - //fprintf(stderr,"%s\n", __func__); CScript scriptPubKeyIn(_scriptPubKeyIn); CPubKey pk; @@ -179,12 +178,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 uint32_t blocktime; const CChainParams& chainparams = Params(); bool fNotarizationBlock = false; std::vector NotarizationNotaries; - //fprintf(stderr,"%s: create new block with pubkey=%s\n", __func__, HexStr(pk).c_str()); // Create new block if ( gpucount < 0 ) gpucount = HUSH_MAXGPUCOUNT; std::unique_ptr pblocktemplate(new CBlockTemplate()); - //fprintf(stderr,"%s: created new block template\n", __func__); if(!pblocktemplate.get()) { fprintf(stderr,"%s: pblocktemplate.get() failure\n", __func__); @@ -200,7 +197,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 pblock->vtx.push_back(CTransaction()); pblocktemplate->vTxFees.push_back(-1); // updated at end pblocktemplate->vTxSigOps.push_back(-1); // updated at end - //fprintf(stderr,"%s: added dummy coinbase\n", __func__); // Largest block you're willing to create: unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE(1)); // MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1)); @@ -217,7 +213,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // until there are no more or the block reaches this size: const unsigned int nBlockMinSize = std::min(nBlockMaxSize, (unsigned int) GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE)); // nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); - //fprintf(stderr,"%s: nBlockMaxSize=%u, nBlockPrioritySize=%u, nBlockMinSize=%u\n", __func__, nBlockMaxSize, nBlockPrioritySize, nBlockMinSize); // Collect memory pool transactions into the block @@ -243,7 +238,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetTime(); - //fprintf(stderr,"%s: nHeight=%d, consensusBranchId=%u, proposedTime=%u\n", __func__, nHeight, consensusBranchId, proposedTime); if (proposedTime == nMedianTimePast) { @@ -282,7 +276,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 vector vecPriority; vecPriority.reserve(mempool.mapTx.size() + 1); - //fprintf(stderr,"%s: going to add txs from mempool\n", __func__); // now add transactions from the mempool int32_t Notarizations = 0; uint64_t txvalue; uint32_t large_zins = 0; // number of ztxs with large number of inputs in block @@ -392,7 +385,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Priority is sum(valuein * age) / modified_txsize unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - // fprintf(stderr,"%s: computing priority with nTxSize=%u\n", __func__, nTxSize); dPriority = tx.ComputePriority(dPriority, nTxSize); uint256 hash = tx.GetHash(); @@ -423,7 +415,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 NotarizationNotaries = TMP_NotarizationNotaries; dPriority = 1e16; fNotarizationBlock = true; - //fprintf(stderr, "Notarization %s set to maximum priority\n",hash.ToString().c_str()); } } } @@ -438,7 +429,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); } } - // fprintf(stderr,"%s: done adding txs from mempool\n", __func__); // Collect transactions into block int64_t interest; @@ -450,7 +440,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 TxPriorityCompare comparer(fSortedByFee); std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - // fprintf(stderr,"%s: compared txs with fSortedByFee=%d\n", __func__, fSortedByFee); while (!vecPriority.empty()) { // Take highest priority transaction off the priority queue: @@ -458,10 +447,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 CFeeRate feeRate = vecPriority.front().get<1>(); const CTransaction& tx = *(vecPriority.front().get<2>()); - // fprintf(stderr,"%s: grabbed first tx from priority queue\n", __func__); std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - // fprintf(stderr,"%s: compared first tx from priority queue\n", __func__); vecPriority.pop_back(); if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD && large_zins >= LARGE_ZINS_MAX) { @@ -478,7 +465,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - // fprintf(stderr,"%s: nTxSize = %u\n", __func__, nTxSize); if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx @@ -491,11 +477,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } - // fprintf(stderr,"%s: looking to see if we need to skip any fee=0 txs\n", __func__); // Skip free transactions if we're past the minimum block size: const uint256& hash = tx.GetHash(); @@ -518,7 +502,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (!view.HaveInputs(tx)) { - //fprintf(stderr,"dont have inputs\n"); continue; } CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); @@ -560,7 +543,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } // Note that flags: we don't want to set mempool/IsStandard() @@ -625,13 +607,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nLastBlockTx = nBlockTx; nLastBlockSize = nBlockSize; - // fprintf(stderr,"%s: nLastBlockTx=%lu , nLastBlockSize=%lu\n", __func__, nLastBlockTx, nLastBlockSize); if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetTime()); //pblock->nTime = blocktime + 1; - // fprintf(stderr,"%s: calling GetNextWorkRequired\n", __func__); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits); @@ -645,7 +625,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - // fprintf(stderr,"%s: mine ht.%d with %.8f\n",__func__,nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); @@ -670,7 +649,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 fprintf(stderr, "appended ccopreturn to assetchains_scriptpub.%s\n", assetchains_scriptpub.c_str()); didinit = true; } - //fprintf(stderr,"mine to -ac_script\n"); //txNew.vout[1].scriptPubKey = CScript() << ParseHex(); int32_t len = strlen(assetchains_scriptpub.c_str()); len >>= 1; @@ -684,12 +662,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 for (i=0; i<33; i++) { ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; - //fprintf(stderr,"%02x",ptr[i+1]); } ptr[34] = OP_CHECKSIG; - //fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n"); } - //printf("autocreate commision vout\n"); } else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) { fprintf(stderr,"timelocked chains not supported in this code!\n"); LEAVE_CRITICAL_SECTION(cs_main); @@ -712,7 +687,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 } return(0); } - //fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats); } else fprintf(stderr, "vout 2 of notarization is not OP_RETURN scriptlen.%i\n", scriptlen); } if ( ASSETCHAINS_CBOPRET != 0 ) @@ -721,7 +695,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(numv+1); txNew.vout[numv].nValue = 0; txNew.vout[numv].scriptPubKey = hush_mineropret(nHeight); - //printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; @@ -754,7 +727,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && (IS_HUSH_NOTARY == 0 || My_notaryid < 0) ) { CValidationState state; - //fprintf(stderr,"%s: check validity\n", __func__); if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks { if ( !isStake ) @@ -766,14 +738,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return. return(0); } - //fprintf(stderr,"valid\n"); } } LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(mempool.cs); - // fprintf(stderr,"%s: done\n", __func__); return pblocktemplate.release(); } @@ -783,7 +753,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce) { - //fprintf(stderr,"RandomXMiner: %s with nExtraNonce=%u\n", __func__, nExtraNonce); // Update nExtraNonce static uint256 hashPrevBlock; if (hashPrevBlock != pblock->hashPrevBlock) @@ -807,7 +776,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake) { CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len; - // fprintf(stderr,"%s: with nHeight=%d\n", __func__, nHeight); // Create a local variable instead of modifying the global assetchains_scriptpub auto assetchains_scriptpub = devtax_scriptpub_for_height(nHeight); @@ -817,7 +785,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, { pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY); scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG; - // fprintf(stderr,"%s: with pubkey=%s\n", __func__, HexStr(pubkey).c_str() ); } else { len = strlen(assetchains_scriptpub.c_str()); len >>= 1; @@ -826,7 +793,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, decode_hex(ptr,len,(char *)assetchains_scriptpub.c_str()); } } else if ( USE_EXTERNAL_PUBKEY != 0 ) { - //fprintf(stderr,"use notary pubkey\n"); pubkey = ParseHex(NOTARY_PUBKEY); scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG; } else { @@ -854,7 +820,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, } } } - // fprintf(stderr,"%s: calling CreateNewBlock\n", __func__); return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); } @@ -868,7 +833,6 @@ void hush_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std: continue; if ( numsent < minpeers || (rand() % 10) == 0 ) { - //fprintf(stderr,"pushmessage\n"); pnode->PushMessage(message,payload); if ( numsent++ > maxpeers ) break; @@ -916,7 +880,6 @@ static bool ProcessBlockFound(CBlock* pblock) } } #endif - //fprintf(stderr,"process new block\n"); // Process this block the same as if we had received it from another node CValidationState state; @@ -993,7 +956,6 @@ CBlockIndex *get_chainactive(int32_t height) } // else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->GetHeight()); } - //fprintf(stderr,"get_chainactive null chainActive.Tip() height %d\n",height); return(0); } @@ -1281,13 +1243,11 @@ void static RandomXMiner() randomx_vm *myVM = nullptr; try { - // fprintf(stderr,"RandomXMiner: mining %s with randomx\n",SMART_CHAIN_SYMBOL); rxdebug("%s: mining %s with randomx\n", SMART_CHAIN_SYMBOL); while (true) { - // fprintf(stderr,"RandomXMiner: beginning mining loop on %s with nExtraNonce=%u\n",SMART_CHAIN_SYMBOL, nExtraNonce); rxdebug("%s: start mining loop on %s with nExtraNonce=%u\n", SMART_CHAIN_SYMBOL, nExtraNonce); if (chainparams.MiningRequiresPeers()) { @@ -1305,10 +1265,8 @@ void static RandomXMiner() if (!fvNodesEmpty )//&& !IsInitialBlockDownload()) break; MilliSleep(15000); - //fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,SMART_CHAIN_SYMBOL,(int32_t)IsInitialBlockDownload()); } while (true); - //fprintf(stderr,"%s Found peers\n",SMART_CHAIN_SYMBOL); miningTimer.start(); } @@ -1333,7 +1291,6 @@ void static RandomXMiner() Mining_start = (uint32_t)time(NULL); } - // fprintf(stderr,"RandomXMiner: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag); rxdebug("%s: using initial key, interval=%d, lag=%d, Mining_height=%u\n", randomxInterval, randomxBlockLag, Mining_height); // Update the shared dataset key — only one thread will actually rebuild, // others will see the key is already current and skip. @@ -1366,14 +1323,12 @@ void static RandomXMiner() // Acquire shared lock to prevent dataset rebuild while we're hashing boost::shared_lock datasetLock(g_rxDatasetManager->datasetMtx); - //fprintf(stderr,"RandomXMiner: Mining_start=%u\n", Mining_start); #ifdef ENABLE_WALLET CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0); #else CBlockTemplate *ptr = CreateNewBlockWithKey(); #endif - // fprintf(stderr,"RandomXMiner: created new block with Mining_start=%u\n",Mining_start); rxdebug("%s: created new block with Mining_start=%u\n",Mining_start); if ( ptr == 0 ) { @@ -1390,7 +1345,6 @@ void static RandomXMiner() sleep(1); continue; } - // fprintf(stderr,"RandomXMiner: getting block template\n"); rxdebug("%s: getting block template\n"); unique_ptr pblocktemplate(ptr); @@ -1419,7 +1373,6 @@ void static RandomXMiner() } rxdebug("%s: incrementing extra nonce\n"); IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); - // fprintf(stderr,"RandomXMiner: %u transactions in block\n",(int32_t)pblock->vtx.size()); LogPrintf("Running HushRandomXMiner with %u transactions in block (%u bytes)\n",pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // Search @@ -1440,7 +1393,6 @@ void static RandomXMiner() } hush_longestchain(); - // fprintf(stderr,"RandomXMiner: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str()); rxdebug("%s: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str()); arith_uint256 hashTarget; hashTarget = HASHTarget; @@ -1451,7 +1403,6 @@ void static RandomXMiner() randomxInput << rxInput; // std::cerr << "RandomXMiner: randomxInput=" << HexStr(randomxInput) << "\n"; - // fprintf(stderr,"RandomXMiner: created randomxKey=%s , randomxInput.size=%lu\n", randomxKey, randomxInput.size() ); //randomxInput); rxdebug("%s: randomxKey=%s randomxInput=%s\n", randomxKey, HexStr(randomxInput).c_str()); rxdebug("%s: calculating randomx hash\n"); @@ -1480,7 +1431,6 @@ void static RandomXMiner() rxdebug("%s: Checking solution against target\n"); pblock->nSolution = soln; solutionTargetChecks.increment(); - // fprintf(stderr,"%s: solutionTargetChecks=%lu\n", __func__, solutionTargetChecks.get()); B = *pblock; h = UintToArith256(B.GetHash()); @@ -1705,10 +1655,8 @@ void static BitcoinMiner() if (!fvNodesEmpty )//&& !IsInitialBlockDownload()) break; MilliSleep(15000); - //fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,SMART_CHAIN_SYMBOL,(int32_t)IsInitialBlockDownload()); } while (true); - //fprintf(stderr,"%s Found peers\n",SMART_CHAIN_SYMBOL); miningTimer.start(); } // @@ -1731,7 +1679,6 @@ void static BitcoinMiner() } if ( SMART_CHAIN_SYMBOL[0] != 0 && ASSETCHAINS_STAKED == 0 ) { - //fprintf(stderr,"%s create new block ht.%d\n",SMART_CHAIN_SYMBOL,Mining_height); //sleep(3); } @@ -1756,7 +1703,6 @@ void static BitcoinMiner() sleep(1); continue; } - //fprintf(stderr,"get template\n"); unique_ptr pblocktemplate(ptr); if (!pblocktemplate.get()) { @@ -1784,7 +1730,6 @@ void static BitcoinMiner() } } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); - //fprintf(stderr,"Running HushMiner.%s with %u transactions in block\n",solver.c_str(),(int32_t)pblock->vtx.size()); LogPrintf("Running HushMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // Search @@ -1800,7 +1745,6 @@ void static BitcoinMiner() gotinvalid = 0; while (true) { - //fprintf(stderr,"gotinvalid.%d\n",gotinvalid); if ( gotinvalid != 0 ) break; hush_longestchain(); @@ -1825,7 +1769,6 @@ void static BitcoinMiner() if ( HUSH_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 ) hashTarget = HASHTarget_POW; //else if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) - // hashTarget = HASHTarget_POW; else hashTarget = HASHTarget; std::function)> validBlock = #ifdef ENABLE_WALLET @@ -1839,7 +1782,6 @@ void static BitcoinMiner() LogPrint("pow", "- Checking solution against target\n"); pblock->nSolution = soln; solutionTargetChecks.increment(); - // fprintf(stderr, "%s: solutionTargetChecks=%lu\n", __func__, solutionTargetChecks.get()); B = *pblock; h = UintToArith256(B.GetHash()); /*for (z=31; z>=16; z--) @@ -1859,7 +1801,6 @@ void static BitcoinMiner() } if ( IS_HUSH_NOTARY != 0 && B.nTime > GetTime() ) { - //fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetTime())); while ( GetTime() < B.nTime-2 ) { sleep(1); @@ -1893,8 +1834,6 @@ void static BitcoinMiner() { h = UintToArith256(B.GetHash()); //for (z=31; z>=0; z--) - // fprintf(stderr,"%02x",((uint8_t *)&h)[z]); - //fprintf(stderr," Invalid block mined, try again\n"); gotinvalid = 1; return(false); } @@ -1969,8 +1908,6 @@ void static BitcoinMiner() if (found) { int32_t i; uint256 hash = pblock->GetHash(); //for (i=0; i<32; i++) - // fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); - //fprintf(stderr," <- %s Block found %d\n",SMART_CHAIN_SYMBOL,Mining_height); //FOUND_BLOCK = 1; //HUSH_MAYBEMINED = Mining_height; break; @@ -2026,7 +1963,6 @@ void static BitcoinMiner() HASHTarget.SetCompact(pblock->nBits); hashTarget = HASHTarget; savebits = pblock->nBits; - //hashTarget = HASHTarget_POW = hush_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); } /*if ( NOTARY_PUBKEY33[0] == 0 ) { diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index d7e42bcd6..94973aa1b 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -325,14 +325,12 @@ bool AsyncRPCOperation_sendmany::main_impl() { CScript scriptPubKey; for (auto t : t_inputs_) { scriptPubKey = GetScriptForDestination(std::get<4>(t)); - //printf("Checking new script: %s\n", scriptPubKey.ToString().c_str()); uint256 txid = std::get<0>(t); int vout = std::get<1>(t); CAmount amount = std::get<2>(t); builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount); } // for other chains, set locktime to spend time locked coinbases - //builder_.SetLockTime((uint32_t)chainActive.Tip()->GetMedianTimePast()); } else { CMutableTransaction rawTx(tx_); for (SendManyInputUTXO & t : t_inputs_) { @@ -342,7 +340,6 @@ bool AsyncRPCOperation_sendmany::main_impl() { CTxIn in(COutPoint(txid, vout)); rawTx.vin.push_back(in); } - //rawTx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); tx_ = CTransaction(rawTx); } } @@ -416,7 +413,6 @@ bool AsyncRPCOperation_sendmany::main_impl() { } // Fetch Sapling anchor and witnesses - //LogPrintf("%s: Gathering anchors and witnesses\n", __FUNCTION__); uint256 anchor; std::vector> witnesses; { @@ -625,7 +621,6 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { continue; } - //printf("%s\n", boost::apply_visitor(AddressVisitorString(), dest).c_str()); if (!destinations.count(dest)) { continue; }