hygiene: Phase 5 — correct stale comments + name safe magic numbers
Fifth phase of the code-hygiene remediation, done per-file (18 files) via an 18-agent Workflow with strict guardrails. No consensus or security VALUES changed (verified: pow/hush_utils/hush_bitcoind/net.h/crypter/stratum have zero non-comment numeric changes); built clean, self-mined, verifychain=true. Totals: 57 stale comments corrected, 46 user-facing branding fixes, 6 behavior-preserving named constants, 4 stratum warnings, 77 items deliberately left (consensus/security values, copyright headers). - Stale comments -> DragonX: corrected HUSH3/HUSH/Komodo/Equihash/Arrakis leftovers that misdescribed the active chain (pow AWT/lwma notes, txdb "Equihash solution" -> RandomX, wallet CLTV/overwinter/Sapling@1 notes, util datadir provenance, crypter's stale mapSproutSpendingKeys invariant). Replaced unprofessional/editorializing comments (profane TODOs, "developers are elite") with neutral technical notes, preserving the real design info. - User-facing branding: dumpwallet header "created by Hush" -> "DragonX"; RPC help text hushd/hush-cli/hushprivkey/hushaddress/Agama -> dragonx*; rebranded provably-dead "HUSH3" symbol-fallback literals to DRAGONX. - Named constants (same values, non-consensus/non-security): addrman peer-selection factors (kChanceFactorGrowth/kChanceScale/deprioritize), sietch MIN_ZOUTS, an init notarization-DB cache size. - Left the security macros (ECC/TFM_TIMING_RESISTANT=420, comment-clarified only), the consensus subsidy/commission literals + 128/129 TRANSITION (comment only), and copyright headers untouched. - Added a prominent WARNING that the stratum server is Equihash-era and NOT updated for DragonX's RandomX PoW (flagged, not rewritten). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+24
-8
@@ -1447,7 +1447,10 @@ uint32_t hush_smartmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t
|
||||
LogPrintf("DragonX raw magic extralen=%d crc0=%x\n",extralen,crc0);
|
||||
}
|
||||
|
||||
//TODO: why is this needed?
|
||||
// Legacy special case: HUSH3 mainnet had a hardcoded network magic (HUSH_MAGIC)
|
||||
// rather than the crc32-derived value used by every other chain. This branch is
|
||||
// dead on DragonX (SMART_CHAIN_SYMBOL is "DRAGONX", never "HUSH3"); it is kept only
|
||||
// so the function still reproduces HUSH3's magic if ever run with that symbol.
|
||||
const bool ishush3 = strncmp(symbol, "HUSH3",5) == 0 ? true : false;
|
||||
if(ishush3) {
|
||||
return HUSH_MAGIC;
|
||||
@@ -1493,16 +1496,19 @@ uint64_t hush_max_money()
|
||||
return hush_current_supply(10000000);
|
||||
}
|
||||
|
||||
// This implements the Hush Emission Curve, the miner subsidy part,
|
||||
// and must be kept in sync with hush_commision() in hush_bitcoind.h!
|
||||
// Changing these functions are consensus changes!
|
||||
// Here Be Dragons! -- Duke Leto
|
||||
// This implements the emission curve (miner subsidy part) and must be kept in
|
||||
// sync with hush_commission() in hush_bitcoind.h! Changing these functions,
|
||||
// including the height literals below, is a CONSENSUS change.
|
||||
// NOTE: this TRANSITION boundary is 128 here, while hush_commission() uses 129.
|
||||
// This off-by-one between the two curves is a historical consensus quirk and is
|
||||
// deliberately left as-is: changing either value would be a consensus change.
|
||||
uint64_t hush_block_subsidy(int height)
|
||||
{
|
||||
uint64_t subsidy = 0;
|
||||
int32_t HALVING1 = GetArg("-z2zheight",340000);
|
||||
//TODO: support INTERVAL :(
|
||||
//int32_t INTERVAL = GetArg("-ac_halving1",840000);
|
||||
// Consensus: TRANSITION is 128 here vs 129 in hush_commission(); do not change (see note above).
|
||||
int32_t TRANSITION = 128;
|
||||
|
||||
if (height < TRANSITION) {
|
||||
@@ -1585,7 +1591,9 @@ uint64_t hush_block_subsidy(int height)
|
||||
return subsidy;
|
||||
}
|
||||
|
||||
// wrapper for more general supply curves of Hush Arrakis Chains
|
||||
// Wrapper for the more general supply curves used by assetchains (era/halving/decay driven).
|
||||
// On DragonX the reward comes from the -ac_reward/-ac_halving parameters set in hush_args();
|
||||
// the ishush3 branch below is a legacy special case that is dead on DragonX.
|
||||
uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
{
|
||||
// Find current era, start from beginning reward, and determine current subsidy
|
||||
@@ -1593,6 +1601,8 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
int64_t subsidyDifference;
|
||||
int32_t numhalvings = 0, curEra = 0, sign = 1;
|
||||
static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era;
|
||||
// Legacy-HUSH3 detection: dead on DragonX (SMART_CHAIN_SYMBOL is "DRAGONX"), used only
|
||||
// to route HUSH3 mainnet through its bespoke hush_block_subsidy() emission curve below.
|
||||
const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||
|
||||
// check for backwards compat, older chains with no explicit rewards had 0.0001 block reward
|
||||
@@ -1629,7 +1639,9 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
if(fDebug)
|
||||
fprintf(stderr,"%s: HUSH3 subsidy=%ld at height=%d\n",__func__,subsidy,nHeight);
|
||||
} else if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) {
|
||||
// The code below is not compatible with HUSH3 mainnet
|
||||
// Generic halving/decay path used by DragonX and other assetchains.
|
||||
// (Legacy HUSH3 mainnet did NOT use this path; it took the ishush3
|
||||
// branch above, which reproduces its bespoke emission curve.)
|
||||
if ( ASSETCHAINS_DECAY[curEra] == 0 ) {
|
||||
subsidy >>= numhalvings;
|
||||
} else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) {
|
||||
@@ -1991,7 +2003,8 @@ void hush_args(char *argv0)
|
||||
uint8_t prevCCi = 0;
|
||||
ASSETCHAINS_CCLIB = GetArg("-ac_cclib","hush3");
|
||||
|
||||
// these are the enabled CCs on HUSH3 mainnet
|
||||
// Default CC set inherited from legacy HUSH3 mainnet; only used when a chain
|
||||
// enables CryptoConditions and does not override -ac_ccenable.
|
||||
Split(GetArg("-ac_ccenable","228,234,235,236,241"), sizeof(ccenables)/sizeof(*ccenables), ccenables, 0);
|
||||
for (i=nonz=0; i<0x100; i++)
|
||||
{
|
||||
@@ -2376,6 +2389,9 @@ void hush_args(char *argv0)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Legacy fallback path taken only when no -ac_name is set (SMART_CHAIN_SYMBOL empty).
|
||||
// Dead on DragonX, which always runs with -ac_name=DRAGONX. The HUSH3/Bitcoin conf
|
||||
// paths and default ports below are historical and left as-is for backwards compat.
|
||||
char fname[512],username[512],password[4096]; int32_t iter; FILE *fp;
|
||||
ASSETCHAINS_P2PPORT = 7770;
|
||||
ASSETCHAINS_RPCPORT = 7771;
|
||||
|
||||
Reference in New Issue
Block a user