hygiene: Phase 3 — dead-code excision (~7,100 lines)
Third phase of the code-hygiene remediation: remove provably-dead code.
Each in-file deletion was adversarially verified (a per-finding investigator
plus a skeptic that greps the tree to refute deletability); the sanity grep
confirms zero dangling references, and the tree builds and self-mines clean.
Removed wholesale:
- src/cc/dapps/ (9 files, ~6,939 lines): a git-tracked but never-built Komodo
DEX / z-migration tool (hushdex.c, zmigrate.c, cJSON.c, ...). Nothing in
Makefile.am/configure.ac references it.
In-file dead code:
- pow.cpp: the `#ifdef original_algo` oldRT_CST_RST function (the macro is
never defined in source or build flags) and two `if ( 0 )` debug blocks.
- walletdb.cpp: the "orphaned staking transaction" cleanup path (deadTxns) —
DragonX is RandomX PoW with no staking, so the guard is always false and the
block never runs; also drop the now-unused static/extern decls.
- cc/eval.h: the ProcessCC / Eval::ImportCoin / ImportPayout / DisputePayout
declarations that have no definition anywhere in the tree.
- rpc/crosschain.cpp: the crosschainproof stub RPC (returned {} unconditionally)
and its registrations in rpc/server.cpp, rpc/server.h, rpc/client.cpp.
- coins.cpp: the commented-out `//TODO: delete` Sprout PushAnchor template.
- wallet.cpp: the permanently-zero KMD `interest2` term in CreateTransaction.
- rpc/net.cpp: hush_longestchain's always-zero `n` var (num > (n>>1) => num>0)
and its `if ( 0 )` debug branch.
- hush_nSPV.h / hush_nSPV_fullnode.h: three `if ( 0 && ... )` dead debug branches.
- net.cpp, crypter.h, saplingconsolidation.cpp (dup set_error_code),
shieldcoinbase.cpp (`donation < 0` on a uint8_t), cclib.cpp (unused
FAUCET2SIZE): single-line dead-code fixes.
Deliberately NOT touched (verification refuted the audit's "dead on DragonX"
premise): the ~2,250-line HUSH3 checkpoint block, the miner notary/timelock
paths, and hush_gateway.h — all reachable at runtime via -ac_name / -ac_*
args (the inherited Komodo assetchain model), and hush_gateway's
hush_opretvalidate is called from ConnectBlock (consensus). Dropping those
requires a deliberate decision to remove HAC/HUSH3 mode, tracked separately.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
-83
@@ -97,76 +97,6 @@ bnTarget = RT_CST_RST (bnTarget, ts, cw, numerator, denominator, W, T, past);
|
||||
#define T ASSETCHAINS_BLOCKTIME
|
||||
#define K ((int64_t)1000000)
|
||||
|
||||
#ifdef original_algo
|
||||
arith_uint256 oldRT_CST_RST(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past)
|
||||
{
|
||||
//if (ts.size() < 2*W || ct.size() < 2*W ) { exit; } // error. a vector was too small
|
||||
//if (ts.size() < past+W || ct.size() < past+W ) { past = min(ct.size(), ts.size()) - W; } // past was too small, adjust
|
||||
int64_t altK; int32_t i,j,k,ii=0; // K is a scaling factor for integer divisions
|
||||
if ( height < 64 )
|
||||
return(bnTarget);
|
||||
//if ( ((ts[0]-ts[W]) * W * 100)/(W-1) < (T * numerator * 100)/denominator )
|
||||
if ( (ts[0] - ts[W]) < (T * numerator)/denominator )
|
||||
{
|
||||
//bnTarget = ((ct[0]-ct[1])/K) * max(K,(K*(nTime-ts[0])*(ts[0]-ts[W])*denominator/numerator)/T/T);
|
||||
bnTarget = ct[0] / arith_uint256(K);
|
||||
//altK = (K * (nTime-ts[0]) * (ts[0]-ts[W]) * denominator * W) / (numerator * (W-1) * (T * T));
|
||||
altK = (K * (nTime-ts[0]) * (ts[0]-ts[W]) * denominator) / (numerator * (T * T));
|
||||
fprintf(stderr,"ht.%d initial altK.%lld %d * %d * %d / %d\n",height,(long long)altK,(nTime-ts[0]),(ts[0]-ts[W]),denominator,numerator);
|
||||
if ( altK > K )
|
||||
altK = K;
|
||||
bnTarget *= arith_uint256(altK);
|
||||
if ( altK < K )
|
||||
return(bnTarget);
|
||||
}
|
||||
/* Check past 24 blocks for any sum of 3 STs < T/2 triggers. This is messy
|
||||
because the blockchain does not allow us to store a variable to know
|
||||
if we are currently in a triggered state that is making a sequence of
|
||||
adjustments to prevTargets, so we have to look for them.
|
||||
Nested loops do this: if block emission has not slowed to be back on track at
|
||||
any time since most recent trigger and we are at current block, aggressively
|
||||
adust prevTarget. */
|
||||
|
||||
for (j=past-1; j>=2; j--)
|
||||
{
|
||||
if ( ts[j]-ts[j+W] < T*numerator/denominator )
|
||||
{
|
||||
ii = 0;
|
||||
for (i=j-2; i>=0; i--)
|
||||
{
|
||||
ii++;
|
||||
// Check if emission caught up. If yes, "trigger stopped at i".
|
||||
// Break loop to try more recent j's to see if trigger activates again.
|
||||
if ( (ts[i] - ts[j+W]) > (ii+W)*T )
|
||||
break;
|
||||
|
||||
// We're here, so there was a TS[j]-TS[j-3] < T/2 trigger in the past and emission rate has not yet slowed up to be back on track so the "trigger is still active", aggressively adjusting target here at block "i"
|
||||
if ( i == 0 )
|
||||
{
|
||||
/* We made it all the way to current block. Emission rate since
|
||||
last trigger never slowed enough to get back on track, so adjust again.
|
||||
If avg last 3 STs = T, this increases target to prevTarget as ST increases to T.
|
||||
This biases it towards ST=~1.75*T to get emission back on track.
|
||||
If avg last 3 STs = T/2, target increases to prevTarget at 2*T.
|
||||
Rarely, last 3 STs can be 1/2 speed => target = prevTarget at T/2, & 1/2 at T.*/
|
||||
|
||||
//bnTarget = ((ct[0]-ct[W])/W/K) * (K*(nTime-ts[0])*(ts[0]-ts[W]))/W/T/T;
|
||||
bnTarget = ct[0];
|
||||
for (k=1; k<W; k++)
|
||||
bnTarget += ct[k];
|
||||
bnTarget /= arith_uint256(W * K);
|
||||
altK = (K * (nTime-ts[0]) * (ts[0]-ts[W])) / (W * T * T);
|
||||
fprintf(stderr,"ht.%d made it to i == 0, j.%d ii.%d altK %lld (%d * %d) %u - %u W.%d\n",height,j,ii,(long long)altK,(nTime-ts[0]),(ts[0]-ts[W]),ts[0],ts[W],W);
|
||||
bnTarget *= arith_uint256(altK);
|
||||
j = 0; // It needed adjusting, we adjusted it, we're finished, so break out of j loop.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(bnTarget);
|
||||
}
|
||||
#endif
|
||||
|
||||
arith_uint256 RT_CST_RST_outer(int32_t height,uint32_t nTime,arith_uint256 bnTarget,uint32_t *ts,arith_uint256 *ct,int32_t numerator,int32_t denominator,int32_t W,int32_t past)
|
||||
{
|
||||
int64_t outerK; int32_t cmpval; arith_uint256 mintarget = bnTarget / arith_uint256(2);
|
||||
@@ -202,13 +132,6 @@ arith_uint256 RT_CST_RST_target(int32_t height,uint32_t nTime,arith_uint256 bnTa
|
||||
bnTarget /= arith_uint256(width * K);
|
||||
innerK = (K * (nTime-ts[0]) * (ts[0]-ts[width])) / (width * T * T);
|
||||
bnTarget *= arith_uint256(innerK);
|
||||
if ( 0 )
|
||||
{
|
||||
int32_t z;
|
||||
for (z=31; z>=0; z--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[z]);
|
||||
fprintf(stderr," ht.%d innerK %lld (%d * %d) %u - %u width.%d\n",height,(long long)innerK,(nTime-ts[0]),(ts[0]-ts[width]),ts[0],ts[width],width);
|
||||
}
|
||||
return(bnTarget);
|
||||
}
|
||||
|
||||
@@ -509,12 +432,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
}
|
||||
fprintf(stderr," exp() to the rescue cmp.%d mult.%d for ht.%d\n",mult>1,(int32_t)mult,height);
|
||||
}
|
||||
if ( 0 && zflags[0] == 0 && zawyflag == 0 && mult <= 1 )
|
||||
{
|
||||
bnTarget = zawy_TSA_EMA(height,tipdiff,(bnTarget+ct[0]+ct[1])/arith_uint256(3),ts[0] - ts[1]);
|
||||
if ( bnTarget < origtarget )
|
||||
zawyflag = 3;
|
||||
}
|
||||
}
|
||||
nbits = bnTarget.GetCompact();
|
||||
nbits = (nbits & 0xfffffffc) | zawyflag;
|
||||
|
||||
Reference in New Issue
Block a user