diff --git a/src/chainparams.cpp b/src/chainparams.cpp index fc05e59b2..d56993c1c 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -148,6 +148,12 @@ public: nMinerThreads = 0; nMaxTipAge = 24 * 60 * 60; nPruneAfterHeight = 100000; + // NOTE: These Equihash parameters and the literal Bitcoin genesis block below are + // inherited from the upstream (Zcash/Komodo) CMainParams and are NOT what DragonX + // mines under. DragonX is a RandomX CPU-mining chain whose real PoW and chain + // parameters are set for its SMART_CHAIN_SYMBOL at runtime (see hush_utils.h and + // chainparams_commandline()). They are retained here for upstream-diff hygiene and + // genesis fixity; do not "fix" them to RandomX values. const size_t N = 200, K = 9; BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); nEquihashN = N; @@ -533,9 +539,7 @@ void hush_setactivation(int32_t height) void *chainparams_commandline() { CChainParams::CCheckpointData checkpointData; - //if(fDebug) { - fprintf(stderr,"chainparams_commandline called with port=%u\n", ASSETCHAINS_P2PPORT); - //} + LogPrint("net", "chainparams_commandline called with port=%u\n", ASSETCHAINS_P2PPORT); if ( SMART_CHAIN_SYMBOL[0] != 0 ) { // A smart chain inherits vSeeds/vFixedSeeds from the base network params, @@ -579,7 +583,7 @@ void *chainparams_commandline() { pCurrentParams->pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff; pCurrentParams->pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff; pCurrentParams->pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; - fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",SMART_CHAIN_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); + LogPrintf("%s: p2p port %u, rpc port %u, magic %08x, supply %u coins\n",SMART_CHAIN_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY); pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = ASSETCHAINS_SAPLING; pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = ASSETCHAINS_OVERWINTER; diff --git a/src/init.cpp b/src/init.cpp index 9f42e43a0..fa51c3963 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -491,9 +491,9 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-zsweepexclude", _("Addresses to exclude from sweeping (default none)")); strUsage += HelpMessageOpt("-autoshield", _("Automatically shield matured coinbase (mining rewards) into a seed-derived wallet z-address (default: true for wallets created or restored by this software, false when the HD seed provenance is unknown). No-op when not mining or wallet is locked.")); - strUsage += HelpMessageOpt("-autoshieldinterval", strprintf(_("Block interval between automatic coinbase-shielding rounds (default: %i, min 5)"), 25)); + strUsage += HelpMessageOpt("-autoshieldinterval", strprintf(_("Block interval between automatic coinbase-shielding rounds (default: %i, min %i)"), DEFAULT_AUTOSHIELD_INTERVAL, MIN_AUTOSHIELD_INTERVAL)); strUsage += HelpMessageOpt("-autoshieldaddress=", _("Destination Sapling z-address for auto-shielded coinbase (default: reuse or create a wallet z-address). Must be spendable by this wallet.")); - strUsage += HelpMessageOpt("-autoshieldfee", strprintf(_("Fee in puposhis for automatic coinbase-shielding transactions (default: %i)"), 10000)); + strUsage += HelpMessageOpt("-autoshieldfee", strprintf(_("Fee in puposhis for automatic coinbase-shielding transactions (default: %i)"), DEFAULT_AUTOSHIELD_FEE)); strUsage += HelpMessageOpt("-sietch-min-zouts=", strprintf(_("Minimum number of shielded (Sapling) outputs Sietch adds to each z_sendmany transaction as decoys, strengthening amount/linkability privacy. Higher values add privacy at the cost of larger transactions (default: %u, clamped to the range 3-50)"), 7)); strUsage += HelpMessageOpt("-autoshieldminutxos", strprintf(_("Only auto-shield once at least this many matured coinbase UTXOs exist (default: %i)"), 1)); @@ -2521,10 +2521,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) "pass -autoshield=1 to enable.\n", __func__, pwalletMain->hdSeedOrigin); } if (pwalletMain->fAutoShieldEnabled) { - int autoShieldInterval = GetArg("-autoshieldinterval", 25); - if (autoShieldInterval < 5) { - fprintf(stderr,"%s: autoshield interval %d below the minimum, clamping to 5\n", __func__, autoShieldInterval); - autoShieldInterval = 5; + int autoShieldInterval = GetArg("-autoshieldinterval", DEFAULT_AUTOSHIELD_INTERVAL); + if (autoShieldInterval < MIN_AUTOSHIELD_INTERVAL) { + InitWarning(strprintf(_("autoshield interval %d below the minimum, clamping to %d"), + autoShieldInterval, MIN_AUTOSHIELD_INTERVAL)); + autoShieldInterval = MIN_AUTOSHIELD_INTERVAL; } pwalletMain->autoShieldInterval = autoShieldInterval; pwalletMain->nextAutoShield = pwalletMain->autoShieldInterval + chainActive.Height(); @@ -2533,16 +2534,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // guard against a fat-finger (e.g. -autoshieldfee=5000000000) that // would otherwise build an over-fee or malformed shield tx that // fails mempool admission every round. - CAmount autoShieldFee = GetArg("-autoshieldfee", 10000); - const CAmount AUTOSHIELD_MIN_FEE = 1000; // comfortably above minRelayTxFee for a small tx - const CAmount AUTOSHIELD_MAX_FEE = 10000000; // 0.1 DRGX; no sane autoshield fee exceeds this + CAmount autoShieldFee = GetArg("-autoshieldfee", DEFAULT_AUTOSHIELD_FEE); if (autoShieldFee < AUTOSHIELD_MIN_FEE || autoShieldFee > AUTOSHIELD_MAX_FEE) { - fprintf(stderr,"%s: -autoshieldfee=%lld out of range [%lld,%lld], using default 10000\n", - __func__, (long long)autoShieldFee, (long long)AUTOSHIELD_MIN_FEE, (long long)AUTOSHIELD_MAX_FEE); - autoShieldFee = 10000; + InitWarning(strprintf(_("-autoshieldfee=%lld out of range [%lld,%lld], using default %lld"), + (long long)autoShieldFee, (long long)AUTOSHIELD_MIN_FEE, (long long)AUTOSHIELD_MAX_FEE, (long long)DEFAULT_AUTOSHIELD_FEE)); + autoShieldFee = DEFAULT_AUTOSHIELD_FEE; } pwalletMain->autoShieldFee = autoShieldFee; - pwalletMain->autoShieldMinUtxos = GetArg("-autoshieldminutxos", 1); + pwalletMain->autoShieldMinUtxos = GetArg("-autoshieldminutxos", DEFAULT_AUTOSHIELD_MIN_UTXOS); if (pwalletMain->autoShieldMinUtxos < 1) { pwalletMain->autoShieldMinUtxos = 1; } diff --git a/src/miner.cpp b/src/miner.cpp index a9794027f..b215bd7b6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1042,7 +1042,7 @@ static void LogProcessMemory(const char* label) { PMC_EX pmc = {}; pmc.cb = sizeof(pmc); if (pfn(GetCurrentProcess(), &pmc, sizeof(pmc))) { - LogPrintf("MemDiag [%s]: WorkingSet=%.1fMB, PrivateUsage=%.1fMB, PagefileUsage=%.1fMB\n", + LogPrint("randomx", "MemDiag [%s]: WorkingSet=%.1fMB, PrivateUsage=%.1fMB, PagefileUsage=%.1fMB\n", label, pmc.WorkingSetSize / (1024.0 * 1024.0), pmc.PrivateUsage / (1024.0 * 1024.0), @@ -1060,7 +1060,7 @@ static void LogProcessMemory(const char* label) { if (strncmp(line, "VmRSS:", 6) == 0 || strncmp(line, "VmSize:", 7) == 0) { // Remove newline line[strlen(line)-1] = '\0'; - LogPrintf("MemDiag [%s]: %s\n", label, line); + LogPrint("randomx", "MemDiag [%s]: %s\n", label, line); } } fclose(f); @@ -1089,7 +1089,7 @@ struct RandomXDatasetManager { if (initialized) return true; flags |= RANDOMX_FLAG_FULL_MEM; - LogPrintf("RandomXDatasetManager: flags=0x%x (JIT=%d, HARD_AES=%d, FULL_MEM=%d, LARGE_PAGES=%d)\n", + LogPrint("randomx", "RandomXDatasetManager: flags=0x%x (JIT=%d, HARD_AES=%d, FULL_MEM=%d, LARGE_PAGES=%d)\n", (int)flags, !!(flags & RANDOMX_FLAG_JIT), !!(flags & RANDOMX_FLAG_HARD_AES), !!(flags & RANDOMX_FLAG_FULL_MEM), !!(flags & RANDOMX_FLAG_LARGE_PAGES)); @@ -1130,11 +1130,11 @@ struct RandomXDatasetManager { // Log the actual memory addresses to help diagnose sharing issues uint8_t *datasetMemory = (uint8_t*)randomx_get_dataset_memory(dataset); size_t datasetSize = datasetItemCount * RANDOMX_DATASET_ITEM_SIZE; - LogPrintf("RandomXDatasetManager: allocated shared dataset:\n"); - LogPrintf(" - Dataset struct at: %p\n", (void*)dataset); - LogPrintf(" - Dataset memory at: %p (size: %.2f GB)\n", (void*)datasetMemory, datasetSize / (1024.0 * 1024.0 * 1024.0)); - LogPrintf(" - Items: %lu, Item size: %d bytes\n", datasetItemCount, RANDOMX_DATASET_ITEM_SIZE); - LogPrintf(" - Expected total process memory: ~%.2f GB + ~2MB per mining thread\n", datasetSize / (1024.0 * 1024.0 * 1024.0)); + LogPrintf("RandomXDatasetManager: allocated shared dataset (%.2f GB, %lu items)\n", + datasetSize / (1024.0 * 1024.0 * 1024.0), datasetItemCount); + LogPrint("randomx", " - Dataset struct at: %p, memory at: %p\n", (void*)dataset, (void*)datasetMemory); + LogPrint("randomx", " - Item size: %d bytes; expected ~%.2f GB + ~2MB per mining thread\n", + RANDOMX_DATASET_ITEM_SIZE, datasetSize / (1024.0 * 1024.0 * 1024.0)); return true; } @@ -1192,9 +1192,9 @@ struct RandomXDatasetManager { if (vm != nullptr) { int id = ++vmCount; uint8_t *datasetMemory = (uint8_t*)randomx_get_dataset_memory(dataset); - LogPrintf("RandomXDatasetManager: VM #%d created — VM at %p, shared dataset at %p\n", + LogPrint("randomx", "RandomXDatasetManager: VM #%d created — VM at %p, shared dataset at %p\n", id, (void*)vm, (void*)datasetMemory); - LogPrintf(" Per-thread overhead: ~2MB scratchpad + ~84KB JIT (dataset NOT copied)\n"); + LogPrint("randomx", " Per-thread overhead: ~2MB scratchpad + ~84KB JIT (dataset NOT copied)\n"); LogProcessMemory("after CreateVM"); } return vm; diff --git a/src/pow.cpp b/src/pow.cpp index 1daf60e61..8ac7fc596 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -872,14 +872,6 @@ bool CheckRandomXSolution(const CBlockHeader *pblock, int32_t height) snprintf(buf, sizeof(buf), "%02x", pblock->nSolution[i]); solutionHex += buf; } - fprintf(stderr, "CheckRandomXSolution(): HASH MISMATCH at height %d\n", height); - fprintf(stderr, " computed : %s\n", computedHex.c_str()); - fprintf(stderr, " nSolution: %s\n", solutionHex.c_str()); - fprintf(stderr, " rxKey size=%lu, input size=%lu, nNonce=%s\n", - rxKey.size(), ssInput.size(), pblock->nNonce.ToString().c_str()); - fprintf(stderr, " nSolution.size()=%lu, RANDOMX_HASH_SIZE=%d\n", - pblock->nSolution.size(), RANDOMX_HASH_SIZE); - // Also log to debug.log LogPrintf("CheckRandomXSolution(): HASH MISMATCH at height %d\n", height); LogPrintf(" computed : %s\n", computedHex); LogPrintf(" nSolution: %s\n", solutionHex); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 132362a88..3dbabf097 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -50,8 +50,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "sendtoaddress", 1 }, { "sendtoaddress", 4 }, { "settxfee", 0 }, - { "getnotarysendmany", 0 }, - { "getnotarysendmany", 1 }, { "getreceivedbyaddress", 1 }, { "getreceivedbyaccount", 1 }, { "listreceivedbyaddress", 0 }, diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 36fd5a473..2cd1d472d 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -460,15 +460,8 @@ UniValue getmininginfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("difficulty", (double)GetNetworkDifficulty())); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1))); - if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) - { - obj.push_back(Pair("localsolps" , getlocalsolps(params, false, mypk))); - obj.push_back(Pair("networksolps", getnetworksolps(params, false, mypk))); - } - else - { - obj.push_back(Pair("localhashps" , GetBoolArg("-gen", false) ? getlocalsolps(params, false, mypk) : (double)0.0)); - } + // DragonX is RandomX-only; the Equihash sol/s reporting path was removed. + obj.push_back(Pair("localhashps" , GetBoolArg("-gen", false) ? getlocalsolps(params, false, mypk) : (double)0.0)); obj.push_back(Pair("networkhashps", getnetworksolps(params, false, mypk))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 9f334dffa..b3a14c699 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -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; iGetHeight(); 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; } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index fbfb85ac2..e473ea785 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -276,11 +276,7 @@ UniValue stop(const UniValue& params, bool fHelp, const CPubKey& mypk) // Shutdown will take long enough that the response should get back StartShutdown(); - if ((strncmp(SMART_CHAIN_SYMBOL, "HUSH3", 5) == 0) ) { - sprintf(buf,"Hush server stopping, for now..."); - } else { - sprintf(buf,"%s server stopping...",SMART_CHAIN_SYMBOL); - } + sprintf(buf,"%s server stopping...",SMART_CHAIN_SYMBOL); return buf; } @@ -292,9 +288,6 @@ static const CRPCCommand vRPCCommands[] = // --------------------- ------------------------ ----------------------- ---------- /* Overall control/query calls */ { "control", "help", &help, true }, - { "control", "getdragonjson", &getdragonjson, true }, - { "control", "getnotarysendmany", &getnotarysendmany, true }, - { "control", "geterablockheights", &geterablockheights, true }, { "control", "stop", &stop, true }, /* P2P networking */ @@ -666,7 +659,6 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms // while a very long wallet rescan is happening and do other read-only devopz if (pcmd->name != "stop" && pcmd->name != "help" && pcmd->name != "z_listaddresses" && pcmd->name != "z_exportkey" && pcmd->name != "getNotarizationsForBlock" && pcmd->name != "scanNotarizationsDB" && - pcmd->name != "getnotarysendmany" && pcmd->name != "geterablockheights" && pcmd->name != "getaddressesbyaccount" && pcmd->name != "listaddresses" && pcmd->name != "z_exportwallet" && pcmd->name != "notaries" && pcmd->name != "signmessage" && pcmd->name != "decoderawtransaction" && pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" && pcmd->name != "getnetworkinfo" && @@ -695,11 +687,7 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms std::string HelpExampleCli(const std::string& methodname, const std::string& args) { - if ((strncmp(SMART_CHAIN_SYMBOL, "HUSH3", 5) == 0) ) { - return "> hush-cli " + methodname + " " + args + "\n"; - } else { - return "> hush-cli -ac_name=" + strprintf("%s", SMART_CHAIN_SYMBOL) + " " + methodname + " " + args + "\n"; - } + return "> dragonx-cli " + methodname + " " + args + "\n"; } std::string HelpExampleRpc(const std::string& methodname, const std::string& args) diff --git a/src/rpc/server.h b/src/rpc/server.h index 7b8859bcc..e6971294a 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -280,9 +280,6 @@ extern UniValue encryptwallet(const UniValue& params, bool fHelp, const CPubKey& extern UniValue validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue getdragonjson(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue getnotarysendmany(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue setpubkey(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getwalletinfo(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& mypk); diff --git a/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp b/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp index 4469adf92..94db62e97 100644 --- a/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_autoshieldcoinbase.cpp @@ -37,9 +37,6 @@ static const size_t AUTOSHIELD_MAX_INPUTS = 400; // Unrelated to the cap above despite sharing the value: this is a SIZE IN BYTES for // one spent P2SH input, mirroring CTXIN_SPEND_P2SH_SIZE in rpcwallet.cpp. static const size_t AUTOSHIELD_CTXIN_P2SH_SIZE = 400; -// Expire unmined autoshield txs after this many blocks, so a tx cannot straddle -// a network-upgrade activation. -static const int AUTOSHIELD_EXPIRY_DELTA = 15; AsyncRPCOperation_autoshieldcoinbase::AsyncRPCOperation_autoshieldcoinbase(int targetHeight) : targetHeight_(targetHeight) {} @@ -310,7 +307,7 @@ bool AsyncRPCOperation_autoshieldcoinbase::main_impl() { // from below), not the stale enqueue-time targetHeight_, so a queue delay // cannot slip a straddling expiry past this guard. auto nextActivationHeight = NextActivationHeight(tipHeight, consensusParams); - if (nextActivationHeight && tipHeight + AUTOSHIELD_EXPIRY_DELTA >= nextActivationHeight.get()) { + if (nextActivationHeight && tipHeight + AUTO_OP_EXPIRY_DELTA >= nextActivationHeight.get()) { LogPrintf("%s: autoshield tx could expire across a NU activation. Skipping this round.\n", opid); return true; } @@ -430,7 +427,7 @@ bool AsyncRPCOperation_autoshieldcoinbase::main_impl() { // stale enqueue-time height here meant the guard was checking a height the // transaction was not actually signed against. auto builder = TransactionBuilder(consensusParams, tipHeight, pwalletMain); - builder.SetExpiryHeight(tipHeight + AUTOSHIELD_EXPIRY_DELTA); + builder.SetExpiryHeight(tipHeight + AUTO_OP_EXPIRY_DELTA); builder.SetFee(fee); for (const auto& t : inputs) { diff --git a/src/wallet/asyncrpcoperation_autoshieldcoinbase.h b/src/wallet/asyncrpcoperation_autoshieldcoinbase.h index 46ad01946..bb21f09ec 100644 --- a/src/wallet/asyncrpcoperation_autoshieldcoinbase.h +++ b/src/wallet/asyncrpcoperation_autoshieldcoinbase.h @@ -11,9 +11,6 @@ #include "zcash/Address.hpp" #include "zcash/zip32.h" -// Default fee for automatic coinbase-shielding transactions -static const CAmount DEFAULT_AUTOSHIELD_FEE = 10000; - // Sentinel for "not a derived account" (i.e. the configured -autoshieldaddress). static const uint32_t AUTOSHIELD_ACCOUNT_NONE = UINT32_MAX; diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 085768315..93431058b 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -19,7 +19,6 @@ CAmount fConsolidationTxFee = DEFAULT_CONSOLIDATION_FEE; bool fConsolidationMapUsed = false; -const int CONSOLIDATION_EXPIRY_DELTA = 15; extern string randomSietchZaddr(); @@ -118,7 +117,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { // the NU-straddle guard agree with the height the tx is signed for. Mirrors // the autoshield op (commit 65130c312). auto nextActivationHeight = NextActivationHeight(tipHeight, consensusParams); - if (nextActivationHeight && tipHeight + CONSOLIDATION_EXPIRY_DELTA >= nextActivationHeight.get()) { + if (nextActivationHeight && tipHeight + AUTO_OP_EXPIRY_DELTA >= nextActivationHeight.get()) { LogPrintf("%s: Consolidation txs would be created before a NU activation but may expire after. Skipping this round.\n",opid); setConsolidationResult(0, 0, std::vector()); return status; @@ -200,7 +199,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { continue; auto builder = TransactionBuilder(consensusParams, tipHeight, pwalletMain); - builder.SetExpiryHeight(tipHeight + CONSOLIDATION_EXPIRY_DELTA); + builder.SetExpiryHeight(tipHeight + AUTO_OP_EXPIRY_DELTA); auto actualAmountToSend = amountToSend < fConsolidationTxFee ? 0 : amountToSend - fConsolidationTxFee; LogPrintf("%s: %s Beginning to create transaction with Sapling output amount=%s\n", __func__, opid, FormatMoney(actualAmountToSend)); diff --git a/src/wallet/asyncrpcoperation_sweep.cpp b/src/wallet/asyncrpcoperation_sweep.cpp index 3abd70590..5c94bf4e5 100644 --- a/src/wallet/asyncrpcoperation_sweep.cpp +++ b/src/wallet/asyncrpcoperation_sweep.cpp @@ -19,7 +19,6 @@ extern string randomSietchZaddr(); CAmount fSweepTxFee = DEFAULT_SWEEP_FEE; bool fSweepMapUsed = false; -const int SWEEP_EXPIRY_DELTA = 15; boost::optional rpcSweepAddress; AsyncRPCOperation_sweep::AsyncRPCOperation_sweep(int targetHeight, bool fromRpc) : targetHeight_(targetHeight), fromRPC_(fromRpc){} @@ -137,7 +136,7 @@ bool AsyncRPCOperation_sweep::main_impl() { // targetHeight_, so a queue delay cannot slip a straddling expiry past this // guard. Mirrors the autoshield op (commit 65130c312). auto nextActivationHeight = NextActivationHeight(tipHeight, consensusParams); - if (nextActivationHeight && tipHeight + SWEEP_EXPIRY_DELTA >= nextActivationHeight.get()) { + if (nextActivationHeight && tipHeight + AUTO_OP_EXPIRY_DELTA >= nextActivationHeight.get()) { LogPrintf("%s: Sweep txs would be created before a NU activation but may expire after. Skipping this round.\n", getId()); setSweepResult(0, 0, std::vector()); sweepComplete_ = true; // nothing to do this round; back nextSweep off one interval instead of re-dispatching every block @@ -270,7 +269,7 @@ bool AsyncRPCOperation_sweep::main_impl() { } auto builder = TransactionBuilder(consensusParams, tipHeight, pwalletMain); - builder.SetExpiryHeight(tipHeight + SWEEP_EXPIRY_DELTA); + builder.SetExpiryHeight(tipHeight + AUTO_OP_EXPIRY_DELTA); LogPrintf("%s: Beginning creating transaction with Sapling output amount=%s\n", getId(), FormatMoney(amountToSend - fee)); // Select Sapling notes diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ff80f062f..d5ec44b2a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -657,7 +657,7 @@ void CWallet::RunSaplingSweep(int blockHeight) { q->popOperationForId(saplingSweepOperationId); } pendingSaplingSweepTxs.clear(); - std::shared_ptr operation(new AsyncRPCOperation_sweep(blockHeight + 5)); + std::shared_ptr operation(new AsyncRPCOperation_sweep(blockHeight + AUTO_OP_TARGET_HEIGHT_OFFSET)); saplingSweepOperationId = operation->getId(); if (!q->addOperation(operation)) { // Queue is closing (shutdown). Release the flag we just set, or it stays @@ -715,7 +715,7 @@ void CWallet::RunSaplingConsolidation(int blockHeight) { q->popOperationForId(saplingConsolidationOperationId); } pendingSaplingConsolidationTxs.clear(); - std::shared_ptr operation(new AsyncRPCOperation_saplingconsolidation(blockHeight + 5)); + std::shared_ptr operation(new AsyncRPCOperation_saplingconsolidation(blockHeight + AUTO_OP_TARGET_HEIGHT_OFFSET)); saplingConsolidationOperationId = operation->getId(); if (!q->addOperation(operation)) { // Queue is closing (shutdown). Release the flag we just set, or it stays @@ -779,7 +779,7 @@ void CWallet::RunAutoShieldCoinbase(int blockHeight) { // running this every interval the map grew without bound. q->popOperationForId(saplingAutoShieldOperationId); } - std::shared_ptr operation(new AsyncRPCOperation_autoshieldcoinbase(blockHeight + 5)); + std::shared_ptr operation(new AsyncRPCOperation_autoshieldcoinbase(blockHeight + AUTO_OP_TARGET_HEIGHT_OFFSET)); saplingAutoShieldOperationId = operation->getId(); if (!q->addOperation(operation)) { // Queue is closing (shutdown). Release the flag we just set, or it stays diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index b54805684..cf77da83f 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -100,6 +100,19 @@ static const unsigned int DEFAULT_TX_RETENTION_LASTTX = 200; //Amount of transactions to delete per run while syncing static const int MAX_DELETE_TX_SIZE = 50000; +// Shared defaults for the automated wallet operations (sweep / consolidation / +// auto-shield-coinbase). Fees are in puposhis (zats); intervals and offsets are +// in blocks. Defined here so the CWallet scheduler fields below, init.cpp's +// option parsing/help text, and the async ops reference one source of truth. +static const CAmount DEFAULT_AUTOSHIELD_FEE = 10000; +static const int DEFAULT_AUTOSHIELD_INTERVAL = 25; +static const int MIN_AUTOSHIELD_INTERVAL = 5; +static const int DEFAULT_AUTOSHIELD_MIN_UTXOS = 1; +static const CAmount AUTOSHIELD_MIN_FEE = 1000; // comfortably above minRelayTxFee for a small tx +static const CAmount AUTOSHIELD_MAX_FEE = 10000000; // 0.1 DRGX; no sane autoshield fee exceeds this +static const int AUTO_OP_TARGET_HEIGHT_OFFSET = 5; // blocks of lookahead when scheduling an async op +static const int AUTO_OP_EXPIRY_DELTA = 15; // NU-straddle expiry window, shared by all three ops + extern const char * DEFAULT_WALLET_DAT; class CBlockIndex; @@ -847,11 +860,11 @@ public: std::string consolidationAddress = ""; int nextAutoShield = 0; - int autoShieldInterval = 25; - CAmount autoShieldFee = 10000; + int autoShieldInterval = DEFAULT_AUTOSHIELD_INTERVAL; + CAmount autoShieldFee = DEFAULT_AUTOSHIELD_FEE; // Minimum matured coinbase UTXOs before a round fires, to avoid per-interval // fee churn on a single freshly-matured reward. - int autoShieldMinUtxos = 1; + int autoShieldMinUtxos = DEFAULT_AUTOSHIELD_MIN_UTXOS; // Configured destination z-addr override; also used to cache the resolved // wallet-owned destination so we keep reusing one address. std::string autoShieldAddress = "";