hygiene: Phase 2 — DragonX-authored cleanup (13 findings)
Second phase of the code-hygiene remediation, covering the items the
DragonX team introduced or the rebrand missed. No consensus behavior
changes; validated on a local self-mining node.
Log cruft:
- chainparams: route the startup ">>>>>>>>>>" banner and the port line
through LogPrintf/LogPrint("net") instead of fprintf(stderr).
- pow: drop the fprintf(stderr) hash-mismatch dump that duplicated the
LogPrintf copy verbatim.
- miner: gate the RandomXDatasetManager per-alloc/per-VM address dumps and
MemDiag /proc reads behind LogPrint("randomx"); keep a one-line
"allocated shared dataset (N GB)" summary at default verbosity.
Named constants (single source of truth in wallet.h):
- DEFAULT_AUTOSHIELD_FEE/INTERVAL, MIN_AUTOSHIELD_INTERVAL,
DEFAULT_AUTOSHIELD_MIN_UTXOS, AUTOSHIELD_MIN/MAX_FEE for the autoshield
option parsing and help text (were bare 10000/25/5 literals repeated
across init.cpp and wallet.h).
- AUTO_OP_TARGET_HEIGHT_OFFSET replaces the three copy-pasted
`blockHeight + 5` async-op scheduling offsets.
- AUTO_OP_EXPIRY_DELTA replaces the three per-file *_EXPIRY_DELTA=15
constants (sweep/consolidation/autoshield) with one shared value.
- Move DEFAULT_AUTOSHIELD_FEE out of the op header into wallet.h so it no
longer collides when both headers are included.
Error surfacing:
- init: report clamped/out-of-range -autoshieldinterval/-autoshieldfee via
InitWarning() (surfaces to GUI/log) instead of fprintf(stderr).
Rebrand / dead foreign-chain code (approved removals):
- server: drop the HUSH3 special-cases in stop() and HelpExampleCli; the
cli example now shows "dragonx-cli" instead of "hush-cli".
- getinfo (misc): remove the stale dPoW notarization block (notarized,
prevMoMheight, notarizedhash, notarizedtxid, notarizedtxid_height,
HUSHnotarized_height, notarized_confirms) — DragonX is a private chain
from genesis with no active dPoW. Also fixes the hardcoded "HUSH3" that
made getinfo query a foreign chain's notarization.
- delete the dead Komodo notary RPCs getera/getdragonjson/
getnotarysendmany/geterablockheights (getera returned 0;
getnotarysendmany was marked "this is broke") and their registrations.
- remove the dead ASSETCHAINS_EQUIHASH reporting branches in getinfo and
getmininginfo — DragonX is RandomX-only.
chainparams: document why the upstream Equihash params and the literal
Bitcoin genesis are retained under RandomX (do not "fix" them).
Deferred: the hdSeedOrigin int->string switch in z_autoshieldstatus
(no shared helper exists to reuse; low value).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+3
-124
@@ -78,106 +78,6 @@ extern int32_t ASSETCHAINS_SAPLING;
|
||||
extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[],ASSETCHAINS_NOTARY_PAY[];
|
||||
extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[];
|
||||
|
||||
//TODO: use non-staked eras
|
||||
// Currently HUSH only uses block heights to define eras
|
||||
int32_t getera(int timestamp)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
UniValue getdragonjson(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (fHelp || params.size() != 0)
|
||||
throw runtime_error("getdragonjson\nreturns json for dragon, for the current ERA.");
|
||||
|
||||
UniValue json(UniValue::VOBJ);
|
||||
UniValue seeds(UniValue::VARR);
|
||||
UniValue notaries(UniValue::VARR);
|
||||
// get the current era, use local time for now.
|
||||
// should ideally take blocktime of last known block?
|
||||
int now = time(NULL);
|
||||
int32_t era = getera(now);
|
||||
|
||||
// loop over seeds array and push back to json array for seeds
|
||||
for (int8_t i = 0; i < 8; i++) {
|
||||
//seeds.push_back(dragonSeeds[i][0]);
|
||||
}
|
||||
|
||||
// get all current notaries
|
||||
for (int8_t i = 0; i < NUM_HUSH_NOTARIES; i++) {
|
||||
UniValue notary(UniValue::VOBJ);
|
||||
notary.push_back(notaries_list[era][i][0]);
|
||||
notaries.push_back(notary);
|
||||
}
|
||||
|
||||
// TODO: should be a config param
|
||||
int minsigs = 13;
|
||||
int BTCminsigs = 13;
|
||||
|
||||
int dragonPort = 5555;
|
||||
json.push_back(Pair("port",dragonPort));
|
||||
json.push_back(Pair("BTCminsigs",BTCminsigs));
|
||||
json.push_back(Pair("minsigs",minsigs));
|
||||
json.push_back(Pair("seeds",seeds));
|
||||
json.push_back(Pair("notaries",notaries));
|
||||
return json;
|
||||
}
|
||||
|
||||
UniValue getnotarysendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (fHelp || params.size() > 1)
|
||||
throw runtime_error(
|
||||
"getnotarysendmany\n"
|
||||
"Returns a sendmany JSON array with all current notaries Raddress's.\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getnotarysendmany", "10")
|
||||
+ HelpExampleRpc("getnotarysendmany", "10")
|
||||
);
|
||||
int amount = 0;
|
||||
if ( params.size() == 1 ) {
|
||||
amount = params[0].get_int();
|
||||
}
|
||||
|
||||
//TODO: this is broke
|
||||
int era = getera(time(NULL));
|
||||
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
for (int i = 0; i<NUM_HUSH_NOTARIES; i++)
|
||||
{
|
||||
char Raddress[18]; uint8_t pubkey33[33];
|
||||
decode_hex(pubkey33,33,(char *)notaries_list[era][i][1]);
|
||||
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
|
||||
ret.push_back(Pair(Raddress,amount));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (fHelp || params.size() != 0)
|
||||
throw runtime_error(
|
||||
"geterablockheights\n"
|
||||
"Returns a JSON object with the first block in each era.\n"
|
||||
);
|
||||
|
||||
CBlockIndex *pindex; int8_t lastera,era = 0; UniValue ret(UniValue::VOBJ);
|
||||
|
||||
for (size_t i = 1; i < chainActive.LastTip()->GetHeight(); i++)
|
||||
{
|
||||
pindex = chainActive[i];
|
||||
era = getera(pindex->nTime)+1;
|
||||
if ( era > lastera )
|
||||
{
|
||||
char str[16];
|
||||
sprintf(str, "%d", era);
|
||||
ret.push_back(Pair(str,(int64_t)i));
|
||||
lastera = era;
|
||||
}
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
extern int getWorkQueueDepth();
|
||||
extern int getWorkQueueMaxDepth();
|
||||
extern int getWorkQueueNumThreads();
|
||||
@@ -202,7 +102,7 @@ UniValue rpcinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,hushnotarized_height,txid_height;
|
||||
int32_t longestchain;
|
||||
if (fHelp || params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getinfo\n"
|
||||
@@ -240,28 +140,13 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
proxyType proxy;
|
||||
GetProxy(NET_IPV4, proxy);
|
||||
notarized_height = hush_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid);
|
||||
//fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL));
|
||||
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("version", CLIENT_VERSION));
|
||||
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
|
||||
obj.push_back(Pair("synced", HUSH_INSYNC!=0));
|
||||
obj.push_back(Pair("notarized", notarized_height));
|
||||
obj.push_back(Pair("prevMoMheight", prevMoMheight));
|
||||
obj.push_back(Pair("notarizedhash", notarized_hash.ToString()));
|
||||
obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
|
||||
if ( HUSH_NSPV_FULLNODE )
|
||||
{
|
||||
txid_height = notarizedtxid_height( (char *)"HUSH3" ,(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height);
|
||||
if ( txid_height > 0 )
|
||||
obj.push_back(Pair("notarizedtxid_height", txid_height));
|
||||
else obj.push_back(Pair("notarizedtxid_height", "mempool"));
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 ) {
|
||||
obj.push_back(Pair("HUSHnotarized_height", hushnotarized_height));
|
||||
}
|
||||
obj.push_back(Pair("notarized_confirms", txid_height < hushnotarized_height ? (hushnotarized_height - txid_height + 1) : 0));
|
||||
//fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL));
|
||||
#ifdef ENABLE_WALLET
|
||||
if (pwalletMain) {
|
||||
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
|
||||
@@ -348,14 +233,8 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
||||
obj.push_back(Pair("commission", ASSETCHAINS_COMMISSION));
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) {
|
||||
uint64_t N = ASSETCHAINS_NK[0] ? ASSETCHAINS_NK[0] : 200;
|
||||
uint64_t K = ASSETCHAINS_NK[1] ? ASSETCHAINS_NK[1] : 9;
|
||||
std::string equihash_algo = "equihash (" + std::to_string(N) + "," + std::to_string(K) + ")";
|
||||
obj.push_back(Pair("algo",equihash_algo));
|
||||
} else {
|
||||
obj.push_back(Pair("algo", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]));
|
||||
}
|
||||
// DragonX is RandomX-only; the Equihash (N,K) reporting path was removed.
|
||||
obj.push_back(Pair("algo", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user