Zcash (forks) genesis block mining script. Runs an external miner for finding valid Equihash solutions. Inspired by GenesisH0, but written from scratch.
- Modify every parameter that influences the block header hash (see Usage)
- Support for silent army and tromp equihash solvers.
- Sensible defaults
- Placeholders of the form {BTC},{ETH}or{ZEC}in theTIMESTAMPinput string get translated to the currency's latest block number and hash.
- Uses the python-zcashlib, which is a (still very much unfinished) extension of the well-knownpython-bitcoinlib.
Clone this repo, create a python 3 virtualenv and install dependencies with pip:
git clone --recursive https://github.com/sebastianst/GenesisZ
python3 -m venv GenesisZ
cd GenesisZ
source bin/activate
pip install -r requirements.txtMake sure you have a working and supported equihash solver. Currently, the
silent army GPU solver (only for
mainnet and testnet parameters N,k=200,9) and tromp equihash CPU solver are supported.
Note that the zcashlib is used as a submodule, since I haven't uploaded it to PyPI yet (and because it's easier for the current interdependent development). That's why you must use the --recursive flag during cloning. When you update this repo, don't forget to update the submodule as well, i.e., run git pull && git submodule update to update.
Mine the zcash mainnet gensis block with the silentarmy solver by calling
./genesis.py -s "/path/to/sa-solver" -r 5000 -t 1477641360or cheat, because you already know the right nonce:
./genesis.py -s "/path/to/sa-solver" -n 1257 -t 1477641360This time using Tromp's solver with 4 threads, checking up to 10 nonces.
./genesis.py -c testnet -t 1477648033 -b 0x2007ffff -E 0x1f07ffff -s '/path/to/equihash/equi' -T 4 -r 10It will find the right solution for nonce 6.
Using Tromp's 48,5 solver with
./genesis.py -c regtest -t 1296688602 -b 0x200f0f0f -E 0x1f07ffff -s '/path/to/equihash/eq485' -T 4 -r 10will find the correct regtest solution for nonce 9.
Zclassic decided to use a custom extra nonce of 0x1d00ffff. Let's mine their
mainnet solution (already setting the right nonce to 0x00...021d) with
./genesis.py -c mainnet -t 1478403829 -E 0x1d00ffff -C Zclassic -z "No taxation without representation. BTC #437541 - 00000000000000000397f175a94dd3f530b957182eb2a9f7b79a44a94a5e0450" -s '/path/to/equihash/equi' -T 4 -n 21dusage: genesis.py [-h] [-c {mainnet,testnet,regtest}] [-t TIME] [-C COINNAME]
                  [-z TIMESTAMP] [-Z PSZTIMESTAMP] [-p PUBKEY] [-b BITS]
                  [-E EXTRANONCE] [-V VALUE] [-n NONCE] [-r ROUNDS]
                  [-s SOLVER] [-S {tromp,silentarmy}] [-T THREADS] [-v]
This script uses any Equihash solver to find a solution for the specified
genesis block
optional arguments:
  -h, --help            show this help message and exit
  -c {mainnet,testnet,regtest}, --chainparams {mainnet,testnet,regtest}
                        Select the core chain parameters for PoW limit and
                        parameters N and K.
  -t TIME, --time TIME  unix time to set in block header (defaults to current
                        time)
  -C COINNAME, --coinname COINNAME
                        the coin name prepends the blake2s hash of timestamp
                        in pszTimestamp
  -z TIMESTAMP, --timestamp TIMESTAMP
                        the pszTimestamp found in the input coinbase
                        transaction script. Will be blake2s'd and then
                        prefixed by coin name. Default is Zcash's mainnet
                        pszTimestamp. You may use tokens of the form {XYZ},
                        which will be replaced by the current block index and
                        hash of coin XZY (BTC, ETH or ZEC). Always the latest
                        block is retrieved, regardless of time argument.
  -Z PSZTIMESTAMP, --pszTimestamp PSZTIMESTAMP
                        Specify the pszTimestamp directly. Will ignore options
                        -C and -z
  -p PUBKEY, --pubkey PUBKEY
                        the pubkey found in the output transaction script
  -b BITS, --bits BITS  the target in compact representation, defining a
                        difficulty of 1
  -E EXTRANONCE, --extra-nonce EXTRANONCE
                        Usually, the coinbase script contains the nBits as
                        fixed first data, which in bitcoin is also referred to
                        as extra nonce. This conventional behaviour can be
                        changed by specifying this parameter (not recommended
                        for mainnet, useful for testnet).
  -V VALUE, --value VALUE
                        output transaction value in zatoshi (1 ZEC = 100000000
                        zatoshi)
  -n NONCE, --nonce NONCE
                        nonce to start with when searching for a valid
                        equihash solution; parsed as hex, leading zeros may be
                        omitted.
  -r ROUNDS, --rounds ROUNDS
                        how many nonces to check at most
  -s SOLVER, --solver SOLVER
                        path to solver binary. Currently supported are
                        silentarmy (sa-solver) and Tromp (equi/equi485).
                        Command line arguments may be passed, although that
                        should be unnecessary.
  -S {tromp,silentarmy}, --solver-type {tromp,silentarmy}
                        Set the type of solver explicitly. Otherwise GenesisZ
                        tries to infer the type from the binary name (equi* ->
                        tromp, sa-solver -> silentarmy)
  -T THREADS, --threads THREADS
                        How many CPU threads to use when solving with Tromp.
  -v, --verbose         verbose output
Make sure to select the right binary with -s when using Tromp's equihash solver:
| #threads | main/testnet ( N,K=200,9) | regtest ( N,K=48,5) | 
|---|---|---|
| 1 | equi1 | eq4851 | 
| >1 | equi | eq485 | 
Note that make only builds equi{,1}, so you have to run make eq485{,1} in Tromp's source directory if you need the solver for regtest.
- More structured and complete output of intermediate information and results. Currently, you need to specify verbose output to see all necessary information.
-  Use solvers' native APIs instead of reading stdout. None of the supported solvers expose such an API now. Maybe write little C wrapper...
-  Make block number selectable for the TIMESTAMPplaceholders. Like{BTC:1234}for block #1234.
Released under the GPLv3, see LICENSE file.