Browse Source

Merge branch 'dev' into duke

duke
Duke 3 months ago
parent
commit
8f2350fd84
  1. 23
      INSTALL.md
  2. 91
      doc/developer-notes.md
  3. 27
      src/hush_utils.h
  4. 2
      src/main.cpp

23
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

91
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.
@ -24,6 +74,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 +260,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**

27
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
@ -1795,15 +1795,26 @@ 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<string> 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<string> 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",
"node7.hush.is","node8.hush.is","node1.hush.land",
"node2.hush.land", "node3.hush.land",
"node4.hush.land", "node5.hush.land"};
}
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
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 +1889,7 @@ 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;
ASSETCHAINS_LASTERA = GetArg("-ac_eras", 1);
if(ishush3) {

2
src/main.cpp

@ -1222,8 +1222,6 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde
{
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

Loading…
Cancel
Save