Rebrand hush3 to DragonX and share RandomX dataset across mining threads

Minimal rebrand (see compliant-rebrand branch for full rebrand):
- Rename binaries: hushd/hush-cli/hush-tx → dragonxd/dragonx-cli/dragonx-tx
- Default to DRAGONX chain params without -ac_* flags (randomx, blocktime=36, private=1)
- Update configure.ac: AC_INIT([DragonX],[1.0.0])
- Update client version string and user-agent to /DragonX:1.0.0/
- Add chainparams.cpp with DRAGONX network parameters
- Update build.sh, miner.cpp, pow.cpp for DragonX
- Add bootstrap-dragonx.sh utility script
- Update .gitignore for release directory

Share single RandomX dataset across all mining threads:
- Add RandomXDatasetManager with readers-writer lock, reducing RAM from
  ~2GB per thread to ~2GB total plus ~2MB per thread for the VM scratchpad
- Add LogProcessMemory() diagnostic helper for Linux and Windows
This commit is contained in:
2026-03-03 17:00:49 -06:00
parent d6ba1aed4e
commit 85c8d7f7dd
27 changed files with 3668 additions and 243 deletions

View File

@@ -94,11 +94,11 @@ noinst_PROGRAMS =
TESTS =
#if BUILD_BITCOIND
bin_PROGRAMS += hushd
bin_PROGRAMS += dragonxd
#endif
if BUILD_BITCOIN_UTILS
bin_PROGRAMS += hush-cli hush-tx
bin_PROGRAMS += dragonx-cli dragonx-tx
endif
if ENABLE_WALLET
bin_PROGRAMS += wallet-utility
@@ -453,16 +453,16 @@ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h
#
# hushd binary #
hushd_SOURCES = bitcoind.cpp
hushd_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
hushd_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS)
hushd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
dragonxd_SOURCES = bitcoind.cpp
dragonxd_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
dragonxd_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS)
dragonxd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if TARGET_WINDOWS
hushd_SOURCES += bitcoind-res.rc
dragonxd_SOURCES += bitcoind-res.rc
endif
hushd_LDADD = \
dragonxd_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \
$(LIBUNIVALUE) \
@@ -476,10 +476,10 @@ hushd_LDADD = \
$(LIBRANDOMX)
if ENABLE_WALLET
hushd_LDADD += $(LIBBITCOIN_WALLET)
dragonxd_LDADD += $(LIBBITCOIN_WALLET)
endif
hushd_LDADD += \
dragonxd_LDADD += \
$(BOOST_LIBS) \
$(BDB_LIBS) \
$(SSL_LIBS) \
@@ -490,27 +490,27 @@ hushd_LDADD += \
$(LIBZCASH_LIBS)
if TARGET_DARWIN
hushd_LDADD += libcc.dylib $(LIBSECP256K1)
dragonxd_LDADD += libcc.dylib $(LIBSECP256K1)
endif
if TARGET_WINDOWS
hushd_LDADD += libcc.dll $(LIBSECP256K1)
dragonxd_LDADD += libcc.dll $(LIBSECP256K1)
endif
if TARGET_LINUX
hushd_LDADD += libcc.so $(LIBSECP256K1)
dragonxd_LDADD += libcc.so $(LIBSECP256K1)
endif
# [+] Decker: use static linking for libstdc++.6.dylib, libgomp.1.dylib, libgcc_s.1.dylib
if TARGET_DARWIN
hushd_LDFLAGS += -static-libgcc
dragonxd_LDFLAGS += -static-libgcc
endif
# hush-cli binary #
hush_cli_SOURCES = bitcoin-cli.cpp
hush_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS)
hush_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
hush_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
dragonx_cli_SOURCES = bitcoin-cli.cpp
dragonx_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS)
dragonx_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
dragonx_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if TARGET_DARWIN
hush_cli_LDFLAGS += -static-libgcc
dragonx_cli_LDFLAGS += -static-libgcc
endif
# wallet-utility binary #
@@ -522,10 +522,10 @@ wallet_utility_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
endif
if TARGET_WINDOWS
hush_cli_SOURCES += bitcoin-cli-res.rc
dragonx_cli_SOURCES += bitcoin-cli-res.rc
endif
hush_cli_LDADD = \
dragonx_cli_LDADD = \
$(LIBBITCOIN_CLI) \
$(LIBUNIVALUE) \
$(LIBBITCOIN_UTIL) \
@@ -554,16 +554,16 @@ wallet_utility_LDADD = \
endif
# hush-tx binary #
hush_tx_SOURCES = hush-tx.cpp
hush_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
hush_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
hush_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
dragonx_tx_SOURCES = hush-tx.cpp
dragonx_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
dragonx_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
dragonx_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if TARGET_WINDOWS
hush_tx_SOURCES += bitcoin-tx-res.rc
dragonx_tx_SOURCES += bitcoin-tx-res.rc
endif
hush_tx_LDADD = \
dragonx_tx_LDADD = \
$(LIBUNIVALUE) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UTIL) \
@@ -574,7 +574,7 @@ hush_tx_LDADD = \
$(LIBZCASH_LIBS) \
$(LIBRANDOMX)
hush_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
dragonx_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
# Zcash Protocol Primitives
libzcash_a_SOURCES = \

View File

@@ -13,7 +13,7 @@
"ac_perc": "11111111",
"ac_eras": "3",
"ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac",
"clientname": "GoldenSandtrout",
"clientname": "DragonX",
"addnode": [
"node1.hush.is",
"node2.hush.is",

View File

@@ -29,8 +29,8 @@
#include <event2/keyvalq_struct.h>
#include "support/events.h"
uint16_t ASSETCHAINS_RPCPORT = 18031;
uint16_t BITCOIND_RPCPORT = 18031;
uint16_t ASSETCHAINS_RPCPORT = 21769;
uint16_t BITCOIND_RPCPORT = 21769;
char SMART_CHAIN_SYMBOL[65];
extern uint16_t ASSETCHAINS_RPCPORT;
@@ -47,7 +47,7 @@ std::string HelpMessageCli()
std::string strUsage;
strUsage += HelpMessageGroup(_("Options:"));
strUsage += HelpMessageOpt("-?", _("This help message"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "HUSH3.conf"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "DRAGONX.conf"));
strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory (this path cannot use '~')"));
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
strUsage += HelpMessageOpt("-regtest", _("Enter regression test mode, which uses a special chain in which blocks can be "
@@ -87,19 +87,19 @@ static int AppInitRPC(int argc, char* argv[])
ParseParameters(argc, argv);
std:string name;
// default HAC is HUSH3 itself, which to the internals, is also a HAC
name = GetArg("-ac_name","HUSH3");
// default HAC is DRAGONX itself, which to the internals, is also a HAC
name = GetArg("-ac_name","DRAGONX");
if ( !name.empty() )
strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1);
if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) {
std::string strUsage = _("Hush RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo();
std::string strUsage = _("DragonX RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo();
if (!mapArgs.count("-version")) {
strUsage += "\n" + _("Usage:") + "\n" +
" hush-cli [options] <command> [params] " + _("Send command to Hush") + "\n" +
" hush-cli [options] help " + _("List commands") + "\n" +
" hush-cli [options] help <command> " + _("Get help for a command") + "\n";
" dragonx-cli [options] <command> [params] " + _("Send command to DragonX") + "\n" +
" dragonx-cli [options] help " + _("List commands") + "\n" +
" dragonx-cli [options] help <command> " + _("Get help for a command") + "\n";
strUsage += "\n" + HelpMessageCli();
} else {

View File

@@ -117,14 +117,14 @@ bool AppInit(int argc, char* argv[])
// Process help and version before taking care about datadir
if (mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version"))
{
std::string strUsage = _("Hush Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n" + PrivacyInfo();
std::string strUsage = _("DragonX Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n" + PrivacyInfo();
if (mapArgs.count("-version"))
{
strUsage += LicenseInfo();
} else {
strUsage += "\n" + _("Usage:") + "\n" +
" hushd [options] " + _("Start a Hush Daemon") + "\n";
" dragonxd [options] " + _("Start DragonX Daemon") + "\n";
strUsage += "\n" + HelpMessage(HMM_BITCOIND);
}
@@ -167,13 +167,13 @@ bool AppInit(int argc, char* argv[])
"\n"
"You can look at the example configuration file for suggestions of default\n"
"options that you may want to change. It should be in one of these locations,\n"
"depending on how you installed Hush\n") +
"depending on how you installed DragonX\n") +
_("- Source code: %s\n"
"- .deb package: %s\n")).c_str(),
GetConfigFile().string().c_str(),
"contrib/debian/examples/HUSH3.conf",
"/usr/share/doc/hush/examples/HUSH3.conf",
"https://git.hush.is/hush/hush3/src/branch/master/contrib/debian/examples/HUSH3.conf");
"contrib/debian/examples/DRAGONX.conf",
"/usr/share/doc/dragonx/examples/DRAGONX.conf",
"https://git.dragonx.is/DragonX/dragonx/src/branch/main/contrib/debian/examples/DRAGONX.conf");
return false;
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
@@ -183,15 +183,15 @@ bool AppInit(int argc, char* argv[])
// Command-line RPC
bool fCommandLine = false;
for (int i = 1; i < argc; i++) {
// detect accidental use of RPC in hushd
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "hush:")) {
// detect accidental use of RPC in dragonxd
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "dragonx:")) {
fCommandLine = true;
}
}
if (fCommandLine)
{
fprintf(stderr, "Error: Ooops! There is no RPC client functionality in hushd. Use the hush-cli utility instead.\n");
fprintf(stderr, "Error: Ooops! There is no RPC client functionality in dragonxd. Use the dragonx-cli utility instead.\n");
exit(EXIT_FAILURE);
}
@@ -199,7 +199,7 @@ bool AppInit(int argc, char* argv[])
fDaemon = GetBoolArg("-daemon", false);
if (fDaemon)
{
fprintf(stdout, "Hush %s server starting\n",SMART_CHAIN_SYMBOL);
fprintf(stdout, "DragonX %s server starting\n",SMART_CHAIN_SYMBOL);
// Daemonize
pid_t pid = fork();

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,7 @@ class CBaseMainParams : public CBaseChainParams
public:
CBaseMainParams()
{
nRPCPort = 18031;
nRPCPort = 21769;
}
};
static CBaseMainParams mainParams;

View File

@@ -32,7 +32,7 @@
* for both bitcoind and bitcoin-core, to make it harder for attackers to
* target servers or GUI users specifically.
*/
const std::string CLIENT_NAME = GetArg("-clientname", "GoldenSandtrout");
const std::string CLIENT_NAME = GetArg("-clientname", "DragonX");
/**
* Client version number

View File

@@ -28,9 +28,9 @@
// client versioning and copyright year
//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it
// Must be kept in sync with configure.ac , ugh!
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 10
#define CLIENT_VERSION_REVISION 5
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 50
//! Set to true for release, false for prerelease or test build
@@ -40,7 +40,7 @@
* Copyright year (2009-this)
* Todo: update this when changing our copyright comments in the source
*/
#define COPYRIGHT_YEAR 2024
#define COPYRIGHT_YEAR 2026
#endif //HAVE_CONFIG_H

View File

@@ -403,7 +403,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_hei
params[0] = 0;
*hushnotarized_heightp = 0;
if ( strcmp(dest,"HUSH3") == 0 ) {
port = HUSH3_PORT;
port = DRAGONX_PORT;
userpass = HUSHUSERPASS;
} else if ( strcmp(dest,"BTC") == 0 )
{
@@ -498,7 +498,7 @@ int32_t hush_verifynotarization(char *symbol,char *dest,int32_t height,int32_t N
{
if ( SMART_CHAIN_SYMBOL[0] != 0 )
{
jsonstr = hush_issuemethod(HUSHUSERPASS,(char *)"getrawtransaction",params,HUSH3_PORT);
jsonstr = hush_issuemethod(HUSHUSERPASS,(char *)"getrawtransaction",params,DRAGONX_PORT);
//printf("userpass.(%s) got (%s)\n",HUSHUSERPASS,jsonstr);
}
}//else jsonstr = _dex_getrawtransaction();

View File

@@ -102,7 +102,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1;
int32_t ASSETCHAINS_STAKED;
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,ASSETCHAINS_FOUNDERS_REWARD;
uint32_t HUSH_INITDONE;
char HUSHUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t HUSH3_PORT = 18031,BITCOIND_RPCPORT = 18031;
char HUSHUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t DRAGONX_PORT = 21769,BITCOIND_RPCPORT = 21769;
uint64_t PENDING_HUSH_TX;
extern int32_t HUSH_LOADINGBLOCKS;
unsigned int MAX_BLOCK_SIGOPS = 20000;

View File

@@ -1413,20 +1413,20 @@ void hush_configfile(char *symbol,uint16_t rpcport)
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
strcat(fname,"HUSH3.conf");
strcat(fname,"DRAGONX.conf");
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;
#ifdef __APPLE__
strcat(fname,"HUSH3.conf");
strcat(fname,"DRAGONX.conf");
#else
strcat(fname,"HUSH3.conf");
strcat(fname,"DRAGONX.conf");
#endif
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
if ( (hushport= _hush_userpass(username,password,fp)) != 0 )
HUSH3_PORT = hushport;
DRAGONX_PORT = hushport;
sprintf(HUSHUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("HUSH.(%s) -> userpass.(%s)\n",fname,HUSHUSERPASS);
@@ -1790,38 +1790,28 @@ void hush_args(char *argv0)
}
name = GetArg("-ac_name","HUSH3");
name = GetArg("-ac_name","DRAGONX");
fprintf(stderr,".oO Starting %s Full Node (Extreme Privacy!) with genproc=%d notary=%d\n",name.c_str(),HUSH_MININGTHREADS, IS_HUSH_NOTARY);
vector<string> HUSH_nodes = {};
// Only HUSH3 uses these by default, other HACs must opt-in via -connect/-addnode
const bool ishush3 = strncmp(name.c_str(), "HUSH3",5) == 0 ? true : false;
vector<string> DRAGONX_nodes = {};
// Only DRAGONX connects to these by default, other chains must opt-in via -connect/-addnode
const bool isdragonx = strncmp(name.c_str(), "DRAGONX",7) == 0 ? true : false;
LogPrint("net", "%s: ishush3=%d\n", __func__, ishush3);
if (ishush3) {
HUSH_nodes = {"node1.hush.is","node2.hush.is","node3.hush.is",
"node4.hush.is","node5.hush.is","node6.hush.is",
"node7.hush.is","node8.hush.is",
"178.250.189.141",
"31.202.19.157",
"45.132.75.69",
"45.63.58.167",
"b2dln7mw7ydnuopls444tuixujhcw5kn5o22cna6gqfmw2fl6drb5nad.onion",
"dslbaa5gut5kapqtd44pbg65tpl5ydsamfy62hjbldhfsvk64qs57pyd.onion",
"vsqdumnh5khjbrzlxoeucbkiuaictdzyc3ezjpxpp2ph3gfwo2ptjmyd.onion",
"plrobkepqjxs2cmig273mxnqh3qhuhdaioyb2n5kafn264ramb7tqxid.onion"
LogPrint("net", "%s: isdragonx=%d\n", __func__, isdragonx);
if (isdragonx) {
DRAGONX_nodes = {"node1.dragonx.is","node2.dragonx.is","node3.dragonx.is",
"node4.dragonx.is","node5.dragonx.is"
};
}
vector<string> more_nodes = mapMultiArgs["-addnode"];
if (more_nodes.size() > 0) {
fprintf(stderr,"%s: Adding %lu more nodes via custom -addnode arguments\n", __func__, more_nodes.size() );
}
// Add default HUSH nodes after custom addnodes, if applicable
if(HUSH_nodes.size() > 0) {
LogPrint("net", "%s: adding %d HUSH3 hostname-based nodes\n", __func__, HUSH_nodes.size() );
more_nodes.insert( more_nodes.end(), HUSH_nodes.begin(), HUSH_nodes.end() );
// Add default DRAGONX nodes after custom addnodes, if applicable
if(DRAGONX_nodes.size() > 0) {
LogPrint("net", "%s: adding %d DRAGONX hostname-based nodes\n", __func__, DRAGONX_nodes.size() );
more_nodes.insert( more_nodes.end(), DRAGONX_nodes.begin(), DRAGONX_nodes.end() );
}
mapMultiArgs["-addnode"] = more_nodes;
@@ -1830,10 +1820,15 @@ void hush_args(char *argv0)
WITNESS_CACHE_SIZE = MAX_REORG_LENGTH+10;
ASSETCHAINS_CC = GetArg("-ac_cc",0);
HUSH_CCACTIVATE = GetArg("-ac_ccactivate",0);
ASSETCHAINS_BLOCKTIME = GetArg("-ac_blocktime",60);
// We do not support ac_public=1 chains, Hush is a platform for privacy
// Set defaults based on chain
int default_blocktime = isdragonx ? 36 : 60;
int default_private = isdragonx ? 1 : 0;
ASSETCHAINS_BLOCKTIME = GetArg("-ac_blocktime", default_blocktime);
// We do not support ac_public=1 chains, DragonX is a platform for privacy
ASSETCHAINS_PUBLIC = 0;
ASSETCHAINS_PRIVATE = GetArg("-ac_private",0);
ASSETCHAINS_PRIVATE = GetArg("-ac_private", default_private);
HUSH_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0);
Split(GetArg("-ac_nk",""), sizeof(ASSETCHAINS_NK)/sizeof(*ASSETCHAINS_NK), ASSETCHAINS_NK, 0);
@@ -1871,7 +1866,9 @@ void hush_args(char *argv0)
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
if ( name.c_str()[0] != 0 )
{
std::string selectedAlgo = GetArg("-ac_algo", std::string(ASSETCHAINS_ALGORITHMS[0]));
// Default algo is randomx for DRAGONX, equihash for others
std::string default_algo = isdragonx ? "randomx" : std::string(ASSETCHAINS_ALGORITHMS[0]);
std::string selectedAlgo = GetArg("-ac_algo", default_algo);
for ( int i = 0; i < ASSETCHAINS_NUMALGOS; i++ )
{
@@ -1900,7 +1897,6 @@ void hush_args(char *argv0)
// Set our symbol from -ac_name value
strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1);
const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
// Set RandomX validation activation height per chain
if (ASSETCHAINS_ALGO == ASSETCHAINS_RANDOMX) {
@@ -1915,9 +1911,6 @@ void hush_args(char *argv0)
}
ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1);
if(ishush3) {
ASSETCHAINS_LASTERA = 3;
}
if ( ASSETCHAINS_LASTERA < 1 || ASSETCHAINS_LASTERA > ASSETCHAINS_MAX_ERAS )
{
ASSETCHAINS_LASTERA = 1;
@@ -1951,33 +1944,13 @@ void hush_args(char *argv0)
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
fprintf(stderr,"%s: Setting custom %s reward HUSH3=%d reward,halving,subsidy chain values...\n",__func__, SMART_CHAIN_SYMBOL, ishush3);
if(ishush3) {
// Migrated from hushd script
ASSETCHAINS_CC = 2;
ASSETCHAINS_BLOCKTIME = 150; // this will change to 75 at the correct block
ASSETCHAINS_COMMISSION = 11111111;
// 6250000 - (Sprout pool at block 500,000)
ASSETCHAINS_SUPPLY = 6178674;
ASSETCHAINS_FOUNDERS = 1;
fprintf(stderr,"%s: Setting custom %s reward isdragonx=%d reward,halving,subsidy chain values...\n",__func__, SMART_CHAIN_SYMBOL, isdragonx);
if(isdragonx) {
// DragonX chain parameters (previously set via wrapper script)
// -ac_name=DRAGONX -ac_algo=randomx -ac_halving=3500000 -ac_reward=300000000 -ac_blocktime=36 -ac_private=1
ASSETCHAINS_SAPLING = 1;
// this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn
ASSETCHAINS_SCRIPTPUB = "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac";
// we do not want to change the magic of HUSH3 mainnet so we do not call devtax_scriptpub_for_height() here,
// instead we call it whenever ASSETCHAINS_SCRIPTPUB is used later on
// Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things
ASSETCHAINS_REWARD[0] = 0;
ASSETCHAINS_REWARD[1] = 1125000000;
ASSETCHAINS_REWARD[2] = 281250000; // 2.8125 HUSH goes to miners per block after 1st halving at Block 340K
ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000
ASSETCHAINS_HALVING[0] = 129;
ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000);
ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (1st halving block plus new halving interval)
ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000;
ASSETCHAINS_ENDSUBSIDY[0] = 129;
ASSETCHAINS_ENDSUBSIDY[1] = GetArg("-z2zheight",340000);
ASSETCHAINS_ENDSUBSIDY[2] = 2*5422111; // TODO: Fix this, twice the previous end of rewards is an estimate
ASSETCHAINS_REWARD[0] = 300000000; // 3 DRAGONX per block
ASSETCHAINS_HALVING[0] = 3500000; // halving every 3.5M blocks
}
Split(GetArg("-ac_decay",""), sizeof(ASSETCHAINS_DECAY)/sizeof(*ASSETCHAINS_DECAY), ASSETCHAINS_DECAY, 0);
Split(GetArg("-ac_notarypay",""), sizeof(ASSETCHAINS_NOTARY_PAY)/sizeof(*ASSETCHAINS_NOTARY_PAY), ASSETCHAINS_NOTARY_PAY, 0);
@@ -2492,11 +2465,11 @@ void hush_args(char *argv0)
void hush_nameset(char *symbol,char *dest,char *source)
{
if ( source[0] == 0 ) {
strcpy(symbol,(char *)"HUSH3");
strcpy(symbol,(char *)"DRAGONX");
strcpy(dest,(char *)"BTC");
} else {
strcpy(symbol,source);
strcpy(dest,(char *)"HUSH3");
strcpy(dest,(char *)"DRAGONX");
}
}

View File

@@ -377,8 +377,8 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288));
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3));
strUsage += HelpMessageOpt("-clientname=<SomeName>", _("Full node client name, default 'GoldenSandtrout'"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "HUSH3.conf"));
strUsage += HelpMessageOpt("-clientname=<SomeName>", _("Full node client name, default 'DragonX'"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "DRAGONX.conf"));
if (mode == HMM_BITCOIND)
{
#if !defined(WIN32)
@@ -605,7 +605,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-stratumallowip=<ip>", _("Allow Stratum work requests from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times"));
// "ac" stands for "affects consensus" or Arrakis Chain
strUsage += HelpMessageGroup(_("Hush Arrakis Chain options:"));
strUsage += HelpMessageGroup(_("DragonX Chain options:"));
strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, either 'equihash' or 'randomx'. default is Equihash (200,9)"));
strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60"));
strUsage += HelpMessageOpt("-ac_beam", _("BEAM integration"));
@@ -1619,7 +1619,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt));
uacomments.push_back(SanitizeString(cmt, SAFE_CHARS_UA_COMMENT));
}
strSubVersion = FormatSubVersion(GetArg("-clientname","GoldenSandtrout"), CLIENT_VERSION, uacomments);
strSubVersion = FormatSubVersion(GetArg("-clientname","DragonX"), CLIENT_VERSION, uacomments);
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.",
strSubVersion.size(), MAX_SUBVERSION_LENGTH));

View File

@@ -289,7 +289,7 @@ int printMiningStatus(bool mining)
lines++;
} else {
std::cout << _("You are currently not mining.") << std::endl;
std::cout << _("To enable mining, add 'gen=1' to your HUSH3.conf and restart.") << std::endl;
std::cout << _("To enable mining, add 'gen=1' to your DRAGONX.conf and restart.") << std::endl;
lines += 2;
}
std::cout << std::endl;

View File

@@ -23,6 +23,7 @@
#include "pow/tromp/equi_miner.h"
#endif
#include <atomic>
#include "amount.h"
#include "chainparams.h"
#include "consensus/consensus.h"
@@ -51,6 +52,7 @@
#include "transaction_builder.h"
#include "sodium.h"
#include <boost/thread.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/tuple/tuple.hpp>
#ifdef ENABLE_MINING
#include <functional>
@@ -1011,8 +1013,213 @@ enum RandomXSolverCancelCheck
Reason2
};
int GetRandomXInterval() { return GetArg("-ac_randomx_interval",1024); }
int GetRandomXBlockLag() { return GetArg("-ac_randomx_lag", 64); }
int GetRandomXInterval();
int GetRandomXBlockLag();
#ifdef _WIN32
#include <windows.h>
static void LogProcessMemory(const char* label) {
// Use K32GetProcessMemoryInfo from kernel32.dll (available on Win7+)
// to avoid linking psapi.lib
typedef struct {
DWORD cb;
DWORD PageFaultCount;
SIZE_T PeakWorkingSetSize;
SIZE_T WorkingSetSize;
SIZE_T QuotaPeakPagedPoolUsage;
SIZE_T QuotaPagedPoolUsage;
SIZE_T QuotaPeakNonPagedPoolUsage;
SIZE_T QuotaNonPagedPoolUsage;
SIZE_T PagefileUsage;
SIZE_T PeakPagefileUsage;
SIZE_T PrivateUsage;
} PMC_EX;
typedef BOOL (WINAPI *PFN)(HANDLE, PMC_EX*, DWORD);
static PFN pfn = (PFN)GetProcAddress(GetModuleHandleA("kernel32.dll"), "K32GetProcessMemoryInfo");
if (pfn) {
PMC_EX pmc = {};
pmc.cb = sizeof(pmc);
if (pfn(GetCurrentProcess(), &pmc, sizeof(pmc))) {
LogPrintf("MemDiag [%s]: WorkingSet=%.1fMB, PrivateUsage=%.1fMB, PagefileUsage=%.1fMB\n",
label,
pmc.WorkingSetSize / (1024.0 * 1024.0),
pmc.PrivateUsage / (1024.0 * 1024.0),
pmc.PagefileUsage / (1024.0 * 1024.0));
}
}
}
#else
static void LogProcessMemory(const char* label) {
// Linux: read /proc/self/status
FILE *f = fopen("/proc/self/status", "r");
if (f) {
char line[256];
while (fgets(line, sizeof(line), f)) {
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);
}
}
fclose(f);
}
}
#endif
// Shared RandomX dataset manager — all miner threads share a single ~2GB dataset
// instead of each allocating their own. The dataset is read-only after initialization
// and RandomX explicitly supports multiple VMs sharing one dataset.
struct RandomXDatasetManager {
randomx_flags flags;
randomx_cache *cache;
randomx_dataset *dataset;
unsigned long datasetItemCount;
std::string currentKey;
std::mutex mtx; // protects Init/Shutdown/CreateVM
boost::shared_mutex datasetMtx; // readers-writer lock: shared for hashing, exclusive for rebuild
bool initialized;
RandomXDatasetManager() : flags(randomx_get_flags()), cache(nullptr), dataset(nullptr),
datasetItemCount(0), initialized(false) {}
bool Init() {
std::lock_guard<std::mutex> lock(mtx);
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",
(int)flags,
!!(flags & RANDOMX_FLAG_JIT), !!(flags & RANDOMX_FLAG_HARD_AES),
!!(flags & RANDOMX_FLAG_FULL_MEM), !!(flags & RANDOMX_FLAG_LARGE_PAGES));
LogProcessMemory("before cache alloc");
cache = randomx_alloc_cache(flags | RANDOMX_FLAG_LARGE_PAGES | RANDOMX_FLAG_SECURE);
if (cache == nullptr) {
LogPrintf("RandomXDatasetManager: cache alloc failed with large pages, trying without...\n");
cache = randomx_alloc_cache(flags | RANDOMX_FLAG_SECURE);
if (cache == nullptr) {
LogPrintf("RandomXDatasetManager: cache alloc failed with secure, trying basic...\n");
cache = randomx_alloc_cache(flags);
if (cache == nullptr) {
LogPrintf("RandomXDatasetManager: cannot allocate cache!\n");
return false;
}
}
}
LogProcessMemory("after cache alloc");
// Try to allocate dataset with large pages first for better performance
dataset = randomx_alloc_dataset(flags | RANDOMX_FLAG_LARGE_PAGES);
if (dataset == nullptr) {
LogPrintf("RandomXDatasetManager: dataset alloc failed with large pages, trying without...\n");
dataset = randomx_alloc_dataset(flags);
if (dataset == nullptr) {
LogPrintf("RandomXDatasetManager: cannot allocate dataset!\n");
randomx_release_cache(cache);
cache = nullptr;
return false;
}
}
datasetItemCount = randomx_dataset_item_count();
initialized = true;
LogProcessMemory("after dataset alloc");
// 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));
return true;
}
// Initialize cache with a key and rebuild the dataset.
// Thread-safe: acquires exclusive lock so all hashing threads must finish first.
void UpdateKey(const void *key, size_t keySize) {
std::string newKey((const char*)key, keySize);
// Fast check with shared lock — skip if key hasn't changed
{
boost::shared_lock<boost::shared_mutex> readLock(datasetMtx);
if (newKey == currentKey) return; // already up to date
}
// Acquire exclusive lock — blocks until all hashing threads release their shared locks
boost::unique_lock<boost::shared_mutex> writeLock(datasetMtx);
// Double-check after acquiring exclusive lock (another thread may have rebuilt first)
if (newKey == currentKey) return;
LogPrintf("RandomXDatasetManager: updating key (size=%lu)\n", keySize);
randomx_init_cache(cache, key, keySize);
currentKey = newKey;
// Rebuild dataset using all available CPU threads
const int initThreadCount = std::thread::hardware_concurrency();
if (initThreadCount > 1) {
std::vector<std::thread> threads;
uint32_t startItem = 0;
const auto perThread = datasetItemCount / initThreadCount;
const auto remainder = datasetItemCount % initThreadCount;
for (int i = 0; i < initThreadCount; ++i) {
const auto count = perThread + (i == initThreadCount - 1 ? remainder : 0);
threads.push_back(std::thread(&randomx_init_dataset, dataset, cache, startItem, count));
startItem += count;
}
for (unsigned i = 0; i < threads.size(); ++i) {
threads[i].join();
}
} else {
randomx_init_dataset(dataset, cache, 0, datasetItemCount);
}
LogPrintf("RandomXDatasetManager: dataset rebuilt\n");
LogProcessMemory("after dataset init");
}
// Creates a per-thread VM using the shared dataset.
// Caller must hold a shared lock on datasetMtx.
// The VM itself is small (~2MB scratchpad + ~84KB JIT code) — the ~2GB dataset is shared via pointer.
// VMs should be created ONCE per thread and reused across blocks to avoid
// heap fragmentation on Windows (repeated 2MB alloc/free causes address-space bloat).
randomx_vm *CreateVM() {
static std::atomic<int> vmCount{0};
LogProcessMemory("before CreateVM");
randomx_vm *vm = randomx_create_vm(flags, nullptr, dataset);
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",
id, (void*)vm, (void*)datasetMemory);
LogPrintf(" Per-thread overhead: ~2MB scratchpad + ~84KB JIT (dataset NOT copied)\n");
LogProcessMemory("after CreateVM");
}
return vm;
}
void Shutdown() {
std::lock_guard<std::mutex> lock(mtx);
if (dataset != nullptr) {
randomx_release_dataset(dataset);
dataset = nullptr;
}
if (cache != nullptr) {
randomx_release_cache(cache);
cache = nullptr;
}
initialized = false;
currentKey.clear();
LogPrintf("RandomXDatasetManager: shutdown complete\n");
}
~RandomXDatasetManager() {
Shutdown();
}
};
// Global shared dataset manager, created by GenerateBitcoins before spawning miner threads
static RandomXDatasetManager *g_rxDatasetManager = nullptr;
#ifdef ENABLE_WALLET
void static RandomXMiner(CWallet *pwallet)
@@ -1050,33 +1257,12 @@ void static RandomXMiner()
);
miningTimer.start();
randomx_flags flags = randomx_get_flags();
flags |= RANDOMX_FLAG_FULL_MEM;
randomx_cache *randomxCache = randomx_alloc_cache(flags | RANDOMX_FLAG_LARGE_PAGES | RANDOMX_FLAG_SECURE );
if (randomxCache == NULL) {
LogPrintf("RandomX cache is null, trying without large pages...\n");
randomxCache = randomx_alloc_cache(flags | RANDOMX_FLAG_SECURE);
if (randomxCache == NULL) {
LogPrintf("RandomX cache is null, trying without secure...\n");
}
randomxCache = randomx_alloc_cache(flags);
if (randomxCache == NULL) {
LogPrintf("RandomX cache is null, cannot mine!\n");
}
}
rxdebug("%s: created randomx flags + cache\n");
randomx_dataset *randomxDataset = randomx_alloc_dataset(flags);
rxdebug("%s: created dataset\n");
if( randomxDataset == nullptr) {
LogPrintf("%s: allocating randomx dataset failed!\n", __func__);
// Use the shared dataset manager — no per-thread dataset allocation
if (g_rxDatasetManager == nullptr || !g_rxDatasetManager->initialized) {
LogPrintf("HushRandomXMiner: shared dataset manager not initialized, aborting!\n");
return;
}
auto datasetItemCount = randomx_dataset_item_count();
rxdebug("%s: dataset items=%lu\n", datasetItemCount);
char randomxHash[RANDOMX_HASH_SIZE];
rxdebug("%s: created randomxHash of size %d\n", RANDOMX_HASH_SIZE);
char randomxKey[82]; // randomx spec says keysize of >60 bytes is implementation-specific
@@ -1147,48 +1333,37 @@ void static RandomXMiner()
// fprintf(stderr,"RandomXMiner: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag);
rxdebug("%s: using initial key, interval=%d, lag=%d, Mining_height=%u\n", randomxInterval, randomxBlockLag, Mining_height);
// Use the initial key at the start of the chain, until the first key block
// Update the shared dataset key — only one thread will actually rebuild,
// others will see the key is already current and skip.
if( (Mining_height) < randomxInterval + randomxBlockLag) {
randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey);
rxdebug("%s: initialized cache with initial key\n");
g_rxDatasetManager->UpdateKey(randomxKey, strlen(randomxKey));
rxdebug("%s: updated shared dataset with initial key\n");
} else {
rxdebug("%s: calculating keyHeight with randomxInterval=%d\n", randomxInterval);
// At heights between intervals, we use the same block key and wait randomxBlockLag blocks until changing
const int keyHeight = ((Mining_height - randomxBlockLag) / randomxInterval) * randomxInterval;
uint256 randomxBlockKey = chainActive[keyHeight]->GetBlockHash();
randomx_init_cache(randomxCache, &randomxBlockKey, sizeof randomxBlockKey);
rxdebug("%s: initialized cache with keyHeight=%d, randomxBlockKey=%s\n", keyHeight, randomxBlockKey.ToString().c_str());
g_rxDatasetManager->UpdateKey(&randomxBlockKey, sizeof randomxBlockKey);
rxdebug("%s: updated shared dataset with keyHeight=%d, randomxBlockKey=%s\n", keyHeight, randomxBlockKey.ToString().c_str());
}
const int initThreadCount = std::thread::hardware_concurrency();
if(initThreadCount > 1) {
rxdebug("%s: initializing dataset with %d threads\n", initThreadCount);
std::vector<std::thread> threads;
uint32_t startItem = 0;
const auto perThread = datasetItemCount / initThreadCount;
const auto remainder = datasetItemCount % initThreadCount;
for (int i = 0; i < initThreadCount; ++i) {
const auto count = perThread + (i == initThreadCount - 1 ? remainder : 0);
threads.push_back(std::thread(&randomx_init_dataset, randomxDataset, randomxCache, startItem, count));
startItem += count;
// Create a per-thread VM once and reuse across blocks.
// The VM just stores a pointer to the shared dataset — the pointer
// remains valid across key changes since UpdateKey rebuilds the dataset
// contents in-place without reallocating. Reusing the VM avoids
// repeated 2MB scratchpad + 84KB JIT alloc/free churn that causes
// Windows heap fragmentation and apparent memory growth per thread.
if (myVM == nullptr) {
// First iteration: acquire shared lock briefly to create VM
boost::shared_lock<boost::shared_mutex> initLock(g_rxDatasetManager->datasetMtx);
myVM = g_rxDatasetManager->CreateVM();
if (myVM == nullptr) {
LogPrintf("RandomXMiner: Cannot create RandomX VM, aborting!\n");
return;
}
for (unsigned i = 0; i < threads.size(); ++i) {
threads[i].join();
}
threads.clear();
} else {
rxdebug("%s: initializing dataset with 1 thread\n");
randomx_init_dataset(randomxDataset, randomxCache, 0, datasetItemCount);
}
rxdebug("%s: dataset initialized\n");
myVM = randomx_create_vm(flags, nullptr, randomxDataset);
if(myVM == NULL) {
LogPrintf("RandomXMiner: Cannot create RandomX VM, aborting!\n");
return;
}
// Acquire shared lock to prevent dataset rebuild while we're hashing
boost::shared_lock<boost::shared_mutex> datasetLock(g_rxDatasetManager->datasetMtx);
//fprintf(stderr,"RandomXMiner: Mining_start=%u\n", Mining_start);
#ifdef ENABLE_WALLET
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0);
@@ -1268,16 +1443,17 @@ void static RandomXMiner()
arith_uint256 hashTarget;
hashTarget = HASHTarget;
CRandomXInput rxInput(pblocktemplate->block);
CDataStream randomxInput(SER_NETWORK, PROTOCOL_VERSION);
// Use the current block as randomx input
randomxInput << pblocktemplate->block;
// Serialize block header without nSolution but with nNonce for deterministic RandomX input
randomxInput << rxInput;
// std::cerr << "RandomXMiner: randomxInput=" << HexStr(randomxInput) << "\n";
// fprintf(stderr,"RandomXMiner: created randomxKey=%s , randomxInput.size=%lu\n", randomxKey, randomxInput.size() ); //randomxInput);
rxdebug("%s: randomxKey=%s randomxInput=%s\n", randomxKey, HexStr(randomxInput).c_str());
rxdebug("%s: calculating randomx hash\n");
randomx_calculate_hash(myVM, &randomxInput, sizeof randomxInput, randomxHash);
randomx_calculate_hash(myVM, &randomxInput[0], randomxInput.size(), randomxHash);
rxdebug("%s: calculated randomx hash\n");
rxdebug("%s: randomxHash=");
@@ -1324,14 +1500,28 @@ void static RandomXMiner()
CValidationState state;
//{ LOCK(cs_main);
if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false))
// Skip RandomX re-validation during TestBlockValidity — we already
// computed the correct hash, and re-verifying allocates ~256MB which
// can trigger the OOM killer on memory-constrained systems.
SetSkipRandomXValidation(true);
bool fValid = TestBlockValidity(state,B, chainActive.LastTip(), true, false);
SetSkipRandomXValidation(false);
if ( !fValid )
{
h = UintToArith256(B.GetHash());
fprintf(stderr,"RandomXMiner: Invalid randomx block mined, try again ");
fprintf(stderr,"RandomXMiner: TestBlockValidity FAILED at ht.%d nNonce=%s hash=",
Mining_height, pblock->nNonce.ToString().c_str());
for (z=31; z>=0; z--)
fprintf(stderr,"%02x",((uint8_t *)&h)[z]);
gotinvalid = 1;
fprintf(stderr," nSolution.size=%lu\n", B.nSolution.size());
// Dump nSolution hex for comparison with validator
fprintf(stderr,"RandomXMiner: nSolution=");
for (unsigned i = 0; i < B.nSolution.size(); i++)
fprintf(stderr,"%02x", B.nSolution[i]);
fprintf(stderr,"\n");
LogPrintf("RandomXMiner: TestBlockValidity FAILED at ht.%d, gotinvalid=1, state=%s\n",
Mining_height, state.GetRejectReason());
gotinvalid = 1;
return(false);
}
//}
@@ -1399,21 +1589,24 @@ void static RandomXMiner()
pblock->nBits = savebits;
}
rxdebug("%s: going to destroy rx VM\n");
randomx_destroy_vm(myVM);
rxdebug("%s: destroyed VM\n");
// Release shared lock so UpdateKey can acquire exclusive lock for dataset rebuild
// VM is kept alive — its dataset pointer remains valid across rebuilds
datasetLock.unlock();
}
} catch (const boost::thread_interrupted&) {
miningTimer.stop();
c.disconnect();
randomx_destroy_vm(myVM);
LogPrintf("%s: destroyed vm via thread interrupt\n", __func__);
randomx_release_dataset(randomxDataset);
rxdebug("%s: released dataset via thread interrupt\n");
randomx_release_cache(randomxCache);
rxdebug("%s: released cache via thread interrupt\n");
if (myVM != nullptr) {
randomx_destroy_vm(myVM);
myVM = nullptr;
LogPrintf("%s: destroyed vm via thread interrupt\n", __func__);
} else {
LogPrintf("%s: WARNING myVM already null in thread interrupt handler, skipping destroy (would double-free)\n", __func__);
fprintf(stderr, "%s: WARNING myVM already null in thread interrupt, would have double-freed!\n", __func__);
}
// Dataset and cache are owned by g_rxDatasetManager — do NOT release here
LogPrintf("HushRandomXMiner terminated\n");
throw;
@@ -1422,20 +1615,21 @@ void static RandomXMiner()
c.disconnect();
fprintf(stderr,"RandomXMiner: runtime error: %s\n", e.what());
randomx_destroy_vm(myVM);
LogPrintf("%s: destroyed vm because of error\n", __func__);
randomx_release_dataset(randomxDataset);
rxdebug("%s: released dataset because of error\n");
randomx_release_cache(randomxCache);
rxdebug("%s: released cache because of error\n");
if (myVM != nullptr) {
randomx_destroy_vm(myVM);
myVM = nullptr;
LogPrintf("%s: destroyed vm because of error\n", __func__);
}
// Dataset and cache are owned by g_rxDatasetManager — do NOT release here
return;
}
randomx_release_dataset(randomxDataset);
rxdebug("%s: released dataset in normal exit\n");
randomx_release_cache(randomxCache);
rxdebug("%s: released cache in normal exit\n");
// Only destroy per-thread VM, dataset/cache are shared
if (myVM != nullptr) {
randomx_destroy_vm(myVM);
myVM = nullptr;
}
miningTimer.stop();
c.disconnect();
}
@@ -1879,8 +2073,18 @@ void static BitcoinMiner()
if (minerThreads != NULL)
{
minerThreads->interrupt_all();
// Wait for all miner threads to fully terminate before destroying shared resources
minerThreads->join_all();
delete minerThreads;
minerThreads = NULL;
// Shutdown shared RandomX dataset manager after all threads are done
if (g_rxDatasetManager != nullptr) {
g_rxDatasetManager->Shutdown();
delete g_rxDatasetManager;
g_rxDatasetManager = nullptr;
LogPrintf("%s: destroyed shared RandomX dataset manager\n", __func__);
}
}
if(fDebug)
@@ -1895,6 +2099,21 @@ void static BitcoinMiner()
minerThreads = new boost::thread_group();
// Initialize shared RandomX dataset manager before spawning miner threads
if (ASSETCHAINS_ALGO == ASSETCHAINS_RANDOMX) {
g_rxDatasetManager = new RandomXDatasetManager();
if (!g_rxDatasetManager->Init()) {
LogPrintf("%s: FATAL - Failed to initialize shared RandomX dataset manager\n", __func__);
fprintf(stderr, "%s: FATAL - Failed to initialize shared RandomX dataset manager\n", __func__);
delete g_rxDatasetManager;
g_rxDatasetManager = nullptr;
delete minerThreads;
minerThreads = NULL;
return;
}
LogPrintf("%s: shared RandomX dataset manager initialized\n", __func__);
}
for (int i = 0; i < nThreads; i++) {
#ifdef ENABLE_WALLET
if ( ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) {

View File

@@ -339,6 +339,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
memset(zflags,0,sizeof(zflags));
if ( pindexLast != 0 )
height = (int32_t)pindexLast->GetHeight() + 1;
if ( ASSETCHAINS_ADAPTIVEPOW > 0 && pindexFirst != 0 && pblock != 0 && height >= (int32_t)(sizeof(ct)/sizeof(*ct)) )
{
tipdiff = (pblock->nTime - pindexFirst->nTime);
@@ -685,7 +686,10 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
return true;
}
// Static objects for CheckRandomXSolution
int GetRandomXInterval() { return GetArg("-ac_randomx_interval", 1024); }
int GetRandomXBlockLag() { return GetArg("-ac_randomx_lag", 64); }
// Cached RandomX validation state — reused across calls, protected by mutex
static std::mutex cs_randomx_validator;
static randomx_cache *s_rxCache = nullptr;
static randomx_vm *s_rxVM = nullptr;
@@ -862,6 +866,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
if ( HUSH_LOADINGBLOCKS != 0 )
return true;
/*
if ( SMART_CHAIN_SYMBOL[0] != 0 || height > 792000 )
{
if ( Params().NetworkIDString() != "regtest" )
@@ -881,6 +886,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
}
return false;
}
*/
}
/*for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);

View File

@@ -169,7 +169,7 @@ UniValue getgenerate(const UniValue& params, bool fHelp, const CPubKey& mypk)
throw runtime_error(
"getgenerate\n"
"\nReturn if the server is set to mine coins or not. The default is false.\n"
"It is set with the command line argument -gen (or HUSH3.conf setting gen).\n"
"It is set with the command line argument -gen (or DRAGONX.conf setting gen).\n"
"It can also be set with the setgenerate call.\n"
"\nResult\n"
"{\n"

View File

@@ -133,7 +133,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
" \"pingtime\": n, (numeric) ping time\n"
" \"pingwait\": n, (numeric) ping wait\n"
" \"version\": v, (numeric) The peer version, such as 170002\n"
" \"subver\": \"/GoldenSandtrout:x.y.z[-v]/\", (string) The string version\n"
" \"subver\": \"/DragonX:x.y.z[-v]/\", (string) The string version\n"
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
" \"banscore\": n, (numeric) The ban score\n"
@@ -505,7 +505,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
"\nResult:\n"
"{\n"
" \"version\": xxxxx, (numeric) the server version\n"
" \"subversion\": \"/GoldenSandtrout:x.y.z[-v]/\", (string) the server subversion string\n"
" \"subversion\": \"/DragonX:x.y.z[-v]/\", (string) the server subversion string\n"
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
" \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
" \"timeoffset\": xxxxx, (numeric) the time offset (deprecated, always 0)\n"

View File

@@ -14,7 +14,7 @@
"ac_perc": "11111111",
"ac_eras": "3",
"ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac",
"clientname": "GoldenSandtrout",
"clientname": "DragonX",
"addnode": [
"1.1.1.1"
]

View File

@@ -710,7 +710,7 @@ boost::filesystem::path GetConfigFile()
if ( SMART_CHAIN_SYMBOL[0] != 0 ) {
sprintf(confname,"%s.conf",SMART_CHAIN_SYMBOL);
} else {
strcpy(confname,"HUSH3.conf");
strcpy(confname,"DRAGONX.conf");
}
boost::filesystem::path pathConfigFile(GetArg("-conf",confname));
if (!pathConfigFile.is_complete())
@@ -731,7 +731,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
{
// Don't overwrite existing settings so command line settings override HUSH3.conf
// Don't overwrite existing settings so command line settings override DRAGONX.conf
string strKey = string("-") + it->string_key;
if (mapSettingsRet.count(strKey) == 0)
{
@@ -1029,14 +1029,16 @@ void SetThreadPriority(int nPriority)
std::string PrivacyInfo()
{
return "\n" +
FormatParagraph(strprintf(_("In order to ensure you are adequately protecting your privacy when using Hush, please see <%s>."),
"https://hush.is/security/")) + "\n";
FormatParagraph(strprintf(_("In order to ensure you are adequately protecting your privacy when using DragonX, please see <%s>."),
"https://dragonx.is/security/")) + "\n";
}
std::string LicenseInfo()
{
return "\n" +
FormatParagraph(strprintf(_("Copyright (C) 2016-%i Duke Leto and The Hush Developers"), COPYRIGHT_YEAR)) + "\n" +
FormatParagraph(strprintf(_("Copyright (C) 2024-%i The DragonX Developers"), COPYRIGHT_YEAR)) + "\n" +
"\n" +
FormatParagraph(strprintf(_("Copyright (C) 2016-2024 Duke Leto and The Hush Developers"))) + "\n" +
"\n" +
FormatParagraph(strprintf(_("Copyright (C) 2016-2020 jl777 and SuperNET developers"))) + "\n" +
"\n" +

View File

@@ -21,7 +21,8 @@
#define HUSH_VERSION_H
// network protocol versioning
static const int PROTOCOL_VERSION = 1987429;
// DragonX 1.0.0 - bumped to separate from old HUSH/DragonX nodes with RandomX bug
static const int PROTOCOL_VERSION = 2000000;
//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
//! In this version, 'getheaders' was introduced.
@@ -30,8 +31,9 @@ static const int GETHEADERS_VERSION = 31800;
//! disconnect from peers older than this proto version (HUSH mainnet)
static const int MIN_HUSH_PEER_PROTO_VERSION = 1987426;
//! disconnect from peers older than this proto version (HACs)
static const int MIN_PEER_PROTO_VERSION = 1987420;
//! disconnect from peers older than this proto version (DragonX/HACs)
//! Set to 2000000 to reject nodes without RandomX validation fix
static const int MIN_PEER_PROTO_VERSION = 2000000;
//! nTime field added to CAddress, starting with this version;
//! if possible, avoid requesting addresses nodes older than this

View File

@@ -13,7 +13,7 @@
char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
int64_t MAX_MONEY = 200000000 * 100000000LL;
uint64_t ASSETCHAINS_SUPPLY;
uint16_t BITCOIND_RPCPORT = 18031;
uint16_t BITCOIND_RPCPORT = 21769;
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
uint32_t ASSETCHAINS_MAGIC = 2387029918;