From 323d2134a1fcc119a4da82f9fc37e912b67e58c6 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 7 Jan 2024 23:25:35 -0500 Subject: [PATCH 1/9] Boost download has been broken for over a week, so we will host our own --- depends/packages/boost.mk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 0062c0bdb..5b4804e14 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,9 +1,12 @@ package=boost $(package)_version=1_72_0 -$(package)_download_path=https://boostorg.jfrog.io/artifactory/main/release/$(subst _,.,$($(package)_version))/source/ +#$(package)_download_path=https://boostorg.jfrog.io/artifactory/main/release/$(subst _,.,$($(package)_version))/source/ +#$(package)_file_name=$(package)_$($(package)_version).tar.bz2 $(package)_sha256_hash=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722 -$(package)_file_name=$(package)_$($(package)_version).tar.bz2 +$(package)_download_path=https://git.hush.is/attachments +$(package)_file_name=94bfb5e0-7e29-4162-a066-bfd00e6b0db1 +$(package)_download_file=94bfb5e0-7e29-4162-a066-bfd00e6b0db1 $(package)_patches=fix-Solaris.patch define $(package)_set_vars From b70370123e0ad21fb83b93727e705feddf85fefe Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 7 Jan 2024 23:32:11 -0500 Subject: [PATCH 2/9] Fix boost download link --- depends/packages/boost.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 5b4804e14..f7d34c253 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -5,8 +5,8 @@ $(package)_version=1_72_0 #$(package)_file_name=$(package)_$($(package)_version).tar.bz2 $(package)_sha256_hash=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722 $(package)_download_path=https://git.hush.is/attachments -$(package)_file_name=94bfb5e0-7e29-4162-a066-bfd00e6b0db1 -$(package)_download_file=94bfb5e0-7e29-4162-a066-bfd00e6b0db1 +$(package)_file_name=7b13759e-8623-4e48-ae08-f78502f4b6a5 +$(package)_download_file=7b13759e-8623-4e48-ae08-f78502f4b6a5 $(package)_patches=fix-Solaris.patch define $(package)_set_vars From 1612ca4da7249f70ba79c10f609a46909a23097a Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 25 Jan 2024 08:56:47 -0800 Subject: [PATCH 3/9] Add some useful tips about gdb and testcoins to dev notes --- doc/developer-notes.md | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index d8027f38e..a2d90a7d3 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -24,6 +24,34 @@ rm zindex.dat blocks chainstate database notarizations hushstate It's possible to confused hush if you ran old code, stop, restart, and then write out zindex.dat that is incorrect, which later hushds will load from disk and believe. +# Generating a backtrace from a coredump + +Sometimes the code coredumps, what are ya gonna do? Generate a backtrace, of course. + +Run `ulimit -c unlimited` to make sure your shell will generate coredumps and +then run the application which coredumps. In the Olden Times Linux would always +make the "core" file in the same dir as the binary that was run which created +it. But I have now seen that some new Linux distributions put them in weird +places, for instance Arch puts them in /var/lib/systemd/coredump . If there are +lots of coredumps and you don't know which one is the latest, sort them by +modification time `ls -lart` or just delete them all and run the code which +generates the core dump. Old coredumps are not very useful and take up lots of space. + +Once you have a coredump file (which is usually called "core" or "core.XYZ" +where XYZ is the PID that generated it) you can then type `gdb binary_name +core_filename` and then type bt to generate the backtrace. + +For this repo, it's likely this is the command you need: +``` +gdb src/hushd core +``` + +NOTE: Even if you are debugging a coredump on a HAC, such as DragonX, the file `src/dragonxd` +is just a shell script that calls `src/hushd` and you always want to give an actual executable +file as the first argument to `gdb`, not a bash script. + +This link about Advanced GDB is very useful: https://interrupt.memfault.com/blog/advanced-gdb + # Parsing RPC output with jq jq is a very useful tool to parse JSON output, install it with: @@ -182,15 +210,14 @@ error and debugging messages are written there. The -debug=... command-line option controls debugging; running with just -debug or -debug=1 will turn on all categories (and give you a very large debug.log file). -**testnet and regtest modes** +**test coins** -Run with the -testnet option to run with "play HUSH" on the test network, if you -are testing multi-machine code that needs to operate across the internet. You can -also make a Hush Smart Chain "testcoin" with a single command: `hushd -ac_name=COIN ...` +The main way to test new things is directly on mainnet or you can also make a +Hush Arrakis Chain "testcoin" with a single command: `hushd -ac_name=COIN ...` -If you are testing something that can run on one machine, run with the -regtest option. -In regression test mode, blocks can be created on-demand; see qa/rpc-tests/ for tests -that run in -regtest mode. +If you are testing something that can run on one machine you can use `-testnode=1` +which makes it so a single machine can create a new blockchain and mine blocks, i.e. +no peers are necessary. **DEBUG_LOCKORDER** From c54b3990d9be009bd4a9ecb9ac16ad8cace3c423 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 25 Jan 2024 09:13:56 -0800 Subject: [PATCH 4/9] Compiling Hush basics --- doc/developer-notes.md | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index a2d90a7d3..df090cd05 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -1,3 +1,53 @@ +# Basics + +First the basics, how to compile code in this repo. + +First you will want to clone the code locally: + +``` +git clone https://git.hush.is/hush/hush3 +cd hush3 +``` + +If you want to compile a branch other than master (the default), such as +our development tip (the `dev` branch) you can switch to it: + +``` +git checkout dev +``` + +Then install needed dependencies. This is different on each OS as well as +older or newer systems. See https://git.hush.is/hush/hush3/src/branch/dev/INSTALL.md for +details on installing dependencies. If you are using a recent-ish Linux distro, this +is probably what you need: + +``` +# install build dependencies +sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib \ + autoconf libtool ncurses-dev unzip git zlib1g-dev wget \ + bsdmainutils automake curl unzip nano libsodium-dev cmake +``` + +Finally to compile the software you use `./build.sh` . It is quite slow +to only use a single thread, so you can use multiple threads, for example 4, +like this: + +``` +./build.sh -j4 +``` + +Each `build.sh` thread will take ~2GB of RAM so beware of that. If you have +compiled before and just made a change to C++ code, you can probably use +`make` instead and use a high number of threads. For example, if your CPU +has 8 physical cores and 16 "virtual cores" then you can use `make -j16` and +things will compile much faster. Each `make` threads takes only about 200MB of RAM. +If `make` fails in a weird way complaining about Makefiles, you probably need to +run `build.sh`, which takes care of regenerating Makefiles and installing some +additional dependencies. + +Sometimes using multiple threads the build can fail, so if it does, try again +with a different number of threads or just one thread before reporting an issue. + # Fresh sync Many times, you will want to do a "fresh sync" test, to verify code works when syncing from the genesis block, which is a different code path than a "partial sync" which means you already have part of blockchain history and are "catching up" to get in sync. From 874c3009cfa5865ee147b2962be4dda237699203 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 28 Jan 2024 06:30:52 -0800 Subject: [PATCH 5/9] Only Hush + DragonX connect to these nodes by default #379 --- src/hush_utils.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/hush_utils.h b/src/hush_utils.h index de03f73ba..d1a037e3b 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -1795,15 +1795,24 @@ void hush_args(char *argv0) name = GetArg("-ac_name","HUSH3"); fprintf(stderr,".oO Starting %s Full Node (Extreme Privacy!) with genproc=%d notary=%d\n",name.c_str(),HUSH_MININGTHREADS, IS_HUSH_NOTARY); - vector 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","node1.hush.land", "node2.hush.land", "node3.hush.land", "node4.hush.land", "node5.hush.land"}; + vector HUSH_nodes = {}; + // Only HUSH3 and DRAGONX connect to these by default, other HACs must opt-in via -connect/-addnode + if (ishush3 || isdragonx) { + 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","node1.hush.land", + "node2.hush.land", "node3.hush.land", + "node4.hush.land", "node5.hush.land"}; + } + vector 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 - more_nodes.insert( more_nodes.end(), HUSH_nodes.begin(), HUSH_nodes.end() ); + // Add default HUSH nodes after custom addnodes, if applicable + if(HUSH_nodes.size() > 0) { + more_nodes.insert( more_nodes.end(), HUSH_nodes.begin(), HUSH_nodes.end() ); + } mapMultiArgs["-addnode"] = more_nodes; HUSH_STOPAT = GetArg("-stopat",0); @@ -1878,7 +1887,8 @@ void hush_args(char *argv0) // Set our symbol from -ac_name value strncpy(SMART_CHAIN_SYMBOL,name.c_str(),sizeof(SMART_CHAIN_SYMBOL)-1); - bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + const bool isdragonx = strncmp(SMART_CHAIN_SYMBOL, "DRAGONX",7) == 0 ? true : false; ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1); if(ishush3) { From 5e69ed0804074b961506c5e53bd3f0667be08bd8 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 28 Jan 2024 09:52:24 -0500 Subject: [PATCH 6/9] Fix compile and const some stuff --- src/hush_utils.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hush_utils.h b/src/hush_utils.h index d1a037e3b..f9c93d16e 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -1473,7 +1473,7 @@ uint32_t hush_smartmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t } //TODO: why is this needed? - bool ishush3 = strncmp(symbol, "HUSH3",5) == 0 ? true : false; + const bool ishush3 = strncmp(symbol, "HUSH3",5) == 0 ? true : false; if(ishush3) { return HUSH_MAGIC; } else { @@ -1619,7 +1619,7 @@ 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; - bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; // fprintf(stderr,"%s: ht=%d ishush3=%d\n", __func__, nHeight, ishush3); // check for backwards compat, older chains with no explicit rewards had 0.0001 block reward @@ -1797,6 +1797,8 @@ void hush_args(char *argv0) vector HUSH_nodes = {}; // Only HUSH3 and DRAGONX connect to these by default, other HACs must opt-in via -connect/-addnode + const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + const bool isdragonx = strncmp(SMART_CHAIN_SYMBOL, "DRAGONX",7) == 0 ? true : false; if (ishush3 || isdragonx) { HUSH_nodes = {"node1.hush.is","node2.hush.is","node3.hush.is", "node4.hush.is","node5.hush.is","node6.hush.is", @@ -1888,7 +1890,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; - const bool isdragonx = strncmp(SMART_CHAIN_SYMBOL, "DRAGONX",7) == 0 ? true : false; ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1); if(ishush3) { From 57cb8fc5362feb8c07493987b41b2c3dd5b4ce78 Mon Sep 17 00:00:00 2001 From: onryo Date: Sun, 11 Feb 2024 13:26:22 +0000 Subject: [PATCH 7/9] Add Fedora install process --- INSTALL.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c13109788..ee7ead5c1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,12 +2,6 @@ Instructions to compile Hush yourself. -## Build HUSH dependencies - -The following build process generally applies to Ubuntu (and similar) Linux -distributions. For best results it is recommended to use Ubuntu Linux 16.04 -or later. - ## Swap Space (Optional) You will need at least 4GB of RAM to build hush from git source, OR you can enable a swap file. To enable a 4GB swap file on modern Linux distributions: @@ -19,7 +13,7 @@ sudo mkswap /swapfile sudo swapon /swapfile ``` -## Build on Linux: +## Build on Debian/Ubuntu: ```sh # install build dependencies @@ -34,6 +28,19 @@ cd hush3 ./build.sh -j3 ``` +## Build on Fedora: + +```sh +# install build dependencies +sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libtool ncurses-devel patch -y +# clone git repo +git clone https://git.hush.is/hush/hush3 +cd hush3 +# Build +# This uses 3 build processes, you need 2GB of RAM for each. +./build.sh -j3 +``` + ### Building On Ubuntu 16.04 and older systems Some older compilers may not be able to compile modern code, such as gcc 5.4 which comes with Ubuntu 16.04 by default. Here is how to install gcc 7 on Ubuntu 16.04. Run these commands as root: @@ -46,7 +53,7 @@ apt-get install -y gcc-7 g++-7 && \ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 ``` -### Build on mac +### Build on Mac These instructions are a work in progress. Please report issues to https://hush.is/tg_support From c94906e01124c939b9c0f0caece61779e6ec92d8 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 12 Feb 2024 09:57:09 -0500 Subject: [PATCH 8/9] Do not spam debug.log with 'Received addr' unless -debug --- src/main.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 85c0556fc..9d0125698 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6995,11 +6995,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CAddress addr = GetLocalAddress(&pfrom->addr); if (addr.IsRoutable()) { - LogPrintf("ProcessMessages: advertizing address %s\n", addr.ToString()); + LogPrintf("ProcessMessages: advertizing routable address %s\n", addr.ToString()); pfrom->PushAddress(addr); } else if (IsPeerAddrLocalGood(pfrom)) { addr.SetIP(pfrom->addrLocal); - LogPrintf("ProcessMessages: advertizing address %s\n", addr.ToString()); + LogPrintf("ProcessMessages: advertizing local good address %s\n", addr.ToString()); pfrom->PushAddress(addr); } } @@ -7187,7 +7187,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } pfrom->m_addr_processed += num_proc; pfrom->m_addr_rate_limited += num_rate_limit; - LogPrintf("ProcessMessage: Received addr: %u addresses (%u processed, %u rate-limited) from peer=%d%s\n", + if (fDebug) + LogPrintf("ProcessMessage: Received addr: %u addresses (%u processed, %u rate-limited) from peer=%d%s\n", vAddr.size(), num_proc, num_rate_limit, From b14070d15bc41edcd2f77e15b33e4b8b4da9055e Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 15 Feb 2024 10:06:37 -0500 Subject: [PATCH 9/9] Overwinter+sapling consensus rules do not apply to height=0 --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9d0125698..4236e3571 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1220,8 +1220,8 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde const int dosLevel, bool (*isInitBlockDownload)(),int32_t validateprices) { - const bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - const bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); + const bool overwinterActive = nHeight >=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); + const bool saplingActive = nHeight >=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); const bool isSprout = false; //!overwinterActive; // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond