hygiene: Phase 4 — route unconditional debug output through LogPrint
Fourth phase of the code-hygiene remediation, addressing the ~1,082 stray
fprintf(stderr)/printf debug calls so consensus and hot paths stop spewing
to stderr/stdout. Done per-file (18 files) with conservative rules; the tree
builds clean, self-mines, and `verifychain` re-validates the whole chain
(pow/txdb/coins/miner paths) with -debug=1 enabling every converted line —
zero tinyformat/format-arg exceptions.
Net across 18 files: 174 commented-out debug lines deleted, 173 unconditional
live prints converted to LogPrint("<cat>",...)/LogPrintf (net/mining/pow/nspv/
zrpc categories, format strings + args preserved exactly), 40 pure-noise or
sensitive prints deleted, and 194 calls DELIBERATELY LEFT (already behind
fDebug/fZdebug guards, or genuine startup/fatal-error output that must reach
the console before logging init).
Notable:
- Deleted sensitive success-path dumps (nSPV SIG_TXHASH + full tx input/
output/change amounts; kvupdate privkey/pubkey hex) that were writing key
and amount material straight to stderr/stdout.
- Removed the raw 32-byte target hex dumps in the zawy adaptive-PoW helpers
and the legacy one-shot `if(height==340000)` HUSH artifact in pow.cpp.
- Converted per-tx relay + ban/banlist (net), per-setgenerate MININGTHREADS
(rpc/mining), signrawtransaction TXPOW, and per-message nSPV traces.
- Left format/arg-mismatched lines untouched (flagged) to avoid introducing
tinyformat runtime throws.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+4
-35
@@ -113,13 +113,7 @@ arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTar
|
||||
}
|
||||
if ( bnTarget > mintarget )
|
||||
bnTarget = mintarget;
|
||||
{
|
||||
int32_t z;
|
||||
for (z=31; z>=0; z--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||
}
|
||||
fprintf(stderr," ht.%d initial W.%d outerK.%lld %d * %d * %d / %d\n",height,W,(long long)outerK,(nTime-ts[0]),(ts[0]-ts[W]),denominator,numerator);
|
||||
} //else fprintf(stderr,"ht.%d no outer trigger %d >= %d\n",height,(ts[0] - ts[W]),(T * numerator)/denominator);
|
||||
}
|
||||
return(bnTarget);
|
||||
}
|
||||
|
||||
@@ -146,12 +140,6 @@ arith_uint256 RT_CST_RST_inner(int32_t height,uint32_t nTime,arith_uint256 bnTar
|
||||
bnTarget = RT_CST_RST_target(height,nTime,bnTarget,ts,ct,W);
|
||||
if ( bnTarget == origtarget ) // force zawyflag to 1
|
||||
bnTarget = mintarget;
|
||||
{
|
||||
int32_t z;
|
||||
for (z=31; z>=0; z--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||
}
|
||||
fprintf(stderr," height.%d O.%-2d, W.%-2d width.%-2d %4d vs %-4d, deficit %4d tip.%d\n",height,outeri,W,width,(ts[0] - ts[width]),expected,expected - (ts[0] - ts[width]),nTime-ts[0]);
|
||||
}
|
||||
return(bnTarget);
|
||||
}
|
||||
@@ -211,23 +199,14 @@ arith_uint256 zawy_TSA_EMA(int32_t height,int32_t tipdiff,arith_uint256 prevTarg
|
||||
B = (bnTarget / arith_uint256(360000)) * arith_uint256(tipdiff * zawy_exponential_val360000(tipdiff/2));
|
||||
C = (bnTarget / arith_uint256(360000)) * arith_uint256(T * zawy_exponential_val360000(tipdiff/2));
|
||||
bnTarget = ((A + B - C) / arith_uint256(tipdiff)) * arith_uint256(K*T);
|
||||
{
|
||||
int32_t z;
|
||||
for (z=31; z>=0; z--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||
}
|
||||
fprintf(stderr," ht.%d TSA bnTarget tipdiff.%d\n",height,tipdiff);
|
||||
return(bnTarget);
|
||||
}
|
||||
|
||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||
{
|
||||
if (pindexLast->GetHeight() == 340000) {
|
||||
LogPrintf("%s: Using blocktime=%d\n",__func__,ASSETCHAINS_BLOCKTIME);
|
||||
}
|
||||
//if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
|
||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_ALGO != ASSETCHAINS_RANDOMX) {
|
||||
fprintf(stderr,"%s: using lwma for next work\n",__func__);
|
||||
LogPrint("pow","%s: using lwma for next work\n",__func__);
|
||||
return lwmaGetNextWorkRequired(pindexLast, pblock, params);
|
||||
}
|
||||
|
||||
@@ -309,13 +288,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
{
|
||||
blocktime = pindexFirst->nTime;
|
||||
diff = (pblock->nTime - blocktime);
|
||||
//fprintf(stderr,"%d ",diff);
|
||||
if ( i < 6 )
|
||||
{
|
||||
diff -= (8+i)*ASSETCHAINS_BLOCKTIME;
|
||||
if ( diff > mult )
|
||||
{
|
||||
//fprintf(stderr,"i.%d diff.%d (%u - %u - %dx)\n",i,(int32_t)diff,pblock->nTime,pindexFirst->nTime,(8+i));
|
||||
mult = diff;
|
||||
}
|
||||
}
|
||||
@@ -325,7 +302,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
bnTot += bnTmp;
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
}
|
||||
//fprintf(stderr,"diffs %d\n",height);
|
||||
// Check we have enough blocks
|
||||
if (pindexFirst == NULL)
|
||||
return nProofOfWorkLimit;
|
||||
@@ -422,15 +398,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
if ( bnTarget < origtarget || bnTarget > easy )
|
||||
{
|
||||
bnTarget = easy;
|
||||
fprintf(stderr,"cmp.%d mult.%d ht.%d -> easy target\n",mult>1,(int32_t)mult,height);
|
||||
LogPrint("pow","cmp.%d mult.%d ht.%d -> easy target\n",mult>1,(int32_t)mult,height);
|
||||
return(HUSH_MINDIFF_NBITS & (~3));
|
||||
}
|
||||
{
|
||||
int32_t z;
|
||||
for (z=31; z>=0; z--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||
}
|
||||
fprintf(stderr," exp() to the rescue cmp.%d mult.%d for ht.%d\n",mult>1,(int32_t)mult,height);
|
||||
}
|
||||
}
|
||||
nbits = bnTarget.GetCompact();
|
||||
@@ -527,8 +497,7 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const
|
||||
bnLimit = UintToArith256(params.powAlternate);
|
||||
|
||||
unsigned int nProofOfWorkLimit = bnLimit.GetCompact();
|
||||
|
||||
//printf("PoWLimit: %u\n", nProofOfWorkLimit);
|
||||
|
||||
// Find the first block in the averaging interval as we total the linearly weighted average
|
||||
const CBlockIndex* pindexFirst = pindexLast;
|
||||
const CBlockIndex* pindexNext;
|
||||
|
||||
Reference in New Issue
Block a user